hydrogen 1.2.3
AutomationPathView.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 AUTOMATION_PATH_VIEW_H
24#define AUTOMATION_PATH_VIEW_H
25
26#include <core/Object.h>
29
30#include <QtGui>
31#include <QtWidgets>
32
34class AutomationPathView : public QWidget, public H2Core::Object<AutomationPathView>
35{
36 Q_OBJECT
38
39 void createBackground();
40
45
48 float m_fOriginX;
49 float m_fOriginY;
52 float m_fTick;
54
55public:
56 AutomationPathView(QWidget *parent = nullptr);
58
60 void setAutomationPath(H2Core::AutomationPath *path, bool bUpdate = true);
61
62 int getGridWidth() const noexcept { return m_nGridWidth; }
63 void setGridWidth(int width);
64
65 void updatePosition( float fTick );
67
68protected:
69 void paintEvent(QPaintEvent *event) override;
70 void mousePressEvent(QMouseEvent *event) override;
71 void mouseReleaseEvent(QMouseEvent *event) override;
72 void mouseMoveEvent(QMouseEvent *event) override;
73 void keyPressEvent(QKeyEvent *event) override;
74
75
76 QPoint translatePoint(float x, float y) const;
77 QPoint translatePoint(const std::pair<float,float> &p) const;
78 bool checkBounds(QMouseEvent *event) const;
79 std::pair<const float, float> locate(QMouseEvent *) const;
80
81 void autoResize();
82
83public slots:
85
86signals:
88
89 void pointAdded(float x, float y);
90 void pointRemoved(float x, float y);
91 void pointMoved(float ox, float oy, float tx, float ty);
92};
93
94#endif
#define noexcept
#define H2_OBJECT(name)
Definition Object.h:224
AutomationPathView(QWidget *parent=nullptr)
float m_fTick
< Point that is being dragged
void pointMoved(float ox, float oy, float tx, float ty)
H2Core::AutomationPath * _path
bool checkBounds(QMouseEvent *event) const
Check if user clicked within area inside margins.
bool m_bPointAdded
< Whether any points are being dragged
void mouseReleaseEvent(QMouseEvent *event) override
Handler for releasing mouse button.
void pointAdded(float x, float y)
void updatePosition(float fTick)
void mouseMoveEvent(QMouseEvent *event) override
Handler for mouse moves.
void keyPressEvent(QKeyEvent *event) override
Handler for key presses.
void onPreferencesChanged(H2Core::Preferences::Changes changes)
int m_nMarginHeight
< Width of song grid cell size - in order to properly align AutomationPathView and SongEditor
void mousePressEvent(QMouseEvent *event) override
Handle mouse click.
H2Core::AutomationPath * getAutomationPath() const noexcept
void pointRemoved(float x, float y)
QPoint translatePoint(float x, float y) const
Locate path point on a wdiget surface.
int getGridWidth() const noexcept
H2Core::AutomationPath::iterator _selectedPoint
< Original position of selected point
void paintEvent(QPaintEvent *event) override
Repaint widget.
std::pair< const float, float > locate(QMouseEvent *) const
Locate clicked point on a path.
float m_fOriginY
< Original position of selected point
float m_fOriginX
< Whether a new point was added during mouse move
void autoResize()
Resize widget to fit everything.
void setGridWidth(int width)
void setAutomationPath(H2Core::AutomationPath *path, bool bUpdate=true)
int m_nMaxPatternSequence
< Height of top and bottom margins
std::map< float, float >::iterator iterator
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...