hydrogen 1.1.1
DrumPatternEditor Class Reference

Drum pattern editor. More...

#include <DrumPatternEditor.h>

Inheritance diagram for DrumPatternEditor:
PatternEditor EventListener Object SelectionWidget< H2Core::Note * >

Public Slots

virtual void updateEditor (bool bPatternOnly=false) override
 
virtual void selectAll () override
 
virtual void deleteSelection () override
 
virtual void paste () override
 Paste selection. More...
 
- Public Slots inherited from PatternEditor
virtual void updateEditor (bool bPatternOnly=false)=0
 
virtual void selectAll ()=0
 
virtual void selectNone ()
 
virtual void deleteSelection ()=0
 
virtual void copy ()
 Copy selection to clipboard in XML. More...
 
virtual void paste ()=0
 
virtual void cut ()
 
virtual void selectInstrumentNotes (int nInstrument)
 
void setCurrentInstrument (int nInstrument)
 

Public Member Functions

 DrumPatternEditor (QWidget *parent, PatternEditorPanel *panel)
 
 ~DrumPatternEditor ()
 
virtual void patternModifiedEvent () override
 This method is called from another thread (audio engine) More...
 
virtual void patternChangedEvent () override
 
virtual void selectedPatternChangedEvent () override
 
virtual void selectedInstrumentChangedEvent () override
 
void addOrDeleteNoteAction (int nColumn, int row, int selectedPatternNumber, int oldLength, float oldVelocity, float oldPan_L, float oldPan_R, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float probability, bool listen, bool isMidi, bool isInstrumentMode, bool isNoteOff, bool isDelete)
 
void moveNoteAction (int nColumn, int nRow, int nPattern, int nNewColumn, int nNewRow, H2Core::Note *note)
 
void addOrRemoveNote (int nColumn, int nRealColumn, int row, bool bDoAdd=true, bool bDoDelete=true)
 
void editNoteLengthAction (int nColumn, int nRealColumn, int row, int length, int selectedPatternNumber)
 
void undoRedoAction (int column, QString mode, int nSelectedPatternNumber, int nSelectedInstrument, float velocity, float pan_L, float pan_R, float leadLag, float probability, int noteKeyVal, int octaveKeyVal)
 NotePropertiesRuler undo redo action. More...
 
void functionClearNotesRedoAction (int nSelectedInstrument, int selectedPatternNumber)
 ========================================================== undo / redo actions from pattern editor instrument list More...
 
void functionClearNotesUndoAction (std::list< H2Core::Note * > noteList, int nSelectedInstrument, int patternNumber)
 
void functionFillNotesUndoAction (QStringList noteList, int nSelectedInstrument, int patternNumber)
 
void functionFillNotesRedoAction (QStringList noteList, int nSelectedInstrument, int patternNumber)
 
void functionRandomVelocityAction (QStringList noteVeloValue, int nSelectedInstrument, int selectedPatternNumber)
 
void functionMoveInstrumentAction (int nSourceInstrument, int nTargetInstrument)
 
void functionDropInstrumentUndoAction (int nTargetInstrument, std::vector< int > *AddedComponents)
 
void functionDropInstrumentRedoAction (QString sDrumkitName, QString sInstrumentName, int nTargetInstrument, std::vector< int > *AddedComponents, H2Core::Filesystem::Lookup lookup)
 
void functionDeleteInstrumentUndoAction (std::list< H2Core::Note * > noteList, int nSelectedInstrument, QString instrumentName, QString drumkitName)
 
void functionAddEmptyInstrumentUndo ()
 
void functionAddEmptyInstrumentRedo ()
 
void functionPasteNotesRedoAction (std::list< H2Core::Pattern * > &changeList, std::list< H2Core::Pattern * > &appliedList)
 
void functionPasteNotesUndoAction (std::list< H2Core::Pattern * > &appliedList)
 
virtual void mouseClickEvent (QMouseEvent *ev) override
 
virtual void mouseDragStartEvent (QMouseEvent *ev) override
 
