hydrogen 1.2.3
SongEditorPositionRuler Class Reference

#include <SongEditor.h>

Inheritance diagram for SongEditorPositionRuler:
WidgetWithScalableFont< 8, 10, 12 > EventListener Object< SongEditorPositionRuler > Base

Public Slots

void createBackground ()
 
void invalidateBackground ()
 
void onPreferencesChanged (H2Core::Preferences::Changes changes)
 
void showBpmWidget (int nColumn)
 
void showTagWidget (int nColumn)
 
void updatePosition ()
 

Public Member Functions

 SongEditorPositionRuler (QWidget *parent)
 
 ~SongEditorPositionRuler ()
 
uint getGridWidth ()
 
virtual void jackTimebaseStateChangedEvent () override
 
virtual void patternModifiedEvent () override
 
virtual void playingPatternsChangedEvent () override
 
virtual void relocationEvent () override
 
void setGridWidth (uint width)
 
virtual void songModeActivationEvent () override
 
virtual void songSizeChangedEvent () override
 
virtual void tempoChangedEvent (int) override
 
virtual void timelineActivationEvent () override
 
virtual void timelineUpdateEvent (int nValue) override
 
virtual void updateSongEvent (int) override
 
- Public Member Functions inherited from EventListener
virtual ~EventListener ()
 
virtual void actionModeChangeEvent (int nValue)
 
virtual void bbtChangedEvent ()
 
virtual void driverChangedEvent ()
 
virtual void drumkitLoadedEvent ()
 
virtual void errorEvent (int nErrorCode)
 
virtual void gridCellToggledEvent ()
 
virtual void instrumentParametersChangedEvent (int nInstrumentNumber)
 
virtual void jacksessionEvent (int nValue)
 
virtual void jackTransportActivationEvent ()
 
virtual void loopModeActivationEvent ()
 
virtual void metronomeEvent (int nValue)
 
virtual void midiActivityEvent ()
 
virtual void midiMapChangedEvent ()
 
virtual void nextPatternsChangedEvent ()
 
virtual void nextShotEvent ()
 
virtual void noteOnEvent (int nInstrument)
 
virtual void patternEditorLockedEvent ()
 
virtual void playbackTrackChangedEvent ()
 
virtual void playlistLoadSongEvent (int nIndex)
 
virtual void progressEvent (int nValue)
 
virtual void quitEvent (int nValue)
 
virtual void selectedInstrumentChangedEvent ()
 
virtual void selectedPatternChangedEvent ()
 
virtual void songModifiedEvent ()
 
virtual void soundLibraryChangedEvent ()
 
virtual void stackedModeActivationEvent (int nValue)
 
virtual void stateChangedEvent (H2Core::AudioEngine::State state)
 
virtual void undoRedoActionEvent (int nValue)
 
virtual void updatePreferencesEvent (int nValue)
 
virtual void XRunEvent ()
 
- Public Member Functions inherited from Object< SongEditorPositionRuler >
 Object ()
 
 Object (const Object< SongEditorPositionRuler > &other)
 
- Public Member Functions inherited from Base
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
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.
 

Static Public Member Functions

static int tickToColumn (float fTick, uint nGridWidth)
 
- 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
 

Private Types

enum class  HoveredRow { None , TempoMarker , Tag , Ruler }
 Indicated the part of the widget the cursor is hovering over. More...
 

Private Member Functions

QRect calcTempoMarkerRect (std::shared_ptr< const H2Core::Timeline::TempoMarker > pTempoMarker, bool bEmphasize=false) const
 
int columnToX (int nColumn) const
 Calculates the position in pixel required to the painter for a particular nColumn of the grid.
 
void drawTempoMarker (std::shared_ptr< const H2Core::Timeline::TempoMarker > pTempoMarker, bool bEmphasize, QPainter &painter)
 
