Skip to content

Commit

Permalink
Fix track handles dissapearing
Browse files Browse the repository at this point in the history
- let Qt handle resizing of Song Editor's scroll area
- don't redraw all clips when moving tracks or resizing the window
  • Loading branch information
allejok96 committed Apr 11, 2022
1 parent 80a6672 commit e3123e3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 35 deletions.
1 change: 0 additions & 1 deletion include/SongEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ class SongEditorWindow : public Editor

protected:
void resizeEvent( QResizeEvent * event ) override;
void changeEvent( QEvent * ) override;

protected slots:
void play() override;
Expand Down
2 changes: 0 additions & 2 deletions include/TrackContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ public slots:
protected:
static const int DEFAULT_PIXELS_PER_BAR = 16;

void resizeEvent( QResizeEvent * ) override;

TimePos m_currentPosition;


Expand Down
32 changes: 11 additions & 21 deletions src/gui/TrackContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,23 @@ TrackContainerView::TrackContainerView( TrackContainer * _tc ) :
m_tc->setHook( this );
//keeps the direction of the widget, undepended on the locale
setLayoutDirection( Qt::LeftToRight );

// The main layout - by default it only contains the scroll area,
// but SongEditor uses the layout to add a TimeLineWidget on top
QVBoxLayout * layout = new QVBoxLayout( this );
layout->setMargin( 0 );
layout->setSpacing( 0 );
layout->addWidget( m_scrollArea );

// The widget that will contain all TrackViews
QWidget * scrollContent = new QWidget;
m_scrollLayout = new QVBoxLayout( scrollContent );
m_scrollLayout->setMargin( 0 );
m_scrollLayout->setSpacing( 0 );
m_scrollLayout->setSizeConstraint( QLayout::SetMinAndMaxSize );

m_scrollArea->setWidget( scrollContent );
m_scrollArea->setWidgetResizable(true);

m_scrollArea->show();
m_rubberBand->hide();
Expand Down Expand Up @@ -126,7 +131,6 @@ TrackView * TrackContainerView::addTrackView( TrackView * _tv )
connect( this, SIGNAL( positionChanged( const TimePos & ) ),
_tv->getTrackContentWidget(),
SLOT( changePosition( const TimePos & ) ) );
realignTracks();
return( _tv );
}

Expand All @@ -143,7 +147,6 @@ void TrackContainerView::removeTrackView( TrackView * _tv )
disconnect( _tv );
m_scrollLayout->removeWidget( _tv );

realignTracks();
if( Engine::getSong() )
{
Engine::getSong()->setModified();
Expand Down Expand Up @@ -174,8 +177,6 @@ void TrackContainerView::moveTrackView( TrackView * trackView, int indexTo )
m_tc->m_tracks.remove( indexFrom );
m_tc->m_tracks.insert( indexTo, track );
m_trackViews.move( indexFrom, indexTo );

realignTracks();
}


Expand Down Expand Up @@ -224,17 +225,15 @@ void TrackContainerView::scrollToTrackView( TrackView * _tv )



/*! \brief Update all TrackViews
*
* Called when all clips on all tracks have to be redrawn (zoom change etc)
*/
void TrackContainerView::realignTracks()
{
m_scrollArea->widget()->setFixedWidth(width());
m_scrollArea->widget()->setFixedHeight(
m_scrollArea->widget()->minimumSizeHint().height());

for( trackViewList::iterator it = m_trackViews.begin();
it != m_trackViews.end(); ++it )
for (TrackView* trackView: m_trackViews)
{
( *it )->show();
( *it )->update();
trackView->update();
}
}

Expand Down Expand Up @@ -431,15 +430,6 @@ void TrackContainerView::dropEvent( QDropEvent * _de )



void TrackContainerView::resizeEvent( QResizeEvent * _re )
{
realignTracks();
QWidget::resizeEvent( _re );
}




RubberBand *TrackContainerView::rubberBand() const
{
return m_rubberBand;
Expand Down
1 change: 0 additions & 1 deletion src/gui/TrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,6 @@ void TrackView::mouseMoveEvent( QMouseEvent * me )
else if( m_action == ResizeTrack )
{
setFixedHeight( qMax<int>( me->y(), MINIMAL_TRACK_HEIGHT ) );
m_trackContainerView->realignTracks();
m_track->setHeight( height() );
}

Expand Down
10 changes: 0 additions & 10 deletions src/gui/editors/SongEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,6 @@ void SongEditor::wheelEvent( QWheelEvent * we )
// update timeline
m_song->m_playPos[Song::Mode_PlaySong].m_timeLine->
setPixelsPerBar( pixelsPerBar() );
// and make sure, all Clip's are resized and relocated
realignTracks();
}

// FIXME: Reconsider if determining orientation is necessary in Qt6.
Expand Down Expand Up @@ -1061,14 +1059,6 @@ void SongEditorWindow::resizeEvent(QResizeEvent *event)
}


void SongEditorWindow::changeEvent(QEvent *event)
{
QWidget::changeEvent(event);
if (event->type() == QEvent::WindowStateChange)
{
m_editor->realignTracks();
}
}


void SongEditorWindow::play()
Expand Down

0 comments on commit e3123e3

Please sign in to comment.