|
hydrogen 1.2.3
|
Song editor. More...
#include <SongEditor.h>
Data Structures | |
| struct | GridCell |
Public Slots | |
| void | copy () |
| Copy a selection of cells to an XML representation in the clipboard. | |
| void | cut () |
| void | deleteSelection () |
| void | onPreferencesChanged (H2Core::Preferences::Changes changes) |
| void | paste () |
| void | scrolled (int) |
| void | selectAll () |
| void | selectNone () |
Public Member Functions | |
| SongEditor (QWidget *parent, QScrollArea *pScrollView, SongEditorPanel *pSongEditorPanel) | |
| ~SongEditor () | |
| void | clearThePatternSequenceVector (QString filename) |
| void | createBackground () |
| int | getCursorColumn () const |
| int | getCursorRow () const |
| int | getGridHeight () |
| int | getGridWidth () |
| void | invalidateBackground () |
| void | modifyPatternCellsAction (std::vector< QPoint > &addCells, std::vector< QPoint > &deleteCells, std::vector< QPoint > &selectCells) |
| Modify many pattern cells at once, for use in a single efficient undo/redo action. | |
| void | setGridWidth (uint width) |
| void | updateEditorandSetTrue () |
| void | updatePosition (float fTick) |
| int | yScrollTarget (QScrollArea *pScrollArea, int *pnPatternInView) |
| Calculate a target Y scroll value for tracking a playing song. | |
Selection interfaces | |
see Selection.h for details. | |
| virtual std::vector< SelectionIndex > | elementsIntersecting (QRect r) override |
| Find list of elements which intersect a rectangular area. | |
| virtual QRect | getKeyboardCursorRect () override |
| Calculate screen space occupied by keyboard cursor. | |
| virtual void | validateSelection () override |
| Ensure that the Selection contains only valid elements. | |
| virtual void | updateWidget () override |
| Selection or selection-related visual elements have changed, widget needs to be updated. | |
| 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 void | updateModifiers (QInputEvent *ev) |
| virtual bool | canDragElements () override |
| Can elements be dragged as well as being selected? This may change to suit widget's current state. | |
Public Member Functions inherited from Object< SongEditor > | |
| Object () | |
| Object (const Object< SongEditor > &other) | |
Public Member Functions inherited from Base | |
| Base () | |
| Base (const Base &other) | |
| virtual const char * | class_name () const |
| 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< QPoint > | |
| 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 () |
| virtual void | startMouseMove (QMouseEvent *ev) |
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 () |
| 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 | playbackTrackChangedEvent () |
| virtual void | playingPatternsChangedEvent () |
| virtual void | playlistLoadSongEvent (int nIndex) |
| virtual void | progressEvent (int nValue) |
| virtual void | quitEvent (int nValue) |
| virtual void | selectedInstrumentChangedEvent () |
| virtual void | selectedPatternChangedEvent () |
| virtual void | songModeActivationEvent () |
| virtual void | songModifiedEvent () |
| virtual void | songSizeChangedEvent () |
| virtual void | soundLibraryChangedEvent () |
| virtual void | stackedModeActivationEvent (int nValue) |
| 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 () |
Static Public Attributes | |
| static constexpr int | nMargin = 10 |
Static Public Attributes inherited from Base | |
| static QString | sPrintIndention = " " |
| String used to format the debugging string output of some core classes. | |
Private Member Functions | |
| void | drawFocus (QPainter &painter) |
| void | drawPattern (int pos, int number, bool invertColour, double width) |
| void | drawSequence () |
| QPoint | movingGridOffset () const |
| Quantise the selection move offset to the sequence grid. | |
| virtual void | patternEditorLockedEvent () override |
| virtual void | patternModifiedEvent () override |
| virtual void | relocationEvent () override |
| void | setPatternActive (int nColumn, int nRow, bool bActivate) |
| void | togglePatternActive (int nColumn, int nRow) |
| void | updateGridCells () |
Conversion between sequence grid coordinates and screen (widget) coordinates. | |
| QPoint | xyToColumnRow (QPoint p) |
| QPoint | columnRowToXy (QPoint p) |
Change the mouse cursor during mouse gestures | |
| virtual void | startMouseLasso (QMouseEvent *ev) override |
| virtual void | endMouseGesture () override |
System events | |
| virtual void | mousePressEvent (QMouseEvent *ev) override |
| virtual void | mouseReleaseEvent (QMouseEvent *ev) override |
| virtual void | mouseMoveEvent (QMouseEvent *ev) override |
| virtual void | keyPressEvent (QKeyEvent *ev) override |
| virtual void | keyReleaseEvent (QKeyEvent *ev) override |
| virtual void | paintEvent (QPaintEvent *ev) override |
| virtual void | focusInEvent (QFocusEvent *ev) override |
| virtual void | focusOutEvent (QFocusEvent *ev) override |
| virtual void | enterEvent (QEvent *ev) override |
| virtual void | leaveEvent (QEvent *ev) override |
Private Attributes | |
| bool | m_bBackgroundInvalid |
| bool | m_bCopyNotMove |
| bool | m_bDrawingActiveCell |
| In "draw" mode, whether we're activating pattern cells ("drawing") or deactivating ("erasing") is set at the start of the draw gesture. | |
| bool | m_bEntered |
| bool | m_bIsMoving |
| bool | m_bSequenceChanged |
| Pattern sequence or selection has changed, so must be redrawn. | |
| QPoint | m_currentMousePosition |
| float | m_fTick |
| Cached position of the playhead. | |
| std::map< QPoint, GridCell > | m_gridCells |
| unsigned | m_nGridHeight |
| unsigned | m_nGridWidth |
| int | m_nMaxPatternColors |
| H2Core::AudioEngine * | m_pAudioEngine |
| H2Core::Hydrogen * | m_pHydrogen |
| QMenu * | m_pPopupMenu |
| QPoint | m_previousGridOffset |
| QPoint | m_previousMousePosition |
| Mouse position during selection gestures (used to detect crossing cell boundaries) | |
| QScrollArea * | m_pScrollView |
| SongEditorPanel * | m_pSongEditorPanel |
| Selection< QPoint > | m_selection |
Background pixmap caching | |
To make painting the song editor sequence grid more efficient, the drawing uses multiple levels of lazy painting.
| |
| QPixmap * | m_pBackgroundPixmap |
| QPixmap * | m_pSequencePixmap |
Position of the keyboard input cursor | |
| int | m_nCursorRow |
| int | m_nCursorColumn |
Additional Inherited Members | |
Public Types inherited from SelectionWidget< QPoint > | |
| typedef QPoint | SelectionIndex |
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 Logger * | logger () |
| 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 | |
Protected Member Functions inherited from Object< SongEditor > | |
| ~Object () | |
Protected Member Functions inherited from Base | |
| ~Base () | |
Static Protected Member Functions inherited from Base | |
| static void | registerClass (const char *name, const atomic_obj_cpt_t *counters) |
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 |
Song editor.
The main widget of SongEditorPanel, responsible for altering the sequence of patterns.
It supports mouse and keyboard based activation of patterns in timeslots, as well as visual editing of multiple pattern+timeslot cells using a 2-dimensional visual representation, with copy, paste, move, delete, duplicate etc.
Definition at line 68 of file SongEditor.h.
| SongEditor | ( | QWidget * | parent, |
| QScrollArea * | pScrollView, | ||
| SongEditorPanel * | pSongEditorPanel ) |
Definition at line 74 of file SongEditor.cpp.
| ~SongEditor | ( | ) |
Definition at line 128 of file SongEditor.cpp.
|
inlineoverridevirtual |
Can elements be dragged as well as being selected? This may change to suit widget's current state.
Reimplemented from SelectionWidget< QPoint >.
Definition at line 238 of file SongEditor.h.
| void clearThePatternSequenceVector | ( | QString | filename | ) |
Definition at line 1357 of file SongEditor.cpp.
|
private |
Definition at line 325 of file SongEditor.cpp.
|
slot |
Copy a selection of cells to an XML representation in the clipboard.
Definition at line 393 of file SongEditor.cpp.
| void createBackground | ( | ) |
Definition at line 1116 of file SongEditor.cpp.
|
slot |
Definition at line 489 of file SongEditor.cpp.
|
slot |
Definition at line 374 of file SongEditor.cpp.
|
private |
Definition at line 1069 of file SongEditor.cpp.
|
private |
Definition at line 1268 of file SongEditor.cpp.
|
private |
Definition at line 1238 of file SongEditor.cpp.
|
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< QPoint >.
Definition at line 1338 of file SongEditor.cpp.
|
inlineoverrideprivatevirtual |
Reimplemented from SelectionWidget< QPoint >.
Definition at line 186 of file SongEditor.h.
|
overrideprivatevirtual |
Definition at line 1104 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 682 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 703 of file SongEditor.cpp.
|
inline |
Definition at line 249 of file SongEditor.h.
|
inline |
Definition at line 245 of file SongEditor.h.
|
inline |
Definition at line 92 of file SongEditor.h.
| int getGridWidth | ( | ) |
Definition at line 302 of file SongEditor.cpp.
|
overridevirtual |
Calculate screen space occupied by keyboard cursor.
Implements SelectionWidget< QPoint >.
Definition at line 1352 of file SongEditor.cpp.
| void invalidateBackground | ( | ) |
Definition at line 1188 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 494 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 677 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 1110 of file SongEditor.cpp.
| void modifyPatternCellsAction | ( | std::vector< QPoint > & | addCells, |
| std::vector< QPoint > & | deleteCells, | ||
| std::vector< QPoint > & | selectCells ) |
Modify many pattern cells at once, for use in a single efficient undo/redo action.
Modify pattern cells by first deleting some, then adding some.
deleteCells and addCells may safely overlap
Definition at line 931 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 900 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 854 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 846 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 850 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 805 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 730 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 920 of file SongEditor.cpp.
|
private |
Quantise the selection move offset to the sequence grid.
Definition at line 1222 of file SongEditor.cpp.
|
slot |
Definition at line 1390 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 1013 of file SongEditor.cpp.
|
slot |
Definition at line 428 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 1006 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 992 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 999 of file SongEditor.cpp.
|
slot |
Definition at line 1099 of file SongEditor.cpp.
|
slot |
Definition at line 348 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 859 of file SongEditor.cpp.
|
slot |
Definition at line 367 of file SongEditor.cpp.
| void setGridWidth | ( | uint | width | ) |
Definition at line 309 of file SongEditor.cpp.
|
private |
Definition at line 336 of file SongEditor.cpp.
|
inlineoverrideprivatevirtual |
Reimplemented from SelectionWidget< QPoint >.
Definition at line 181 of file SongEditor.h.
|
private |
Definition at line 331 of file SongEditor.cpp.
| void updateEditorandSetTrue | ( | ) |
Definition at line 1384 of file SongEditor.cpp.
|
private |
Definition at line 1193 of file SongEditor.cpp.
|
virtual |
Definition at line 776 of file SongEditor.cpp.
| void updatePosition | ( | float | fTick | ) |
Definition at line 975 of file SongEditor.cpp.
|
overridevirtual |
Selection or selection-related visual elements have changed, widget needs to be updated.
At a minimum, the widget's own update() method should be called.
Implements SelectionWidget< QPoint >.
Definition at line 948 of file SongEditor.cpp.
|
inlineoverridevirtual |
Ensure that the Selection contains only valid elements.
Implements SelectionWidget< QPoint >.
Definition at line 230 of file SongEditor.h.
|
private |
Definition at line 320 of file SongEditor.cpp.
| int yScrollTarget | ( | QScrollArea * | pScrollArea, |
| int * | pnPatternInView ) |
Calculate a target Y scroll value for tracking a playing song.
Songs with many patterns may not fit in the current viewport of the Song Editor. Depending on how the song is structured, as the viewport scrolls to show different times, the playing patterns may end up being off-screen. It would be ideal to be able to follow the progression of the song in a meaningful and useful way, but since multiple patterns may be active at any one time, it's non-trivial to define a useful behaviour that captures more than the simple case of a song with one pattern active at a time.
As an attempt to define a useful behaviour which captures what the user might expect to happen, we define the behaviour as follows:
This covers the trivial cases where only a single pattern is playing, and gives some intuitive behaviour for songs containing multiple playing patterns where the general progression is diagonal but with constant (or near-constant) background elements, and the "minimum scrolling" allows the user to hint if we stray off the path.
Definition at line 158 of file SongEditor.cpp.
|
private |
Definition at line 146 of file SongEditor.h.
|
private |
Definition at line 132 of file SongEditor.h.
|
private |
In "draw" mode, whether we're activating pattern cells ("drawing") or deactivating ("erasing") is set at the start of the draw gesture.
Definition at line 139 of file SongEditor.h.
|
private |
Definition at line 215 of file SongEditor.h.
|
private |
Definition at line 131 of file SongEditor.h.
|
private |
Pattern sequence or selection has changed, so must be redrawn.
Definition at line 142 of file SongEditor.h.
|
private |
Definition at line 177 of file SongEditor.h.
|
private |
Cached position of the playhead.
Definition at line 222 of file SongEditor.h.
|
private |
Definition at line 213 of file SongEditor.h.
|
private |
Definition at line 164 of file SongEditor.h.
|
private |
Definition at line 163 of file SongEditor.h.
|
private |
Definition at line 129 of file SongEditor.h.
|
private |
Definition at line 130 of file SongEditor.h.
|
private |
Definition at line 134 of file SongEditor.h.
|
private |
Definition at line 127 of file SongEditor.h.
|
private |
Definition at line 157 of file SongEditor.h.
|
private |
Definition at line 126 of file SongEditor.h.
|
private |
Definition at line 144 of file SongEditor.h.
|
private |
Definition at line 177 of file SongEditor.h.
|
private |
Mouse position during selection gestures (used to detect crossing cell boundaries)
Definition at line 177 of file SongEditor.h.
|
private |
Definition at line 123 of file SongEditor.h.
|
private |
Definition at line 158 of file SongEditor.h.
|
private |
Definition at line 124 of file SongEditor.h.
|
private |
Definition at line 121 of file SongEditor.h.
|
staticconstexpr |
Definition at line 106 of file SongEditor.h.