hydrogen 1.2.3
WidgetWithInput.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#ifndef WIDGET_WITH_INPUT_H
24#define WIDGET_WITH_INPUT_H
25
26#include <memory>
27
28#include <QtGui>
29#include <QtWidgets>
30
31#include "MidiLearnable.h"
32
33#include <core/Timehelper.h>
34
59class WidgetWithInput : public QWidget, public MidiLearnable {
60 Q_OBJECT
61
62public:
63 WidgetWithInput( QWidget* parent, bool bUseIntSteps, QString sBaseTooltip, int nScrollSpeed, int nScrollSpeedFast, float fMin, float fMax, bool bModifyOnChange );
65 void setMin( float fMin );
66 float getMin() const;
67
68 void setMax( float fMax );
69 float getMax() const;
70
71 virtual void setValue( float fValue, bool bTriggeredByUserInteraction = false );
72 float getValue() const;
73
74 void setDefaultValue( float fDefaultValue );
75 float getDefaultValue() const;
77
78 bool getIsActive() const;
79 void setIsActive( bool bIsActive );
80
81 QString getBaseTooltip() const;
82 void setBaseTooltip( const QString& sBaseTooltip );
83
84 int getWidgetWidth() const;
85 void setWidgetWidth( int nWidgetWidth );
86 int getWidgetHeight() const;
87 void setWidgetHeight( int nWidgetHeight );
88
89 int getScrollSpeed() const;
90 void setScrollSpeed( int nScrollSpeed ) const;
91 int getScrollSpeedFast() const;
92 void setScrollSpeedFast( int nScrollSpeedFast ) const;
93
94signals:
96
97protected:
98 virtual void mousePressEvent(QMouseEvent *ev);
99 virtual void mouseReleaseEvent( QMouseEvent *ev );
100 virtual void mouseMoveEvent(QMouseEvent *ev);
101 virtual void wheelEvent( QWheelEvent *ev );
102 virtual void enterEvent( QEvent *ev );
103 virtual void leaveEvent( QEvent *ev );
104 virtual void keyPressEvent( QKeyEvent *ev );
105
106 void updateTooltip() override;
107
110
113
117
118 float m_fMin;
119 float m_fMax;
120 float m_fValue;
122
125
129
136
140};
141
142inline float WidgetWithInput::getValue() const {
143 return m_fValue;
144}
145inline float WidgetWithInput::getMin() const {
146 return m_fMin;
147}
148inline float WidgetWithInput::getMax() const {
149 return m_fMax;
150}
152 return m_fDefaultValue;
153}
154inline bool WidgetWithInput::getIsActive() const {
155 return m_bIsActive;
156}
157inline QString WidgetWithInput::getBaseTooltip() const {
158 return m_sBaseTooltip;
159}
161 return m_nWidgetWidth;
162}
164 return m_nWidgetHeight;
165}
167 return m_nScrollSpeed;
168}
170 return m_nScrollSpeedFast;
171}
172
173#endif
Every widget which supports MidiLearn should derive from this Class.
Base class for active user input widget, which are not based on a high-level Qt widget.
virtual void wheelEvent(QWheelEvent *ev)
int getScrollSpeedFast() const
float getDefaultValue() const
int getWidgetWidth() const
virtual void enterEvent(QEvent *ev)
int getWidgetHeight() const
virtual void mouseReleaseEvent(QMouseEvent *ev)
int m_nScrollSpeedFast
Fast version used when the Control modifier is pressed.
virtual void setValue(float fValue, bool bTriggeredByUserInteraction=false)
QString m_sInputBuffer
All key input will be appended to this string.
QString getBaseTooltip() const
virtual void leaveEvent(QEvent *ev)
float getMin() const
void valueChanged(WidgetWithInput *ref)
void updateTooltip() override
Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed.
virtual void keyPressEvent(QKeyEvent *ev)
timeval m_inputBufferTimeval
bool m_bModifyOnChange
Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change...
void setWidgetHeight(int nWidgetHeight)
bool getIsActive() const
void setBaseTooltip(const QString &sBaseTooltip)
void setMin(float fMin)
WidgetWithInput(QWidget *parent, bool bUseIntSteps, QString sBaseTooltip, int nScrollSpeed, int nScrollSpeedFast, float fMin, float fMax, bool bModifyOnChange)
void setDefaultValue(float fDefaultValue)
double m_inputBufferTimeout
Number of seconds before m_sInputBuffer will be flushed (happens asynchronically whenever the next ke...
void setScrollSpeed(int nScrollSpeed) const
virtual void mousePressEvent(QMouseEvent *ev)
void setIsActive(bool bIsActive)
float getValue() const
int getScrollSpeed() const
void setMax(float fMax)
virtual void mouseMoveEvent(QMouseEvent *ev)
float getMax() const
void setWidgetWidth(int nWidgetWidth)
void setScrollSpeedFast(int nScrollSpeedFast) const