diff --git a/designsystems/fusion/QskFusionSkin.cpp b/designsystems/fusion/QskFusionSkin.cpp index 50188ee8..5feceb48 100644 --- a/designsystems/fusion/QskFusionSkin.cpp +++ b/designsystems/fusion/QskFusionSkin.cpp @@ -489,7 +489,7 @@ void Editor::setupRadioBox() setStrutSize( Q::CheckIndicatorPanel, 20_dp, 20_dp ); - for ( auto subControl : { Q::CheckIndicatorPanel, Q::CheckIndicator, Q::Halo } ) + for ( auto subControl : { Q::CheckIndicatorPanel, Q::CheckIndicator } ) setBoxShape( subControl, 100, Qt::RelativeSize ); // circular setBoxBorderMetrics( Q::CheckIndicatorPanel, 1_dp ); diff --git a/designsystems/material3/QskMaterial3Skin.cpp b/designsystems/material3/QskMaterial3Skin.cpp index 12a8aa53..d54a67a4 100644 --- a/designsystems/material3/QskMaterial3Skin.cpp +++ b/designsystems/material3/QskMaterial3Skin.cpp @@ -480,9 +480,17 @@ void Editor::setupRadioBox() setSpacing( Q::Button, 10_dp ); setStrutSize( Q::CheckIndicatorPanel, 20_dp, 20_dp ); - setStrutSize( Q::Halo, 40_dp, 40_dp ); - for ( auto subControl : { Q::CheckIndicatorPanel, Q::CheckIndicator, Q::Halo } ) + for ( const auto state1 : { Q::Hovered, Q::Focused, Q::Pressed } ) + { + for ( const auto state2 : { A::NoState, Q::Selected } ) + { + const auto aspect = Q::CheckIndicatorPanel | state1 | state2; + setShadowMetrics( aspect, { 10_dp, 0 } ); + } + } + + for ( auto subControl : { Q::CheckIndicatorPanel, Q::CheckIndicator } ) setBoxShape( subControl, 100, Qt::RelativeSize ); // circular setBoxBorderMetrics( Q::CheckIndicatorPanel, 2_dp ); @@ -494,11 +502,41 @@ void Editor::setupRadioBox() setColor( Q::Text, m_pal.onBackground ); setColor( Q::Text | Q::Disabled, m_pal.onSurface38 ); - setColor( Q::Halo, stateLayerColor( m_pal.onSurface, m_pal.focusOpacity ) ); - setColor( Q::Halo | Q::Selected, - stateLayerColor( m_pal.primary, m_pal.focusOpacity ) ); + for ( const auto state1 : { Q::Hovered, Q::Focused, Q::Pressed } ) + { + for ( const auto state2 : { A::NoState, Q::Selected } ) + { + const auto aspect = Q::CheckIndicatorPanel | state1 | state2; - setColor( Q::CheckIndicator, Qt::transparent); + 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 ); + } + + } + } + + setColor( Q::CheckIndicator, Qt::transparent ); setColor( Q::CheckIndicator | Q::Selected, m_pal.primary ); setColor( Q::CheckIndicator | Q::Selected | Q::Disabled, m_pal.onSurface38 ); @@ -509,7 +547,7 @@ void Editor::setupRadioBox() setBoxBorderColors( Q::CheckIndicatorPanel | Q::Disabled | Q::Selected, m_pal.onSurface38 ); - setAnimation( Q::Halo | A::Metric | A::Position, qskDuration ); + setAnimation( Q::CheckIndicator | A::Metric | A::Position, qskDuration ); } void Editor::setupFocusIndicator() @@ -1484,7 +1522,7 @@ static inline QFont createFont( int pointSize, int lineHeight, } checkFont = false; } - + font.setPixelSize( pixelSize ); if ( spacing > 0.0 ) diff --git a/src/controls/QskRadioBox.cpp b/src/controls/QskRadioBox.cpp index e7076222..7cde8fc5 100644 --- a/src/controls/QskRadioBox.cpp +++ b/src/controls/QskRadioBox.cpp @@ -13,7 +13,6 @@ QSK_SUBCONTROL( QskRadioBox, Button ) QSK_SUBCONTROL( QskRadioBox, CheckIndicatorPanel ) QSK_SUBCONTROL( QskRadioBox, CheckIndicator ) QSK_SUBCONTROL( QskRadioBox, Text ) -QSK_SUBCONTROL( QskRadioBox, Halo ) QSK_STATE( QskRadioBox, Selected, QskAspect::FirstUserState << 1 ) QSK_STATE( QskRadioBox, Pressed, QskAspect::FirstUserState << 2 ) @@ -38,7 +37,7 @@ QskRadioBox::QskRadioBox( QQuickItem* parent ) setFocusPolicy( Qt::StrongFocus ); setAcceptedMouseButtons( Qt::LeftButton ); - setPositionHint( Halo, -1 ); + setPositionHint( CheckIndicator, -1 ); setAcceptHoverEvents( true ); } @@ -182,7 +181,7 @@ void QskRadioBox::keyPressEvent( QKeyEvent* event ) { setFocusedIndex( nextTabIndex ); - const auto aspect = Halo | QskAspect::Metric | QskAspect::Position; + const auto aspect = CheckIndicator | QskAspect::Metric | QskAspect::Position; const auto hint = animationHint( aspect | skinStates() ); if( hint.isValid() ) @@ -277,7 +276,7 @@ void QskRadioBox::setHoveredIndex( int index ) return; m_data->hoveredIndex = index; - setPositionHint( Halo | Hovered, index ); + setPositionHint( CheckIndicator | Hovered, index ); update(); } @@ -288,7 +287,7 @@ void QskRadioBox::setFocusedIndex( int index ) return; m_data->focusedIndex = index; - setPositionHint( Halo, index ); + setPositionHint( CheckIndicator, index ); update(); diff --git a/src/controls/QskRadioBox.h b/src/controls/QskRadioBox.h index de65c457..92bb615e 100644 --- a/src/controls/QskRadioBox.h +++ b/src/controls/QskRadioBox.h @@ -22,7 +22,7 @@ class QSK_EXPORT QskRadioBox : public QskControl using Inherited = QskControl; public: - QSK_SUBCONTROLS( Panel, Button, CheckIndicatorPanel, CheckIndicator, Text, Halo ) + QSK_SUBCONTROLS( Panel, Button, CheckIndicatorPanel, CheckIndicator, Text ) QSK_STATES( Selected, Pressed ) QskRadioBox( QQuickItem* parent = nullptr ); diff --git a/src/controls/QskRadioBoxSkinlet.cpp b/src/controls/QskRadioBoxSkinlet.cpp index 98201ea5..5bbc5987 100644 --- a/src/controls/QskRadioBoxSkinlet.cpp +++ b/src/controls/QskRadioBoxSkinlet.cpp @@ -40,7 +40,7 @@ namespace QskRadioBoxSkinlet::QskRadioBoxSkinlet( QskSkin* ) { setNodeRoles( { PanelRole, ButtonRole, CheckPanelRole, - CheckIndicatorRole, TextRole, HaloRole } ); + CheckIndicatorRole, TextRole } ); } QskRadioBoxSkinlet::~QskRadioBoxSkinlet() @@ -50,12 +50,8 @@ QskRadioBoxSkinlet::~QskRadioBoxSkinlet() QRectF QskRadioBoxSkinlet::subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subcontrol ) const { - using Q = QskRadioBox; - - auto radioBox = static_cast< const QskRadioBox* >( skinnable ); - - if( subcontrol == Q::Halo ) - return haloRect( radioBox, contentsRect ); + Q_UNUSED( skinnable ); + Q_UNUSED( subcontrol ); return contentsRect; } @@ -81,9 +77,6 @@ QSGNode* QskRadioBoxSkinlet::updateSubNode( const QskSkinnable* skinnable, case TextRole: return updateSeriesNode( skinnable, Q::Text, node ); - - case HaloRole: - return updateBoxNode( skinnable, node, Q::Halo ); } return Inherited::updateSubNode( skinnable, nodeRole, node ); @@ -96,29 +89,6 @@ int QskRadioBoxSkinlet::sampleCount( return radioBox->options().count(); } -QRectF QskRadioBoxSkinlet::haloRect( - const QskRadioBox* radioBox, const QRectF& rect ) const -{ - using Q = QskRadioBox; - - const auto index = qFloor( radioBox->positionHint( Q::Halo ) ); - if( index < 0 ) - return QRectF(); - - QRectF r; - r.setSize( radioBox->strutSizeHint( Q::Halo ) ); - - if ( !r.isEmpty() ) - { - const auto checkBoxRect = sampleRect( - radioBox, rect, Q::CheckIndicatorPanel, index ); - - r.moveCenter( checkBoxRect.center() ); - } - - return r; -} - QRectF QskRadioBoxSkinlet::buttonRect( const QskRadioBox* radioBox, const QRectF& rect, int index ) const { @@ -219,12 +189,12 @@ QskAspect::States QskRadioBoxSkinlet::sampleStates( states |= Q::Pressed; #if 1 - if( radioBox->positionHint( Q::Halo | Q::Hovered ) == index ) + if( radioBox->positionHint( Q::CheckIndicator | Q::Hovered ) == index ) states |= Q::Hovered; else states &= ~Q::Hovered; - if( radioBox->positionHint( Q::Halo ) == index ) + if( radioBox->positionHint( Q::CheckIndicator ) == index ) states |= Q::Focused; else states &= ~Q::Focused; diff --git a/src/controls/QskRadioBoxSkinlet.h b/src/controls/QskRadioBoxSkinlet.h index 73db392b..7a3f17b4 100644 --- a/src/controls/QskRadioBoxSkinlet.h +++ b/src/controls/QskRadioBoxSkinlet.h @@ -24,7 +24,6 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet CheckPanelRole, CheckIndicatorRole, TextRole, - HaloRole, RoleCount }; @@ -57,8 +56,6 @@ class QSK_EXPORT QskRadioBoxSkinlet : public QskSkinlet QRectF textRect( const QskRadioBox*, const QRectF&, int ) const; QRectF checkPanelRect( const QskRadioBox*, const QRectF&, int index ) const; QRectF buttonRect( const QskRadioBox*, const QRectF&, int index ) const; - - QRectF haloRect( const QskRadioBox*, const QRectF& ) const; }; #endif