QSkinny 0.8.0
C++/Qt UI toolkit
Loading...
Searching...
No Matches
QskLayoutElement.h
1/******************************************************************************
2 * QSkinny - Copyright (C) The authors
3 * SPDX-License-Identifier: BSD-3-Clause
4 *****************************************************************************/
5
6#ifndef QSK_LAYOUT_ELEMENT_H
7#define QSK_LAYOUT_ELEMENT_H
8
9#include "QskGlobal.h"
10#include <qnamespace.h>
11#include <qrect.h>
12
13class QskSizePolicy;
15
16class QSK_EXPORT QskLayoutElement
17{
18 public:
20 virtual ~QskLayoutElement();
21
22 QskLayoutMetrics metrics( Qt::Orientation, qreal constraint ) const;
23
24 virtual QskSizePolicy sizePolicy() const = 0;
25 virtual Qt::Alignment alignment() const = 0;
26
27 QSizeF constrainedSize( const QSizeF& ) const;
28
29 QSizeF sizeConstraint( Qt::SizeHint, const QSizeF& constraint ) const;
30
31 virtual QSizeF sizeHint( Qt::SizeHint,
32 const QSizeF& constraint = QSizeF() ) const = 0;
33
34 qreal heightForWidth( qreal ) const;
35 qreal widthForHeight( qreal ) const;
36
37 private:
38 Q_DISABLE_COPY( QskLayoutElement )
39
40 qreal metric( Qt::Orientation, Qt::SizeHint, qreal constraint ) const;
41
42 qreal boundedSize( Qt::Orientation, qreal ) const;
43};
44
45inline qreal QskLayoutElement::heightForWidth( qreal width ) const
46{
47 return sizeHint( Qt::PreferredSize, QSizeF( width, -1.0 ) ).height();
48}
49
50inline qreal QskLayoutElement::widthForHeight( qreal height ) const
51{
52 return sizeHint( Qt::PreferredSize, QSizeF( -1.0, height ) ).width();
53}
54
55class QQuickItem;
56
57class QSK_EXPORT QskItemLayoutElement final : public QskLayoutElement
58{
59 public:
60 QskItemLayoutElement( const QQuickItem* );
61
62 QskSizePolicy sizePolicy() const override;
63 Qt::Alignment alignment() const override;
64
65 private:
66 QSizeF sizeHint( Qt::SizeHint, const QSizeF& ) const override;
67
68 const QQuickItem* m_item = nullptr;
69};
70
71#endif