LMMS
Loading...
Searching...
No Matches
AutomatableButton.h
Go to the documentation of this file.
1/*
2 * AutomatableButton.h - class AutomatableButton, the base for all buttons
3 *
4 * Copyright (c) 2006-2008 Tobias Doerffel <tobydox/at/users.sourceforge.net>
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#ifndef LMMS_GUI_AUTOMATABLE_BUTTON_H
26#define LMMS_GUI_AUTOMATABLE_BUTTON_H
27
28#include <QPushButton>
29
31
32namespace lmms::gui
33{
34
36
37
38class LMMS_EXPORT AutomatableButton : public QPushButton, public BoolModelView
39{
40 Q_OBJECT
41public:
42 AutomatableButton( QWidget * _parent, const QString & _name
43 = QString() );
44 ~AutomatableButton() override;
45
46 inline void setCheckable( bool _on )
47 {
48 QPushButton::setCheckable( _on );
49 model()->setJournalling( _on );
50 }
51
52 void modelChanged() override;
53
54
55public slots:
56 virtual void update();
57 virtual void toggle();
58 virtual void setChecked( bool _on )
59 {
60 // QPushButton::setChecked is called in update-slot
61 model()->setValue( _on );
62 }
63
64
65protected:
66 void contextMenuEvent( QContextMenuEvent * _me ) override;
67 void mousePressEvent( QMouseEvent * _me ) override;
68 void mouseReleaseEvent( QMouseEvent * _me ) override;
69
70
71private:
73
74
76
77 using QPushButton::setChecked;
78 using QPushButton::isChecked;
79} ;
80
81
82
83class LMMS_EXPORT AutomatableButtonGroup : public QWidget, public IntModelView
84{
85 Q_OBJECT
86public:
87 AutomatableButtonGroup( QWidget * _parent, const QString & _name
88 = QString() );
89 ~AutomatableButtonGroup() override;
90
91 void addButton( AutomatableButton * _btn );
92 void removeButton( AutomatableButton * _btn );
93
94 void activateButton( AutomatableButton * _btn );
95
96 void modelChanged() override;
97
98
99private slots:
100 void updateButtons();
101
102
103private:
104 QList<AutomatableButton *> m_buttons;
105
106} ;
107
108
109} // namespace lmms::gui
110
111#endif // LMMS_GUI_AUTOMATABLE_BUTTON_H
Definition AutomatableButton.h:84
void updateButtons()
Definition AutomatableButton.cpp:266
QList< AutomatableButton * > m_buttons
Definition AutomatableButton.h:104
void modelChanged() override
Definition AutomatableButton.cpp:255
void addButton(AutomatableButton *_btn)
Definition AutomatableButton.cpp:213
void activateButton(AutomatableButton *_btn)
Definition AutomatableButton.cpp:239
void removeButton(AutomatableButton *_btn)
Definition AutomatableButton.cpp:230
AutomatableButtonGroup(QWidget *_parent, const QString &_name=QString())
Definition AutomatableButton.cpp:190
Definition AutomatableButton.h:39
AutomatableButtonGroup * m_group
Definition AutomatableButton.h:72
friend class AutomatableButtonGroup
Definition AutomatableButton.h:75
void setCheckable(bool _on)
Definition AutomatableButton.h:46
virtual void setChecked(bool _on)
Definition AutomatableButton.h:58
AutomatableButton(QWidget *_parent, const QString &_name=QString())
Definition AutomatableButton.cpp:38
BoolModel * model()
Definition AutomatableModelView.h:121
Definition AudioPortAudio.cpp:223
TypedModelView< BoolModel > BoolModelView
Definition AutomatableModelView.h:133
TypedModelView< IntModel > IntModelView
Definition AutomatableModelView.h:132