hydrogen 1.2.3
DrumPatternEditor.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2002-2008 by Alex >Comix< Cominu [comix@users.sourceforge.net]
4 * Copyright(c) 2008-2024 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
5 *
6 * http://www.hydrogen-music.org
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY, without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see https://www.gnu.org/licenses
20 *
21 */
22
23
24#ifndef DRUM_PATTERN_EDITOR_H
25#define DRUM_PATTERN_EDITOR_H
26
27#include "../EventListener.h"
28#include "../Selection.h"
29#include "PatternEditor.h"
30#include "NotePropertiesRuler.h"
32
33#include <core/Object.h>
36
37#include <QtGui>
38#include <QtWidgets>
39
41
45
46class DrumPatternEditor : public PatternEditor, protected WidgetWithScalableFont<7, 9, 11>
47{
49 Q_OBJECT
50
51 public:
52 DrumPatternEditor(QWidget* parent, PatternEditorPanel *panel);
54
55 // Implements EventListener interface
56 virtual void selectedPatternChangedEvent() override;
57 virtual void selectedInstrumentChangedEvent() override;
58 virtual void drumkitLoadedEvent() override;
59 virtual void songModeActivationEvent() override;
60 // ~ Implements EventListener interface
61 void addOrDeleteNoteAction( int nColumn,
62 int row,
63 int selectedPatternNumber,
64 int oldLength,
65 float oldVelocity,
66 float fOldPan,
67 float oldLeadLag,
68 int oldNoteKeyVal,
69 int oldOctaveKeyVal,
70 float probability,
71 bool listen,
72 bool isMidi,
73 bool isInstrumentMode,
74 bool isNoteOff,
75 bool isDelete );
76 void moveNoteAction( int nColumn,
77 int nRow,
78 int nPattern,
79 int nNewColumn,
80 int nNewRow,
81 H2Core::Note *note);
82
83 void addOrRemoveNote( int nColumn, int nRealColumn, int row,
84 bool bDoAdd = true, bool bDoDelete = true,
85 bool bIsNoteOff = false );
86 void undoRedoAction( int column,
88 int nSelectedPatternNumber,
89 int nSelectedInstrument,
90 float velocity,
91 float pan,
92 float leadLag,
93 float probability,
94 int noteKeyVal,
95 int octaveKeyVal );
96 void functionClearNotesRedoAction( int nSelectedInstrument, int selectedPatternNumber );
97 void functionClearNotesUndoAction( std::list< H2Core::Note* > noteList, int nSelectedInstrument, int patternNumber );
98 void functionFillNotesUndoAction( QStringList noteList, int nSelectedInstrument, int patternNumber );
99 void functionFillNotesRedoAction( QStringList noteList, int nSelectedInstrument, int patternNumber );
100 void functionRandomVelocityAction( QStringList noteVeloValue, int nSelectedInstrument, int selectedPatternNumber );
101 void functionMoveInstrumentAction( int nSourceInstrument, int nTargetInstrument );
102 void functionDropInstrumentUndoAction( int nTargetInstrument, std::vector<int>* AddedComponents );
110 void functionDropInstrumentRedoAction(QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument, std::vector<int>* pAddedComponents );
111 void functionDeleteInstrumentUndoAction( std::list< H2Core::Note* > noteList, int nSelectedInstrument, QString instrumentName, QString drumkitName );
114 void functionPasteNotesRedoAction(std::list<H2Core::Pattern*> & changeList, std::list<H2Core::Pattern*> & appliedList);
115 void functionPasteNotesUndoAction(std::list<H2Core::Pattern*> & appliedList);
116
117 // Synthetic UI events from selection manager
118 virtual void mouseClickEvent( QMouseEvent *ev ) override;
119 virtual void mouseDragStartEvent( QMouseEvent *ev ) override;
120 virtual void mouseDragUpdateEvent( QMouseEvent *ev ) override;
121 virtual void selectionMoveEndEvent( QInputEvent *ev ) override;
122
123 // Selected notes are indexed by their address to ensure that a
124 // note is definitely uniquely identified. This carries the risk
125 // that state pointers to deleted notes may find their way into
126 // the selection.
127 virtual std::vector<SelectionIndex> elementsIntersecting( QRect r ) override;
128
129 virtual QRect getKeyboardCursorRect() override;
130
131 public slots:
132 virtual void updateEditor( bool bPatternOnly = false ) override;
133 virtual void selectAll() override;
134 virtual void deleteSelection() override;
135 virtual void paste() override;
137
138 private:
139 void createBackground() override;
149 void drawNote( H2Core::Note* pNote, QPainter& painter, bool bIsForeground = true );
150 void drawPattern( QPainter& painter );
151 void drawBackground( QPainter& pointer );
152 void drawFocus( QPainter& painter );
153
154 virtual void keyPressEvent (QKeyEvent *ev) override;
155 virtual void keyReleaseEvent (QKeyEvent *ev) override;
156 virtual void showEvent ( QShowEvent *ev ) override;
157 virtual void hideEvent ( QHideEvent *ev ) override;
158 virtual void paintEvent(QPaintEvent *ev) override;
159 virtual void mousePressEvent( QMouseEvent *ev ) override;
160
161 QString renameCompo( QString OriginalName );
162};
163
164
165#endif
#define H2_OBJECT(name)
Definition Object.h:224
Drum pattern editor.
void functionClearNotesUndoAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, int patternNumber)
virtual void hideEvent(QHideEvent *ev) override
void functionRandomVelocityAction(QStringList noteVeloValue, int nSelectedInstrument, int selectedPatternNumber)
virtual void mouseDragUpdateEvent(QMouseEvent *ev) override
Update the state during a Selection drag.
void drawNote(H2Core::Note *pNote, QPainter &painter, bool bIsForeground=true)
Draw a note.
virtual void keyReleaseEvent(QKeyEvent *ev) override
virtual void updateEditor(bool bPatternOnly=false) override
virtual void mousePressEvent(QMouseEvent *ev) override
Raw Qt mouse events are passed to the Selection.
void functionDropInstrumentUndoAction(int nTargetInstrument, std::vector< int > *AddedComponents)
virtual std::vector< SelectionIndex > elementsIntersecting(QRect r) override
Find all elements which intersect a selection area.
virtual void selectionMoveEndEvent(QInputEvent *ev) override
Move or copy notes.
DrumPatternEditor(QWidget *parent, PatternEditorPanel *panel)
void drawPattern(QPainter &painter)
Draws a pattern.
virtual QRect getKeyboardCursorRect() override
The screen area occupied by the keyboard cursor.
void functionMoveInstrumentAction(int nSourceInstrument, int nTargetInstrument)
void addOrRemoveNote(int nColumn, int nRealColumn, int row, bool bDoAdd=true, bool bDoDelete=true, bool bIsNoteOff=false)
virtual void selectAll() override
void onPreferencesChanged(H2Core::Preferences::Changes changes)
void drawBackground(QPainter &pointer)
void moveNoteAction(int nColumn, int nRow, int nPattern, int nNewColumn, int nNewRow, H2Core::Note *note)
virtual void songModeActivationEvent() override
virtual void drumkitLoadedEvent() override
virtual void keyPressEvent(QKeyEvent *ev) override
Handle key press events.
virtual void paste() override
Paste selection.
virtual void showEvent(QShowEvent *ev) override
virtual void mouseDragStartEvent(QMouseEvent *ev) override
void functionFillNotesRedoAction(QStringList noteList, int nSelectedInstrument, int patternNumber)
void createBackground() override
Updates m_pBackgroundPixmap to show the latest content.
virtual void selectedInstrumentChangedEvent() override
void addOrDeleteNoteAction(int nColumn, int row, int selectedPatternNumber, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float probability, bool listen, bool isMidi, bool isInstrumentMode, bool isNoteOff, bool isDelete)
void functionFillNotesUndoAction(QStringList noteList, int nSelectedInstrument, int patternNumber)
virtual void mouseClickEvent(QMouseEvent *ev) override
virtual void paintEvent(QPaintEvent *ev) override
virtual void deleteSelection() override
void undoRedoAction(int column, NotePropertiesRuler::Mode mode, int nSelectedPatternNumber, int nSelectedInstrument, float velocity, float pan, float leadLag, float probability, int noteKeyVal, int octaveKeyVal)
NotePropertiesRuler undo redo action.
void functionPasteNotesUndoAction(std::list< H2Core::Pattern * > &appliedList)
void functionClearNotesRedoAction(int nSelectedInstrument, int selectedPatternNumber)
========================================================== undo / redo actions from pattern editor in...
virtual void selectedPatternChangedEvent() override
void functionDeleteInstrumentUndoAction(std::list< H2Core::Note * > noteList, int nSelectedInstrument, QString instrumentName, QString drumkitName)
void drawFocus(QPainter &painter)
QString renameCompo(QString OriginalName)
void functionPasteNotesRedoAction(std::list< H2Core::Pattern * > &changeList, std::list< H2Core::Pattern * > &appliedList)
void functionDropInstrumentRedoAction(QString sDrumkitPath, QString sInstrumentName, int nTargetInstrument, std::vector< int > *pAddedComponents)
A note plays an associated instrument with a velocity left and right pan.
Definition Note.h:102
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
Pattern Editor Panel.
Pattern Editor.
Widget is affected by the "Font size" settings in the PreferencesDialog.