virtual void mouseDragUpdateEvent (QMouseEvent *ev) override
 Update the state during a Selection drag. More...
 
virtual void mouseDragEndEvent (QMouseEvent *ev) override
 
virtual void selectionMoveEndEvent (QInputEvent *ev) override
 Move or copy notes. More...
 
virtual std::vector< SelectionIndexelementsIntersecting (QRect r) override
 Find all elements which intersect a selection area. More...
 
virtual QRect getKeyboardCursorRect () override
 The screen area occupied by the keyboard cursor. More...
 
- Public Member Functions inherited from PatternEditor
 PatternEditor (QWidget *pParent, const char *sClassName, PatternEditorPanel *panel)
 
void setResolution (uint res, bool bUseTriplets)
 Set the editor grid resolution, dividing a whole note into res subdivisions. More...
 
uint getResolution () const
 
bool isUsingTriplets () const
 
float getGridWidth () const
 
unsigned getGridHeight () const
 
void zoomIn ()
 Zoom in / out on the time axis. More...
 
void zoomOut ()
 
void clearSelection ()
 Clear the pattern editor selection. More...
 
void mergeSelectionGroups (PatternEditor *pPatternEditor)
 Merge together the selection groups of two PatternEditor objects to share a common selection. More...
 
virtual void validateSelection () override
 Ensure that the Selection contains only valid elements. More...
 
virtual void updateModifiers (QInputEvent *ev)
 Update the status of modifier keys in response to input events. More...
 
virtual void updateWidget () override
 Update a widget in response to a change in selection. More...
 
virtual bool checkDeselectElements (std::vector< SelectionIndex > &elements) override
 Deselecting notes. More...
 
virtual void startMouseLasso (QMouseEvent *ev) override
 Change the mouse cursor during mouse gestures. More...
 
virtual void startMouseMove (QMouseEvent *ev) override
 
virtual void endMouseGesture () override
 
bool notesMatchExactly (H2Core::Note *pNoteA, H2Core::Note *pNoteB) const
 Do two notes match exactly, from the pattern editor's point of view? They match if all user-editable properties are the same. More...
 
