M3 radiobox setup simplified

This commit is contained in:
Uwe Rathmann 2024-10-25 18:52:02 +02:00
parent 99b4bddac9
commit 33980a5887
2 changed files with 7 additions and 24 deletions

View File

@ -501,31 +501,10 @@ void Editor::setupRadioBox()
setShadowMetrics( aspect, { 10_dp, 0 } );
QRgb rgb;
if ( state1 == Q::Hovered )
{
rgb = ( state2 == Q::Selected ) ? m_pal.primary8 : m_pal.onSurface8;
rgb = stateLayerColor( rgb, m_pal.hoverOpacity );
setShadowColor( aspect, rgb );
}
else if ( state1 == Q::Focused )
{
rgb = ( state2 == Q::Selected ) ? m_pal.primary12 : m_pal.onSurface12;
rgb = stateLayerColor( rgb, m_pal.focusOpacity );
setShadowColor( aspect, rgb );
}
else
{
rgb = ( state2 == Q::Selected ) ? m_pal.onSurface12 : m_pal.primary12;
rgb = stateLayerColor( rgb, m_pal.pressedOpacity );
setShadowColor( aspect, rgb );
setShadowColor( aspect | Q::Focused, rgb );
}
auto rgb = ( state2 == Q::Selected ) ? m_pal.primary : m_pal.onSurface;
rgb = stateLayerColor( rgb, m_pal.stateOpacity( state1 ) );
setShadowColor( aspect, rgb );
}
}
@ -1518,6 +1497,9 @@ qreal QskMaterial3Theme::stateOpacity( int state ) const
if ( state == QskControl::Focused )
return focusOpacity;
if ( state == QskControl::Disabled )
return disabledOpacity;
return state ? pressedOpacity : 0.0;
}

View File

@ -92,6 +92,7 @@ class QSK_MATERIAL3_EXPORT QskMaterial3Theme
const qreal focusOpacity = 0.12;
const qreal pressedOpacity = 0.12;
const qreal draggedOpacity = 0.16;
const qreal disabledOpacity = 0.38;
qreal stateOpacity( int state ) const;