hydrogen 1.1.1
PatternEditor Class Referenceabstract

Pattern Editor. More...

#include <PatternEditor.h>

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

Public Slots

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

 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 mouseClickEvent (QMouseEvent *ev)=0
 
virtual void mouseDragStartEvent (QMouseEvent *ev)=0
 
virtual void mouseDragUpdateEvent (QMouseEvent *ev)=0
 
virtual void mouseDragEndEvent (QMouseEvent *ev)=0
 
virtual void selectionMoveUpdateEvent (QMouseEvent *ev)
 
virtual void selectionMoveEndEvent (QInputEvent *ev)=0
 
virtual void selectionMoveCancelEvent ()
 

Static Public Member Functions

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

Protected Member Functions

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

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
 

Additional Inherited Members

- Public Types inherited from SelectionWidget< H2Core::Note * >
typedef H2Core::NoteSelectionIndex
 
- Static Public Attributes inherited from Object
static QString sPrintIndention = " "
 String used to format the debugging string output of some core classes. More...
 
- Static Protected Attributes inherited from Object
static Logger__logger = nullptr
 logger instance pointer More...
 

Detailed Description

Pattern Editor.

The PatternEditor class is an abstract base class for functionality common to Pattern Editor components (DrumPatternEditor, PianoRollEditor, NotePropertiesRuler).

This covers common elements such as some selection handling, timebase functions, and drawing grid lines.

Constructor & Destructor Documentation

◆ PatternEditor()

PatternEditor ( QWidget *  pParent,
const char *  sClassName,
PatternEditorPanel panel 
)

Member Function Documentation

◆ checkDeselectElements()

bool checkDeselectElements ( std::vector< SelectionIndex > &  elements)
overridevirtual

Deselecting notes.

◆ clearSelection()

void clearSelection ( )
inline

Clear the pattern editor selection.

◆ computeNoteColor()

QColor computeNoteColor ( float  velocity)
static

Calculate colour to use for note representation based on note velocity.

◆ copy

void copy ( )
virtualslot

Copy selection to clipboard in XML.

◆ cut

void cut ( )
virtualslot

◆ deleteSelection

virtual void deleteSelection ( )
pure virtualslot

◆ deselectAndOverwriteNotes()

void deselectAndOverwriteNotes ( std::vector< H2Core::Note * > &  selected,
std::vector< H2Core::Note * > &  overwritten 
)

Deselect some notes, and "overwrite" some others.

◆ drawGridLines()

void drawGridLines ( QPainter &  p,
Qt::PenStyle  style = Qt::SolidLine 
) const
protected

Draw lines for note grid.

◆ drawNoteSymbol()

void drawNoteSymbol ( QPainter &  p,
QPoint  pos,
H2Core::Note pNote 
) const
protected

Draw a note.

◆ endMouseGesture()

virtual void endMouseGesture ( )
inlineoverridevirtual

Reimplemented from SelectionWidget< H2Core::Note * >.

◆ getColumn()

int getColumn ( int  x,
bool  bUseFineGrained = false 
) const
protected

◆ getGridHeight()

unsigned getGridHeight ( ) const
inline

◆ getGridWidth()

float getGridWidth ( ) const
inline

◆ getResolution()

uint getResolution ( ) const
inline

◆ granularity()

int granularity ( ) const
inlineprotected

Granularity of grid positioning (in ticks)

◆ isUsingTriplets()

bool isUsingTriplets ( ) const
inline

◆ mergeSelectionGroups()

void mergeSelectionGroups ( PatternEditor pPatternEditor)
inline

Merge together the selection groups of two PatternEditor objects to share a common selection.

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent *  ev)
overridevirtual

Reimplemented in NotePropertiesRuler.

◆ mousePressEvent()

void mousePressEvent ( QMouseEvent *  ev)
overridevirtual

Raw Qt mouse events are passed to the Selection.

◆ mouseReleaseEvent()

void mouseReleaseEvent ( QMouseEvent *  ev)
overridevirtual

◆ movingGridOffset()

QPoint movingGridOffset ( ) const
protected

◆ notesMatchExactly()

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.

◆ paste

virtual void paste ( )
pure virtualslot

◆ selectAll

virtual void selectAll ( )
pure virtualslot

◆ selectedNoteColor()

QColor selectedNoteColor ( const H2Core::UIStyle pStyle) const
protected

Colour to use for outlining selected notes.

◆ selectInstrumentNotes

void selectInstrumentNotes ( int  nInstrument)
virtualslot

◆ selectNone

void selectNone ( )
virtualslot

◆ setCurrentInstrument

void setCurrentInstrument ( int  nInstrument)
slot

◆ setResolution()

void setResolution ( uint  res,
bool  bUseTriplets 
)

Set the editor grid resolution, dividing a whole note into res subdivisions.

◆ startMouseLasso()

virtual void startMouseLasso ( QMouseEvent *  ev)
inlineoverridevirtual

Change the mouse cursor during mouse gestures.

Reimplemented from SelectionWidget< H2Core::Note * >.

◆ startMouseMove()

virtual void startMouseMove ( QMouseEvent *  ev)
inlineoverridevirtual

Reimplemented from SelectionWidget< H2Core::Note * >.

◆ undoDeselectAndOverwriteNotes()

void undoDeselectAndOverwriteNotes ( std::vector< H2Core::Note * > &  selected,
std::vector< H2Core::Note * > &  overwritten 
)

◆ updateEditor

virtual void updateEditor ( bool  bPatternOnly = false)
pure virtualslot

◆ updateModifiers()

void updateModifiers ( QInputEvent *  ev)
virtual

Update the status of modifier keys in response to input events.

◆ updatePatternInfo()

void updatePatternInfo ( )
protected

Update current pattern information.

◆ updateWidget()

virtual void updateWidget ( )
inlineoverridevirtual

Update a widget in response to a change in selection.

Implements SelectionWidget< H2Core::Note * >.

◆ validateSelection()

void validateSelection ( )
overridevirtual

Ensure that the Selection contains only valid elements.

Ensure selection only refers to valid notes, and does not contain any stale references to deleted notes.

Implements SelectionWidget< H2Core::Note * >.

◆ zoomIn()

void zoomIn ( )

Zoom in / out on the time axis.

◆ zoomOut()

void zoomOut ( )

Field Documentation

◆ m_bCopyNotMove

bool m_bCopyNotMove
protected

◆ m_bFineGrained

bool m_bFineGrained
protected

◆ m_bSelectNewNotes

bool m_bSelectNewNotes
protected

◆ m_bUseTriplets

bool m_bUseTriplets
protected

◆ m_fGridWidth

float m_fGridWidth
protected

◆ m_nEditorHeight

uint m_nEditorHeight
protected

◆ m_nEditorWidth

uint m_nEditorWidth
protected

◆ m_nGridHeight

unsigned m_nGridHeight
protected

◆ m_nMargin

const int m_nMargin = 20
protected

◆ m_nResolution

uint m_nResolution
protected

◆ m_nSelectedPatternNumber

int m_nSelectedPatternNumber
protected

◆ m_pDraggedNote

H2Core::Note* m_pDraggedNote
protected

◆ m_pPattern

H2Core::Pattern* m_pPattern
protected

◆ m_pPatternEditorPanel

PatternEditorPanel* m_pPatternEditorPanel
protected

◆ m_pPopupMenu

QMenu* m_pPopupMenu
protected

◆ m_selection

Selection< SelectionIndex > m_selection
protected

The Selection object.