RetroArch
flowlayout.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the examples of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:BSD$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** BSD License Usage
18 ** Alternatively, you may use this file under the terms of the BSD license
19 ** as follows:
20 **
21 ** "Redistribution and use in source and binary forms, with or without
22 ** modification, are permitted provided that the following conditions are
23 ** met:
24 ** * Redistributions of source code must retain the above copyright
25 ** notice, this list of conditions and the following disclaimer.
26 ** * Redistributions in binary form must reproduce the above copyright
27 ** notice, this list of conditions and the following disclaimer in
28 ** the documentation and/or other materials provided with the
29 ** distribution.
30 ** * Neither the name of The Qt Company Ltd nor the names of its
31 ** contributors may be used to endorse or promote products derived
32 ** from this software without specific prior written permission.
33 **
34 **
35 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
37 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
40 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
41 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
42 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
43 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
44 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
45 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
46 **
47 ** $QT_END_LICENSE$
48 **
49 ****************************************************************************/
50 
51 /* Original work Copyright (C) 2016 The Qt Company Ltd.
52  * Modified work Copyright (C) 2018 - Brad Parker
53  */
54 
55 /* bparker: Removed C++11 override keyword from original source
56  * Changed QList to QVector
57  */
58 
59 #ifndef FLOWLAYOUT_H
60 #define FLOWLAYOUT_H
61 
62 #include <QLayout>
63 #include <QRect>
64 #include <QStyle>
65 
66 class ThumbnailWidget;
67 
68 class FlowLayout : public QLayout
69 {
70  Q_OBJECT
71 public:
72  explicit FlowLayout(QWidget *parent, int margin = -1, int hSpacing = -1, int vSpacing = -1);
73  explicit FlowLayout(int margin = -1, int hSpacing = -1, int vSpacing = -1);
74  ~FlowLayout();
75 
76  void addItem(QLayoutItem *item);
77  int horizontalSpacing() const;
78  int verticalSpacing() const;
79  Qt::Orientations expandingDirections() const;
80  bool hasHeightForWidth() const;
81  int heightForWidth(int) const;
82  int count() const;
83  QLayoutItem* itemAt(int index) const;
84  QSize minimumSize() const;
85  void setGeometry(const QRect &rect);
86  QSize sizeHint() const;
87  QLayoutItem* takeAt(int index);
88  void addWidgetDeferred(QPointer<ThumbnailWidget> widget);
89 
90 signals:
91  void signalAddWidgetDeferred(QPointer<ThumbnailWidget> widget);
92 
93 private slots:
94  void onAddWidgetDeferred(QPointer<ThumbnailWidget> widget);
95 
96 private:
97  int doLayout(const QRect &rect, bool testOnly) const;
98  int smartSpacing(QStyle::PixelMetric pm) const;
99 
100  QVector<QLayoutItem*> itemList;
101  int m_hSpace;
102  int m_vSpace;
103 };
104 
105 #endif // FLOWLAYOUT_H
int verticalSpacing() const
Definition: flowlayout.cpp:95
int m_hSpace
Definition: flowlayout.h:101
int count() const
Definition: flowlayout.cpp:103
QLayoutItem * takeAt(int index)
Definition: flowlayout.cpp:113
void setGeometry(const QRect &rect)
Definition: flowlayout.cpp:137
int doLayout(const QRect &rect, bool testOnly) const
Definition: flowlayout.cpp:166
void onAddWidgetDeferred(QPointer< ThumbnailWidget > widget)
Definition: flowlayout.cpp:241
int m_vSpace
Definition: flowlayout.h:102
int heightForWidth(int) const
Definition: flowlayout.cpp:131
Qt::Orientations expandingDirections() const
Definition: flowlayout.cpp:121
joypad_connection_t * slots
Definition: btstack_hid.c:629
bool hasHeightForWidth() const
Definition: flowlayout.cpp:126
Definition: flowlayout.h:68
QSize sizeHint() const
Definition: flowlayout.cpp:143
FlowLayout(QWidget *parent, int margin=-1, int hSpacing=-1, int vSpacing=-1)
Definition: flowlayout.cpp:60
int horizontalSpacing() const
Definition: flowlayout.cpp:87
GLuint index
Definition: glext.h:6671
void addItem(QLayoutItem *item)
Definition: flowlayout.cpp:82
void addWidgetDeferred(QPointer< ThumbnailWidget > widget)
Definition: flowlayout.cpp:236
int smartSpacing(QStyle::PixelMetric pm) const
Definition: flowlayout.cpp:221
QVector< QLayoutItem * > itemList
Definition: flowlayout.h:100
QLayoutItem * itemAt(int index) const
Definition: flowlayout.cpp:108
~FlowLayout()
Definition: flowlayout.cpp:74
void signalAddWidgetDeferred(QPointer< ThumbnailWidget > widget)
QSize minimumSize() const
Definition: flowlayout.cpp:148
Definition: ui_qt.h:114