QskControl::LayoutOutWhenHidden flag added

This commit is contained in:
Uwe Rathmann 2020-03-10 10:30:44 +01:00
parent 4dad15f591
commit 1941fbc847
6 changed files with 32 additions and 3 deletions

View File

@ -59,7 +59,14 @@ class QSK_EXPORT QskControl : public QskQuickItem, public QskSkinnable
enum LayoutHint enum LayoutHint
{ {
// How to be treated by layouts // How to be treated by layouts
RetainSizeWhenHidden = 1 << 0 RetainSizeWhenHidden = 1 << 0,
/*
Adjust the item even, even when being hidden
Depending on the type of layout the value only works
in combination with RetainSizeWhenHidden
*/
LayoutOutWhenHidden = 1 << 1
}; };
Q_ENUM( LayoutHint ) Q_ENUM( LayoutHint )

View File

@ -581,7 +581,7 @@ void QskGridLayoutEngine::layoutItems()
{ {
auto item = element.item(); auto item = element.item();
if ( item && qskIsVisibleToParent( item ) ) if ( requiresAdjustment( item ) )
{ {
const auto grid = m_data->effectiveGrid( element ); const auto grid = m_data->effectiveGrid( element );
layoutItem( item, grid ); layoutItem( item, grid );

View File

@ -6,6 +6,7 @@
#include "QskLayoutEngine2D.h" #include "QskLayoutEngine2D.h"
#include "QskLayoutChain.h" #include "QskLayoutChain.h"
#include "QskLayoutHint.h" #include "QskLayoutHint.h"
#include "QskControl.h"
#include "QskQuick.h" #include "QskQuick.h"
#include <qguiapplication.h> #include <qguiapplication.h>
@ -652,3 +653,19 @@ QskSizePolicy::ConstraintType QskLayoutEngine2D::constraintType() const
return static_cast< QskSizePolicy::ConstraintType >( m_data->constraintType ); return static_cast< QskSizePolicy::ConstraintType >( m_data->constraintType );
} }
bool QskLayoutEngine2D::requiresAdjustment( const QQuickItem* item ) const
{
if ( qskIsVisibleToParent( item ) )
return true;
if ( auto control = qskControlCast( item ) )
{
constexpr auto mask =
QskControl::RetainSizeWhenHidden | QskControl::LayoutOutWhenHidden;
if ( control->layoutHints() & mask )
return true;
}
return false;
}

View File

@ -67,6 +67,7 @@ class QskLayoutEngine2D
}; };
void invalidate( int what ); void invalidate( int what );
bool requiresAdjustment( const QQuickItem* ) const;
private: private:
Q_DISABLE_COPY( QskLayoutEngine2D ) Q_DISABLE_COPY( QskLayoutEngine2D )

View File

@ -348,7 +348,7 @@ void QskLinearLayoutEngine::layoutItems()
if ( auto item = element.item() ) if ( auto item = element.item() )
{ {
if ( qskIsVisibleToParent( item ) ) if ( requiresAdjustment( item ) )
{ {
const QRect grid( col, row, 1, 1 ); const QRect grid( col, row, 1, 1 );
layoutItem( item, grid ); layoutItem( item, grid );

View File

@ -331,6 +331,10 @@ void QskStackBox::updateLayout()
if ( maybeUnresized() ) if ( maybeUnresized() )
return; return;
#if 1
// what about QskControl::LayoutOutWhenHidden
#endif
const auto index = m_data->currentIndex; const auto index = m_data->currentIndex;
if ( index >= 0 ) if ( index >= 0 )