LMMS
Loading...
Searching...
No Matches
ControlLayout.h
Go to the documentation of this file.
1/*
2 * ControlLayout.h - layout for controls
3 *
4 * Copyright (c) 2019-2019 Johannes Lorenz <j.git$$$lorenz-ho.me, $$$=@>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25/****************************************************************************
26**
27** Copyright (C) 2016 The Qt Company Ltd.
28** Contact: https://www.qt.io/licensing/
29**
30** $QT_BEGIN_LICENSE:BSD$
31** Commercial License Usage
32** Licensees holding valid commercial Qt licenses may use this file in
33** accordance with the commercial license agreement provided with the
34** Software or, alternatively, in accordance with the terms contained in
35** a written agreement between you and The Qt Company. For licensing terms
36** and conditions see https://www.qt.io/terms-conditions. For further
37** information use the contact form at https://www.qt.io/contact-us.
38**
39** BSD License Usage
40** Alternatively, you may use this file under the terms of the BSD license
41** as follows:
42**
43** "Redistribution and use in source and binary forms, with or without
44** modification, are permitted provided that the following conditions are
45** met:
46** * Redistributions of source code must retain the above copyright
47** notice, this list of conditions and the following disclaimer.
48** * Redistributions in binary form must reproduce the above copyright
49** notice, this list of conditions and the following disclaimer in
50** the documentation and/or other materials provided with the
51** distribution.
52** * Neither the name of The Qt Company Ltd nor the names of its
53** contributors may be used to endorse or promote products derived
54** from this software without specific prior written permission.
55**
56**
57** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
58** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
59** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
60** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
61** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
63** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
64** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
65** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
66** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
67** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
68**
69** $QT_END_LICENSE$
70**
71****************************************************************************/
72
73#ifndef LMMS_GUI_CONTROL_LAYOUT_H
74#define LMMS_GUI_CONTROL_LAYOUT_H
75
76#include <QLayout>
77#include <QMultiMap>
78#include <QStyle>
79
80class QLayoutItem;
81class QLineEdit;
82
83
84namespace lmms::gui
85{
86
95class ControlLayout : public QLayout
96{
97 Q_OBJECT
98
99 using ControlLayoutMap = QMap<QString, QLayoutItem*>;
100
101public:
102 explicit ControlLayout(QWidget *parent,
103 int margin = -1, int hSpacing = -1, int vSpacing = -1);
104 ~ControlLayout() override;
105
106 void addItem(QLayoutItem *item) override;
107 int horizontalSpacing() const;
108 int verticalSpacing() const;
109 Qt::Orientations expandingDirections() const override;
110 bool hasHeightForWidth() const override;
111 int heightForWidth(int) const override;
112 int count() const override;
113 QLayoutItem *itemAt(int index) const override;
114 QLayoutItem *itemByString(const QString& key) const;
115 QSize minimumSize() const override;
116 void setGeometry(const QRect &rect) override;
117 QSize sizeHint() const override;
118 QLayoutItem *takeAt(int index) override;
122
123private slots:
124 void onTextChanged(const QString&);
125
126private:
127 int doLayout(const QRect &rect, bool testOnly) const;
128 int smartSpacing(QStyle::PixelMetric pm) const;
129 ControlLayoutMap::const_iterator pairAt(int index) const;
130
134 // relevant dimension is width, as later, heightForWidth() will be called
135 // 400 looks good and is ~4 knobs in a row
136 constexpr const static int m_minWidth = 400;
137 QLineEdit* m_searchBar;
139 static constexpr const char* s_searchBarName = "!!searchBar!!";
140};
141
142} // namespace lmms::gui
143
144#endif // LMMS_GUI_CONTROL_LAYOUT_H
static constexpr const char * s_searchBarName
name of search bar, must be ASCII sorted before any alpha numerics
Definition ControlLayout.h:139
QLayoutItem * itemAt(int index) const override
Definition ControlLayout.cpp:163
ControlLayoutMap m_itemMap
Definition ControlLayout.h:131
QLineEdit * m_searchBar
Definition ControlLayout.h:137
void addItem(QLayoutItem *item) override
Definition ControlLayout.cpp:113
QSize minimumSize() const override
Definition ControlLayout.cpp:214
QLayoutItem * takeAt(int index) override
Definition ControlLayout.cpp:176
void setGeometry(const QRect &rect) override
Definition ControlLayout.cpp:203
ControlLayout(QWidget *parent, int margin=-1, int hSpacing=-1, int vSpacing=-1)
Definition ControlLayout.cpp:89
void removeFocusFromSearchBar()
Definition ControlLayout.cpp:182
int doLayout(const QRect &rect, bool testOnly) const
Definition ControlLayout.cpp:233
QLayoutItem * itemByString(const QString &key) const
Definition ControlLayout.cpp:169
int m_vSpace
Definition ControlLayout.h:133
Qt::Orientations expandingDirections() const override
Definition ControlLayout.cpp:187
int heightForWidth(int) const override
Definition ControlLayout.cpp:197
int horizontalSpacing() const
Definition ControlLayout.cpp:121
QMap< QString, QLayoutItem * > ControlLayoutMap
Definition ControlLayout.h:99
~ControlLayout() override
Definition ControlLayout.cpp:102
void onTextChanged(const QString &)
Definition ControlLayout.cpp:107
bool hasHeightForWidth() const override
Definition ControlLayout.cpp:192
QSize sizeHint() const override
Definition ControlLayout.cpp:209
int count() const override
Definition ControlLayout.cpp:139
ControlLayoutMap::const_iterator pairAt(int index) const
Definition ControlLayout.cpp:145
int verticalSpacing() const
Definition ControlLayout.cpp:130
constexpr static const int m_minWidth
Definition ControlLayout.h:136
int smartSpacing(QStyle::PixelMetric pm) const
Definition ControlLayout.cpp:303
int m_hSpace
Definition ControlLayout.h:132
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:223
ZCONST char * key
Definition crypt.c:587