hydrogen 1.2.6
WidgetWithInput Class Reference

Base class for active user input widget, which are not based on a high-level Qt widget. More...

#include <WidgetWithInput.h>

Inheritance diagram for WidgetWithInput:
MidiLearnable EventListener Fader Rotary

Signals

void valueChanged (WidgetWithInput *ref)
 

Public Member Functions

 WidgetWithInput (QWidget *parent, bool bUseIntSteps, QString sBaseTooltip, int nScrollSpeed, int nScrollSpeedFast, float fMin, float fMax, bool bModifyOnChange)
 
 ~WidgetWithInput ()
 
QString getBaseTooltip () const
 
float getDefaultValue () const
 
bool getIsActive () const
 
float getMax () const
 
float getMin () const
 
int getScrollSpeed () const
 
int getScrollSpeedFast () const
 
float getValue () const
 
int getWidgetHeight () const
 
int getWidgetWidth () const
 
void resetValueToDefault ()
 
void setBaseTooltip (const QString &sBaseTooltip)
 
void setDefaultValue (float fDefaultValue)
 
void setIsActive (bool bIsActive)
 
void setMax (float fMax)
 
void setMin (float fMin)
 
void setScrollSpeed (int nScrollSpeed) const
 
void setScrollSpeedFast (int nScrollSpeedFast) const
 
virtual void setValue (float fValue, bool bTriggeredByUserInteraction=false)
 
void setWidgetHeight (int nWidgetHeight)
 
void setWidgetWidth (int nWidgetWidth)
 
- Public Member Functions inherited from MidiLearnable
 MidiLearnable ()
 
 ~MidiLearnable ()
 
std::shared_ptr< ActiongetAction () const
 
void midiMapChangedEvent () override
 Update m_registeredMidiEvents since the underlying #H2Core::MidiMap changed.
 
void setAction (std::shared_ptr< Action > pAction)
 

Protected Member Functions

virtual void enterEvent (QEvent *ev) override
 
virtual void keyPressEvent (QKeyEvent *ev)
 
virtual void leaveEvent (QEvent *ev)
 
virtual void mouseMoveEvent (QMouseEvent *ev)
 
virtual void mousePressEvent (QMouseEvent *ev)
 
virtual void mouseReleaseEvent (QMouseEvent *ev)
 
void updateTooltip () override
 Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed.
 
virtual void wheelEvent (QWheelEvent *ev)
 

Protected Attributes

bool m_bEntered
 
bool m_bIgnoreMouseMove
 
bool m_bIsActive
 
bool m_bModifyOnChange
 Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change.
 
bool m_bUseIntSteps
 
float m_fDefaultValue
 
float m_fMax
 
float m_fMin
 
float m_fMousePressValue
 
float m_fMousePressY
 
float m_fValue
 
double m_inputBufferTimeout
 Number of seconds before m_sInputBuffer will be flushed (happens asynchronically whenever the next key input occurs.)
 
timeval m_inputBufferTimeval
 
int m_nScrollSpeed
 
int m_nScrollSpeedFast
 Fast version used when the Control modifier is pressed.
 
int m_nWidgetHeight
 
int m_nWidgetWidth
 
QString m_sBaseTooltip
 
QString m_sInputBuffer
 All key input will be appended to this string.
 
- Protected Attributes inherited from MidiLearnable
std::shared_ptr< Actionm_pAction
 
std::vector< std::pair< H2Core::MidiMessage::Event, int > > m_registeredMidiEvents
 Stores all MIDI events mapped to m_pAction.
 

Detailed Description

Base class for active user input widget, which are not based on a high-level Qt widget.

The widgets can be set by click-drag, wheel event, and by keyboard. For the latter the widget has to be clicked first, in order for it to acquire focus. The derived class must indicate the presence of the focus in its paintEvent() using the H2Core::ColorTheme::m_highlightColor.

The widget will be reset to its default value of Ctrl-clicking it. It's MIDI learnable and the MIDI action - added by the parent - can be bound by the user by Shift-clicking it. The derived class must display an available MIDI action and a possible binding in its tooltip.

The current value of the derived class has to be displayed in the tooltip and when altering the value via mouse or keyboard a static tooltip must be used to indicate the new value.

For keyboard input a buffer is used to accumulate all provided numbers. After 2 seconds the input buffer is flushed and the next key press will fill a fresh buffer. Alternatively, the user can use the ESC key to immediately flush the input buffer.

Definition at line 59 of file WidgetWithInput.h.

Constructor & Destructor Documentation

◆ WidgetWithInput()

WidgetWithInput ( QWidget * parent,
bool bUseIntSteps,
QString sBaseTooltip,
int nScrollSpeed,
int nScrollSpeedFast,
float fMin,
float fMax,
bool bModifyOnChange )

Definition at line 40 of file WidgetWithInput.cpp.

◆ ~WidgetWithInput()

Definition at line 68 of file WidgetWithInput.cpp.

Member Function Documentation

◆ enterEvent()

void enterEvent ( QEvent * ev)
overrideprotectedvirtual

Definition at line 265 of file WidgetWithInput.cpp.

◆ getBaseTooltip()

QString getBaseTooltip ( ) const
inline

Definition at line 161 of file WidgetWithInput.h.

◆ getDefaultValue()

float getDefaultValue ( ) const
inline

Definition at line 155 of file WidgetWithInput.h.

◆ getIsActive()

bool getIsActive ( ) const
inline

Definition at line 158 of file WidgetWithInput.h.

◆ getMax()

float getMax ( ) const
inline

Definition at line 152 of file WidgetWithInput.h.

◆ getMin()

