41 setFocusPolicy( Qt::ClickFocus );
50 qreal pixelRatio = devicePixelRatio();
52 height() * pixelRatio );
74 if ( path ==
_path ) {
93 if ( pSong !=
nullptr ) {
158 (
float)contentHeight)
161 return std::pair<const float,float>(x,y);
179 qreal pixelRatio = devicePixelRatio();
186 QPainter painter(
this );
188 QRectF( pixelRatio * ev->rect().x(),
189 pixelRatio * ev->rect().y(),
190 pixelRatio * ev->rect().width(),
191 pixelRatio * ev->rect().height() ) );
198 if (
m_fTick != -1 && pSongEditorPanel !=
nullptr ) {
202 static_cast<float>(pSongEditorPanel->getSongEditor()->
206 painter.drawLine( nX + nOffset, 0, nX + nOffset, height() );
216 QColor backgroundColor =
217 pPref->getColorTheme()->m_songEditor_automationBackgroundColor;
218 QColor automationLineColor =
219 pPref->getColorTheme()->m_songEditor_automationLineColor;
220 QColor nodeColor = pPref->getColorTheme()->m_songEditor_automationNodeColor;
221 QColor textColor = pPref->getColorTheme()->m_songEditor_textColor;
224 qreal pixelRatio = devicePixelRatio();
236 painter.setRenderHint(QPainter::Antialiasing);
239 painter.setPen( Qt::black );
240 painter.drawLine( 0, 0, width(), 0 );
242 QPen rulerPen(Qt::DotLine);
243 rulerPen.setColor( textColor );
244 painter.setPen(rulerPen);
256 painter.drawLine(0, def.y(), width(), def.y());
258 QPen linePen( automationLineColor );
260 painter.setPen(linePen);
262 if (
_path->empty()) {
265 painter.drawLine(0, p.y(), width(), p.y());
267 std::pair<float, float> firstPoint = *
_path->begin();
271 for (
auto point : *
_path) {
273 painter.drawLine(lastPoint, current);
276 QPoint last(width(), lastPoint.y());
277 painter.drawLine(lastPoint, last);
281 QPen circlePen( nodeColor );
282 circlePen.setWidth(1);
283 painter.setPen(circlePen);
284 painter.setBrush(QBrush( pPref->getColorTheme()->m_windowColor ));
286 for (
auto point : *
_path) {
289 painter.drawEllipse(center, 3, 3);
316 _path->add_point(x, y);
398 if ( event->key() == Qt::Key_Delete || event->key() == Qt::Key_Backspace ) {
static const uint SONG_EDITOR_MAX_GRID_WIDTH
static const uint SONG_EDITOR_MIN_GRID_WIDTH
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.
void updateAutomationPath()
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
QPixmap * m_pBackgroundPixmap
static constexpr int m_nMinimumHeight
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::shared_ptr< Song > getSong() const
Get the current song.
static Hydrogen * get_instance()
Returns the current Hydrogen instance __instance.
void setIsModified(bool bIsModified)
Wrapper around Song::setIsModified() that checks whether a song is set.
Manager for User Preferences File (singleton)
static Preferences * get_instance()
Returns a pointer to the current Preferences singleton stored in __instance.
Changes
Bitwise or-able options showing which part of the Preferences were altered using the PreferencesDialo...
@ Colors
At least one of the colors has changed.
static HydrogenApp * get_instance()
Returns the instance of HydrogenApp class.
void preferencesChanged(H2Core::Preferences::Changes changes)
Propagates a change in the Preferences through the GUI.
SongEditorPanel * getSongEditorPanel()
Compatibility class to support QMouseEvent more esily in Qt5 and Qt6.
static constexpr int nPlayheadWidth
static void setPlayheadPen(QPainter *p, bool bHovered=false)
static int getPlayheadShaftOffset()
static constexpr int nMargin