QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskLinearLayoutEngine.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_LINEAR_LAYOUT_ENGINE_H
7#define QSK_LINEAR_LAYOUT_ENGINE_H
8
9#include "QskGlobal.h"
10#include "QskLayoutEngine2D.h"
11
12#include <qnamespace.h>
13#include <memory>
14
15class QQuickItem;
16class QSizeF;
17class QRectF;
18
20{
21 public:
22 QskLinearLayoutEngine( Qt::Orientation, uint dimension );
23 ~QskLinearLayoutEngine() override;
24
25 Qt::Orientation orientation() const;
26 bool setOrientation( Qt::Orientation );
27
28 bool setDimension( uint dimension );
29 uint dimension() const;
30
31 int count() const override final;
32
33 int insertItem( QQuickItem*, int index );
34 int addItem( QQuickItem* );
35
36 int insertSpacerAt( int index, qreal spacing );
37 int addSpacer( qreal spacing );
38
39 bool removeAt( int index );
40 bool clear();
41
42 int indexOf( const QQuickItem* ) const;
43
44 QQuickItem* itemAt( int index ) const;
45 qreal spacerAt( int index ) const;
46
47 bool setStretchFactorAt( int index, int stretchFactor );
48 int stretchFactorAt( int index ) const;
49
50 private:
51 Q_DISABLE_COPY(QskLinearLayoutEngine)
52
53 QskSizePolicy sizePolicyAt( int index ) const override final;
54 void layoutItems() override;
55
56 int effectiveCount() const;
57 int effectiveCount( Qt::Orientation ) const override;
58
59 void invalidateElementCache() override;
60
61 virtual void setupChain( Qt::Orientation, const QskLayoutChain::Segments&,
62 QskLayoutChain& ) const override final;
63
64 class PrivateData;
65 std::unique_ptr< PrivateData > m_data;
66};
67
68inline int QskLinearLayoutEngine::addItem( QQuickItem* item )
69{
70 return insertItem( item, -1 );
71}
72
73inline int QskLinearLayoutEngine::addSpacer( qreal spacing )
74{
75 return insertSpacerAt( -1, spacing );
76}
77
78#endif