virtual bool event (QEvent *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
 
virtual void paintEvent (QPaintEvent *ev) override
 
void showToolTip (const QPoint &pos, const QPoint &globalPos)
 
int xToColumn (int nX) const
 

Private Attributes

bool m_bBackgroundInvalid
 
bool m_bRightBtnPressed
 
float m_fTick
 Cached position of the playhead.
 
HoveredRow m_hoveredRow
 
int m_nActiveBpmWidgetColumn
 
int m_nActiveColumns
 Area covering the length of the song columns.
 
int m_nColumn
 Cached and coarsed-grained position of the playhead.
 
uint m_nGridWidth
 
int m_nHoveredColumn
 
int m_nTagHeight
 
H2Core::AudioEnginem_pAudioEngine
 
QPixmap * m_pBackgroundPixmap
 
H2Core::Hydrogenm_pHydrogen
 
QTimer * m_pTimer
 

Static Private Attributes

static constexpr uint m_nHeight = 50
 

Additional Inherited Members

- 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< 8, 10, 12 >
constexpr int getPointSize (H2Core::FontTheme::FontSize fontSize) const
 
- Protected Member Functions inherited from EventListener
virtual ~EventListener ()
 
virtual void actionModeChangeEvent (int nValue)
 
virtual void bbtChangedEvent ()
 
virtual void driverChangedEvent ()
 
virtual void drumkitLoadedEvent ()
 
virtual void errorEvent (int nErrorCode)
 
virtual void gridCellToggledEvent ()
 
virtual void instrumentParametersChangedEvent (int nInstrumentNumber)
 
virtual void jacksessionEvent (int nValue)
 
virtual void jackTransportActivationEvent ()
 
virtual void loopModeActivationEvent ()
 
virtual void metronomeEvent (int nValue)
 
virtual void midiActivityEvent ()
 
virtual void midiMapChangedEvent ()
 
virtual void nextPatternsChangedEvent ()
 
virtual void nextShotEvent ()
 
virtual void noteOnEvent (int nInstrument)
 
virtual void patternEditorLockedEvent ()
 
virtual void playbackTrackChangedEvent ()
 
virtual void playlistLoadSongEvent (int nIndex)
 
virtual void progressEvent (int nValue)
 
virtual void quitEvent (int nValue)
 
virtual void selectedInstrumentChangedEvent ()
 
virtual void selectedPatternChangedEvent ()
 
virtual void songModifiedEvent ()
 
virtual void soundLibraryChangedEvent ()
 
virtual void stackedModeActivationEvent (int nValue)
 
virtual void stateChangedEvent (H2Core::AudioEngine::State state)
 
virtual void undoRedoActionEvent (int nValue)
 
virtual void updatePreferencesEvent (int nValue)
 
virtual void XRunEvent ()
 
- Protected Member Functions inherited from Object< SongEditorPositionRuler >
 ~Object ()
 
 Object ()
 
 Object (const Object< SongEditorPositionRuler > &other)
 
- Protected Member Functions inherited from Base
 ~Base ()
 
 Base ()
 
 Base (const Base &other)
 
virtual const char * class_name () const
 
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.
 
- 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 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 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 QString sPrintIndention = " "
 String used to format the debugging string output of some core classes.
 

Detailed Description

Definition at line 363 of file SongEditor.h.

Member Enumeration Documentation

◆ HoveredRow

enum class HoveredRow
strongprivate

Indicated the part of the widget the cursor is hovering over.

Enumerator
None 

Cursor is not hovering the widget.

TempoMarker 

Upper half until the lower end of the tempo marker text.

Tag 

Still part of the upper half, but only the last m_nTagHeight pixels.

Ruler 

Lower half.

Definition at line 407 of file SongEditor.h.

Constructor & Destructor Documentation

◆ SongEditorPositionRuler()

SongEditorPositionRuler ( QWidget * parent)
explicit

Definition at line 2474 of file SongEditor.cpp.

◆ ~SongEditorPositionRuler()

Definition at line 2524 of file SongEditor.cpp.

Member Function Documentation

◆ calcTempoMarkerRect()

QRect calcTempoMarkerRect ( std::shared_ptr< const H2Core::Timeline::TempoMarker > pTempoMarker,
bool bEmphasize = false ) const
private
Parameters
pTempoMarkerAssociated TempoMarker
bEmphasizeWhether the text of pTempoMarker will be printed with bold font.

Definition at line 3177 of file SongEditor.cpp.

◆ columnToX()

int columnToX ( int nColumn) const
private

Calculates the position in pixel required to the painter for a particular nColumn of the grid.

TODO: There needs to be some refactoring / common basis for song (and pattern) editor classes.

Definition at line 3330 of file SongEditor.cpp.

◆ createBackground

void createBackground ( )
slot

Definition at line 2561 of file SongEditor.cpp.

◆ drawTempoMarker()

void drawTempoMarker ( std::shared_ptr< const H2Core::Timeline::TempoMarker > pTempoMarker,
bool bEmphasize,
QPainter & painter )
private

Definition at line 3211 of file SongEditor.cpp.

◆ event()

bool event ( QEvent * ev)
overrideprivatevirtual

Definition at line 2764 of file SongEditor.cpp.

◆ getGridWidth()

uint getGridWidth ( )

Definition at line 2541 of file SongEditor.cpp.

◆ invalidateBackground

void invalidateBackground ( )
slot

Definition at line 2557 of file SongEditor.cpp.

◆ jackTimebaseStateChangedEvent()

void jackTimebaseStateChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2785 of file SongEditor.cpp.

◆ leaveEvent()

void leaveEvent ( QEvent * ev)
overrideprivatevirtual

Definition at line 2712 of file SongEditor.cpp.

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 2720 of file SongEditor.cpp.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 2852 of file SongEditor.cpp.

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent * ev)
overrideprivatevirtual