void deselectAndOverwriteNotes (std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
 Deselect some notes, and "overwrite" some others. More...
 
void undoDeselectAndOverwriteNotes (std::vector< H2Core::Note * > &selected, std::vector< H2Core::Note * > &overwritten)
 
virtual void mousePressEvent (QMouseEvent *ev) override
 Raw Qt mouse events are passed to the Selection. More...
 
virtual void mouseMoveEvent (QMouseEvent *ev) override
 
virtual void mouseReleaseEvent (QMouseEvent *ev) override
 
- Public Member Functions inherited from EventListener
virtual void stateChangedEvent (int nState)
 
virtual void patternChangedEvent ()
 
virtual void patternModifiedEvent ()
 
virtual void songModifiedEvent ()
 
virtual void selectedPatternChangedEvent ()
 
virtual void selectedInstrumentChangedEvent ()
 
virtual void parametersInstrumentChangedEvent ()
 
virtual void midiActivityEvent ()
 
virtual void noteOnEvent (int nInstrument)
 
virtual void XRunEvent ()
 
virtual void errorEvent (int nErrorCode)
 
virtual void metronomeEvent (int nValue)
 
virtual void rubberbandbpmchangeEvent ()
 
virtual void progressEvent (int nValue)
 
virtual void jacksessionEvent (int nValue)
 
virtual void playlistLoadSongEvent (int nIndex)
 
virtual void undoRedoActionEvent (int nValue)
 
virtual void tempoChangedEvent (int nValue)
 
virtual void updateSongEvent (int nValue)
 
virtual void quitEvent (int nValue)
 
virtual void timelineActivationEvent (int nValue)
 
virtual void timelineUpdateEvent (int nValue)
 
virtual void jackTransportActivationEvent (int nValue)
 
virtual void jackTimebaseActivationEvent (int nValue)
 
virtual void songModeActivationEvent (int nValue)
 
virtual void loopModeActivationEvent (int nValue)
 
virtual void updatePreferencesEvent (int nValue)
 
virtual void actionModeChangeEvent (int nValue)
 
virtual ~EventListener ()
 
- Public Member Functions inherited from Object
 ~Object ()
 destructor More...
 
 Object (const Object &obj)
 copy constructor More...
 
 Object (const char *class_name)
 constructor More...
 
const char * class_name () const
 return the class name More...
 
virtual QString toQString (const QString &sPrefix, bool bShort=true) const
 Formatted string version for debugging purposes. More...
 
void Print (bool bShort=true) const
 Prints content of toQString() via DEBUGLOG. More...
 
- Public Member Functions inherited from SelectionWidget< H2Core::Note * >
virtual std::vector< SelectionIndexelementsIntersecting (QRect r)=0
 Find list of elements which intersect a rectangular area. More...
 
virtual bool canDragElements ()
 Can elements be dragged as well as being selected? This may change to suit widget's current state. More...
 
virtual QRect getKeyboardCursorRect ()=0
 Calculate screen space occupied by keyboard cursor. More...
 
virtual void validateSelection ()=0
 Ensure that the Selection contains only valid elements. More...
 
virtual void updateWidget ()=0
 Selection or selection-related visual elements have changed, widget needs to be updated. More...
 
virtual bool checkDeselectElements (std::vector< SelectionIndex > &elements)
 Inform the client that we're deselecting elements. More...
 
virtual QScrollArea * findScrollArea ()
 Find the QScrollArea, if any, which contains the widget. More...
 
virtual void selectionMoveUpdateEvent (QMouseEvent *ev)
 
virtual void selectionMoveCancelEvent ()
 

Private Member Functions

void __draw_note (H2Core::Note *note, QPainter &painter)
 Draws a note. More...
 
void __draw_pattern (QPainter &painter)
 Draws a pattern. More...
 
void __draw_grid (QPainter &painter)
 
void __create_background (QPainter &pointer)
 
virtual void keyPressEvent (QKeyEvent *ev) override
 Handle key press events. More...
 
virtual void keyReleaseEvent (QKeyEvent *ev) override
 
virtual void showEvent (QShowEvent *ev) override
 
virtual void hideEvent (QHideEvent *ev) override
 
virtual void paintEvent (QPaintEvent *ev) override
 
virtual void focusInEvent (QFocusEvent *ev) override
 
int findFreeCompoID (int startingPoint=0)
 
int findExistingCompo (QString SourceName)
 
QString renameCompo (QString OriginalName)
 

Private Attributes

int __nRealColumn
 
int __nColumn
 
int __row
 
int __oldLength
 

Additional Inherited Members

- 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. More...
 
- Static Public Member Functions inherited from Object
static void set_count (bool flag)
 enable/disable class instances counting More...
 
static bool count_active ()
 return true if class instances counting is enabled More...
 
static unsigned objects_count ()
 return the number of objects More...
 
static void write_objects_map_to (std::ostream &out)
 output the full objects map to a given ostream More...
 
static void write_objects_map_to_cerr ()
 output objects map to stderr More...
 
static int bootstrap (Logger *logger, bool count=false)
 must be called before any Object instantiation ! More...
 
static Loggerlogger ()
 return the logger instance More...
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Protected Member Functions inherited from PatternEditor
int granularity () const
 Granularity of grid positioning (in ticks) More...
 
int getColumn (int x, bool bUseFineGrained=false) const
 
QPoint movingGridOffset () const
 
void drawGridLines (QPainter &p, Qt::PenStyle style=Qt::SolidLine) const
 Draw lines for note grid. More...
 
QColor selectedNoteColor (const H2Core::UIStyle *pStyle) const
 Colour to use for outlining selected notes. More...
 
void drawNoteSymbol (QPainter &p, QPoint pos, H2Core::Note *pNote) const
 Draw a note. More...
 
void updatePatternInfo ()
 Update current pattern information. More...
 
- Protected Attributes inherited from PatternEditor
Selection< SelectionIndexm_selection
 The Selection object. More...
 
uint m_nEditorHeight
 
uint m_nEditorWidth
 
float m_fGridWidth
 
unsigned m_nGridHeight
 
int m_nSelectedPatternNumber
 
H2Core::Patternm_pPattern
 
const int m_nMargin = 20
 
uint m_nResolution
 
bool m_bUseTriplets
 
bool m_bFineGrained
 
bool m_bCopyNotMove
 
bool m_bSelectNewNotes
 
H2Core::Notem_pDraggedNote
 
PatternEditorPanelm_pPatternEditorPanel
 
QMenu * m_pPopupMenu
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Drum pattern editor.

Constructor & Destructor Documentation

◆ DrumPatternEditor()

DrumPatternEditor ( QWidget *  parent,
PatternEditorPanel panel 
)

◆ ~DrumPatternEditor()

Member Function Documentation

◆ __create_background()

void __create_background ( QPainter &  pointer)
private

◆ __draw_grid()

void __draw_grid ( QPainter &  painter)
private

◆ __draw_note()

void __draw_note ( H2Core::Note note,
QPainter &  painter 
)
private

Draws a note.

◆ __draw_pattern()

void __draw_pattern ( QPainter &  painter)
private

Draws a pattern.

◆ addOrDeleteNoteAction()

void addOrDeleteNoteAction ( int  nColumn,
int  row,
int  selectedPatternNumber,
int  oldLength,
float  oldVelocity,
float  oldPan_L,
float  oldPan_R,
float  oldLeadLag,
int  oldNoteKeyVal,
int  oldOctaveKeyVal,
float  probability,
bool  listen,
bool  isMidi,
bool  isInstrumentMode,
bool  isNoteOff,
bool  isDelete 
)

◆ addOrRemoveNote()

void addOrRemoveNote ( int  nColumn,
int  nRealColumn,
int  row,
bool  bDoAdd = true,
bool  bDoDelete = true 
)

◆ deleteSelection

void deleteSelection ( )
overridevirtualslot

◆ editNoteLengthAction()

void editNoteLengthAction ( int  nColumn,
int  nRealColumn,
int  row,
int  length,
int  selectedPatternNumber 
)

◆ elementsIntersecting()

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

Find all elements which intersect a selection area.

Implements SelectionWidget< H2Core::Note * >.

◆ findExistingCompo()

int findExistingCompo ( QString  SourceName)
private

◆ findFreeCompoID()

int findFreeCompoID ( int  startingPoint = 0)
private

◆ focusInEvent()

void focusInEvent ( QFocusEvent *  ev)
overrideprivatevirtual

◆ functionAddEmptyInstrumentRedo()

void functionAddEmptyInstrumentRedo ( )

◆ functionAddEmptyInstrumentUndo()

void functionAddEmptyInstrumentUndo ( )

◆ functionClearNotesRedoAction()

void functionClearNotesRedoAction ( int  nSelectedInstrument,
int  selectedPatternNumber 
)

========================================================== undo / redo actions from pattern editor instrument list

◆ functionClearNotesUndoAction()

void functionClearNotesUndoAction ( std::list< H2Core::Note * >  noteList,
int  nSelectedInstrument,
int  patternNumber 
)

◆ functionDeleteInstrumentUndoAction()

void functionDeleteInstrumentUndoAction ( std::list< H2Core::Note * >  noteList,
int  nSelectedInstrument,
QString  instrumentName,
QString  drumkitName 
)

◆ functionDropInstrumentRedoAction()

void functionDropInstrumentRedoAction ( QString  sDrumkitName,
QString  sInstrumentName,
int  nTargetInstrument,
std::vector< int > *  AddedComponents,
H2Core::Filesystem::Lookup  lookup 
)
Parameters
lookupWhere to search (system/user folder or both) for the drumkit.

◆ functionDropInstrumentUndoAction()

void functionDropInstrumentUndoAction ( int  nTargetInstrument,
std::vector< int > *  AddedComponents 
)

◆ functionFillNotesRedoAction()

void functionFillNotesRedoAction ( QStringList  noteList,
int  nSelectedInstrument,
int  patternNumber 
)

◆ functionFillNotesUndoAction()

void functionFillNotesUndoAction ( QStringList  noteList,
int  nSelectedInstrument,
int  patternNumber 
)

◆ functionMoveInstrumentAction()

void functionMoveInstrumentAction ( int  nSourceInstrument,
int  nTargetInstrument 
)

◆ functionPasteNotesRedoAction()

void functionPasteNotesRedoAction ( std::list< H2Core::Pattern * > &  changeList,
std::list< H2Core::Pattern * > &  appliedList 
)

◆ functionPasteNotesUndoAction()

void functionPasteNotesUndoAction ( std::list< H2Core::Pattern * > &  appliedList)

◆ functionRandomVelocityAction()

void functionRandomVelocityAction ( QStringList  noteVeloValue,
int  nSelectedInstrument,
int  selectedPatternNumber 
)

◆ getKeyboardCursorRect()

QRect getKeyboardCursorRect ( )
overridevirtual

The screen area occupied by the keyboard cursor.

Implements SelectionWidget< H2Core::Note * >.

◆ hideEvent()

void hideEvent ( QHideEvent *  ev)
overrideprivatevirtual

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  ev)
overrideprivatevirtual

