2019-06-19 14:08:45 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef QSK_LINEAR_LAYOUT_ENGINE_H
|
|
|
|
#define QSK_LINEAR_LAYOUT_ENGINE_H
|
|
|
|
|
2019-07-13 11:01:48 +02:00
|
|
|
#include "QskGlobal.h"
|
2019-07-27 12:36:52 +02:00
|
|
|
#include "QskLayoutEngine2D.h"
|
2019-07-13 11:01:48 +02:00
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
#include <qnamespace.h>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class QQuickItem;
|
2019-07-13 11:01:48 +02:00
|
|
|
class QSizeF;
|
|
|
|
class QRectF;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
class QskLinearLayoutEngine : public QskLayoutEngine2D
|
2019-06-19 14:08:45 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
QskLinearLayoutEngine( Qt::Orientation, uint dimension );
|
2019-07-27 12:36:52 +02:00
|
|
|
~QskLinearLayoutEngine() override;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
|
|
|
Qt::Orientation orientation() const;
|
2019-07-12 15:37:42 +02:00
|
|
|
bool setOrientation( Qt::Orientation );
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-12 15:37:42 +02:00
|
|
|
bool setDimension( uint dimension );
|
2019-06-19 14:08:45 +02:00
|
|
|
uint dimension() const;
|
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
int count() const override final;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
int insertItem( QQuickItem*, int index );
|
|
|
|
int addItem( QQuickItem* );
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
int insertSpacerAt( int index, qreal spacing );
|
|
|
|
int addSpacer( qreal spacing );
|
2019-07-12 15:37:42 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
bool removeAt( int index );
|
|
|
|
bool clear();
|
2019-07-12 15:37:42 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
QQuickItem* itemAt( int index ) const override final;
|
2019-09-16 12:36:29 +02:00
|
|
|
qreal spacerAt( int index ) const;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-12 15:37:42 +02:00
|
|
|
bool setStretchFactorAt( int index, int stretchFactor );
|
2019-06-19 14:08:45 +02:00
|
|
|
int stretchFactorAt( int index ) const;
|
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
private:
|
|
|
|
Q_DISABLE_COPY(QskLinearLayoutEngine)
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
void layoutItems() override;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
int effectiveCount() const;
|
|
|
|
int effectiveCount( Qt::Orientation ) const override;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
void invalidateElementCache() override;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
virtual void setupChain( Qt::Orientation,
|
|
|
|
const QskLayoutChain::Segments&, QskLayoutChain& ) const override;
|
2019-06-19 14:08:45 +02:00
|
|
|
|
|
|
|
class PrivateData;
|
|
|
|
std::unique_ptr< PrivateData > m_data;
|
|
|
|
};
|
|
|
|
|
2019-07-27 12:36:52 +02:00
|
|
|
inline int QskLinearLayoutEngine::addItem( QQuickItem* item )
|
|
|
|
{
|
|
|
|
return insertItem( item, -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
inline int QskLinearLayoutEngine::addSpacer( qreal spacing )
|
|
|
|
{
|
|
|
|
return insertSpacerAt( -1, spacing );
|
|
|
|
}
|
|
|
|
|
2019-06-19 14:08:45 +02:00
|
|
|
#endif
|