diff --git a/skins/fluent2/QskFluent2Skin.cpp b/skins/fluent2/QskFluent2Skin.cpp index 3aaf09d7..c8615dcb 100644 --- a/skins/fluent2/QskFluent2Skin.cpp +++ b/skins/fluent2/QskFluent2Skin.cpp @@ -620,6 +620,10 @@ void Editor::setupDialogButtonBoxColors( void Editor::setupDrawerMetrics() { + using Q = QskDrawer; + using A = QskAspect; + + setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } void Editor::setupDrawerColors( QskAspect::Section, const QskFluent2Theme& ) @@ -738,6 +742,7 @@ void Editor::setupListViewColors( void Editor::setupMenuMetrics() { using Q = QskMenu; + using A = QskAspect; setPadding( Q::Panel, { 4, 6, 4, 6 } ); setBoxBorderMetrics( Q::Panel, 1 ); @@ -751,6 +756,8 @@ void Editor::setupMenuMetrics() setStrutSize( Q::Icon, 12, 12 ); setPadding( Q::Icon, { 8, 8, 0, 8 } ); + + setAnimation( Q::Panel | A::Position, 100 ); } void Editor::setupMenuColors( @@ -867,8 +874,6 @@ void Editor::setupPopup( const QskFluent2Theme& theme ) setHint( Q::Overlay | A::Style, true ); setGradient( Q::Overlay, pal.background.overlay.defaultColor ); - - setAnimation( Q::Popup, 150 ); } void Editor::setupProgressBarMetrics() @@ -1874,6 +1879,8 @@ void Editor::setupSwitchButtonColors( void Editor::setupSubWindow( const QskFluent2Theme& theme ) { using Q = QskSubWindow; + using A = QskAspect; + const auto& pal = theme.palette; setPadding( Q::Panel, { 0, 31, 0, 0 } ); @@ -1891,6 +1898,8 @@ void Editor::setupSubWindow( const QskFluent2Theme& theme ) setColor( Q::TitleBarText, pal.fillColor.text.primary ); setAlignment( Q::TitleBarText, Qt::AlignLeft ); setTextOptions( Q::TitleBarText, Qt::ElideRight, QskTextOptions::NoWrap ); + + setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } void Editor::setupVirtualKeyboardMetrics() diff --git a/skins/material3/QskMaterial3Skin.cpp b/skins/material3/QskMaterial3Skin.cpp index b30ebc69..ad81f397 100644 --- a/skins/material3/QskMaterial3Skin.cpp +++ b/skins/material3/QskMaterial3Skin.cpp @@ -331,8 +331,6 @@ void Editor::setupPopup() setHint( Q::Overlay | A::Style, true ); setGradient( Q::Overlay, stateLayerColor( m_pal.outline, 0.8 ) ); - - setAnimation( Q::Popup, qskDuration ); } void Editor::setupMenu() @@ -381,6 +379,8 @@ void Editor::setupMenu() setFontRole( Q::Text, QskMaterial3Skin::M3BodyMedium ); setAnimation( Q::Cursor | A::Position | A::Metric, 75, QEasingCurve::OutCubic ); + + setAnimation( Q::Panel | A::Position, 75 ); } void Editor::setupTextLabel() @@ -806,6 +806,10 @@ void Editor::setupDialogButtonBox() void Editor::setupDrawer() { + using Q = QskDrawer; + using A = QskAspect; + + setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } void Editor::setupSlider() @@ -1255,6 +1259,7 @@ void Editor::setupSubWindow() for ( auto subControl : { Q::Panel, Q::TitleBarPanel, Q::TitleBarText } ) setAnimation( subControl | A::Color, qskDuration ); + setAnimation( Q::Panel | A::Position, qskDuration, QEasingCurve::OutCubic ); } QskMaterial3Theme::QskMaterial3Theme( QskSkin::ColorScheme colorScheme ) diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index f7dac2e0..9de18a3d 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -410,8 +410,6 @@ void Editor::setupPopup() setHint( Q::Overlay | A::Style, true ); setGradient( Q::Overlay, qRgba( 220, 220, 220, 150 ) ); - - setAnimation( Q::Popup, 200 ); } void Editor::setupMenu() @@ -449,6 +447,7 @@ void Editor::setupMenu() setGraphicRole( Q::Icon | Q::Selected, CursorSymbol ); setAnimation( Q::Cursor | A::Position | A::Metric, 75, QEasingCurve::OutCubic ); + setAnimation( Q::Panel | A::Position, 100 ); } void Editor::setupTextLabel() @@ -759,6 +758,10 @@ void Editor::setupDialogButtonBox() void Editor::setupDrawer() { + using Q = QskDrawer; + using A = QskAspect; + + setAnimation( Q::Panel | A::Position, 300, QEasingCurve::OutCubic ); } void Editor::setupTabButton() @@ -1120,8 +1123,12 @@ void Editor::setupSubWindow() setAlignment( Q::TitleBarText, Qt::AlignLeft | Qt::AlignVCenter ); +#if 1 for ( auto subControl : { Q::Panel, Q::TitleBarPanel, Q::TitleBarText } ) setAnimation( subControl | A::Color, qskDuration ); +#endif + + setAnimation( Q::Panel | A::Position, qskDuration, QEasingCurve::OutCubic ); } void Editor::setupSpinBox() diff --git a/src/controls/QskDrawer.cpp b/src/controls/QskDrawer.cpp index 55749f08..fa254316 100644 --- a/src/controls/QskDrawer.cpp +++ b/src/controls/QskDrawer.cpp @@ -19,6 +19,8 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END +QSK_SUBCONTROL( QskDrawer, Panel ) + static inline qreal qskDefaultDragMargin() { // a skin hint ??? @@ -79,7 +81,7 @@ static inline QRectF qskAlignedToEdge( static QPointF qskDrawerTranslation( const QskDrawer* drawer, const QSizeF& size ) { - const auto ratio = 1.0 - drawer->transitioningFactor(); + const auto ratio = 1.0 - drawer->fadingFactor(); auto dx = 0.0; auto dy = 0.0; @@ -170,7 +172,7 @@ namespace bool isAcceptedPos( const QPointF& pos ) const override { auto drawer = qobject_cast< const QskDrawer* >( targetItem() ); - if ( drawer->isTransitioning() ) + if ( drawer->isFading() ) return false; auto rect = qskItemRect( watchedItem() ); @@ -255,8 +257,7 @@ QskDrawer::QskDrawer( Qt::Edge edge, QQuickItem* parentItem ) setAutoLayoutChildren( true ); setInteractive( true ); - connect( this, &QskPopup::transitioningChanged, - this, &QQuickItem::setClip ); + connect( this, &QskPopup::fadingChanged, this, &QQuickItem::setClip ); } QskDrawer::~QskDrawer() @@ -393,12 +394,12 @@ void QskDrawer::updateResources() void QskDrawer::updateNode( QSGNode* node ) { - if ( isTransitioning() && clip() ) + if ( isFading() && clip() ) { if ( auto clipNode = QQuickItemPrivate::get( this )->clipNode() ) { /* - The clipRect is changing while transitioning. Couldn't + The clipRect is changing while fading. Couldn't find a way how to trigger updates - maybe be enabling/disabling the clip. So we do the updates manually. TODO ... */ @@ -416,7 +417,7 @@ void QskDrawer::updateNode( QSGNode* node ) QRectF QskDrawer::clipRect() const { - if ( isTransitioning() && parentItem() ) + if ( isFading() && parentItem() ) { /* We might not fit into our parent and our children not @@ -454,4 +455,9 @@ QRectF QskDrawer::clipRect() const return Inherited::clipRect(); } +QskAspect QskDrawer::fadingAspect() const +{ + return QskDrawer::Panel | QskAspect::Position; +} + #include "moc_QskDrawer.cpp" diff --git a/src/controls/QskDrawer.h b/src/controls/QskDrawer.h index f766faaf..631e5492 100644 --- a/src/controls/QskDrawer.h +++ b/src/controls/QskDrawer.h @@ -23,6 +23,8 @@ class QSK_EXPORT QskDrawer : public QskPopup WRITE setInteractive NOTIFY interactiveChanged ) public: + QSK_SUBCONTROLS( Panel ); + QskDrawer( QQuickItem* = nullptr ); QskDrawer( Qt::Edge, QQuickItem* = nullptr ); @@ -39,6 +41,7 @@ class QSK_EXPORT QskDrawer : public QskPopup qreal dragMargin() const; QRectF clipRect() const override; + QskAspect fadingAspect() const override; Q_SIGNALS: void edgeChanged( Qt::Edge ); diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index e7a5cd9f..e3af5707 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -22,7 +22,6 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END -QSK_SUBCONTROL( QskMenu, Overlay ) QSK_SUBCONTROL( QskMenu, Panel ) QSK_SUBCONTROL( QskMenu, Segment ) QSK_SUBCONTROL( QskMenu, Cursor ) @@ -72,10 +71,10 @@ QskMenu::QskMenu( QQuickItem* parent ) initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); // we hide the focus indicator while sliding - connect( this, &QskPopup::transitioningChanged, + connect( this, &QskPopup::fadingChanged, this, &QskControl::focusIndicatorRectChanged ); - connect( this, &QskPopup::transitioningChanged, + connect( this, &QskPopup::fadingChanged, this, &QQuickItem::setClip ); connect( this, &QskPopup::opened, this, @@ -90,7 +89,7 @@ QskMenu::~QskMenu() QRectF QskMenu::clipRect() const { - if ( isTransitioning() ) + if ( isFading() ) { constexpr qreal d = 1e6; return QRectF( -d, m_data->origin.y() - y(), 2.0 * d, d ); @@ -283,23 +282,23 @@ QString QskMenu::triggeredText() const void QskMenu::updateResources() { - if ( isTransitioning() ) - { - const auto dy = ( 1.0 - transitioningFactor() ) * height(); - setPosition( m_data->origin.x(), m_data->origin.y() - dy ); - } + qreal dy = 0.0; + if ( isFading() ) + dy = ( 1.0 - fadingFactor() ) * height(); + + setPosition( m_data->origin.x(), m_data->origin.y() - dy ); Inherited::updateResources(); } void QskMenu::updateNode( QSGNode* node ) { - if ( isTransitioning() && clip() ) + if ( isFading() && clip() ) { if ( auto clipNode = QQuickItemPrivate::get( this )->clipNode() ) { /* - The clipRect is changing while transitioning. Couldn't + The clipRect is changing while fading. Couldn't find a way how to trigger updates - maybe be enabling/disabling the clip. So we do the updates manually. TODO ... */ @@ -500,7 +499,7 @@ void QskMenu::aboutToShow() QRectF QskMenu::focusIndicatorRect() const { - if ( isTransitioning() ) + if ( isFading() ) return QRectF(); if( currentIndex() >= 0 ) @@ -544,6 +543,11 @@ void QskMenu::trigger( int index ) } } +QskAspect QskMenu::fadingAspect() const +{ + return QskMenu::Panel | QskAspect::Position; +} + int QskMenu::exec() { (void) execPopup(); diff --git a/src/controls/QskMenu.h b/src/controls/QskMenu.h index 1f16dbaa..b0042455 100644 --- a/src/controls/QskMenu.h +++ b/src/controls/QskMenu.h @@ -37,7 +37,7 @@ class QSK_EXPORT QskMenu : public QskPopup using Inherited = QskPopup; public: - QSK_SUBCONTROLS( Overlay, Panel, Segment, Cursor, Text, Icon, Separator ) + QSK_SUBCONTROLS( Panel, Segment, Cursor, Text, Icon, Separator ) QSK_STATES( Selected, Pressed ) QskMenu( QQuickItem* parentItem = nullptr ); @@ -82,6 +82,7 @@ class QSK_EXPORT QskMenu : public QskPopup bool isPressed() const; QRectF clipRect() const override; + QskAspect fadingAspect() const override; Q_INVOKABLE int exec(); diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index bb390445..b066e225 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -19,16 +19,10 @@ QSK_QT_PRIVATE_BEGIN #include QSK_QT_PRIVATE_END -QSK_SUBCONTROL( QskPopup, Popup ) QSK_SUBCONTROL( QskPopup, Overlay ) QSK_SYSTEM_STATE( QskPopup, Closed, QskAspect::FirstSystemState << 1 ) -static QskAspect qskTransitioningAspect() -{ - return QskPopup::Popup | QskAspect::Metric; -} - static void qskSetFocus( QQuickItem* item, bool on ) { if ( item->window() == nullptr ) @@ -83,11 +77,11 @@ static bool qskReplayMousePress() return false; } -static void qskStartTransition( QskPopup* popup, bool on ) +static void qskStartFading( QskPopup* popup, bool on ) { - const auto aspect = qskTransitioningAspect(); + const auto aspect = popup->fadingAspect(); - auto hint = popup->animationHint( aspect.subControl() ); + auto hint = popup->animationHint( aspect ); if ( hint.isValid() ) { @@ -240,11 +234,11 @@ void QskPopup::setOpen( bool on ) else Q_EMIT closed(); - qskStartTransition( this, on ); + qskStartFading( this, on ); - if ( isTransitioning() ) + if ( isFading() ) { - Q_EMIT transitioningChanged( true ); + Q_EMIT fadingChanged( true ); } else { @@ -263,14 +257,19 @@ bool QskPopup::isOpen() const return !hasSkinState( QskPopup::Closed ); } -bool QskPopup::isTransitioning() const +QskAspect QskPopup::fadingAspect() const { - return runningHintAnimator( qskTransitioningAspect() ) != nullptr; + return QskAspect(); } -qreal QskPopup::transitioningFactor() const +bool QskPopup::isFading() const { - if ( auto animator = runningHintAnimator( qskTransitioningAspect() ) ) + return runningHintAnimator( fadingAspect() ) != nullptr; +} + +qreal QskPopup::fadingFactor() const +{ + if ( auto animator = runningHintAnimator( fadingAspect() ) ) return animator->currentValue().value< qreal >(); return isOpen() ? 1.0 : 0.0; @@ -336,7 +335,7 @@ bool QskPopup::isTransitionAccepted( QskAspect aspect ) const if ( ( aspect.value() == 0 ) ) return true; - if ( aspect.subControl() == effectiveSubcontrol( QskPopup::Popup ) ) + if ( aspect.subControl() == effectiveSubcontrol( fadingAspect().subControl() ) ) return true; if ( aspect.subControl() == effectiveSubcontrol( QskPopup::Overlay ) ) @@ -487,7 +486,7 @@ bool QskPopup::event( QEvent* event ) const auto animatorEvent = static_cast< QskAnimatorEvent* >( event ); if ( ( animatorEvent->state() == QskAnimatorEvent::Terminated ) - && ( animatorEvent->aspect() == qskTransitioningAspect() ) ) + && ( animatorEvent->aspect() == fadingAspect() ) ) { if ( !isOpen() ) { @@ -497,7 +496,7 @@ bool QskPopup::event( QEvent* event ) deleteLater(); } - Q_EMIT transitioningChanged( false ); + Q_EMIT fadingChanged( false ); } break; @@ -645,7 +644,7 @@ int QskPopup::execPopup() */ connect( popup, &QObject::destroyed, this, &EventLoop::reject ); - connect( popup, &QskPopup::transitioningChanged, this, &EventLoop::maybeQuit ); + connect( popup, &QskPopup::fadingChanged, this, &EventLoop::maybeQuit ); connect( popup, &QskPopup::openChanged, this, &EventLoop::maybeQuit ); } @@ -660,7 +659,7 @@ int QskPopup::execPopup() { if ( auto popup = qobject_cast< const QskPopup* >( parent() ) ) { - if ( popup->isOpen() || popup->isTransitioning() ) + if ( popup->isOpen() || popup->isFading() ) return; } @@ -668,7 +667,7 @@ int QskPopup::execPopup() } }; - if ( isOpen() || isTransitioning() ) + if ( isOpen() || isFading() ) { qWarning() << "QskPopup::exec: popup is already opened"; return -1; diff --git a/src/controls/QskPopup.h b/src/controls/QskPopup.h index a8ccb709..caf66346 100644 --- a/src/controls/QskPopup.h +++ b/src/controls/QskPopup.h @@ -14,7 +14,7 @@ class QSK_EXPORT QskPopup : public QskControl Q_PROPERTY( bool open READ isOpen WRITE setOpen NOTIFY openChanged ) Q_PROPERTY( bool modal READ isModal WRITE setModal NOTIFY modalChanged ) - Q_PROPERTY( bool transitioning READ isTransitioning NOTIFY transitioningChanged ) + Q_PROPERTY( bool fading READ isFading NOTIFY fadingChanged ) Q_PROPERTY( bool overlay READ hasOverlay WRITE setOverlay RESET resetOverlay NOTIFY overlayChanged ) @@ -24,7 +24,7 @@ class QSK_EXPORT QskPopup : public QskControl using Inherited = QskControl; public: - QSK_SUBCONTROLS( Popup, Overlay ) + QSK_SUBCONTROLS( Overlay ) QSK_STATES( Closed ) enum PopupFlag @@ -56,12 +56,13 @@ class QSK_EXPORT QskPopup : public QskControl void setPriority( uint ); uint priority() const; - bool isTransitioning() const; - qreal transitioningFactor() const; - bool isOpen() const; bool isClosed() const; + bool isFading() const; + qreal fadingFactor() const; + virtual QskAspect fadingAspect() const; + virtual QRectF overlayRect() const; public Q_SLOTS: @@ -75,7 +76,7 @@ class QSK_EXPORT QskPopup : public QskControl void opened(); void closed(); void openChanged( bool ); - void transitioningChanged( bool ); + void fadingChanged( bool ); void modalChanged( bool ); void overlayChanged( bool ); diff --git a/src/controls/QskPopupSkinlet.cpp b/src/controls/QskPopupSkinlet.cpp index 04730b3b..b989dc1e 100644 --- a/src/controls/QskPopupSkinlet.cpp +++ b/src/controls/QskPopupSkinlet.cpp @@ -50,7 +50,7 @@ QSGNode* QskPopupSkinlet::updateOverlayNode( { using Q = QskPopup; - const auto factor = popup->transitioningFactor(); + const auto factor = popup->fadingFactor(); if ( factor <= 0.0 ) return nullptr; diff --git a/src/controls/QskSubWindow.cpp b/src/controls/QskSubWindow.cpp index 728a1f24..229b4000 100644 --- a/src/controls/QskSubWindow.cpp +++ b/src/controls/QskSubWindow.cpp @@ -255,8 +255,13 @@ void QskSubWindow::itemChange( QQuickItem::ItemChange change, void QskSubWindow::updateResources() { - setOpacity( transitioningFactor() ); + setOpacity( fadingFactor() ); Inherited::updateResources(); } +QskAspect QskSubWindow::fadingAspect() const +{ + return QskSubWindow::Panel | QskAspect::Position; +} + #include "moc_QskSubWindow.cpp" diff --git a/src/controls/QskSubWindow.h b/src/controls/QskSubWindow.h index 76bb5d52..42afd11b 100644 --- a/src/controls/QskSubWindow.h +++ b/src/controls/QskSubWindow.h @@ -83,6 +83,7 @@ class QSK_EXPORT QskSubWindow : public QskPopup QRectF titleBarRect() const; QRectF layoutRectForSize( const QSizeF& ) const override; + QskAspect fadingAspect() const override; Q_SIGNALS: void decorationsChanged( Decorations ); diff --git a/src/controls/QskSubWindowSkinlet.cpp b/src/controls/QskSubWindowSkinlet.cpp index 771b0668..84e9a571 100644 --- a/src/controls/QskSubWindowSkinlet.cpp +++ b/src/controls/QskSubWindowSkinlet.cpp @@ -98,10 +98,10 @@ QSGNode* QskSubWindowSkinlet::updateSubNode( { /* Overloading QskPopupSkinlet: as the opacity of the subwindow already - depends on the transitioningFactor we do not want the additional opacity + depends on the fadingFactor we do not want the additional opacity adjustments for the overlay node. Maybe we should have a flag that indicates if the popup does - opacity or geometry transitions, when opening/closing TODO ... + opacity or geometry transitions, when fading TODO ... */ updateBoxNode( subWindow, node, Q::Overlay ); break;