diff --git a/skins/fluent2/QskFluent2Skin.cpp b/skins/fluent2/QskFluent2Skin.cpp index fdb93bf1..725fa4c9 100644 --- a/skins/fluent2/QskFluent2Skin.cpp +++ b/skins/fluent2/QskFluent2Skin.cpp @@ -725,6 +725,7 @@ void Editor::setupMenuColors( setShadowColor( Q::Panel, theme.shadow.flyout.color ); setGradient( Q::Segment | Q::Hovered, pal.fillColor.subtle.secondary ); + setGradient( Q::Segment | Q::Selected | Q::Pressed, pal.fillColor.subtle.tertiary ); setGradient( Q::Segment | Q::Selected, pal.fillColor.subtle.secondary ); @@ -739,9 +740,14 @@ void Editor::setupMenuColors( setBoxBorderColors( Q::Segment | Q::Selected, QskGradient( { { 0.25, c1 }, { 0.25, c2 }, { 0.75, c2 }, { 0.75, c1 } } ) ); + setBoxBorderColors( Q::Segment | Q::Selected | Q::Pressed, + QskGradient( { { 0.33, c1 }, { 0.33, c2 }, { 0.67, c2 }, { 0.67, c1 } } ) ); + setColor( Q::Text, pal.fillColor.text.primary ); + setColor( Q::Text | Q::Selected | Q::Pressed, pal.fillColor.text.secondary ); setGraphicRole( Q::Icon, QskFluent2Skin::GraphicRoleFillColorTextPrimary ); + setGraphicRole( Q::Icon | Q::Selected | Q::Pressed, QskFluent2Skin::GraphicRoleFillColorTextSecondary ); } void Editor::setupPageIndicatorMetrics() diff --git a/skins/material3/QskMaterial3Skin.cpp b/skins/material3/QskMaterial3Skin.cpp index 8728a0ee..4ebd9606 100644 --- a/skins/material3/QskMaterial3Skin.cpp +++ b/skins/material3/QskMaterial3Skin.cpp @@ -361,6 +361,8 @@ void Editor::setupMenu() setGradient( Q::Segment | Q::Selected, m_pal.primary12 ); const auto hoverSelectedColor = flattenedColor( m_pal.onSurface, m_pal.primary12, m_pal.hoverOpacity ); setGradient( Q::Segment | Q::Selected | Q::Hovered, hoverSelectedColor ); + const auto pressedSelectedColor = flattenedColor( m_pal.onSurface, m_pal.primary12, m_pal.pressedOpacity ); + setGradient( Q::Segment | Q::Pressed | Q::Selected, pressedSelectedColor ); setPadding( Q::Icon, 7_dp ); setStrutSize( Q::Icon, 24_dp, 24_dp ); diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index b72877e8..7390e317 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -27,6 +27,7 @@ QSK_SUBCONTROL( QskMenu, Icon ) QSK_SUBCONTROL( QskMenu, Separator ) QSK_SYSTEM_STATE( QskMenu, Selected, QskAspect::FirstSystemState << 2 ) +QSK_SYSTEM_STATE( QskMenu, Pressed, QskAspect::FirstSystemState << 3 ) static inline int qskActionIndex( const QVector< int >& actions, int index ) { @@ -309,7 +310,7 @@ void QskMenu::keyPressEvent( QKeyEvent* event ) void QskMenu::keyReleaseEvent( QKeyEvent* ) { - if( m_data->isPressed ) + if( isPressed() ) { m_data->isPressed = false; @@ -416,7 +417,7 @@ void QskMenu::mouseReleaseEvent( QMouseEvent* event ) { if ( event->button() == Qt::LeftButton ) { - if( m_data->isPressed ) + if( isPressed() ) { m_data->isPressed = false; @@ -481,6 +482,11 @@ int QskMenu::indexAtPosition( const QPointF& pos ) const return m_data->actions.value( index, -1 ); } +bool QskMenu::isPressed() const +{ + return m_data->isPressed; +} + void QskMenu::trigger( int index ) { if ( index >= 0 && index < m_data->options.count() ) diff --git a/src/controls/QskMenu.h b/src/controls/QskMenu.h index ce4da4fc..bc4cb2ca 100644 --- a/src/controls/QskMenu.h +++ b/src/controls/QskMenu.h @@ -38,7 +38,7 @@ class QSK_EXPORT QskMenu : public QskPopup public: QSK_SUBCONTROLS( Overlay, Panel, Segment, Cursor, Text, Icon, Separator ) - QSK_STATES( Selected ) + QSK_STATES( Selected, Pressed ) QskMenu( QQuickItem* parentItem = nullptr ); ~QskMenu() override; @@ -79,6 +79,8 @@ class QSK_EXPORT QskMenu : public QskPopup QRectF cellRect( int index ) const; int indexAtPosition( const QPointF& ) const; + bool isPressed() const; + Q_INVOKABLE int exec(); Q_SIGNALS: diff --git a/src/controls/QskMenuSkinlet.cpp b/src/controls/QskMenuSkinlet.cpp index c99e94e1..0629b137 100644 --- a/src/controls/QskMenuSkinlet.cpp +++ b/src/controls/QskMenuSkinlet.cpp @@ -394,7 +394,18 @@ QskAspect::States QskMenuSkinlet::sampleStates( const auto menu = static_cast< const QskMenu* >( skinnable ); if ( menu->currentIndex() == menu->actions()[ index ] ) - states |= QskMenu::Selected; + { + states |= Q::Selected; + + if( menu->isPressed() ) + { + states |= Q::Pressed; + } + else + { + states &= ~Q::Pressed; + } + } const auto cursorPos = menu->effectiveSkinHint( Q::Segment | Q::Hovered | A::Metric | A::Position ).toPointF();