hydrogen 1.2.6
PianoRollEditor Class Reference

#include <PianoRollEditor.h>

Inheritance diagram for PianoRollEditor:
PatternEditor WidgetWithScalableFont< 7, 9, 11 > Object< PianoRollEditor > EventListener Object< PatternEditor > SelectionWidget< H2Core::Note * > Base Base

Public Slots

virtual void deleteSelection () override
 
void onPreferencesChanged (H2Core::Preferences::Changes changes)
 
virtual void paste () override
 Paste selection.
 
virtual void selectAll () override
 
virtual void updateEditor (bool bPatternOnly=false) override
 
- Public Slots inherited from PatternEditor
virtual void copy ()
 Copy selection to clipboard in XML.
 
virtual void cut ()
 
virtual void deleteSelection ()=0
 
void onPreferencesChanged (H2Core::Preferences::Changes changes)
 
virtual void paste ()=0
 
void scrolled (int nValue)
 
virtual void selectAll ()=0
 
virtual void selectInstrumentNotes (int nInstrument)
 
virtual void selectNone ()
 
void setCurrentInstrument (int nInstrument)
 
virtual void updateEditor (bool bPatternOnly=false)=0
 

Public Member Functions

 PianoRollEditor (QWidget *pParent, PatternEditorPanel *panel, QScrollArea *pScrollView)
 
 ~PianoRollEditor ()
 
void addOrDeleteNoteAction (int nColumn, int pressedLine, int selectedPatternNumber, int selectedinstrument, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float fProbability, bool noteOff, bool isDelete)
 
virtual std::vector< SelectionIndexelementsIntersecting (QRect r) override
 Selections are indexed by Note pointers.
 
virtual QRect getKeyboardCursorRect () override
 Position of keyboard input cursor on screen.
 
virtual void mouseClickEvent (QMouseEvent *ev) override
 
virtual void mouseDragStartEvent (QMouseEvent *ev) override
 
virtual void mouseDragUpdateEvent (QMouseEvent *ev) override
 
virtual void mousePressEvent (QMouseEvent *ev) override
 Raw Qt mouse events are passed to the Selection.
 
void moveNoteAction (int nColumn, H2Core::Note::Octave octave, H2Core::Note::Key key, int nPattern, int nNewColumn, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey, H2Core::Note *pNote)
 
virtual void selectedInstrumentChangedEvent () override
 
virtual void selectedPatternChangedEvent () override
 
virtual void selectionMoveEndEvent (QInputEvent *ev) override
 
virtual void songModeActivationEvent () override
 
- Public Member Functions inherited from PatternEditor
 PatternEditor (QWidget *pParent, PatternEditorPanel *panel)
 
 ~PatternEditor ()
 
virtual bool checkDeselectElements (std::vector< SelectionIndex > &elements) override
 Deselecting notes.
 
void clearSelection ()
 Clear the pattern editor selection.
 
