Skip to content

Commit

Permalink
QskPopup::fading renamed to QskPopup::transitioning
Browse files Browse the repository at this point in the history
  • Loading branch information
uwerat committed Oct 19, 2023
1 parent 4cbd0d6 commit b3c7eb7
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 69 deletions.
23 changes: 10 additions & 13 deletions src/controls/QskDrawer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand All @@ -485,7 +482,7 @@ void QskDrawer::setFading( bool on )

QRectF QskDrawer::clipRect() const
{
if ( !isFading() )
if ( !isTransitioning() )
return Inherited::clipRect();

/*
Expand Down Expand Up @@ -534,7 +531,7 @@ void QskDrawer::setIntermediate( bool on )

QRectF QskDrawer::focusIndicatorRect() const
{
if ( isFading() )
if ( isTransitioning() )
return QRectF();

return Inherited::focusIndicatorRect();
Expand Down
3 changes: 1 addition & 2 deletions src/controls/QskDrawer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand Down
8 changes: 4 additions & 4 deletions src/controls/QskMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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,
Expand Down Expand Up @@ -452,7 +452,7 @@ void QskMenu::aboutToShow()

QRectF QskMenu::focusIndicatorRect() const
{
if ( isFading() )
if ( isTransitioning() )
return QRectF();

if( currentIndex() >= 0 )
Expand Down
2 changes: 1 addition & 1 deletion src/controls/QskMenuSkinlet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() );
Expand Down
58 changes: 21 additions & 37 deletions src/controls/QskPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class QskPopup::PrivateData
PrivateData()
: flags( 0 )
, isModal( false )
, hasFaderEffect( true )
, autoGrabFocus( true )
, handoverFocus( true )
{
Expand All @@ -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;
Expand Down Expand Up @@ -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
{
Expand All @@ -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;
}
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() )
{
Expand All @@ -506,7 +490,7 @@ bool QskPopup::event( QEvent* event )
deleteLater();
}

Q_EMIT fadingChanged( false );
Q_EMIT transitioningChanged( false );
}

break;
Expand Down Expand Up @@ -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 );
}

Expand All @@ -658,15 +642,15 @@ int QskPopup::execPopup()
{
if ( auto popup = qobject_cast< const QskPopup* >( parent() ) )
{
if ( popup->isOpen() || popup->isFading() )
if ( popup->isOpen() || popup->isTransitioning() )
return;
}

QEventLoop::exit( 0 );
}
};

if ( isOpen() || isFading() )
if ( isOpen() || isTransitioning() )
{
qWarning() << "QskPopup::exec: popup is already opened";
return -1;
Expand Down
26 changes: 14 additions & 12 deletions src/controls/QskPopup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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

0 comments on commit b3c7eb7

Please sign in to comment.