hydrogen 1.2.6
WidgetWithInput.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2008-2025 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#ifdef H2CORE_HAVE_QT6
103 virtual void enterEvent( QEnterEvent *ev ) override;
104#else
105 virtual void enterEvent( QEvent *ev ) override;
106#endif
107 virtual void leaveEvent( QEvent *ev );
108 virtual void keyPressEvent( QKeyEvent *ev );
109
110 void updateTooltip() override;
111
114
117
121
122 float m_fMin;
123 float m_fMax;
124 float m_fValue;
126
129
133
140
144};
145
146inline float WidgetWithInput::getValue() const {
147 return m_fValue;
148}
149inline float WidgetWithInput::getMin() const {
150 return m_fMin;
151}
152inline float WidgetWithInput::getMax() const {
153 return m_fMax;
154}
156 return m_fDefaultValue;
157}
158inline bool WidgetWithInput::getIsActive() const {
159 return m_bIsActive;
160}
161inline QString WidgetWithInput::getBaseTooltip() const {
162 return m_sBaseTooltip;
163}
165 return m_nWidgetWidth;
166}
168 return m_nWidgetHeight;
169}
171 return m_nScrollSpeed;
172}
174 return m_nScrollSpeedFast;
175}
176
177#endif
virtual void wheelEvent(QWheelEvent *ev)
int getScrollSpeedFast() const
float getDefaultValue() const
int getWidgetWidth() const
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 enterEvent(QEvent *ev) override
virtual void mouseMoveEvent(QMouseEvent *ev)
float getMax() const
void setWidgetWidth(int nWidgetWidth)
void setScrollSpeedFast(int nScrollSpeedFast) const