hydrogen 1.1.1
NotePropertiesRuler Class Reference

#include <NotePropertiesRuler.h>

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

Public Types

enum  NotePropertiesMode {
  VELOCITY , PAN , LEADLAG , NOTEKEY ,
  PROBABILITY
}
 NotePropertiesEditor is (currently) a single class instantiated in different "modes" to select which property it edits. More...
 
- Public Types inherited from SelectionWidget< H2Core::Note * >
typedef H2Core::NoteSelectionIndex
 

Public Slots

virtual void updateEditor (bool bPatternOnly=false) override
 
virtual void selectAll () override
 
virtual void deleteSelection () override
 
virtual void copy () override
 
virtual void paste () override
 
virtual void cut () override
 
- 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

 NotePropertiesRuler (QWidget *parent, PatternEditorPanel *pPatternEditorPanel, NotePropertiesMode mode)
 
 ~NotePropertiesRuler ()
 
 NotePropertiesRuler (const NotePropertiesRuler &)=delete
 
NotePropertiesRuleroperator= (const NotePropertiesRuler &rhs)=delete
 
Property drag (or click) gestures

The user can drag (or just click) on a note's bar or dot to change that property.

Properties are updated live during the drag gesture, with 'undo' information being written at the end.

void propertyDragStart (QMouseEvent *ev)
 
void propertyDragUpdate (QMouseEvent *ev)
 Update notes for a property adjust drag, in response to the mouse moving. More...
 
void propertyDragEnd ()
 
PatternEditor interfaces
virtual std::vector< SelectionIndexelementsIntersecting (QRect r) override
 Find list of elements which intersect a rectangular area. 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 selectionMoveUpdateEvent (QMouseEvent *ev) override
 
virtual void selectionMoveEndEvent (QInputEvent *ev) override
 
virtual void selectionMoveCancelEvent () override
 Move of selection is cancelled. Revert notes to preserved state. 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...
 

Private Member Functions

void finishUpdateEditor ()
 
void createVelocityBackground (QPixmap *pixmap)
 
void createPanBackground (QPixmap *pixmap)
 
void createLeadLagBackground (QPixmap *pixmap)
 
void createNoteKeyBackground (QPixmap *pixmap)
 
void paintEvent (QPaintEvent *ev) override
 
void wheelEvent (QWheelEvent *ev) override
 Scroll wheel gestures will adjust the property of notes under the mouse cursor (or selected notes, if any). More...
 
void keyPressEvent (QKeyEvent *ev) override
 
void focusInEvent (QFocusEvent *ev) override
 
void focusOutEvent (QFocusEvent *ev) override
 
void addUndoAction ()
 
void prepareUndoAction (int x)
 Preserve current note properties at position x (or in selection, if any) for use in later UndoAction. More...
 
virtual void mouseMoveEvent (QMouseEvent *ev) override
 
virtual void selectedPatternChangedEvent () override
 
virtual void selectedInstrumentChangedEvent () override
 
void clearOldNotes ()
 
void adjustNotePropertyDelta (H2Core::Note *pNote, float fDelta, bool bMessage=false)
 Adjust a note's property by applying a delta to the current value, and clipping to the appropriate range. More...
 

Private Attributes

bool m_bNeedsUpdate
 
NotePropertiesMode m_Mode
 
QPixmap * m_pBackground
 
double m_fLastSetValue
 
bool m_bValueHasBeenSet
 
int m_nSelectedPatternNumber
 
std::map< H2Core::Note *, H2Core::Note * > m_oldNotes
 Map of notes currently in the pattern -> old notes with their properties. More...
 
int m_nDragPreviousColumn
 

Additional Inherited Members

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

Member Enumeration Documentation

◆ NotePropertiesMode

NotePropertiesEditor is (currently) a single class instantiated in different "modes" to select which property it edits.

There are individual instances for each property which are hidden and shown depending on what the user selects.

Enumerator
VELOCITY 
PAN 
LEADLAG 
NOTEKEY 
PROBABILITY 

Constructor & Destructor Documentation

◆ NotePropertiesRuler() [1/2]

NotePropertiesRuler ( QWidget *  parent,
PatternEditorPanel pPatternEditorPanel,
NotePropertiesMode  mode 
)

◆ ~NotePropertiesRuler()

◆ NotePropertiesRuler() [2/2]

Member Function Documentation

◆ addUndoAction()

void addUndoAction ( )
private

◆ adjustNotePropertyDelta()

void adjustNotePropertyDelta ( H2Core::Note pNote,
float  fDelta,
bool  bMessage = false 
)
private

Adjust a note's property by applying a delta to the current value, and clipping to the appropriate range.

Optionally, show a message with the value for some properties.

◆ clearOldNotes()

void clearOldNotes ( )
private

◆ copy

virtual void copy ( )
inlineoverridevirtualslot

