|
hydrogen 1.2.6
|
Generic Button with SVG icons or text. More...
#include <Button.h>
Public Types | |
| enum class | Type { Push , Toggle , Icon } |
Public Slots | |
| void | onPreferencesChanged (H2Core::Preferences::Changes changes) |
Signals | |
| void | rightClicked () |
Public Member Functions | |
| Button (const Button &)=delete | |
| Button (QWidget *pParent, QSize size=QSize(), Type type=Type::Toggle, const QString &sIcon="", const QString &sText="", bool bUseRedBackground=false, QSize iconSize=QSize(0, 0), QString sBaseTooltip="", bool bColorful=false, bool bModifyOnChange=false, int nBorderRadius=-1) | |
| Either the path to a SVG image or a text to be displayed has to be provided. | |
| virtual | ~Button () |
| int | getBorderRadius () const |
| int | getFixedFontSize () const |
| bool | getIsActive () const |
| Type | getType () const |
| bool | getUseRedBackground () const |
| Button & | operator= (const Button &rhs)=delete |
| void | setBaseToolTip (const QString &sNewTip) |
| void | setBorderRadius (int nBorderRadius) |
| void | setFixedFontSize (int nPixelSize) |
| Overwrites the automatically set value. | |
| void | setIsActive (bool bIsActive) |
| void | setSize (QSize size) |
| void | setType (Type type) |
| void | setUseRedBackground (bool bUseRedBackground) |
Public Member Functions inherited from Object< Button > | |
| Object () | |
| Object (const Object< Button > &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. | |
Public Member Functions inherited from MidiLearnable | |
| MidiLearnable () | |
| ~MidiLearnable () | |
| std::shared_ptr< Action > | getAction () const |
| void | midiMapChangedEvent () override |
| Update m_registeredMidiEvents since the underlying #H2Core::MidiMap changed. | |
| void | setAction (std::shared_ptr< Action > pAction) |
Private Slots | |
| void | onClick () |
Private Member Functions | |
| virtual void | mousePressEvent (QMouseEvent *ev) override |
| virtual void | paintEvent (QPaintEvent *ev) override |
| void | updateFont () |
| void | updateIcon () |
| void | updateStyleSheet () |
| void | updateTooltip () override |
| Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed. | |
Private Attributes | |
| bool | m_bColorful |
| bool | m_bIsActive |
| bool | m_bLastCheckedState |
| bool | m_bModifyOnChange |
Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change. | |
| bool | m_bUseRedBackground |
| QSize | m_iconSize |
| int | m_nBorderRadius |
| int | m_nFixedFontSize |
| QString | m_sBaseTooltip |
| QString | m_sIcon |
| 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 Logger * | logger () |
| 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 WidgetWithScalableFont< 6, 8, 10 > | |
| constexpr int | getPointSize (H2Core::FontTheme::FontSize fontSize) const |
Protected Member Functions inherited from Object< Button > | |
| ~Object () | |
| Object () | |
| Object (const Object< Button > &other) | |
Protected Member Functions inherited from Base | |
| ~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. | |
Protected Member Functions inherited from MidiLearnable | |
| MidiLearnable () | |
| ~MidiLearnable () | |
| std::shared_ptr< Action > | getAction () const |
| void | midiMapChangedEvent () override |
| Update m_registeredMidiEvents since the underlying #H2Core::MidiMap changed. | |
| void | setAction (std::shared_ptr< Action > pAction) |
Static Protected Member Functions inherited from Base | |
| static void | registerClass (const char *name, const atomic_obj_cpt_t *counters) |
| 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 Logger * | logger () |
| 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 | |
Protected Attributes inherited from MidiLearnable | |
| std::shared_ptr< Action > | m_pAction |
| std::vector< std::pair< H2Core::MidiMessage::Event, int > > | m_registeredMidiEvents |
| Stores all MIDI events mapped to m_pAction. | |
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 |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. | |
Generic Button with SVG icons or text.
The class comes in two different types, as Button::Type::Push and Button::Type::Toggle. If it is set checkabale via Button::Type::Toggle, the button will change color after it is clicked by mouse and the button is released. The action associated with the button will, however, be triggered once the button is clicked (this is implemented in the parent wigets and can be changed. But giving immediate feedback seems to be intuitive.)
Most icons used are black and white. For those, the black one will be used in unchecked state and the white one in checked.
Buttons are MIDI learnable. This means they can be associated with a MIDI action. If done, the action (and the binding) will show up in the tooltip.
|
strong |
| Button | ( | QWidget * | pParent, |
| QSize | size = QSize(), | ||
| Type | type = Type::Toggle, | ||
| const QString & | sIcon = "", | ||
| const QString & | sText = "", | ||
| bool | bUseRedBackground = false, | ||
| QSize | iconSize = QSize( 0, 0 ), | ||
| QString | sBaseTooltip = "", | ||
| bool | bColorful = false, | ||
| bool | bModifyOnChange = false, | ||
| int | nBorderRadius = -1 ) |
Either the path to a SVG image or a text to be displayed has to be provided.
If both are given, the icon will be used over the text. If the text should be used instead, sIcon must the an empty string.
| pParent | |
| size | |
| type | |
| sIcon | |
| sText | |
| bUseRedBackground | |
| iconSize | |
| sBaseTooltip | |
| bColorful | If set to false, the icon sIcon is expected to exist in both subfolders "black" and "white" in the "icons" folder. If the button is not checked, the black version is used and if checked, the white one is used instead. |
| bModifyOnChange | Whether Hydrogen::setIsModified() is invoked with true as soon as the value of the widget does change. |
| nBorderRadius | Radius of the button in pixel, which will be passed to the style sheet. |
Definition at line 37 of file Button.cpp.
|
virtual |
Definition at line 96 of file Button.cpp.
|
inline |
|
overrideprivatevirtual |
Definition at line 311 of file Button.cpp.
|
privateslot |
Definition at line 481 of file Button.cpp.
|
slot |
Definition at line 468 of file Button.cpp.
|
overrideprivatevirtual |
Definition at line 455 of file Button.cpp.
|
signal |
| void setBaseToolTip | ( | const QString & | sNewTip | ) |
Definition at line 306 of file Button.cpp.
| void setBorderRadius | ( | int | nBorderRadius | ) |
Definition at line 487 of file Button.cpp.
|
inline |
| void setIsActive | ( | bool | bIsActive | ) |
Definition at line 99 of file Button.cpp.
| void setSize | ( | QSize | size | ) |
Definition at line 364 of file Button.cpp.
| void setType | ( | Type | type | ) |
Definition at line 376 of file Button.cpp.
| void setUseRedBackground | ( | bool | bUseRedBackground | ) |
Definition at line 122 of file Button.cpp.
|
private |
Definition at line 396 of file Button.cpp.
|
private |
Definition at line 108 of file Button.cpp.
|
private |
Definition at line 129 of file Button.cpp.
|
overrideprivatevirtual |
Indicates child class to recalculate its tool tip in case m_registeredMidiEvents changed.
Reimplemented from MidiLearnable.
Definition at line 329 of file Button.cpp.
|
private |