|
hydrogen 1.2.6
|
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 | logBacktrace () const |
| Print the current stack at point into the debug log. | |
| 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 (int nValue) |
| 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 | m_nMinimumHeight = 90 |
| Default value of Preferences::m_nSongEditorGridHeight * 5 (patterns) | |
| 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 |
| static bool | bLogColors = true |
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 76 of file SongEditor.cpp.
| ~SongEditor | ( | ) |
Definition at line 129 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 245 of file SongEditor.h.
| void clearThePatternSequenceVector | ( | QString | filename | ) |
Definition at line 1372 of file SongEditor.cpp.
|
private |
Definition at line 326 of file SongEditor.cpp.
|
slot |
Copy a selection of cells to an XML representation in the clipboard.
Definition at line 394 of file SongEditor.cpp.
| void createBackground | ( | ) |
Definition at line 1129 of file SongEditor.cpp.
|
slot |
Definition at line 490 of file SongEditor.cpp.
|
slot |
Definition at line 375 of file SongEditor.cpp.
|
private |
Definition at line 1078 of file SongEditor.cpp.
|
private |
Definition at line 1283 of file SongEditor.cpp.
|
private |
Definition at line 1253 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 1353 of file SongEditor.cpp.
|
inlineoverrideprivatevirtual |
Reimplemented from SelectionWidget< QPoint >.
Definition at line 189 of file SongEditor.h.
|
overrideprivatevirtual |
Definition at line 1116 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 683 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 704 of file SongEditor.cpp.
|
inline |
Definition at line 256 of file SongEditor.h.
|
inline |
Definition at line 252 of file SongEditor.h.
|
inline |
Definition at line 92 of file SongEditor.h.
| int getGridWidth | ( | ) |
Definition at line 303 of file SongEditor.cpp.
|
overridevirtual |
Calculate screen space occupied by keyboard cursor.
Implements SelectionWidget< QPoint >.
Definition at line 1367 of file SongEditor.cpp.
| void invalidateBackground | ( | ) |
Definition at line 1203 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 495 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 678 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 1123 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 939 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 905 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 859 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 851 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 855 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 808 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 731 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 928 of file SongEditor.cpp.
|
private |
Quantise the selection move offset to the sequence grid.
Definition at line 1237 of file SongEditor.cpp.
|
slot |
Definition at line 1405 of file SongEditor.cpp.
|
overrideprivatevirtual |
Definition at line 1022 of file SongEditor.cpp.
|
slot |
Definition at line 429 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 1015 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 1001 of file SongEditor.cpp.
|
overrideprivatevirtual |
Reimplemented from EventListener.
Definition at line 1008 of file SongEditor.cpp.
|
slot |
Definition at line 1108 of file SongEditor.cpp.
|
slot |
Definition at line 349 of file SongEditor.cpp.
|
overridevirtual |
Implements SelectionWidget< QPoint >.
Definition at line 864 of file SongEditor.cpp.
|
slot |
Definition at line 368 of file SongEditor.cpp.
| void setGridWidth | ( | uint | width | ) |
Definition at line 310 of file SongEditor.cpp.
|
private |
Definition at line 337 of file SongEditor.cpp.
|
inlineoverrideprivatevirtual |
Reimplemented from SelectionWidget< QPoint >.
Definition at line 184 of file SongEditor.h.
|
private |
Definition at line 332 of file SongEditor.cpp.
| void updateEditorandSetTrue | ( | ) |
Definition at line 1399 of file SongEditor.cpp.
|
private |
Definition at line 1208 of file SongEditor.cpp.
|
virtual |
Definition at line 779 of file SongEditor.cpp.
| void updatePosition | ( | float | fTick | ) |
Definition at line 984 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 956 of file SongEditor.cpp.
|
inlineoverridevirtual |
Ensure that the Selection contains only valid elements.
Implements SelectionWidget< QPoint >.
Definition at line 237 of file SongEditor.h.
|
private |
Definition at line 321 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 159 of file SongEditor.cpp.
|
private |
Definition at line 149 of file SongEditor.h.
|
private |
Definition at line 135 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 142 of file SongEditor.h.
|
private |
Definition at line 222 of file SongEditor.h.
|
private |
Definition at line 134 of file SongEditor.h.
|
private |
Pattern sequence or selection has changed, so must be redrawn.
Definition at line 145 of file SongEditor.h.
|
private |
Definition at line 180 of file SongEditor.h.
|
private |
Cached position of the playhead.
Definition at line 229 of file SongEditor.h.
|
private |
Definition at line 220 of file SongEditor.h.
|
private |
Definition at line 167 of file SongEditor.h.
|
private |
Definition at line 166 of file SongEditor.h.
|
private |
Definition at line 132 of file SongEditor.h.
|
private |
Definition at line 133 of file SongEditor.h.
|
private |
Definition at line 137 of file SongEditor.h.
|
staticconstexpr |
Default value of Preferences::m_nSongEditorGridHeight * 5 (patterns)
Definition at line 109 of file SongEditor.h.
|
private |
Definition at line 130 of file SongEditor.h.
|
private |
Definition at line 160 of file SongEditor.h.
|
private |
Definition at line 129 of file SongEditor.h.
|
private |
Definition at line 147 of file SongEditor.h.
|
private |
Definition at line 180 of file SongEditor.h.
|
private |
Mouse position during selection gestures (used to detect crossing cell boundaries)
Definition at line 180 of file SongEditor.h.
|
private |
Definition at line 126 of file SongEditor.h.
|
private |
Definition at line 161 of file SongEditor.h.
|
private |
Definition at line 127 of file SongEditor.h.
|
private |
Definition at line 124 of file SongEditor.h.
|
staticconstexpr |
Definition at line 106 of file SongEditor.h.