◆ createLeadLagBackground()

void createLeadLagBackground ( QPixmap *  pixmap)
private

◆ createNoteKeyBackground()

void createNoteKeyBackground ( QPixmap *  pixmap)
private

◆ createPanBackground()

void createPanBackground ( QPixmap *  pixmap)
private

◆ createVelocityBackground()

void createVelocityBackground ( QPixmap *  pixmap)
private

◆ cut

virtual void cut ( )
inlineoverridevirtualslot

◆ deleteSelection

virtual void deleteSelection ( )
inlineoverridevirtualslot

◆ elementsIntersecting()

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

Find list of elements which intersect a rectangular area.

This may be a selection lasso rectangle, or a single point such as a mouse click. This should concern itself only with the geometry.

Implements SelectionWidget< H2Core::Note * >.

◆ finishUpdateEditor()

void finishUpdateEditor ( )
private

◆ focusInEvent()

void focusInEvent ( QFocusEvent *  ev)
overrideprivate

◆ focusOutEvent()

void focusOutEvent ( QFocusEvent *  ev)
overrideprivate

◆ getKeyboardCursorRect()

QRect getKeyboardCursorRect ( )
overridevirtual

The screen area occupied by the keyboard cursor.

Implements SelectionWidget< H2Core::Note * >.

◆ keyPressEvent()

void keyPressEvent ( QKeyEvent *  ev)
overrideprivate

◆ mouseClickEvent()

void mouseClickEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragEndEvent()

void mouseDragEndEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragStartEvent()

void mouseDragStartEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseDragUpdateEvent()

void mouseDragUpdateEvent ( QMouseEvent *  ev)
overridevirtual

◆ mouseMoveEvent()

void mouseMoveEvent ( QMouseEvent *  ev)
overrideprivatevirtual

Reimplemented from PatternEditor.

◆ operator=()

NotePropertiesRuler & operator= ( const NotePropertiesRuler rhs)
delete

◆ paintEvent()

void paintEvent ( QPaintEvent *  ev)
overrideprivate

◆ paste

virtual void paste ( )
inlineoverridevirtualslot

◆ prepareUndoAction()

void prepareUndoAction ( int  x)
private

Preserve current note properties at position x (or in selection, if any) for use in later UndoAction.

◆ propertyDragEnd()

void propertyDragEnd ( )

◆ propertyDragStart()

void propertyDragStart ( QMouseEvent *  ev)

◆ propertyDragUpdate()

void propertyDragUpdate ( QMouseEvent *  ev)

Update notes for a property adjust drag, in response to the mouse moving.

This modifies the values of the notes as the mouse moves, but does not complete an undo action until the notes final value has been set. This occurs either when the mouse is released, or when the pointer moves off of the note's column.

◆ selectAll

void selectAll ( )
overridevirtualslot

◆ selectedInstrumentChangedEvent()

void selectedInstrumentChangedEvent ( )
overrideprivatevirtual

Reimplemented from EventListener.

◆ selectedPatternChangedEvent()

void selectedPatternChangedEvent ( )
overrideprivatevirtual

Reimplemented from EventListener.

◆ selectionMoveCancelEvent()

void selectionMoveCancelEvent ( )
overridevirtual

Move of selection is cancelled. Revert notes to preserved state.

Reimplemented from SelectionWidget< H2Core::Note * >.

◆ selectionMoveEndEvent()

void selectionMoveEndEvent ( QInputEvent *  ev)
overridevirtual

◆ selectionMoveUpdateEvent()

void selectionMoveUpdateEvent ( QMouseEvent *  ev)
overridevirtual

Reimplemented from SelectionWidget< H2Core::Note * >.

◆ updateEditor

void updateEditor ( bool  bPatternOnly = false)
overridevirtualslot

◆ wheelEvent()

void wheelEvent ( QWheelEvent *  ev)
overrideprivate

Scroll wheel gestures will adjust the property of notes under the mouse cursor (or selected notes, if any).

Unlike drag gestures, each individual wheel movement will result in an undo/redo action since the events are discrete.

Field Documentation

◆ m_bNeedsUpdate

bool m_bNeedsUpdate
private

◆ m_bValueHasBeenSet

bool m_bValueHasBeenSet
private

◆ m_fLastSetValue

double m_fLastSetValue
private

◆ m_Mode

NotePropertiesMode m_Mode
private

◆ m_nDragPreviousColumn

int m_nDragPreviousColumn
private

◆ m_nSelectedPatternNumber

int m_nSelectedPatternNumber
private

◆ m_oldNotes

std::map< H2Core::Note *, H2Core::Note *> m_oldNotes
private

Map of notes currently in the pattern -> old notes with their properties.

Populated at the beginning of a properties editing gesture.

◆ m_pBackground

QPixmap* m_pBackground
private