From 8627616175d0bd35266da26be454749a129d6e16 Mon Sep 17 00:00:00 2001 From: Andrew Wiltshire <62200778+AW1534@users.noreply.github.com> Date: Fri, 12 Dec 2025 15:02:25 +0000 Subject: [PATCH] Make playhead red when recording (#7847) Co-authored-by: Dalton Messmer Co-authored-by: Fawn Co-authored-by: Andrew Wiltshire --- .../classic/recording_playpos_marker.png | Bin 0 -> 261 bytes data/themes/classic/style.css | 1 + .../default/recording_playpos_marker.png | Bin 0 -> 263 bytes data/themes/default/style.css | 1 + include/PositionLine.h | 7 +++++++ include/SongEditor.h | 9 ++++++--- include/TimeLineWidget.h | 11 ++++++++++- src/gui/editors/PianoRoll.cpp | 17 ++++++++++++++++- src/gui/editors/PositionLine.cpp | 14 ++++++++++++-- src/gui/editors/SongEditor.cpp | 6 ++++++ src/gui/editors/TimeLineWidget.cpp | 9 +++++---- 11 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 data/themes/classic/recording_playpos_marker.png create mode 100644 data/themes/default/recording_playpos_marker.png diff --git a/data/themes/classic/recording_playpos_marker.png b/data/themes/classic/recording_playpos_marker.png new file mode 100644 index 0000000000000000000000000000000000000000..61fcdd98be4760cbc6b6627dcfba0eccb05a126e GIT binary patch literal 261 zcmeAS@N?(olHy`uVBq!ia0vp^fNn{1`6_P!Id>I(3)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4N!tD z$=lt9;Xep2*t>i(P=vFp$wj`elF{r5}E)kxJ*g_ literal 0 HcmV?d00001 diff --git a/data/themes/classic/style.css b/data/themes/classic/style.css index 6957c8d6f..baaaab6ec 100644 --- a/data/themes/classic/style.css +++ b/data/themes/classic/style.css @@ -141,6 +141,7 @@ lmms--gui--FileBrowser QCheckBox lmms--gui--PositionLine { qproperty-tailGradient: false; qproperty-lineColor: rgb(255, 255, 255); + qproperty-recordingColor: rgb(255, 71, 87); } lmms--gui--PianoRoll { diff --git a/data/themes/default/recording_playpos_marker.png b/data/themes/default/recording_playpos_marker.png new file mode 100644 index 0000000000000000000000000000000000000000..73d57ff0819cb93ffc4b880e9a169699cfdc2b10 GIT binary patch literal 263 zcmeAS@N?(olHy`uVBq!ia0vp^fNn{1`6_P!Id>I(3)EF2VS{N990fib~Fff!FFfhDIU|_JC!N4G1FlSew4N!tD z$=lt9;Xep2*t>i(P=vF QCursor; QPixmap m_posMarkerPixmap = embed::getIconPixmap("playpos_marker"); + QPixmap m_recordingPosMarkerPixmap = embed::getIconPixmap("recording_playpos_marker"); QColor m_inactiveLoopColor = QColor{52, 63, 53, 64}; QBrush m_inactiveLoopBrush = QColor{255, 255, 255, 32}; @@ -232,6 +238,9 @@ private: std::array m_oldLoopPos; TimePos m_dragStartPos; + bool m_isRecording = false; + bool m_isPlayheadVisible = true; + TextFloat* m_hint = nullptr; int m_initalXSelect; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 82590ad69..917d2550a 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -4149,6 +4149,9 @@ void PianoRoll::record() m_recording = true; Engine::getSong()->playMidiClip( m_midiClip, false ); + + m_timeLine->setRecording(true); + m_positionLine->setRecording(true); } @@ -4176,6 +4179,11 @@ void PianoRoll::recordAccompany() { Engine::getSong()->playPattern(); } + + auto* songEditor = GuiApplication::instance()->songEditor()->m_editor; + + songEditor->timeLine()->setRecording(true); + songEditor->positionLine()->setRecording(true); } @@ -4204,7 +4212,7 @@ bool PianoRoll::toggleStepRecording() } } - return m_stepRecorder.isRecording();; + return m_stepRecorder.isRecording(); } @@ -4215,6 +4223,13 @@ void PianoRoll::stop() Engine::getSong()->stop(); m_recording = false; m_scrollBack = m_timeLine->autoScroll() != TimeLineWidget::AutoScrollState::Disabled; + + auto* songEditor = GuiApplication::instance()->songEditor()->m_editor; + + songEditor->timeLine()->setRecording(false); + songEditor->positionLine()->setRecording(false); + m_timeLine->setRecording(false); + m_positionLine->setRecording(false); } diff --git a/src/gui/editors/PositionLine.cpp b/src/gui/editors/PositionLine.cpp index 1b43d6383..e2ce3194b 100644 --- a/src/gui/editors/PositionLine.cpp +++ b/src/gui/editors/PositionLine.cpp @@ -34,7 +34,8 @@ PositionLine::PositionLine(QWidget* parent, Song::PlayMode playMode) : QWidget(parent), m_playMode(playMode), m_hasTailGradient(false), - m_lineColor(0, 0, 0, 0) + m_lineColor(0, 0, 0, 0), + m_recordingColor(255, 71, 87) { resize(8, height()); @@ -42,10 +43,19 @@ PositionLine::PositionLine(QWidget* parent, Song::PlayMode playMode) : setAttribute(Qt::WA_TransparentForMouseEvents); } +void PositionLine::setRecording(bool recording) +{ + if (m_isRecording != recording) + { + m_isRecording = recording; + update(); + } +} + void PositionLine::paintEvent(QPaintEvent* pe) { QPainter p(this); - auto c = QColor(m_lineColor); + auto c = !m_isRecording ? m_lineColor : m_recordingColor; // If width is 1, we don't need a gradient if (width() == 1) diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 22dca6ab6..88706bfe5 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -1098,6 +1098,8 @@ void SongEditorWindow::play() void SongEditorWindow::record() { m_editor->m_song->record(); + m_editor->m_timeLine->setRecording(true); + m_editor->m_positionLine->setRecording(true); } @@ -1106,6 +1108,8 @@ void SongEditorWindow::record() void SongEditorWindow::recordAccompany() { m_editor->m_song->playAndRecord(); + m_editor->m_timeLine->setRecording(true); + m_editor->m_positionLine->setRecording(true); } @@ -1115,6 +1119,8 @@ void SongEditorWindow::stop() { m_editor->m_song->stop(); getGUI()->pianoRoll()->stopRecording(); + m_editor->m_timeLine->setRecording(false); + m_editor->m_positionLine->setRecording(false); } diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index 0e74ff445..9c7ae5178 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -24,7 +24,6 @@ #include "TimeLineWidget.h" - #include #include #include @@ -221,14 +220,16 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.fillRect(rightHandle, color); } + const QPixmap& marker = !m_isRecording ? m_posMarkerPixmap : m_recordingPosMarkerPixmap; + // Only draw the position marker if the position line is in view - if (markerX(m_pos) >= m_xOffset && markerX(m_pos) < width() - m_posMarkerPixmap.width() / 2) + if (m_isPlayheadVisible && markerX(m_pos) >= m_xOffset && markerX(m_pos) < width() - marker.width() / 2) { // Let the position marker extrude to the left p.setClipping(false); p.setOpacity(0.6); - p.drawPixmap(markerX(m_pos) - (m_posMarkerPixmap.width() / 2), - height() - m_posMarkerPixmap.height(), m_posMarkerPixmap); + p.drawPixmap(markerX(m_pos) - (marker.width() / 2), + height() - marker.height(), marker); } }