diff --git a/src/controls/QskDrawer.cpp b/src/controls/QskDrawer.cpp index 614271d29..3b965e365 100644 --- a/src/controls/QskDrawer.cpp +++ b/src/controls/QskDrawer.cpp @@ -204,7 +204,7 @@ namespace bool isAcceptedPos( const QPointF& pos ) const override { auto drawer = qobject_cast< const QskDrawer* >( targetItem() ); - if ( drawer->isFading() ) + if ( drawer->isTransitioning() ) return false; auto rect = qskItemRect( watchedItem() ); @@ -271,7 +271,7 @@ QskDrawer::QskDrawer( QQuickItem* parentItem ) setInteractive( true ); setPopupFlag( PopupFlag::CloseOnPressOutside, true ); - setFaderAspect( Panel | QskAspect::Position | QskAspect::Metric ); + setTransitionAspect( Panel | QskAspect::Position | QskAspect::Metric ); /* The drawer wants to be on top of the parent - not being @@ -281,8 +281,8 @@ QskDrawer::QskDrawer( QQuickItem* parentItem ) setPlacementPolicy( QskPlacementPolicy::Ignore ); m_data->resetListener( this ); - connect( this, &QskPopup::openChanged, this, &QskDrawer::setFading ); - connect( this, &QskPopup::fadingChanged, this, &QskDrawer::setIntermediate ); + connect( this, &QskPopup::openChanged, this, &QskDrawer::setSliding ); + connect( this, &QskPopup::transitioningChanged, this, &QskDrawer::setIntermediate ); } QskDrawer::~QskDrawer() @@ -436,8 +436,8 @@ QRectF QskDrawer::layoutRectForSize( const QSizeF& size ) const { qreal ratio; - if ( isFading() ) - ratio = metric( faderAspect() ); + if ( isTransitioning() ) + ratio = metric( transitionAspect() ); else ratio = isOpen() ? 1.0 : 0.0; @@ -467,15 +467,12 @@ void QskDrawer::itemChange( QQuickItem::ItemChange change, } } -void QskDrawer::setFading( bool on ) +void QskDrawer::setSliding( bool on ) { - if ( !hasFaderEffect() ) - return; - const qreal from = on ? 0.0 : 1.0; const qreal to = on ? 1.0 : 0.0; - const auto aspect = faderAspect(); + const auto aspect = transitionAspect(); auto hint = animationHint( aspect ); hint.updateFlags = QskAnimationHint::UpdatePolish; @@ -485,7 +482,7 @@ void QskDrawer::setFading( bool on ) QRectF QskDrawer::clipRect() const { - if ( !isFading() ) + if ( !isTransitioning() ) return Inherited::clipRect(); /* @@ -534,7 +531,7 @@ void QskDrawer::setIntermediate( bool on ) QRectF QskDrawer::focusIndicatorRect() const { - if ( isFading() ) + if ( isTransitioning() ) return QRectF(); return Inherited::focusIndicatorRect(); diff --git a/src/controls/QskDrawer.h b/src/controls/QskDrawer.h index d7e66d0ca..de02b435b 100644 --- a/src/controls/QskDrawer.h +++ b/src/controls/QskDrawer.h @@ -55,8 +55,7 @@ class QSK_EXPORT QskDrawer : public QskPopup void keyPressEvent( QKeyEvent* ) override; private: - void setFading( bool ); - void setFadingClip( bool ); + void setSliding( bool ); void setIntermediate( bool ); diff --git a/src/controls/QskMenu.cpp b/src/controls/QskMenu.cpp index 7390e3172..43ed0a1f1 100644 --- a/src/controls/QskMenu.cpp +++ b/src/controls/QskMenu.cpp @@ -58,7 +58,7 @@ QskMenu::QskMenu( QQuickItem* parent ) , m_data( new PrivateData ) { setModal( true ); - setFaderAspect( QskMenu::Panel | QskAspect::Position | QskAspect::Metric ); + setTransitionAspect( QskMenu::Panel | QskAspect::Position | QskAspect::Metric ); setPopupFlag( QskPopup::CloseOnPressOutside, true ); setPopupFlag( QskPopup::DeleteOnClose, true ); @@ -67,8 +67,8 @@ QskMenu::QskMenu( QQuickItem* parent ) initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); - // we hide the focus indicator while fading - connect( this, &QskMenu::fadingChanged, this, + // we hide the focus indicator while sliding + connect( this, &QskMenu::transitioningChanged, this, &QskControl::focusIndicatorRectChanged ); connect( this, &QskMenu::opened, this, @@ -452,7 +452,7 @@ void QskMenu::aboutToShow() QRectF QskMenu::focusIndicatorRect() const { - if ( isFading() ) + if ( isTransitioning() ) return QRectF(); if( currentIndex() >= 0 ) diff --git a/src/controls/QskMenuSkinlet.cpp b/src/controls/QskMenuSkinlet.cpp index d75323a99..13be2b34d 100644 --- a/src/controls/QskMenuSkinlet.cpp +++ b/src/controls/QskMenuSkinlet.cpp @@ -236,7 +236,7 @@ QSGNode* QskMenuSkinlet::updateSubNode( auto slideInNode = QskSGNode::ensureNode< QskSlideInNode >( node ); - const auto progress = popup->metric( popup->faderAspect() ); + const auto progress = popup->metric( popup->transitionAspect() ); slideInNode->updateTranslation( rect, Qt::TopEdge, progress ); auto contentsNode = updateContentsNode( popup, slideInNode->contentsNode() ); diff --git a/src/controls/QskPopup.cpp b/src/controls/QskPopup.cpp index 507148361..bef481468 100644 --- a/src/controls/QskPopup.cpp +++ b/src/controls/QskPopup.cpp @@ -130,7 +130,6 @@ class QskPopup::PrivateData PrivateData() : flags( 0 ) , isModal( false ) - , hasFaderEffect( true ) , autoGrabFocus( true ) , handoverFocus( true ) { @@ -139,11 +138,10 @@ class QskPopup::PrivateData InputGrabber* inputGrabber = nullptr; uint priority = 0; - QskAspect faderAspect; + QskAspect transitionAspect; int flags : 4; bool isModal : 1; - bool hasFaderEffect : 1; const bool autoGrabFocus : 1; const bool handoverFocus : 1; @@ -218,9 +216,9 @@ void QskPopup::setOpen( bool on ) else Q_EMIT closed(); - if ( isFading() ) + if ( isTransitioning() ) { - Q_EMIT fadingChanged( true ); + Q_EMIT transitioningChanged( true ); } else { @@ -239,13 +237,13 @@ bool QskPopup::isOpen() const return !hasSkinState( QskPopup::Closed ); } -bool QskPopup::isFading() const +bool QskPopup::isTransitioning() const { - if ( m_data->faderAspect.value() == 0 ) + if ( m_data->transitionAspect.value() == 0 ) return false; QskSkinHintStatus status; - (void) effectiveSkinHint( m_data->faderAspect, &status ); + (void) effectiveSkinHint( m_data->transitionAspect, &status ); return status.source == QskSkinHintStatus::Animator; } @@ -298,37 +296,37 @@ void QskPopup::updateInputGrabber() } } -QskAspect QskPopup::faderAspect() const +QskAspect QskPopup::transitionAspect() const { - return m_data->faderAspect; + return m_data->transitionAspect; } -void QskPopup::setFaderAspect( QskAspect aspect ) +void QskPopup::setTransitionAspect( QskAspect aspect ) { - auto faderAspect = aspect; - faderAspect.clearStates(); // animated values are always stateless + auto transitionAspect = aspect; + transitionAspect.clearStates(); // animated values are always stateless - if ( faderAspect == m_data->faderAspect ) + if ( transitionAspect == m_data->transitionAspect ) return; - if ( isFading() ) + if ( isTransitioning() ) { // stop the running animation TODO ... } - m_data->faderAspect = faderAspect; + m_data->transitionAspect = transitionAspect; } bool QskPopup::isTransitionAccepted( QskAspect aspect ) const { - if ( isVisible() && m_data->hasFaderEffect ) + if ( isVisible() ) { if ( ( aspect.value() == 0 ) ) { return true; } - if ( aspect == m_data->faderAspect ) + if ( aspect == m_data->transitionAspect ) return true; if ( aspect.isColor() ) @@ -371,20 +369,6 @@ bool QskPopup::isModal() const return m_data->isModal; } -void QskPopup::setFaderEffect( bool on ) -{ - if ( on != m_data->hasFaderEffect ) - { - m_data->hasFaderEffect = on; - Q_EMIT faderEffectChanged( on ); - } -} - -bool QskPopup::hasFaderEffect() const -{ - return m_data->hasFaderEffect; -} - void QskPopup::setPopupFlags( PopupFlags flags ) { const auto newFlags = static_cast< int >( flags ); @@ -496,7 +480,7 @@ bool QskPopup::event( QEvent* event ) const auto animtorEvent = static_cast< QskAnimatorEvent* >( event ); if ( ( animtorEvent->state() == QskAnimatorEvent::Terminated ) - && ( animtorEvent->aspect() == m_data->faderAspect ) ) + && ( animtorEvent->aspect() == m_data->transitionAspect ) ) { if ( !isOpen() ) { @@ -506,7 +490,7 @@ bool QskPopup::event( QEvent* event ) deleteLater(); } - Q_EMIT fadingChanged( false ); + Q_EMIT transitioningChanged( false ); } break; @@ -643,7 +627,7 @@ int QskPopup::execPopup() */ connect( popup, &QObject::destroyed, this, &EventLoop::reject ); - connect( popup, &QskPopup::fadingChanged, this, &EventLoop::maybeQuit ); + connect( popup, &QskPopup::transitioningChanged, this, &EventLoop::maybeQuit ); connect( popup, &QskPopup::openChanged, this, &EventLoop::maybeQuit ); } @@ -658,7 +642,7 @@ int QskPopup::execPopup() { if ( auto popup = qobject_cast< const QskPopup* >( parent() ) ) { - if ( popup->isOpen() || popup->isFading() ) + if ( popup->isOpen() || popup->isTransitioning() ) return; } @@ -666,7 +650,7 @@ int QskPopup::execPopup() } }; - if ( isOpen() || isFading() ) + if ( isOpen() || isTransitioning() ) { qWarning() << "QskPopup::exec: popup is already opened"; return -1; diff --git a/src/controls/QskPopup.h b/src/controls/QskPopup.h index b2c99c7db..f811a26d7 100644 --- a/src/controls/QskPopup.h +++ b/src/controls/QskPopup.h @@ -14,13 +14,11 @@ 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 overlay READ hasOverlay WRITE setOverlay RESET resetOverlay NOTIFY overlayChanged ) - Q_PROPERTY( bool faderEffect READ hasFaderEffect - WRITE setFaderEffect NOTIFY faderEffectChanged ) - Q_PROPERTY( uint priority READ priority WRITE setPriority NOTIFY priorityChanged ) using Inherited = QskControl; @@ -58,16 +56,16 @@ class QSK_EXPORT QskPopup : public QskControl void setPriority( uint ); uint priority() const; - void setFaderEffect( bool ); - bool hasFaderEffect() const; - - QskAspect faderAspect() const; - void setFaderAspect( QskAspect ); + // transitions between open/closed states + QskAspect transitionAspect() const; + void setTransitionAspect( QskAspect ); - virtual QRectF overlayRect() const; + bool isTransitioning() const; bool isOpen() const; - bool isFading() const; + bool isClosed() const; + + virtual QRectF overlayRect() const; public Q_SLOTS: void open(); @@ -80,12 +78,11 @@ class QSK_EXPORT QskPopup : public QskControl void opened(); void closed(); void openChanged( bool ); - void fadingChanged( bool ); + void transitioningChanged( bool ); void modalChanged( bool ); void overlayChanged( bool ); void priorityChanged( uint ); - void faderEffectChanged( bool ); protected: void aboutToShow() override; @@ -115,6 +112,11 @@ class QSK_EXPORT QskPopup : public QskControl std::unique_ptr< PrivateData > m_data; }; +inline bool QskPopup::isClosed() const +{ + return !isOpen(); +} + Q_DECLARE_OPERATORS_FOR_FLAGS( QskPopup::PopupFlags ) #endif