Commit 5a447b59 authored by Marco Martin's avatar Marco Martin

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
parent c1ba29e0
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment