hydrogen 1.2.3
PianoRollEditor.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#ifndef PIANO_ROLL_EDITOR_H
24#define PIANO_ROLL_EDITOR_H
25
26#include <core/Object.h>
28#include <core/Basics/Note.h>
29#include "../EventListener.h"
30#include "../Selection.h"
31#include "PatternEditor.h"
32#include "NotePropertiesRuler.h"
34
35#include <QtGui>
36#include <QtWidgets>
37
39class PianoRollEditor: public PatternEditor, protected WidgetWithScalableFont<7, 9, 11>, public H2Core::Object<PianoRollEditor>
40{
42 Q_OBJECT
43 public:
44 PianoRollEditor( QWidget *pParent, PatternEditorPanel *panel,
45 QScrollArea *pScrollView );
47
48
49 // Implements EventListener interface
50 virtual void selectedPatternChangedEvent() override;
51 virtual void selectedInstrumentChangedEvent() override;
52 virtual void songModeActivationEvent() override;
53 // ~ Implements EventListener interface
54
55 void addOrDeleteNoteAction( int nColumn,
56 int pressedLine,
57 int selectedPatternNumber,
58 int selectedinstrument,
59 int oldLength,
60 float oldVelocity,
61 float fOldPan,
62 float oldLeadLag,
63 int oldNoteKeyVal,
64 int oldOctaveKeyVal,
65 float fProbability,
66 bool noteOff,
67 bool isDelete );
68
69 void moveNoteAction( int nColumn,
72 int nPattern,
73 int nNewColumn,
74 H2Core::Note::Octave newOctave,
75 H2Core::Note::Key newKey,
76 H2Core::Note *pNote);
77
78
79 // Selection manager interface
81
82 virtual std::vector<SelectionIndex> elementsIntersecting( QRect r ) override;
83 virtual void mouseClickEvent( QMouseEvent *ev ) override;
84 virtual void mousePressEvent( QMouseEvent *ev ) override;
85 virtual void mouseDragStartEvent( QMouseEvent *ev ) override;
86 virtual void mouseDragUpdateEvent( QMouseEvent *ev ) override;
87 virtual void selectionMoveEndEvent( QInputEvent *ev ) override;
88 virtual QRect getKeyboardCursorRect() override;
89
90
91 public slots:
92 virtual void updateEditor( bool bPatternOnly = false ) override;
93 virtual void selectAll() override;
94 virtual void deleteSelection() override;
95 virtual void paste() override;
97
98 private:
99 void createBackground() override;
100 void drawPattern();
101 void drawFocus( QPainter& painter );
111 void drawNote( H2Core::Note *pNote, QPainter *pPainter, bool bIsForeground );
112
113 void addOrRemoveNote( int nColumn, int nRealColumn, int nLine,
114 int nNotekey, int nOctave,
115 bool bDoAdd = true, bool bDoDelete = true );
116
117 virtual void paintEvent(QPaintEvent *ev) override;
118 virtual void keyPressEvent ( QKeyEvent * ev ) override;
119
120 void finishUpdateEditor();
121
124
126 QPixmap *m_pTemp;
127
128 // Note pitch position of cursor
130 QPoint cursorPosition();
131
132 QScrollArea *m_pScrollView;
133};
134
135#endif
136
#define H2_OBJECT(name)
Definition Object.h:224
A note plays an associated instrument with a velocity left and right pan.
Definition Note.h:102
Key
possible keys
Definition Note.h:106
Octave
possible octaves
Definition Note.h:110
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
Pattern Editor Panel.
Pattern Editor.
virtual std::vector< SelectionIndex > elementsIntersecting(QRect r) override
Selections are indexed by Note pointers.
virtual void mouseDragUpdateEvent(QMouseEvent *ev) override
void moveNoteAction(int nColumn, H2Core::Note::Octave octave, H2Core::Note::Key key, int nPattern, int nNewColumn, H2Core::Note::Octave newOctave, H2Core::Note::Key newKey, H2Core::Note *pNote)
virtual void updateEditor(bool bPatternOnly=false) override
virtual void mousePressEvent(QMouseEvent *ev) override
Raw Qt mouse events are passed to the Selection.
virtual void selectionMoveEndEvent(QInputEvent *ev) override
virtual QRect getKeyboardCursorRect() override
Position of keyboard input cursor on screen.
void addOrDeleteNoteAction(int nColumn, int pressedLine, int selectedPatternNumber, int selectedinstrument, int oldLength, float oldVelocity, float fOldPan, float oldLeadLag, int oldNoteKeyVal, int oldOctaveKeyVal, float fProbability, bool noteOff, bool isDelete)
void addOrRemoveNote(int nColumn, int nRealColumn, int nLine, int nNotekey, int nOctave, bool bDoAdd=true, bool bDoDelete=true)
virtual void selectAll() override
void onPreferencesChanged(H2Core::Preferences::Changes changes)
virtual void songModeActivationEvent() override
virtual void keyPressEvent(QKeyEvent *ev) override
PianoRollEditor(QWidget *pParent, PatternEditorPanel *panel, QScrollArea *pScrollView)
QScrollArea * m_pScrollView
virtual void paste() override
Paste selection.
virtual void mouseDragStartEvent(QMouseEvent *ev) override
void createBackground() override
Updates m_pBackgroundPixmap to show the latest content.
virtual void selectedInstrumentChangedEvent() override
void drawNote(H2Core::Note *pNote, QPainter *pPainter, bool bIsForeground)
Draw a note.
virtual void mouseClickEvent(QMouseEvent *ev) override
virtual void paintEvent(QPaintEvent *ev) override
QPixmap * m_pBackground
virtual void deleteSelection() override
virtual void selectedPatternChangedEvent() override
void drawFocus(QPainter &painter)
Widget is affected by the "Font size" settings in the PreferencesDialog.