kstyle: add sunken state for checkbuttons and radiobuttons back

wilder-5.24
Jan Blackquill 5 years ago committed by Nate Graham
parent af9ef940a3
commit 4fe1675c22
  1. 23
      kstyle/breezehelper.cpp
  2. 8
      kstyle/breezehelper.h
  3. 20
      kstyle/breezestyle.cpp

@ -37,6 +37,8 @@ namespace Breeze
//* contrast for arrow and treeline rendering
static const qreal arrowShade = 0.15;
static const auto radioCheckSunkenDarkeningFactor = 110;
//____________________________________________________________________
Helper::Helper( KSharedConfig::Ptr config, QObject *parent ) :
QObject ( parent ),
@ -847,7 +849,8 @@ namespace Breeze
void Helper::renderCheckBoxBackground(
QPainter* painter, const QRect& rect,
const QPalette& palette,
CheckBoxState state, bool neutalHighlight, qreal animation ) const
CheckBoxState state, bool neutalHighlight,
bool sunken, qreal animation ) const
{
// setup painter
painter->setRenderHint( QPainter::Antialiasing, true );
@ -869,7 +872,7 @@ namespace Breeze
switch (state) {
case CheckOff:
painter->setBrush( palette.base() );
painter->setBrush( palette.base().color().darker(sunken ? radioCheckSunkenDarkeningFactor : 100) );
painter->drawRoundedRect( frameRect, radius, radius );
break;
@ -880,7 +883,7 @@ namespace Breeze
break;
case CheckAnimated:
painter->setBrush( palette.base() );
painter->setBrush( palette.base().color().darker(sunken ? radioCheckSunkenDarkeningFactor : 100) );
painter->drawRoundedRect( frameRect, radius, radius );
painter->setBrush( transparent );
painter->setOpacity( animation );
@ -895,9 +898,11 @@ namespace Breeze
QPainter* painter, const QRect& rect,
const QPalette& palette, bool mouseOver,
CheckBoxState state, CheckBoxState target,
bool neutalHighlight,
bool neutalHighlight, bool sunken,
qreal animation, qreal hoverAnimation ) const
{
Q_UNUSED(sunken)
// setup painter
painter->setRenderHint( QPainter::Antialiasing, true );
@ -985,7 +990,7 @@ namespace Breeze
}
//______________________________________________________________________________
void Helper::renderRadioButtonBackground( QPainter* painter, const QRect& rect, const QPalette& palette, RadioButtonState state, bool neutalHighlight, qreal animation ) const
void Helper::renderRadioButtonBackground( QPainter* painter, const QRect& rect, const QPalette& palette, RadioButtonState state, bool neutalHighlight, bool sunken, qreal animation ) const
{
// setup painter
@ -1006,7 +1011,7 @@ namespace Breeze
switch (state) {
case RadioOff:
painter->setBrush( palette.base() );
painter->setBrush( palette.base().color().darker(sunken ? radioCheckSunkenDarkeningFactor : 100) );
painter->drawEllipse( frameRect );
break;
case RadioOn:
@ -1014,7 +1019,7 @@ namespace Breeze
painter->drawEllipse( frameRect );
break;
case RadioAnimated:
painter->setBrush( palette.base() );
painter->setBrush( palette.base().color().darker(sunken ? radioCheckSunkenDarkeningFactor : 100) );
painter->drawEllipse( frameRect );
painter->setBrush( transparent );
painter->setOpacity( animation );
@ -1027,8 +1032,10 @@ namespace Breeze
void Helper::renderRadioButton(
QPainter* painter, const QRect& rect,
const QPalette& palette, bool mouseOver,
RadioButtonState state, bool neutralHighlight, qreal animation, qreal animationHover ) const
RadioButtonState state, bool neutralHighlight, bool sunken, qreal animation, qreal animationHover ) const
{
Q_UNUSED(sunken)
// setup painter
painter->setRenderHint( QPainter::Antialiasing, true );

@ -192,16 +192,16 @@ namespace Breeze
void renderSeparator( QPainter*, const QRect&, const QColor&, bool vertical = false ) const;
//* checkbox
void renderCheckBoxBackground( QPainter*, const QRect&, const QPalette& palette, CheckBoxState state, bool neutalHighlight, qreal animation = AnimationData::OpacityInvalid ) const;
void renderCheckBoxBackground( QPainter*, const QRect&, const QPalette& palette, CheckBoxState state, bool neutalHighlight, bool sunken, qreal animation = AnimationData::OpacityInvalid ) const;
//* checkbox
void renderCheckBox( QPainter*, const QRect&, const QPalette& palette, bool mouseOver, CheckBoxState state, CheckBoxState target, bool neutalHighlight, qreal animation = AnimationData::OpacityInvalid, qreal hoverAnimation = AnimationData::OpacityInvalid ) const;
void renderCheckBox( QPainter*, const QRect&, const QPalette& palette, bool mouseOver, CheckBoxState state, CheckBoxState target, bool neutalHighlight, bool sunken, qreal animation = AnimationData::OpacityInvalid, qreal hoverAnimation = AnimationData::OpacityInvalid ) const;
//* radio button
void renderRadioButtonBackground( QPainter*, const QRect&, const QPalette& palette, RadioButtonState state, bool neutalHighlight, qreal animation = AnimationData::OpacityInvalid ) const;
void renderRadioButtonBackground( QPainter*, const QRect&, const QPalette& palette, RadioButtonState state, bool neutalHighlight, bool sunken, qreal animation = AnimationData::OpacityInvalid ) const;
//* radio button
void renderRadioButton( QPainter*, const QRect&, const QPalette& palette, bool mouseOver, RadioButtonState state, bool neutalHighlight, qreal animation = AnimationData::OpacityInvalid, qreal hoverAnimation = AnimationData::OpacityInvalid ) const;
void renderRadioButton( QPainter*, const QRect&, const QPalette& palette, bool mouseOver, RadioButtonState state, bool neutalHighlight, bool sunken, qreal animation = AnimationData::OpacityInvalid, qreal hoverAnimation = AnimationData::OpacityInvalid ) const;
//* slider groove
void renderSliderGroove( QPainter*, const QRect&, const QColor& ) const;

@ -3898,6 +3898,7 @@ namespace Breeze
// store flags
const State& state( option->state );
const bool enabled( state & State_Enabled );
const bool sunken( state & State_Sunken );
const bool mouseOver( enabled && ( state & State_MouseOver ) );
// checkbox state
@ -3915,8 +3916,8 @@ namespace Breeze
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
// render
_helper->renderCheckBoxBackground( painter, rect, palette, checkBoxState, hasHighlightNeutral( widget, option, mouseOver), animation );
_helper->renderCheckBox( painter, rect, palette, mouseOver, checkBoxState, target, hasHighlightNeutral( widget, option, mouseOver), animation, opacity );
_helper->renderCheckBoxBackground( painter, rect, palette, checkBoxState, hasHighlightNeutral( widget, option, mouseOver), sunken, animation );
_helper->renderCheckBox( painter, rect, palette, mouseOver, checkBoxState, target, hasHighlightNeutral( widget, option, mouseOver), sunken, animation, opacity );
return true;
}
@ -3932,6 +3933,7 @@ namespace Breeze
// store flags
const State& state( option->state );
const bool enabled( state & State_Enabled );
const bool sunken( state & State_Sunken );
const bool mouseOver( enabled && ( state & State_MouseOver ) );
// radio button state
@ -3947,8 +3949,8 @@ namespace Breeze
const qreal opacity( _animations->widgetStateEngine().opacity( widget, AnimationHover ) );
// render
_helper->renderRadioButtonBackground( painter, rect, palette, radioButtonState, hasHighlightNeutral( widget, option, mouseOver), animation );
_helper->renderRadioButton( painter, rect, palette, mouseOver, radioButtonState, hasHighlightNeutral( widget, option, mouseOver), animation, opacity );
_helper->renderRadioButtonBackground( painter, rect, palette, radioButtonState, hasHighlightNeutral( widget, option, mouseOver), sunken, animation );
_helper->renderRadioButton( painter, rect, palette, mouseOver, radioButtonState, hasHighlightNeutral( widget, option, mouseOver), sunken, animation, opacity );
return true;
@ -4811,7 +4813,7 @@ namespace Breeze
const State& state( option->state );
const bool enabled( state & State_Enabled );
const bool selected( enabled && (state & State_Selected) );
const bool sunken( enabled && (state & (State_On|State_Sunken) ) );
const bool sunken( enabled && (state & (State_Sunken) ) );
const bool reverseLayout( option->direction == Qt::RightToLeft );
const bool useStrongFocus( StyleConfigData::menuItemDrawStrongFocus() );
@ -4860,16 +4862,16 @@ namespace Breeze
const bool active( menuItemOption->checked );
const auto shadow( _helper->shadowColor( palette ) );
const auto color( _helper->checkBoxIndicatorColor( palette, false, enabled && active ) );
_helper->renderCheckBoxBackground( painter, checkBoxRect, palette, state, false, AnimationData::OpacityInvalid );
_helper->renderCheckBox( painter, checkBoxRect, palette, false, state, state, false );
_helper->renderCheckBoxBackground( painter, checkBoxRect, palette, state, false, sunken );
_helper->renderCheckBox( painter, checkBoxRect, palette, false, state, state, false, sunken );
} else if( menuItemOption->checkType == QStyleOptionMenuItem::Exclusive ) {
checkBoxRect = visualRect( option, checkBoxRect );
const bool active( menuItemOption->checked );
_helper->renderRadioButtonBackground( painter, checkBoxRect, palette, active ? RadioOn : RadioOff, false, AnimationData::OpacityInvalid );
_helper->renderRadioButton( painter, checkBoxRect, palette, false, active ? RadioOn:RadioOff, false );
_helper->renderRadioButtonBackground( painter, checkBoxRect, palette, active ? RadioOn : RadioOff, false, sunken );
_helper->renderRadioButton( painter, checkBoxRect, palette, false, active ? RadioOn:RadioOff, false, sunken );
}

Loading…
Cancel
Save