From 650f2cef0752297526fa4ccfa65530fd48aeb607 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 20 Jan 2020 11:52:34 +0100 Subject: [PATCH] Center only during drawing, not the hit rects Summary: center only the drawing of the components but never modify the subcontrolrects (and hit targets) BUG: 416348 FIXED-IN: 5.18.0 Test Plan: now the handle activates immediately without one single pixel margin Reviewers: #vdg, hpereiradacosta, ndavis Reviewed By: #vdg, ndavis Subscribers: ngraham, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D26783 --- kstyle/breezestyle.cpp | 52 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 10 deletions(-) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index 910401b3..647ace9f 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -2324,16 +2324,10 @@ namespace Breeze //___________________________________________________________________________________________________________________ QRect Style::scrollBarInternalSubControlRect( const QStyleOptionComplex* option, SubControl subControl ) const { + const auto& rect = option->rect; const State& state( option->state ); const bool horizontal( state & State_Horizontal ); - QRect rect = option->rect; - if (horizontal) { - rect.setTop(PenWidth::Frame); - } else { - rect.setLeft(PenWidth::Frame); - } - switch( subControl ) { @@ -5108,9 +5102,20 @@ namespace Breeze if( !sliderOption ) return true; // copy rect and palette - const auto& rect( option->rect ); + //const auto& rect( option->rect ); const auto& palette( option->palette ); + // need to make it center due to the thin line separator + QRect rect = option->rect; + + if( option->state & State_Horizontal ) { + rect.setTop(PenWidth::Frame); + } else if (option->direction == Qt::RightToLeft) { + rect.setRight(rect.right() - PenWidth::Frame); + } else { + rect.setLeft(PenWidth::Frame); + } + //try to understand if anywhere the widget is under mouse, not just the handle, use _animations in case of QWidget, option->styleObject in case of QML #if QT_VERSION >= 0x050000 bool widgetMouseOver( ( option->state & State_MouseOver ) ); @@ -5170,7 +5175,16 @@ namespace Breeze const bool reverseLayout( option->direction == Qt::RightToLeft ); // adjust rect, based on number of buttons to be drawn - const auto rect( scrollBarInternalSubControlRect( sliderOption, SC_ScrollBarAddLine ) ); + auto rect( scrollBarInternalSubControlRect( sliderOption, SC_ScrollBarAddLine ) ); + + // need to make it center due to the thin line separator + if( option->state & State_Horizontal ) { + rect.setTop(PenWidth::Frame); + } else if (option->direction == Qt::RightToLeft) { + rect.setRight(rect.right() - PenWidth::Frame); + } else { + rect.setLeft(PenWidth::Frame); + } QColor color; QStyleOptionSlider copy( *sliderOption ); @@ -5243,7 +5257,16 @@ namespace Breeze const bool reverseLayout( option->direction == Qt::RightToLeft ); // adjust rect, based on number of buttons to be drawn - const auto rect( scrollBarInternalSubControlRect( sliderOption, SC_ScrollBarSubLine ) ); + auto rect( scrollBarInternalSubControlRect( sliderOption, SC_ScrollBarSubLine ) ); + + // need to make it center due to the thin line separator + if( option->state & State_Horizontal ) { + rect.setTop(PenWidth::Frame); + } else if (option->direction == Qt::RightToLeft) { + rect.setRight(rect.right() - PenWidth::Frame); + } else { + rect.setLeft(PenWidth::Frame); + } QColor color; QStyleOptionSlider copy( *sliderOption ); @@ -6579,6 +6602,15 @@ namespace Breeze // retrieve groove rectangle auto grooveRect( subControlRect( CC_ScrollBar, option, SC_ScrollBarGroove, widget ) ); + // need to make it center due to the thin line separator + if( option->state & State_Horizontal ) { + grooveRect.setTop(PenWidth::Frame); + } else if (option->direction == Qt::RightToLeft) { + grooveRect.setRight(grooveRect.right() - PenWidth::Frame); + } else { + grooveRect.setLeft(PenWidth::Frame); + } + const auto& palette( option->palette ); const auto color( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.3 * (animated ? opacity : 1) ) ); const auto& state( option->state );