dynamic constraints for QskStackBox added
This commit is contained in:
parent
ff9e9ab63c
commit
cf58650c05
|
@ -7,6 +7,8 @@
|
||||||
#include "QskStackBoxAnimator.h"
|
#include "QskStackBoxAnimator.h"
|
||||||
#include "QskLayoutItem.h"
|
#include "QskLayoutItem.h"
|
||||||
#include "QskLayoutEngine.h"
|
#include "QskLayoutEngine.h"
|
||||||
|
#include "QskLayoutConstraint.h"
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
|
||||||
class QskStackBox::PrivateData
|
class QskStackBox::PrivateData
|
||||||
|
@ -237,6 +239,36 @@ QSizeF QskStackBox::contentsSizeHint() const
|
||||||
return QSizeF( width, height );
|
return QSizeF( width, height );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal QskStackBox::heightForWidth( qreal width ) const
|
||||||
|
{
|
||||||
|
qreal height = -1;
|
||||||
|
|
||||||
|
const QskLayoutEngine& engine = this->engine();
|
||||||
|
for ( int i = 0; i < engine.itemCount(); i++ )
|
||||||
|
{
|
||||||
|
const QskLayoutItem* layoutItem = engine.layoutItemAt( i );
|
||||||
|
if ( const auto item = layoutItem->item() )
|
||||||
|
height = qMax( height, QskLayoutConstraint::heightForWidth( item, width ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return height;
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal QskStackBox::widthForHeight( qreal height ) const
|
||||||
|
{
|
||||||
|
qreal width = -1;
|
||||||
|
|
||||||
|
const QskLayoutEngine& engine = this->engine();
|
||||||
|
for ( int i = 0; i < engine.itemCount(); i++ )
|
||||||
|
{
|
||||||
|
const QskLayoutItem* layoutItem = engine.layoutItemAt( i );
|
||||||
|
if ( const auto item = layoutItem->item() )
|
||||||
|
width = qMax( width, QskLayoutConstraint::widthForHeight( item, height ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return width;
|
||||||
|
}
|
||||||
|
|
||||||
void QskStackBox::layoutItemInserted( QskLayoutItem* layoutItem, int index )
|
void QskStackBox::layoutItemInserted( QskLayoutItem* layoutItem, int index )
|
||||||
{
|
{
|
||||||
Q_UNUSED( index )
|
Q_UNUSED( index )
|
||||||
|
|
|
@ -34,6 +34,9 @@ public:
|
||||||
|
|
||||||
virtual QSizeF contentsSizeHint() const override;
|
virtual QSizeF contentsSizeHint() const override;
|
||||||
|
|
||||||
|
virtual qreal heightForWidth( qreal width ) const override;
|
||||||
|
virtual qreal widthForHeight( qreal height ) const override;
|
||||||
|
|
||||||
void setAnimator( QskStackBoxAnimator* );
|
void setAnimator( QskStackBoxAnimator* );
|
||||||
const QskStackBoxAnimator* animator() const;
|
const QskStackBoxAnimator* animator() const;
|
||||||
QskStackBoxAnimator* animator();
|
QskStackBoxAnimator* animator();
|
||||||
|
|
Loading…
Reference in New Issue