39 setFocusPolicy( Qt::ClickFocus );
48 qreal pixelRatio = devicePixelRatio();
50 height() * pixelRatio );
72 if ( path ==
_path ) {
91 if ( pSong !=
nullptr ) {
151 float y = ((contentHeight-
event->y()+
m_nMarginHeight)/(
float)contentHeight)
154 return std::pair<const float,float>(x,y);
172 qreal pixelRatio = devicePixelRatio();
179 QPainter painter(
this );
181 QRectF( pixelRatio * ev->rect().x(),
182 pixelRatio * ev->rect().y(),
183 pixelRatio * ev->rect().width(),
184 pixelRatio * ev->rect().height() ) );
191 if (
m_fTick != -1 && pSongEditorPanel !=
nullptr ) {
195 static_cast<float>(pSongEditorPanel->getSongEditor()->
199 painter.drawLine( nX + nOffset, 0, nX + nOffset, height() );
209 QColor backgroundColor =
210 pPref->getColorTheme()->m_songEditor_automationBackgroundColor;
211 QColor automationLineColor =
212 pPref->getColorTheme()->m_songEditor_automationLineColor;
213 QColor nodeColor = pPref->getColorTheme()->m_songEditor_automationNodeColor;
214 QColor textColor = pPref->getColorTheme()->m_songEditor_textColor;
217 qreal pixelRatio = devicePixelRatio();
229 painter.setRenderHint(QPainter::Antialiasing);
232 painter.setPen( Qt::black );
233 painter.drawLine( 0, 0, width(), 0 );
235 QPen rulerPen(Qt::DotLine);
236 rulerPen.setColor( textColor );
237 painter.setPen(rulerPen);
249 painter.drawLine(0, def.y(), width(), def.y());
251 QPen linePen( automationLineColor );
253 painter.setPen(linePen);
258 painter.drawLine(0, p.y(), width(), p.y());
260 std::pair<float, float> firstPoint = *
_path->
begin();
264 for (
auto point : *
_path) {
266 painter.drawLine(lastPoint, current);
269 QPoint last(width(), lastPoint.y());
270 painter.drawLine(lastPoint, last);
274 QPen circlePen( nodeColor );
275 circlePen.setWidth(1);
276 painter.setPen(circlePen);
277 painter.setBrush(QBrush( pPref->getColorTheme()->m_windowColor ));
279 for (
auto point : *
_path) {
282 painter.drawEllipse(center, 3, 3);
391 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
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
float get_default() const noexcept
bool empty() const noexcept
float get_max() const noexcept
void remove_point(float x)
Remove point from path.
iterator move(iterator &in, float x, float y)
Move point to other location.
iterator find(float x)
Find point near specific location.
void add_point(float x, float y)
Add a point to path.
float get_min() const noexcept
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()
static constexpr int nPlayheadWidth
static void setPlayheadPen(QPainter *p, bool bHovered=false)
static int getPlayheadShaftOffset()
static constexpr int nMargin