Definition at line 2907 of file SongEditor.cpp.

◆ onPreferencesChanged

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

Definition at line 3351 of file SongEditor.cpp.

◆ paintEvent()

void paintEvent ( QPaintEvent * ev)
overrideprivatevirtual

Definition at line 2914 of file SongEditor.cpp.

◆ patternModifiedEvent()

void patternModifiedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2700 of file SongEditor.cpp.

◆ playingPatternsChangedEvent()

void playingPatternsChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2706 of file SongEditor.cpp.

◆ relocationEvent()

void relocationEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2531 of file SongEditor.cpp.

◆ setGridWidth()

void setGridWidth ( uint width)

Definition at line 2546 of file SongEditor.cpp.

◆ showBpmWidget

void showBpmWidget ( int nColumn)
slot

Definition at line 2837 of file SongEditor.cpp.

◆ showTagWidget

void showTagWidget ( int nColumn)
slot

Definition at line 2831 of file SongEditor.cpp.

◆ showToolTip()

void showToolTip ( const QPoint & pos,
const QPoint & globalPos )
private

Definition at line 2798 of file SongEditor.cpp.

◆ songModeActivationEvent()

void songModeActivationEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2774 of file SongEditor.cpp.

◆ songSizeChangedEvent()

void songSizeChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2535 of file SongEditor.cpp.

◆ tempoChangedEvent()

void tempoChangedEvent ( int )
overridevirtual

Reimplemented from EventListener.

Definition at line 2683 of file SongEditor.cpp.

◆ tickToColumn()

int tickToColumn ( float fTick,
uint nGridWidth )
static

Definition at line 3338 of file SongEditor.cpp.

◆ timelineActivationEvent()

void timelineActivationEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 2780 of file SongEditor.cpp.

◆ timelineUpdateEvent()

void timelineUpdateEvent ( int nValue)
overridevirtual

Reimplemented from EventListener.

Definition at line 3345 of file SongEditor.cpp.

◆ updatePosition

void updatePosition ( )
slot

Definition at line 3270 of file SongEditor.cpp.

◆ updateSongEvent()

void updateSongEvent ( int nValue)
overridevirtual

Reimplemented from EventListener.

Definition at line 2790 of file SongEditor.cpp.

◆ xToColumn()

int xToColumn ( int nX) const
private

Definition at line 3333 of file SongEditor.cpp.

Field Documentation

◆ m_bBackgroundInvalid

bool m_bBackgroundInvalid
private

Definition at line 432 of file SongEditor.h.

◆ m_bRightBtnPressed

bool m_bRightBtnPressed
private

Definition at line 433 of file SongEditor.h.

◆ m_fTick

float m_fTick
private

Cached position of the playhead.

Definition at line 422 of file SongEditor.h.

◆ m_hoveredRow

HoveredRow m_hoveredRow
private

Definition at line 419 of file SongEditor.h.

◆ m_nActiveBpmWidgetColumn

int m_nActiveBpmWidgetColumn
private

Definition at line 403 of file SongEditor.h.

◆ m_nActiveColumns

int m_nActiveColumns
private

Area covering the length of the song columns.

Definition at line 429 of file SongEditor.h.

◆ m_nColumn

int m_nColumn
private

Cached and coarsed-grained position of the playhead.

Definition at line 424 of file SongEditor.h.

◆ m_nGridWidth

uint m_nGridWidth
private

Definition at line 400 of file SongEditor.h.

◆ m_nHeight

constexpr uint m_nHeight = 50
staticconstexprprivate

Definition at line 401 of file SongEditor.h.

◆ m_nHoveredColumn

int m_nHoveredColumn
private

Definition at line 404 of file SongEditor.h.

◆ m_nTagHeight

int m_nTagHeight
private

Definition at line 426 of file SongEditor.h.

◆ m_pAudioEngine

H2Core::AudioEngine* m_pAudioEngine
private

Definition at line 398 of file SongEditor.h.

◆ m_pBackgroundPixmap

QPixmap* m_pBackgroundPixmap
private

Definition at line 431 of file SongEditor.h.

◆ m_pHydrogen

H2Core::Hydrogen* m_pHydrogen
private

Definition at line 397 of file SongEditor.h.

◆ m_pTimer

QTimer* m_pTimer
private

Definition at line 399 of file SongEditor.h.