hydrogen 1.2.6
LCDSpinBox Class Reference

Custom spin box. More...

#include <LCDSpinBox.h>

Inheritance diagram for LCDSpinBox:
Object< LCDSpinBox > Base

Public Types

enum class  Kind { Default , PatternSizeNumerator , PatternSizeDenominator }
 
enum class  Type { Int , Double }
 

Public Slots

void onPreferencesChanged (H2Core::Preferences::Changes changes)
 
void setValue (double fValue)
 

Signals

void slashKeyPressed ()
 
void valueChanged (int)
 

Public Member Functions

 LCDSpinBox (QWidget *pParent, QSize size=QSize(), Type type=Type::Int, double fMin=0.0, double fMax=1.0, bool bModifyOnChange=false, bool bMinusOneAsOff=false)
 
 ~LCDSpinBox ()
 
bool getIsActive () const
 
bool getIsHovered () const
 
void setIsActive (bool bIsActive)
 
void setKind (Kind kind)
 
void setModifyOnChange (bool bModifyOnChange)
 
void setSize (QSize size)
 
void setType (Type type)
 
virtual QValidator::State validate (QString &text, int &pos) const override
 
- Public Member Functions inherited from Object< LCDSpinBox >
 Object ()
 
 Object (const Object< LCDSpinBox > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
void logBacktrace () const
 Print the current stack at point into the debug log.
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG.
 
virtual QString toQString (const QString &sPrefix="", bool bShort=true) const
 Formatted string version for debugging purposes.
 

Private Slots

void valueChanged (double fNewValue)
 

Private Member Functions

virtual void enterEvent (QEvent *ev) override
 
virtual bool event (QEvent *ev) override
 
virtual void keyPressEvent (QKeyEvent *ev) override
 
virtual void leaveEvent (QEvent *ev) override
 
virtual void mouseMoveEvent (QMouseEvent *ev) override
 
virtual void mousePressEvent (QMouseEvent *ev) override
 
virtual void mouseReleaseEvent (QMouseEvent *ev) override
 
double nextValueInPatternSizeDenominator (bool bUp, bool bAccelerated)
 
virtual void paintEvent (QPaintEvent *ev) override
 
virtual QString textFromValue (double fValue) const override
 
void updateStyleSheet ()
 
virtual double valueFromText (const QString &sText) const override
 
virtual void wheelEvent (QWheelEvent *ev) override
 

Private Attributes

bool m_bEntered
 
bool m_bIsActive
 
bool m_bMinusOneAsOff
 In some widgets the QString "off" will be displayed instead of -1.
 
bool m_bModifyOnChange
 Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change.
 
Kind m_kind
 
QSize m_size
 
Type m_type
 

Additional Inherited Members

- Static Public Member Functions inherited from Base
static const char * _class_name ()
 return the class name
 
static QString base_clock (const QString &sMsg)
 Measures the current time and stores it in __last_clock.
 
static QString base_clock_in (const QString &sMsg)
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation !
 
static bool count_active ()
 
static int getAliveObjectCount ()
 
static object_map_t getObjectMap ()
 
static Loggerlogger ()
 return the logger instance
 
static int objects_count ()
 
static void printObjectMapDiff (object_map_t map)
 Creates the difference between a snapshot of the object map and its current state and prints it to std::cout.
 
static void set_count (bool flag)
 enable/disable class instances counting
 
static void write_objects_map_to (std::ostream &out, object_map_t *map=nullptr)
 output the full objects map to a given ostream
 
static void write_objects_map_to_cerr ()
 output objects map to stderr
 
- Static Public Attributes inherited from Base
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 
- Protected Member Functions inherited from Object< LCDSpinBox >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Static Protected Attributes inherited from Base
static bool __count = false
 should we count class instances
 
static timeval __last_clock = { 0, 0 }
 
static Logger__logger = nullptr
 
static bool bLogColors = true
 

Detailed Description

Custom spin box.

The QDoubleSpinBox is used for both integer and float values instead of using QSpinBox as a base for the former. This is done to keep the code concise. All internal values will be handled as floats and only textFromValue() makes a difference.

The LCDSpinBox::Kind was introduced to handle custom constraints for the widgets concerning with the pattern size in the PatternEditorPanel.

Updating the font family in QDoubleSpinBox is not supported and changing the font size (both via setFont()) yields erratic results.

Definition at line 49 of file LCDSpinBox.h.

Member Enumeration Documentation

◆ Kind

enum class Kind
strong
Enumerator
Default 

Behaves like QDoubleSpinBox.

PatternSizeNumerator 

The minimum value - a fractional one - can only be reached by entering it using the keyboard.

up/down keys as well as mouse wheel increment the number by one and will stay at integer values per default.

PatternSizeDenominator 

Only a limited number of values is allowed.

Definition at line 61 of file LCDSpinBox.h.

◆ Type

enum class Type
strong
Enumerator
Int 
Double 

Definition at line 56 of file LCDSpinBox.h.

Constructor & Destructor Documentation

◆ LCDSpinBox()

LCDSpinBox ( QWidget * pParent,
QSize size = QSize(),
Type type = Type::Int,
double fMin = 0.0,
double fMax = 1.0,
bool bModifyOnChange = false,
bool bMinusOneAsOff = false )

Definition at line 31 of file LCDSpinBox.cpp.

◆ ~LCDSpinBox()

~LCDSpinBox ( )

Definition at line 63 of file LCDSpinBox.cpp.

Member Function Documentation

◆ enterEvent()

void enterEvent ( QEvent * ev)
overrideprivatevirtual

Definition at line 375 of file LCDSpinBox.cpp.

◆ event()

bool event ( QEvent * ev)
overrideprivatevirtual

Definition at line 300 of file LCDSpinBox.cpp.

◆ getIsActive()

bool getIsActive ( ) const
inline

Definition at line 142 of file LCDSpinBox.h.

◆ getIsHovered()

bool getIsHovered ( ) const
inline

Definition at line 145 of file LCDSpinBox.h.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent * ev)
overrideprivatevirtual

