handling of selection states for sampled subcontrols added
This commit is contained in:
parent
330df7308a
commit
0f9c86d63b
@ -20,6 +20,37 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
We need to find a way how to retrieve the extra states that are provided
|
||||||
|
by QskSkinlet::sampleStates from the control in a generic way. For the moment we
|
||||||
|
return a hardcoded list of states that we know because we know. TODO ...
|
||||||
|
*/
|
||||||
|
#include "QskMenu.h"
|
||||||
|
#include "QskRadioBox.h"
|
||||||
|
#include "QskSegmentedBar.h"
|
||||||
|
#include "QskListView.h"
|
||||||
|
|
||||||
|
static QskAspect::State qskSelectedSampleState( const QskControl* control )
|
||||||
|
{
|
||||||
|
if ( qobject_cast< const QskMenu* >( control ) )
|
||||||
|
return QskMenu::Selected;
|
||||||
|
|
||||||
|
if ( qobject_cast< const QskRadioBox* >( control ) )
|
||||||
|
return QskRadioBox::Selected;
|
||||||
|
|
||||||
|
if ( qobject_cast< const QskSegmentedBar* >( control ) )
|
||||||
|
return QskSegmentedBar::Selected;
|
||||||
|
|
||||||
|
if ( qobject_cast< const QskListView* >( control ) )
|
||||||
|
return QskListView::Selected;
|
||||||
|
|
||||||
|
return QskAspect::NoState;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static bool qskHasHintTable( const QskSkin* skin, const QskSkinHintTable& hintTable )
|
static bool qskHasHintTable( const QskSkin* skin, const QskSkinHintTable& hintTable )
|
||||||
{
|
{
|
||||||
return skin->hintTable().hints().isSharedWith( hintTable.hints() );
|
return skin->hintTable().hints().isSharedWith( hintTable.hints() );
|
||||||
@ -145,8 +176,8 @@ namespace
|
|||||||
bool isControlAffected( const QskControl*,
|
bool isControlAffected( const QskControl*,
|
||||||
const QVector< QskAspect::Subcontrol >&, QskAspect ) const;
|
const QVector< QskAspect::Subcontrol >&, QskAspect ) const;
|
||||||
|
|
||||||
void addHints( const QskControl*,
|
void addHint( const QskControl*,
|
||||||
const QskAnimationHint&, const QSet< QskAspect >& candidates,
|
const QskAnimationHint&, QskAspect,
|
||||||
const QskSkinHintTable&, const QskSkinHintTable& );
|
const QskSkinHintTable&, const QskSkinHintTable& );
|
||||||
|
|
||||||
void storeAnimator( const QskControl*, const QskAspect,
|
void storeAnimator( const QskControl*, const QskAspect,
|
||||||
@ -293,22 +324,42 @@ void WindowAnimator::addItemAspects( QQuickItem* item,
|
|||||||
const QskAnimationHint& animatorHint, const QSet< QskAspect >& candidates,
|
const QskAnimationHint& animatorHint, const QSet< QskAspect >& candidates,
|
||||||
const QskSkinHintTable& table1, const QskSkinHintTable& table2 )
|
const QskSkinHintTable& table1, const QskSkinHintTable& table2 )
|
||||||
{
|
{
|
||||||
if ( !item->isVisible() )
|
if ( auto control = qskControlCast( ( const QQuickItem* )item ) )
|
||||||
return;
|
|
||||||
|
|
||||||
if ( auto control = qskControlCast( item ) )
|
|
||||||
{
|
{
|
||||||
if ( control->isInitiallyPainted() &&
|
if ( control->isVisible() && control->isInitiallyPainted() &&
|
||||||
qskHasHintTable( control->effectiveSkin(), table2 ) )
|
qskHasHintTable( control->effectiveSkin(), table2 ) )
|
||||||
{
|
{
|
||||||
addHints( control, animatorHint, candidates, table1, table2 );
|
const auto subControls = control->subControls();
|
||||||
|
|
||||||
|
const auto& localTable = control->hintTable();
|
||||||
|
|
||||||
|
for ( auto aspect : candidates )
|
||||||
|
{
|
||||||
|
if ( isControlAffected( control, subControls, aspect ) )
|
||||||
|
{
|
||||||
|
aspect.setVariation( control->effectiveVariation() );
|
||||||
|
aspect.setStates( control->skinStates() );
|
||||||
|
aspect.setSection( control->section() );
|
||||||
|
|
||||||
|
if ( !localTable.resolvedHint( aspect ) )
|
||||||
|
addHint( control, animatorHint, aspect, table1, table2 );
|
||||||
|
|
||||||
|
if ( auto state = qskSelectedSampleState( control ) )
|
||||||
|
{
|
||||||
|
aspect.addStates( state );
|
||||||
|
if ( !localTable.resolvedHint( aspect ) )
|
||||||
|
addHint( control, animatorHint, aspect, table1, table2 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
/*
|
/*
|
||||||
As it is hard to identify which controls depend on the animated
|
As it is hard to identify which controls depend on the animated
|
||||||
graphic filters we schedule an initial update and let the
|
graphic filters we schedule an initial update and let the
|
||||||
controls do the rest: see QskSkinnable::effectiveGraphicFilter
|
controls do the rest: see QskSkinnable::effectiveGraphicFilter
|
||||||
*/
|
*/
|
||||||
control->update();
|
item->update();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,28 +387,10 @@ void WindowAnimator::update()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowAnimator::addHints( const QskControl* control,
|
void WindowAnimator::addHint( const QskControl* control,
|
||||||
const QskAnimationHint& animatorHint, const QSet< QskAspect >& candidates,
|
const QskAnimationHint& animatorHint, QskAspect aspect,
|
||||||
const QskSkinHintTable& table1, const QskSkinHintTable& table2 )
|
const QskSkinHintTable& table1, const QskSkinHintTable& table2 )
|
||||||
{
|
{
|
||||||
const auto subControls = control->subControls();
|
|
||||||
|
|
||||||
const auto& localTable = control->hintTable();
|
|
||||||
|
|
||||||
for ( auto aspect : candidates )
|
|
||||||
{
|
|
||||||
if ( !isControlAffected( control, subControls, aspect ) )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
aspect.setVariation( control->effectiveVariation() );
|
|
||||||
aspect.setStates( control->skinStates() );
|
|
||||||
|
|
||||||
if ( localTable.resolvedHint( aspect ) )
|
|
||||||
{
|
|
||||||
// value is not from the skin - ignored
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
QskAspect r1, r2;
|
QskAspect r1, r2;
|
||||||
|
|
||||||
const auto v1 = table1.resolvedHint( aspect, &r1 );
|
const auto v1 = table1.resolvedHint( aspect, &r1 );
|
||||||
@ -408,7 +441,6 @@ void WindowAnimator::addHints( const QskControl* control,
|
|||||||
storeAnimator( control, aspect, QVariant(), *v2, animatorHint );
|
storeAnimator( control, aspect, QVariant(), *v2, animatorHint );
|
||||||
storeUpdateInfo( control, aspect );
|
storeUpdateInfo( control, aspect );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool WindowAnimator::isControlAffected( const QskControl* control,
|
inline bool WindowAnimator::isControlAffected( const QskControl* control,
|
||||||
@ -445,7 +477,8 @@ inline bool WindowAnimator::isControlAffected( const QskControl* control,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void WindowAnimator::storeAnimator( const QskControl* control, const QskAspect aspect,
|
inline void WindowAnimator::storeAnimator(
|
||||||
|
const QskControl* control, const QskAspect aspect,
|
||||||
const QVariant& value1, const QVariant& value2, QskAnimationHint hint )
|
const QVariant& value1, const QVariant& value2, QskAnimationHint hint )
|
||||||
{
|
{
|
||||||
if ( m_animatorMap.find( aspect ) == m_animatorMap.cend() )
|
if ( m_animatorMap.find( aspect ) == m_animatorMap.cend() )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user