LMMS
Loading...
Searching...
No Matches
FadeButton.h
Go to the documentation of this file.
1/*
2 * FadeButton.h - declaration of class fadeButton
3 *
4 * Copyright (c) 2005-2009 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_FADE_BUTTON_H
26#define LMMS_GUI_FADE_BUTTON_H
27
28#include <QAbstractButton>
29#include <QColor>
30#include <QElapsedTimer>
31
32
33namespace lmms::gui
34{
35
36
37class FadeButton : public QAbstractButton
38{
39 Q_OBJECT
40public:
41 enum class State
42 {
45 };
46
57 const QColor& inactiveColor,
58 const QColor& normalColor,
59 const QColor& corruptedColor,
60 const QColor& mutedColor,
61 const QColor& holdColor,
62 QWidget* parent = nullptr);
63
65 FadeButton(QWidget* parent = nullptr);
66
68 ~FadeButton() override = default;
69
71 auto state() const -> State;
72
74 auto muted() const -> bool;
75
77 void setState(State state);
78
80 void setMuted(bool mute);
81
82public slots:
83 void activate();
84 void activateOnce();
85 void noteEnd();
86
87private:
88 void paintEvent(QPaintEvent* pe) override;
89
91
92 QElapsedTimer m_stateTimer;
93 QElapsedTimer m_releaseTimer;
94
100
103
104 QColor fadeToColor(QColor, QColor, QElapsedTimer, float);
105 QColor activeColor() const;
106} ;
107
108
109} // namespace lmms::gui
110
111#endif // LMMS_GUI_FADE_BUTTON_H
#define override
Definition DistrhoDefines.h:73
QColor fadeToColor(QColor, QColor, QElapsedTimer, float)
Definition FadeButton.cpp:167
QElapsedTimer m_stateTimer
Definition FadeButton.h:92
QColor m_normalColor
Definition FadeButton.h:96
int activeNotes
Definition FadeButton.h:101
auto muted() const -> bool
Definition FadeButton.cpp:68
State m_state
Definition FadeButton.h:90
void setState(State state)
Set the state of the fade button to state.
Definition FadeButton.cpp:73
~FadeButton() override=default
Destroys the fade button.
void noteEnd()
Definition FadeButton.cpp:101
bool m_muted
Definition FadeButton.h:102
QColor activeColor() const
Definition FadeButton.cpp:183
void activate()
Definition FadeButton.cpp:83
FadeButton(const QColor &inactiveColor, const QColor &normalColor, const QColor &corruptedColor, const QColor &mutedColor, const QColor &holdColor, QWidget *parent=nullptr)
Creates a fade button with the given color palette.
Definition FadeButton.cpp:38
auto state() const -> State
Definition FadeButton.cpp:63
void paintEvent(QPaintEvent *pe) override
Definition FadeButton.cpp:124
QElapsedTimer m_releaseTimer
Definition FadeButton.h:93
void activateOnce()
Definition FadeButton.cpp:93
QColor m_corruptedColor
Definition FadeButton.h:97
QColor m_mutedColor
Definition FadeButton.h:98
QColor m_inactiveColor
Definition FadeButton.h:95
void setMuted(bool mute)
Mute or unmute the fade button.
Definition FadeButton.cpp:78
State
Definition FadeButton.h:42
@ Corrupted
Definition FadeButton.h:44
@ Normal
Definition FadeButton.h:43
QColor m_holdColor
Definition FadeButton.h:99
static uintptr_t parent
Definition pugl.h:1644
Definition AudioPortAudio.cpp:209
#define false
Definition ordinals.h:83
#define const
Definition zconf.h:137