hydrogen 1.1.1
PianoRollEditor Class Reference

#include <PianoRollEditor.h>

Inheritance diagram for PianoRollEditor:
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

 PianoRollEditor (QWidget *pParent, PatternEditorPanel *panel, QScrollArea *pScrollView)
 
 ~PianoRollEditor ()
 
virtual void selectedPatternChangedEvent () override
 
virtual void selectedInstrumentChangedEvent () override
 
virtual void patternModifiedEvent () override
 
int lineToPitch (int nLine)
 
int pitchToLine (int nPitch)
 
H2Core::Note::Octave pitchToOctave (int nPitch)
 
H2Core::Note::Key pitchToKey (int nPitch)
 
int octaveKeyToPitch (H2Core::Note::Octave octave, H2Core::Note::Key key)
 
void addOrDeleteNoteAction (int nColumn, int pressedLine, int selectedPatternNumber, int selectedinstrument, int oldLength, float oldVelocity, float oldPan_L, float oldPan_R, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float fProbability, bool noteOff, bool isDelete)
 
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)
 
void editNotePropertiesAction (int nColumn, int nRealColumn, int selectedPatternNumber, int selectedInstrumentnumber, float velocity, float pan_L, float pan_R, float leadLag, int pressedLine)
 
void editNoteLengthAction (int nColumn, int nRealColumn, int length, int selectedPatternNumber, int nSelectedInstrumentnumber, int pressedLine)
 
virtual std::vector< SelectionIndexelementsIntersecting (QRect r) override
 Selections are indexed by Note pointers. More...
 
virtual void mouseClickEvent (QMouseEvent *ev) override
 
virtual void mouseDragStartEvent (QMouseEvent *ev) override
 
virtual void mouseDragUpdateEvent (QMouseEvent *ev) override
 
virtual void mouseDragEndEvent (QMouseEvent *ev) override
 
virtual void selectionMoveEndEvent (QInputEvent *ev) override
 
virtual QRect getKeyboardCursorRect () override
 Position of keyboard input cursor on screen. 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 finishUpdateEditor ()
 
QPoint cursorPosition ()
 
void createBackground ()
 
void drawPattern ()
 
void drawNote (H2Core::Note *pNote, QPainter *pPainter)
 
void addOrRemoveNote (int nColumn, int nRealColumn, int nLine, int nNotekey, int nOctave, bool bDoAdd=true, bool bDoDelete=true)
 
virtual void paintEvent (QPaintEvent *ev) override
 
virtual void keyPressEvent (QKeyEvent *ev) override
 
virtual void focusInEvent (QFocusEvent *ev) override
 

Private Attributes

bool m_bNeedsUpdate
 
bool m_bNeedsBackgroundUpdate
 
unsigned m_nOctaves
 
QPixmap * m_pBackground
 
QPixmap * m_pTemp
 
int m_pOldPoint
 
int m_nCursorPitch
 
QScrollArea * m_pScrollView
 
int __selectedInstrumentnumber
 
int __nRealColumn
 
int __nColumn
 
int __pressedLine
 
int __oldLength
 
float __velocity
 
float __oldVelocity
 
float __pan_L
 
float __oldPan_L
 
float __pan_R
 
float __oldPan_R
 
float __leadLag
 
float __oldLeadLag
 

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...
 

Constructor & Destructor Documentation

◆ PianoRollEditor()

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

◆ ~PianoRollEditor()

Member Function Documentation

◆ addOrDeleteNoteAction()

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

◆ addOrRemoveNote()

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

◆ createBackground()

void createBackground ( )
private

◆ cursorPosition()

QPoint cursorPosition ( )
private

◆ deleteSelection

void deleteSelection ( )
overridevirtualslot

◆ drawNote()

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

◆ drawPattern()

void drawPattern ( )
private

◆ editNoteLengthAction()

void editNoteLengthAction ( int  nColumn,
int  nRealColumn,
int  length,
int  selectedPatternNumber,
int  nSelectedInstrumentnumber,
int  pressedLine 
)

◆ editNotePropertiesAction()

void editNotePropertiesAction ( int  nColumn,
int  nRealColumn,
int  selectedPatternNumber,
int  selectedInstrumentnumber,
float  velocity,
float  pan_L,
float  pan_R,
float  leadLag,
int  pressedLine 
)

◆ elementsIntersecting()

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

Selections are indexed by Note pointers.

Implements SelectionWidget< H2Core::Note * >.

◆ finishUpdateEditor()

void finishUpdateEditor ( )
private

◆ focusInEvent()

void focusInEvent ( QFocusEvent *  ev)
overrideprivatevirtual

◆ getKeyboardCursorRect()

QRect getKeyboardCursorRect ( )
overridevirtual

Position of keyboard input cursor on screen.

Implements SelectionWidget< H2Core::Note * >.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  ev)
overrideprivatevirtual

◆ lineToPitch()

int lineToPitch ( int  nLine)
inline

◆ mouseClickEvent()

void mouseClickEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragEndEvent()

void mouseDragEndEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragStartEvent()

void mouseDragStartEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragUpdateEvent()

void mouseDragUpdateEvent ( QMouseEvent *  ev)
overridevirtual

◆ 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 
)

◆ octaveKeyToPitch()

int octaveKeyToPitch ( H2Core::Note::Octave  octave,
H2Core::Note::Key  key 
)
inline

◆ paintEvent()

void paintEvent ( QPaintEvent *  ev)
overrideprivatevirtual

◆ paste

void paste ( )
overridevirtualslot

Paste selection.

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

◆ patternModifiedEvent()

void patternModifiedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ pitchToKey()

H2Core::Note::Key pitchToKey ( int  nPitch)
inline

◆ pitchToLine()

int pitchToLine ( int  nPitch)
inline

◆ pitchToOctave()

H2Core::Note::Octave pitchToOctave ( int  nPitch)
inline

◆ selectAll

void selectAll ( )
overridevirtualslot

◆ selectedInstrumentChangedEvent()

void selectedInstrumentChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ selectedPatternChangedEvent()

void selectedPatternChangedEvent ( )
overridevirtual

Reimplemented from EventListener.

◆ selectionMoveEndEvent()

void selectionMoveEndEvent ( QInputEvent *  ev)
overridevirtual

◆ updateEditor

void updateEditor ( bool  bPatternOnly = false)
overridevirtualslot

Field Documentation

◆ __leadLag

float __leadLag
private

◆ __nColumn

int __nColumn
private

◆ __nRealColumn

int __nRealColumn
private

◆ __oldLeadLag

float __oldLeadLag
private

◆ __oldLength

int __oldLength
private

◆ __oldPan_L

float __oldPan_L
private

◆ __oldPan_R

float __oldPan_R
private

◆ __oldVelocity

float __oldVelocity
private

◆ __pan_L

float __pan_L
private

◆ __pan_R

float __pan_R
private

◆ __pressedLine

int __pressedLine
private

◆ __selectedInstrumentnumber

int __selectedInstrumentnumber
private

◆ __velocity

float __velocity
private

◆ m_bNeedsBackgroundUpdate

bool m_bNeedsBackgroundUpdate
private

◆ m_bNeedsUpdate

bool m_bNeedsUpdate
private

◆ m_nCursorPitch

int m_nCursorPitch
private

◆ m_nOctaves

unsigned m_nOctaves
private

◆ m_pBackground

QPixmap* m_pBackground
private

◆ m_pOldPoint

int m_pOldPoint
private

◆ m_pScrollView

QScrollArea* m_pScrollView
private

◆ m_pTemp

QPixmap* m_pTemp
private