hydrogen 1.2.6
NotePropertiesRuler.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-2025 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 NOTE_PROPERTIES_RULER_H
24#define NOTE_PROPERTIES_RULER_H
25
26#include "../EventListener.h"
28
29#include <QtGui>
30#include <QtWidgets>
31
32#include <core/Basics/Note.h>
33#include <core/Object.h>
35#include <map>
36
37#include "PatternEditor.h"
38
39namespace H2Core
40{
41 class Pattern;
42 class NoteKey;
43}
44
46
51class NotePropertiesRuler : public PatternEditor, protected WidgetWithScalableFont<7, 9, 11>
52{
54 Q_OBJECT
55 public:
56
57 NotePropertiesRuler( QWidget *parent, PatternEditorPanel *pPatternEditorPanel, Mode mode );
59
62
68 void propertyDragStart( QMouseEvent *ev );
69 void propertyDragUpdate( QMouseEvent *ev );
70 void propertyDragEnd();
72
75 virtual std::vector<SelectionIndex> elementsIntersecting( QRect r ) override;
76 virtual void mouseClickEvent( QMouseEvent *ev ) override;
77 virtual void mousePressEvent( QMouseEvent *ev ) override;
78 virtual void mouseDragStartEvent( QMouseEvent *ev ) override;
79 virtual void mouseDragUpdateEvent( QMouseEvent *ev ) override;
80 virtual void mouseDragEndEvent( QMouseEvent *ev ) override;
81 virtual void selectionMoveUpdateEvent( QMouseEvent *ev ) override;
82 virtual void selectionMoveEndEvent( QInputEvent *ev ) override;
83 virtual void selectionMoveCancelEvent() override;
84 virtual QRect getKeyboardCursorRect() override;
86
87
88 public slots:
89 virtual void updateEditor( bool bPatternOnly = false ) override;
90 virtual void selectAll() override;
91 virtual void deleteSelection() override {}
92 virtual void copy() override {}
93 virtual void paste() override {}
94 virtual void cut() override {}
96 void scrolled( int );
97
98 private:
99
101 static constexpr int nNoteKeyLineHeight = 10;
103 static constexpr int nNoteKeyOctaveHeight = 90;
106 static constexpr int nNoteKeySpaceHeight = 10;
109 static int nNoteKeyHeight;
111 static constexpr int nDefaultHeight = 100;
112
114 void createBackground() override;
115 void drawDefaultBackground( QPainter& painter, int nHeight = 0, int nIncrement = 0 );
116 void drawFocus( QPainter& painter );
117
120
121 void createNormalizedBackground(QPixmap *pixmap);
122 void createCenteredBackground(QPixmap *pixmap);
123 void createNoteKeyBackground(QPixmap *pixmap);
124
125 void paintEvent(QPaintEvent *ev) override;
126 void wheelEvent(QWheelEvent *ev) override;
127 void keyPressEvent( QKeyEvent *ev ) override;
128 void addUndoAction();
129 void prepareUndoAction( int x );
130#ifdef H2CORE_HAVE_QT6
131 virtual void enterEvent( QEnterEvent *ev ) override;
132#else
133 virtual void enterEvent( QEvent *ev ) override;
134#endif
135 void leaveEvent( QEvent *ev ) override;
136
137 virtual void mouseMoveEvent( QMouseEvent *ev ) override;
138
139
140 // Implements EventListener interface
141 virtual void selectedPatternChangedEvent() override;
142 virtual void selectedInstrumentChangedEvent() override;
143 virtual void songModeActivationEvent() override;
144 // ~ Implements EventListener interface
145
147
150 std::map< H2Core::Note *, H2Core::Note *> m_oldNotes;
151 void clearOldNotes();
152
153 void adjustNotePropertyDelta( H2Core::Note *pNote, float fDelta, bool bMessage = false );
154
157};
158
159
160#endif
#define H2_OBJECT(name)
Definition Object.h:227
A note plays an associated instrument with a velocity left and right pan.
Definition Note.h:101
Pattern class is a Note container.
Definition Pattern.h:46
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
virtual void mouseDragUpdateEvent(QMouseEvent *ev) override
std::map< H2Core::Note *, H2Core::Note * > m_oldNotes
Map of notes currently in the pattern -> old notes with their properties.
virtual void mouseMoveEvent(QMouseEvent *ev) override
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
The screen area occupied by the keyboard cursor.
NotePropertiesRuler(const NotePropertiesRuler &)=delete
static constexpr int nNoteKeyOctaveHeight
Height of the whole octave section.
void prepareUndoAction(int x)
Preserve current note properties at position x (or in selection, if any) for use in later UndoAction.
NotePropertiesRuler(QWidget *parent, PatternEditorPanel *pPatternEditorPanel, Mode mode)
static constexpr int nNoteKeyLineHeight
Height of a single line in the key section.
NotePropertiesRuler & operator=(const NotePropertiesRuler &rhs)=delete
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 ra...
virtual void selectionMoveUpdateEvent(QMouseEvent *ev) override
static constexpr int nDefaultHeight
Height of all editors except the NoteKey one.
virtual void deleteSelection() override
virtual void selectAll() override
void onPreferencesChanged(H2Core::Preferences::Changes changes)
virtual void paste() override
virtual void cut() override
virtual void songModeActivationEvent() override
void leaveEvent(QEvent *ev) override
void wheelEvent(QWheelEvent *ev) override
Scroll wheel gestures will adjust the property of notes under the mouse cursor (or selected notes,...
void createNoteKeyBackground(QPixmap *pixmap)
void keyPressEvent(QKeyEvent *ev) override
void createNormalizedBackground(QPixmap *pixmap)
virtual void mouseDragStartEvent(QMouseEvent *ev) override
void propertyDragUpdate(QMouseEvent *ev)
Update notes for a property adjust drag, in response to the mouse moving.
void createBackground() override
Updates m_pBackgroundPixmap to show the latest content.
virtual void selectedInstrumentChangedEvent() override
virtual void copy() override
static int nNoteKeyHeight
The height of the overall NoteKey Editor.
void drawDefaultBackground(QPainter &painter, int nHeight=0, int nIncrement=0)
virtual void mouseDragEndEvent(QMouseEvent *ev) override
virtual void mouseClickEvent(QMouseEvent *ev) override
void paintEvent(QPaintEvent *ev) override
void createCenteredBackground(QPixmap *pixmap)
virtual void selectionMoveCancelEvent() override
Move of selection is cancelled. Revert notes to preserved state.
static constexpr int nNoteKeySpaceHeight
Height of the non-interactive space in NoteKey editor between octave and key section.
virtual void selectedPatternChangedEvent() override
void drawFocus(QPainter &painter)
void propertyDragStart(QMouseEvent *ev)
virtual void enterEvent(QEvent *ev) override
virtual std::vector< SelectionIndex > elementsIntersecting(QRect r) override
Find list of elements which intersect a rectangular area.
Pattern Editor Panel.
PatternEditor(QWidget *pParent, PatternEditorPanel *panel)
Widget is affected by the "Font size" settings in the PreferencesDialog.