From a57265cf8dad3c341793e87177620b1531589941 Mon Sep 17 00:00:00 2001 From: Michael Fulghum <83775891+mrf7777@users.noreply.github.com> Date: Tue, 4 Oct 2022 00:43:23 -0500 Subject: [PATCH] Limit height of while position line to height of all tracks (#6509) * Position line height fits all tracks when line is moved or updated * Refactor track height calculation; create connection to update position line height --- include/TrackContainerView.h | 4 ++-- src/gui/editors/SongEditor.cpp | 7 +++++-- src/gui/editors/TrackContainerView.cpp | 16 +++++++++++++++- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/TrackContainerView.h b/include/TrackContainerView.h index 116fd68f9..444420d98 100644 --- a/include/TrackContainerView.h +++ b/include/TrackContainerView.h @@ -148,6 +148,7 @@ public: return "trackcontainerview"; } + unsigned int totalHeightOfTracks() const; RubberBand *rubberBand() const; @@ -206,10 +207,9 @@ private: RubberBand * m_rubberBand; - - signals: void positionChanged( const lmms::TimePos & _pos ); + void tracksRealigned(); } ; diff --git a/src/gui/editors/SongEditor.cpp b/src/gui/editors/SongEditor.cpp index 330216e43..5fb11ee32 100644 --- a/src/gui/editors/SongEditor.cpp +++ b/src/gui/editors/SongEditor.cpp @@ -98,6 +98,9 @@ SongEditor::SongEditor( Song * song ) : connect( m_timeLine, SIGNAL(selectionFinished()), this, SLOT(stopRubberBand())); + // when tracks realign, adjust height of position line + connect(this, &TrackContainerView::tracksRealigned, this, &SongEditor::updatePositionLine); + m_positionLine = new PositionLine(this); static_cast( layout() )->insertWidget( 1, m_timeLine ); @@ -820,7 +823,7 @@ void SongEditor::updatePosition( const TimePos & t ) m_positionLine->hide(); } - m_positionLine->setFixedHeight( height() ); + updatePositionLine(); } @@ -828,7 +831,7 @@ void SongEditor::updatePosition( const TimePos & t ) void SongEditor::updatePositionLine() { - m_positionLine->setFixedHeight( height() ); + m_positionLine->setFixedHeight(totalHeightOfTracks()); } diff --git a/src/gui/editors/TrackContainerView.cpp b/src/gui/editors/TrackContainerView.cpp index 966228ac8..351fe8295 100644 --- a/src/gui/editors/TrackContainerView.cpp +++ b/src/gui/editors/TrackContainerView.cpp @@ -263,6 +263,8 @@ void TrackContainerView::realignTracks() trackView->show(); trackView->update(); } + + emit tracksRealigned(); } @@ -487,7 +489,19 @@ void TrackContainerView::scrollArea::wheelEvent( QWheelEvent * _we ) } + + +unsigned int TrackContainerView::totalHeightOfTracks() const +{ + unsigned int heightSum = 0; + for (auto & trackView : m_trackViews) + { + heightSum += trackView->getTrack()->getHeight(); + } + return heightSum; +} + } // namespace gui -} // namespace lmms \ No newline at end of file +} // namespace lmms