void deselectAndOverwriteNotes (std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
 Deselect some notes, and "overwrite" some others.
 
void editNoteLengthAction (int nColumn, int nRealColumn, int nRow, int nLength, int nSelectedPatternNumber, int nSelectedInstrumentnumber, Editor editor)
 
void editNotePropertiesAction (int nColumn, int nRealColumn, int nRow, int nSelectedPatternNumber, int nSelectedInstrumentNumber, Mode mode, Editor editor, float fVelocity, float fPan, float fLeadLag, float fProbability)
 
virtual void endMouseGesture () override
 
unsigned getGridHeight () const
 
float getGridWidth () const
 
uint getResolution () const
 
bool isUsingTriplets () const
 
int lineToPitch (int nLine)
 
void mergeSelectionGroups (PatternEditor *pPatternEditor)
 Merge together the selection groups of two PatternEditor objects to share a common selection.
 
virtual void mouseDragEndEvent (QMouseEvent *ev) override
 
virtual void mouseMoveEvent (QMouseEvent *ev) override
 
virtual void mouseReleaseEvent (QMouseEvent *ev) override
 
bool notesMatchExactly (H2Core::Note *pNoteA, H2Core::Note *pNoteB) const
 Do two notes match exactly, from the pattern editor's point of view?
 
int pitchToLine (int nPitch)
 
void setResolution (uint res, bool bUseTriplets)
 Set the editor grid resolution, dividing a whole note into res subdivisions.
 
virtual void stackedModeActivationEvent (int nValue) override
 
virtual void startMouseLasso (QMouseEvent *ev) override
 Change the mouse cursor during mouse gestures.
 
virtual void startMouseMove (QMouseEvent *ev) override
 
void undoDeselectAndOverwriteNotes (std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
 
virtual void updateModifiers (QInputEvent *ev)
 Update the status of modifier keys in response to input events.
 
void updatePosition (float fTick)
 Caches the AudioEngine::m_nPatternTickPosition in the member variable m_nTick and triggers an update().
 
virtual void updateWidget () override
 Update a widget in response to a change in selection.
 
virtual void validateSelection () override
 Ensure that the Selection contains only valid elements.
 
void zoomIn ()
 Zoom in / out on the time axis.
 
void zoomOut ()
 
- 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 jackTimebaseStateChangedEvent (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 patternModifiedEvent ()
 
virtual void playbackTrackChangedEvent ()
 
virtual void playingPatternsChangedEvent ()
 
virtual void playlistLoadSongEvent (int nIndex)
 
virtual void progressEvent (int nValue)
 
virtual void quitEvent (int nValue)
 
virtual void relocationEvent ()
 
virtual void songModifiedEvent ()
 
virtual void songSizeChangedEvent ()
 
virtual void soundLibraryChangedEvent ()
 
virtual void stateChangedEvent (H2Core::AudioEngine::State state)
 
virtual void tempoChangedEvent (int nValue)
 
virtual void timelineActivationEvent ()
 
virtual void timelineUpdateEvent (int nValue)
 
virtual void undoRedoActionEvent (int nValue)
 
virtual void updatePreferencesEvent (int nValue)
 
virtual void updateSongEvent (int nValue)
 
virtual void XRunEvent ()
 
- Public Member Functions inherited from Object< PatternEditor >
 Object ()
 
 Object (const Object< PatternEditor > &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 SelectionWidget< H2Core::Note * >
virtual bool canDragElements ()
 Can elements be dragged as well as being selected? This may change to suit widget's current state.
 
virtual bool checkDeselectElements (std::vector< SelectionIndex > &elements)
 Inform the client that we're deselecting elements.
 
virtual QScrollArea * findScrollArea ()
 Find the QScrollArea, if any, which contains the widget.
 
virtual void selectionMoveUpdateEvent (QMouseEvent *ev)
 
virtual void selectionMoveCancelEvent ()
 
- Public Member Functions inherited from Object< PianoRollEditor >
 Object ()
 
 Object (const Object< PianoRollEditor > &other)
 

Private Member Functions

void addOrRemoveNote (int nColumn, int nRealColumn, int nLine, int nNotekey, int nOctave, bool bDoAdd=true, bool bDoDelete=true)
 
void createBackground () override
 Updates m_pBackgroundPixmap to show the latest content.
 
QPoint cursorPosition ()
 
void drawFocus (QPainter &painter)
 
void drawNote (H2Core::Note *pNote, QPainter *pPainter, bool bIsForeground)
 Draw a note.
 
void drawPattern ()
 
void finishUpdateEditor ()
 
virtual void keyPressEvent (QKeyEvent *ev) override
 
virtual void paintEvent (QPaintEvent *ev) override
 

Private Attributes

bool m_bNeedsBackgroundUpdate
 
bool m_bNeedsUpdate
 
int m_nCursorPitch
 
QPixmap * m_pBackground
 
QScrollArea * m_pScrollView
 
QPixmap * m_pTemp
 

Additional Inherited Members

- Public Types inherited from PatternEditor
enum class  Editor { DrumPattern = 0 , PianoRoll = 1 , NotePropertiesRuler = 2 , None = 3 }
 
enum class  Mode {
  Velocity = 0 , Pan = 1 , LeadLag = 2 , NoteKey = 3 ,
  Probability = 4 , None = 5
}
 
- Public Types inherited from SelectionWidget< H2Core::Note * >
typedef H2Core::NoteSelectionIndex
 
- Static Public Member Functions inherited from PatternEditor
static QColor computeNoteColor (float velocity)
 Calculate colour to use for note representation based on note velocity.
 
static bool isUsingAdditionalPatterns (const H2Core::Pattern *pPattern)
 Determines whether to pattern editor should show further patterns (determined by getPattersToShow()) or just the currently selected one.
 
static QString modeToQString (Mode mode)
 
static void triggerStatusMessage (H2Core::Note *pNote, Mode mode)
 
- 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 PatternEditor
static constexpr int nMargin = 20
 
- 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 PatternEditor
void drawGridLines (QPainter &p, Qt::PenStyle style=Qt::SolidLine) const
 Draw lines for note grid.
 
void drawNoteSymbol (QPainter &p, QPoint pos, H2Core::Note *pNote, bool bIsForeground=true) const
 Draw a note.
 
virtual void enterEvent (QEvent *ev) override
 
virtual void focusInEvent (QFocusEvent *ev) override
 
virtual void focusOutEvent (QFocusEvent *ev) override
 
int getColumn (int x, bool bUseFineGrained=false) const
 
std::vector< H2Core::Pattern * > getPatternsToShow (void)
 Get notes to show in pattern editor.
 
int granularity () const
 Granularity of grid positioning (in ticks)
 
void invalidateBackground ()
 
virtual void leaveEvent (QEvent *ev) override
 
QPoint movingGridOffset () const
 
QColor selectedNoteColor () const
 Colour to use for outlining selected notes.
 
void storeNoteProperties (const H2Core::Note *pNote)
 Stores the properties of pNote in member variables.
 
void updatePatternInfo ()
 Update current pattern information.
 
void updateWidth ()
 Adjusts m_nActiveWidth and m_nEditorWidth to the current state of the editor.
 
- Protected Member Functions inherited from Object< PatternEditor >
 ~Object ()
 
- Protected Member Functions inherited from Base
 ~Base ()
 
- Protected Member Functions inherited from WidgetWithScalableFont< 7, 9, 11 >
constexpr int getPointSize (H2Core::FontTheme::FontSize fontSize) const
 
- Protected Member Functions inherited from Object< PianoRollEditor >
 ~Object ()
 
 Object ()
 
 Object (const Object< PianoRollEditor > &other)
 
- Static Protected Member Functions inherited from Base
static void registerClass (const char *name, const atomic_obj_cpt_t *counters)
 
- Protected Attributes inherited from PatternEditor
bool m_bBackgroundInvalid
 
bool m_bCopyNotMove
 
bool m_bEntered
 Indicates whether the mouse pointer entered the widget.
 
bool m_bFineGrained
 
bool m_bSelectNewNotes
 
bool m_bUseTriplets
 
Editor m_editor
 
float m_fGridWidth
 
float m_fLeadLag = 0
 
float m_fOldLeadLag = 0
 
float m_fOldPan = 0
 
float m_fOldProbability = 0
 
float m_fOldVelocity = 0
 
float m_fPan = 0
 
float m_fProbability = 0
 
float m_fVelocity = 0
 
Mode m_mode
 
int m_nActiveWidth
 
int m_nColumn = 0
 
uint m_nEditorHeight
 
uint m_nEditorWidth
 
unsigned m_nGridHeight
 
unsigned m_nOctaves = 7
 
int m_nOldLength = 0
 
int m_nOldPoint
 
int m_nPressedLine = 0
 
int m_nRealColumn = 0
 
uint m_nResolution
 
int m_nRow = 0
 
int m_nSelectedInstrumentNumber = 0
 Cached properties used when adjusting a note property via right-press mouse movement.
 
int m_nSelectedPatternNumber = 0
 
int m_nTick
 
H2Core::AudioEnginem_pAudioEngine
 
QPixmap * m_pBackgroundPixmap
 
H2Core::Notem_pDraggedNote
 
H2Core::Patternm_pPattern
 
PatternEditorPanelm_pPatternEditorPanel
 
QMenu * m_pPopupMenu
 
Selection< SelectionIndexm_selection
 The Selection object.
 
- 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

Definition at line 39 of file PianoRollEditor.h.

Constructor & Destructor Documentation

◆ PianoRollEditor()

PianoRollEditor ( QWidget * pParent,
PatternEditorPanel * panel,
QScrollArea * pScrollView )

Definition at line 45 of file PianoRollEditor.cpp.

◆ ~PianoRollEditor()

Definition at line 76 of file PianoRollEditor.cpp.

Member Function Documentation

◆ addOrDeleteNoteAction()

void addOrDeleteNoteAction ( int nColumn,
int pressedLine,
int selectedPatternNumber,
int selectedinstrument,
int oldLength,
float oldVelocity,
float fOldPan,
float oldLeadLag,
int oldNoteKeyVal,
int oldOctaveKeyVal,
float fProbability,
bool noteOff,
bool isDelete )

Definition at line 643 of file PianoRollEditor.cpp.

◆ addOrRemoveNote()

void addOrRemoveNote ( int nColumn,
int nRealColumn,
int nLine,
int nNotekey,
int nOctave,
bool bDoAdd = true,
bool bDoDelete = true )
private

Definition at line 385 of file PianoRollEditor.cpp.

◆ createBackground()

void createBackground ( )
overrideprivatevirtual

Updates m_pBackgroundPixmap to show the latest content.

Reimplemented from PatternEditor.

Definition at line 214 of file PianoRollEditor.cpp.

◆ cursorPosition()

QPoint cursorPosition ( )
private

Definition at line 785 of file PianoRollEditor.cpp.

◆ deleteSelection

void deleteSelection ( )
overridevirtualslot

Definition at line 798 of file PianoRollEditor.cpp.

◆ drawFocus()

void drawFocus ( QPainter & painter)
private

Definition at line 183 of file PianoRollEditor.cpp.

◆ drawNote()

void drawNote ( H2Core::Note * pNote,
QPainter * pPainter,
bool bIsForeground )
private

Draw a note.

Parameters
pNoteParticular note to draw
pPainterPainting device
bIsForegroundWhether the pNote is contained in the pattern currently shown in the pattern editor (the one selected in the song editor)

Definition at line 374 of file PianoRollEditor.cpp.

◆ drawPattern()

void drawPattern ( )
private

Definition at line 344 of file PianoRollEditor.cpp.

◆ elementsIntersecting()

std::vector< PianoRollEditor::SelectionIndex > elementsIntersecting ( QRect r)
overridevirtual

Selections are indexed by Note pointers.

Implements SelectionWidget< H2Core::Note * >.

Definition at line 1207 of file PianoRollEditor.cpp.

◆ finishUpdateEditor()

void finishUpdateEditor ( )
private

Definition at line 98 of file PianoRollEditor.cpp.

◆ getKeyboardCursorRect()

QRect getKeyboardCursorRect ( )
overridevirtual

Position of keyboard input cursor on screen.

Implements SelectionWidget< H2Core::Note * >.

Definition at line 1251 of file PianoRollEditor.cpp.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent * ev)
overrideprivatevirtual

Definition at line 963 of file PianoRollEditor.cpp.

◆ mouseClickEvent()

void mouseClickEvent ( QMouseEvent * ev)
overridevirtual

Implements SelectionWidget< H2Core::Note * >.

Definition at line 458 of file PianoRollEditor.cpp.

◆ mouseDragStartEvent()

void mouseDragStartEvent ( QMouseEvent * ev)
overridevirtual

Reimplemented from PatternEditor.

Definition at line 580 of file PianoRollEditor.cpp.

◆ mouseDragUpdateEvent()

void mouseDragUpdateEvent ( QMouseEvent * ev)
overridevirtual

Reimplemented from PatternEditor.

Definition at line 630 of file PianoRollEditor.cpp.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent * ev)
overridevirtual

Raw Qt mouse events are passed to the Selection.

Reimplemented from PatternEditor.

Definition at line 535 of file PianoRollEditor.cpp.

◆ moveNoteAction()

void moveNoteAction ( int nColumn,
H2Core::Note::Octave octave,
H2Core::Note::Key key,
int nPattern,
int nNewColumn,
H2Core::Note::Octave newOctave,
H2Core::Note::Key newKey,
H2Core::Note * pNote )

Definition at line 726 of file PianoRollEditor.cpp.

◆ onPreferencesChanged

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

Definition at line 1267 of file PianoRollEditor.cpp.

◆ paintEvent()

void paintEvent ( QPaintEvent * ev)
overrideprivatevirtual

Definition at line 132 of file PianoRollEditor.cpp.

◆ paste

void paste ( )
overridevirtualslot

Paste selection.

Selection is XML containing notes, contained in a root 'note_selection' element.

Definition at line 852 of file PianoRollEditor.cpp.

◆ selectAll

void selectAll ( )
overridevirtualslot

Definition at line 792 of file PianoRollEditor.cpp.

◆ selectedInstrumentChangedEvent()

void selectedInstrumentChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 117 of file PianoRollEditor.cpp.

◆ selectedPatternChangedEvent()

void selectedPatternChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

Definition at line 123 of file PianoRollEditor.cpp.

◆ selectionMoveEndEvent()

void selectionMoveEndEvent ( QInputEvent * ev)
overridevirtual

Implements SelectionWidget< H2Core::Note * >.

Definition at line 1114 of file PianoRollEditor.cpp.

◆ songModeActivationEvent()

void songModeActivationEvent ( )
overridevirtual

Reimplemented from PatternEditor.

Definition at line 128 of file PianoRollEditor.cpp.

◆ updateEditor

void updateEditor ( bool bPatternOnly = false)
overridevirtualslot

Definition at line 83 of file PianoRollEditor.cpp.

Field Documentation

◆ m_bNeedsBackgroundUpdate

bool m_bNeedsBackgroundUpdate
private

Definition at line 123 of file PianoRollEditor.h.

◆ m_bNeedsUpdate

bool m_bNeedsUpdate
private

Definition at line 122 of file PianoRollEditor.h.

◆ m_nCursorPitch

int m_nCursorPitch
private

Definition at line 129 of file PianoRollEditor.h.

◆ m_pBackground

QPixmap* m_pBackground
private

Definition at line 125 of file PianoRollEditor.h.

◆ m_pScrollView

QScrollArea* m_pScrollView
private

Definition at line 132 of file PianoRollEditor.h.

◆ m_pTemp

QPixmap* m_pTemp
private

Definition at line 126 of file PianoRollEditor.h.