startHintTransitions added to be able to start transitions withot

changing the state
This commit is contained in:
Uwe Rathmann 2022-09-09 11:29:47 +02:00
parent 47df732f4a
commit 996e849fc5
2 changed files with 80 additions and 57 deletions

View File

@ -1302,28 +1302,52 @@ void QskSkinnable::setSkinStates( QskAspect::States newStates )
auto control = owningControl();
#if DEBUG_STATE
qDebug() << control->className() << ":"
const auto className = control ? control->className() : "QskSkinnable";
qDebug() << className << ":"
<< skinStateAsPrintable( m_data->skinState ) << "->"
<< skinStateAsPrintable( newState );
#endif
const auto skin = effectiveSkin();
if ( skin )
if ( control && control->window() )
{
const auto mask = skin->hintTable().states() | m_data->hintTable.states();
if ( ( newStates & mask ) == ( m_data->skinStates & mask ) )
const bool needUpdate = startHintTransitions( m_data->skinStates, newStates );
if ( needUpdate )
{
// the modified bits are not handled by the skin
if ( control->flags() & QQuickItem::ItemHasContents )
control->update();
}
}
m_data->skinStates = newStates;
return;
}
}
if ( control->window() && isTransitionAccepted( QskAspect() ) )
bool QskSkinnable::startHintTransitions(
QskAspect::States oldStates, QskAspect::States newStates )
{
const auto skin = effectiveSkin();
auto control = owningControl();
if ( skin == nullptr || control == nullptr || control->window() == nullptr )
return false;
const auto mask = m_data->hintTable.states() | skin->hintTable().states();
if ( ( newStates & mask ) == ( oldStates & mask ) )
{
/*
When there are no aspects for the changed state bits we know
that there won't be any animated transitions
*/
return false;
}
if ( !isTransitionAccepted( QskAspect() ) )
{
// the control does not like any animated transition at the moment
return false;
}
bool started = false; // at least one transition has been started
QskAspect aspect;
aspect.setPlacement( effectivePlacement() );
aspect.setSection( section() );
@ -1376,17 +1400,15 @@ void QskSkinnable::setSkinStates( QskAspect::States newStates )
{
startHintTransition( aspect, hint,
storedHint( a1 ), storedHint( a2 ) );
}
started = true;
}
}
}
}
}
m_data->skinStates = newStates;
if ( control->flags() & QQuickItem::ItemHasContents )
control->update();
return started;
}
QskSkin* QskSkinnable::effectiveSkin() const

View File

@ -258,6 +258,7 @@ class QSK_EXPORT QskSkinnable
private:
Q_DISABLE_COPY( QskSkinnable )
bool startHintTransitions( QskAspect::States, QskAspect::States );
void startHintTransition( QskAspect,
QskAnimationHint, const QVariant& from, const QVariant& to );