float getMin ( ) const
inline

Definition at line 149 of file WidgetWithInput.h.

◆ getScrollSpeed()

int getScrollSpeed ( ) const
inline

Definition at line 170 of file WidgetWithInput.h.

◆ getScrollSpeedFast()

int getScrollSpeedFast ( ) const
inline

Definition at line 173 of file WidgetWithInput.h.

◆ getValue()

float getValue ( ) const
inline

Definition at line 146 of file WidgetWithInput.h.

◆ getWidgetHeight()

int getWidgetHeight ( ) const
inline

Definition at line 167 of file WidgetWithInput.h.

◆ getWidgetWidth()

int getWidgetWidth ( ) const
inline

Definition at line 164 of file WidgetWithInput.h.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent * ev)
protectedvirtual

Definition at line 278 of file WidgetWithInput.cpp.

◆ leaveEvent()

void leaveEvent ( QEvent * ev)
protectedvirtual

Definition at line 272 of file WidgetWithInput.cpp.

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent * ev)
protectedvirtual

Reimplemented in Fader.

Definition at line 234 of file WidgetWithInput.cpp.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * ev)
protectedvirtual

Reimplemented in Fader.

Definition at line 157 of file WidgetWithInput.cpp.

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent * ev)
protectedvirtual

Definition at line 186 of file WidgetWithInput.cpp.

◆ resetValueToDefault()

void resetValueToDefault ( )

Definition at line 439 of file WidgetWithInput.cpp.

◆ setBaseTooltip()

void setBaseTooltip ( const QString & sBaseTooltip)

◆ setDefaultValue()

void setDefaultValue ( float fDefaultValue)

Definition at line 414 of file WidgetWithInput.cpp.

◆ setIsActive()

void setIsActive ( bool bIsActive)

Definition at line 108 of file WidgetWithInput.cpp.

◆ setMax()

void setMax ( float fMax)

Definition at line 385 of file WidgetWithInput.cpp.

◆ setMin()

void setMin ( float fMin)

Definition at line 357 of file WidgetWithInput.cpp.

◆ setScrollSpeed()

void setScrollSpeed ( int nScrollSpeed) const

◆ setScrollSpeedFast()

void setScrollSpeedFast ( int nScrollSpeedFast) const

◆ setValue()

void setValue ( float fValue,
bool bTriggeredByUserInteraction = false )
virtual

Definition at line 113 of file WidgetWithInput.cpp.

◆ setWidgetHeight()

void setWidgetHeight ( int nWidgetHeight)

◆ setWidgetWidth()

void setWidgetWidth ( int nWidgetWidth)

◆ updateTooltip()

void updateTooltip ( )
overrideprotectedvirtual

Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed.

Reimplemented from MidiLearnable.

Definition at line 70 of file WidgetWithInput.cpp.

◆ valueChanged

void valueChanged ( WidgetWithInput * ref)
signal

◆ wheelEvent()

void wheelEvent ( QWheelEvent * ev)
protectedvirtual

Definition at line 199 of file WidgetWithInput.cpp.

Field Documentation

◆ m_bEntered

bool m_bEntered
protected

Definition at line 128 of file WidgetWithInput.h.

◆ m_bIgnoreMouseMove

bool m_bIgnoreMouseMove
protected

Definition at line 130 of file WidgetWithInput.h.

◆ m_bIsActive

bool m_bIsActive
protected

Definition at line 127 of file WidgetWithInput.h.

◆ m_bModifyOnChange

bool m_bModifyOnChange
protected

Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change.

Definition at line 143 of file WidgetWithInput.h.

◆ m_bUseIntSteps

bool m_bUseIntSteps
protected

Definition at line 112 of file WidgetWithInput.h.

◆ m_fDefaultValue

float m_fDefaultValue
protected

Definition at line 125 of file WidgetWithInput.h.

◆ m_fMax

float m_fMax
protected

Definition at line 123 of file WidgetWithInput.h.

◆ m_fMin

float m_fMin
protected

Definition at line 122 of file WidgetWithInput.h.

◆ m_fMousePressValue

float m_fMousePressValue
protected

Definition at line 131 of file WidgetWithInput.h.

◆ m_fMousePressY

float m_fMousePressY
protected

Definition at line 132 of file WidgetWithInput.h.

◆ m_fValue

float m_fValue
protected

Definition at line 124 of file WidgetWithInput.h.

◆ m_inputBufferTimeout

double m_inputBufferTimeout
protected

Number of seconds before m_sInputBuffer will be flushed (happens asynchronically whenever the next key input occurs.)

Definition at line 139 of file WidgetWithInput.h.

◆ m_inputBufferTimeval

timeval m_inputBufferTimeval
protected

Definition at line 136 of file WidgetWithInput.h.

◆ m_nScrollSpeed

int m_nScrollSpeed
protected

Definition at line 118 of file WidgetWithInput.h.

◆ m_nScrollSpeedFast

int m_nScrollSpeedFast
protected

Fast version used when the Control modifier is pressed.

Definition at line 120 of file WidgetWithInput.h.

◆ m_nWidgetHeight

int m_nWidgetHeight
protected

Definition at line 116 of file WidgetWithInput.h.

◆ m_nWidgetWidth

int m_nWidgetWidth
protected

Definition at line 115 of file WidgetWithInput.h.

◆ m_sBaseTooltip

QString m_sBaseTooltip
protected

Definition at line 113 of file WidgetWithInput.h.

◆ m_sInputBuffer

QString m_sInputBuffer
protected

All key input will be appended to this string.

Definition at line 135 of file WidgetWithInput.h.