Handle key press events.

Events are passed to Selection first, which may claim them (in which case they are ignored here).

◆ keyReleaseEvent()

void keyReleaseEvent ( QKeyEvent *  ev)
overrideprivatevirtual

◆ mouseClickEvent()

void mouseClickEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragEndEvent()

void mouseDragEndEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragStartEvent()

void mouseDragStartEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragUpdateEvent()

void mouseDragUpdateEvent ( QMouseEvent *  ev)
overridevirtual

Update the state during a Selection drag.

Implements SelectionWidget< H2Core::Note * >.

◆ moveNoteAction()

void moveNoteAction ( int  nColumn,
int  nRow,
int  nPattern,
int  nNewColumn,
int  nNewRow,
H2Core::Note note 
)

◆ paintEvent()

void paintEvent ( QPaintEvent *  ev)
overrideprivatevirtual

◆ paste

void paste ( )
overridevirtualslot

Paste selection.

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

◆ patternChangedEvent()

void patternChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ patternModifiedEvent()

void patternModifiedEvent ( )
overridevirtual

This method is called from another thread (audio engine)

Reimplemented from EventListener.

◆ renameCompo()

QString renameCompo ( QString  OriginalName)
private

◆ selectAll

void selectAll ( )
overridevirtualslot

◆ selectedInstrumentChangedEvent()

void selectedInstrumentChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ selectedPatternChangedEvent()

void selectedPatternChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ selectionMoveEndEvent()

void selectionMoveEndEvent ( QInputEvent *  ev)
overridevirtual

Move or copy notes.

Moves or copies notes at the end of a Selection move, handling the behaviours necessary for out-of-range moves or copies.

Implements SelectionWidget< H2Core::Note * >.

◆ showEvent()

void showEvent ( QShowEvent *  ev)
overrideprivatevirtual

◆ undoRedoAction()

void undoRedoAction ( int  column,
QString  mode,
int  nSelectedPatternNumber,
int  nSelectedInstrument,
float  velocity,
float  pan_L,
float  pan_R,
float  leadLag,
float  probability,
int  noteKeyVal,
int  octaveKeyVal 
)

NotePropertiesRuler undo redo action.

◆ updateEditor

void updateEditor ( bool  bPatternOnly = false)
overridevirtualslot

Field Documentation

◆ __nColumn

int __nColumn
private

◆ __nRealColumn

int __nRealColumn
private

◆ __oldLength

int __oldLength
private

◆ __row

int __row
private