Definition at line 136 of file LCDSpinBox.cpp.

◆ leaveEvent()

void leaveEvent ( QEvent * ev)
overrideprivatevirtual

Definition at line 381 of file LCDSpinBox.cpp.

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 320 of file LCDSpinBox.cpp.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 310 of file LCDSpinBox.cpp.

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 330 of file LCDSpinBox.cpp.

◆ nextValueInPatternSizeDenominator()

double nextValueInPatternSizeDenominator ( bool bUp,
bool bAccelerated )
private

Definition at line 192 of file LCDSpinBox.cpp.

◆ onPreferencesChanged

void onPreferencesChanged ( H2Core::Preferences::Changes changes)
slot

Definition at line 423 of file LCDSpinBox.cpp.

◆ paintEvent()

void paintEvent ( QPaintEvent * ev)
overrideprivatevirtual

Definition at line 340 of file LCDSpinBox.cpp.

◆ setIsActive()

void setIsActive ( bool bIsActive)

Definition at line 84 of file LCDSpinBox.cpp.

◆ setKind()

void setKind ( Kind kind)
inline

Definition at line 136 of file LCDSpinBox.h.

◆ setModifyOnChange()

void setModifyOnChange ( bool bModifyOnChange)
inline

Definition at line 139 of file LCDSpinBox.h.

◆ setSize()

void setSize ( QSize size)

Definition at line 77 of file LCDSpinBox.cpp.

◆ setType()

void setType ( Type type)

Definition at line 66 of file LCDSpinBox.cpp.

◆ setValue

void setValue ( double fValue)
slot

Definition at line 292 of file LCDSpinBox.cpp.

◆ slashKeyPressed

void slashKeyPressed ( )
signal

◆ textFromValue()

QString textFromValue ( double fValue) const
overrideprivatevirtual

Definition at line 230 of file LCDSpinBox.cpp.

◆ updateStyleSheet()

void updateStyleSheet ( )
private

Definition at line 386 of file LCDSpinBox.cpp.

◆ validate()

QValidator::State validate ( QString & text,
int & pos ) const
overridevirtual

Definition at line 247 of file LCDSpinBox.cpp.

◆ valueChanged [1/2]

void valueChanged ( double fNewValue)
privateslot

Definition at line 430 of file LCDSpinBox.cpp.

◆ valueChanged [2/2]

void valueChanged ( int )
signal

◆ valueFromText()

double valueFromText ( const QString & sText) const
overrideprivatevirtual

Definition at line 279 of file LCDSpinBox.cpp.

◆ wheelEvent()

void wheelEvent ( QWheelEvent * ev)
overrideprivatevirtual

Definition at line 93 of file LCDSpinBox.cpp.

Field Documentation

◆ m_bEntered

bool m_bEntered
private

Definition at line 107 of file LCDSpinBox.h.

◆ m_bIsActive

bool m_bIsActive
private

Definition at line 108 of file LCDSpinBox.h.

◆ m_bMinusOneAsOff

bool m_bMinusOneAsOff
private

In some widgets the QString "off" will be displayed instead of -1.

Definition at line 112 of file LCDSpinBox.h.

◆ m_bModifyOnChange

bool m_bModifyOnChange
private

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

Definition at line 116 of file LCDSpinBox.h.

◆ m_kind

Kind m_kind
private

Definition at line 105 of file LCDSpinBox.h.

◆ m_size

QSize m_size
private

Definition at line 103 of file LCDSpinBox.h.

◆ m_type

Type m_type
private

Definition at line 104 of file LCDSpinBox.h.