1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-21 22:12:58 +02:00

Bug2180: Type-to-create labels twice should work...

Bug began at 0750f62e88

Track::SetSelected is virtual, after all, but then LabelTrack informs
LabelTrackView of selection changes by events, so that LabelTrack remains
independent of LabelTrackView.

This might make much of the rest of the guily commit unnecessary (the resetting
of selected index to -1 only lazily), but it is harmless.
This commit is contained in:
Paul Licameli
2019-07-31 15:31:09 -04:00
parent 37eab87bff
commit e589ed8ecf
5 changed files with 36 additions and 3 deletions

View File

@@ -78,6 +78,8 @@ void LabelTrackView::BindTo( LabelTrack *pParent )
EVT_LABELTRACK_DELETION, &LabelTrackView::OnLabelDeleted, this );
pParent->Bind(
EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
pParent->Bind(
EVT_LABELTRACK_SELECTION, &LabelTrackView::OnSelectionChange, this );
}
void LabelTrackView::UnbindFrom( LabelTrack *pParent )
@@ -1912,6 +1914,16 @@ void LabelTrackView::OnLabelPermuted( LabelTrackEvent &e )
++ mSelIndex;
}
void LabelTrackView::OnSelectionChange( LabelTrackEvent &e )
{
e.Skip();
if ( e.mpTrack.lock() != FindTrack() )
return;
if ( !FindTrack()->GetSelected() )
mSelIndex = -1;
}
wxBitmap & LabelTrackView::GetGlyph( int i)
{
return theTheme.Bitmap( i + bmpLabelGlyph0);

View File

@@ -222,6 +222,7 @@ private:
void OnLabelAdded( LabelTrackEvent& );
void OnLabelDeleted( LabelTrackEvent& );
void OnLabelPermuted( LabelTrackEvent& );
void OnSelectionChange( LabelTrackEvent& );
std::shared_ptr<LabelTrack> FindLabelTrack();
std::shared_ptr<const LabelTrack> FindLabelTrack() const;