mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
Bug2180: Type-to-create labels twice should work...
Bug began at 0750f62e88ee96cd4804c19ba54e3ac1d2ff1b73 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:
parent
37eab87bff
commit
e589ed8ecf
@ -49,6 +49,7 @@ for drawing different aspects of the label and its text box.
|
|||||||
wxDEFINE_EVENT(EVT_LABELTRACK_ADDITION, LabelTrackEvent);
|
wxDEFINE_EVENT(EVT_LABELTRACK_ADDITION, LabelTrackEvent);
|
||||||
wxDEFINE_EVENT(EVT_LABELTRACK_DELETION, LabelTrackEvent);
|
wxDEFINE_EVENT(EVT_LABELTRACK_DELETION, LabelTrackEvent);
|
||||||
wxDEFINE_EVENT(EVT_LABELTRACK_PERMUTED, LabelTrackEvent);
|
wxDEFINE_EVENT(EVT_LABELTRACK_PERMUTED, LabelTrackEvent);
|
||||||
|
wxDEFINE_EVENT(EVT_LABELTRACK_SELECTION, LabelTrackEvent);
|
||||||
|
|
||||||
static ProjectFileIORegistry::Entry registerFactory{
|
static ProjectFileIORegistry::Entry registerFactory{
|
||||||
wxT( "labeltrack" ),
|
wxT( "labeltrack" ),
|
||||||
@ -249,6 +250,18 @@ LabelStruct::LabelStruct(const SelectedRegion ®ion,
|
|||||||
y = 0;
|
y = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabelTrack::SetSelected( bool s )
|
||||||
|
{
|
||||||
|
bool selected = GetSelected();
|
||||||
|
Track::SetSelected( s );
|
||||||
|
if ( selected != GetSelected() ) {
|
||||||
|
LabelTrackEvent evt{
|
||||||
|
EVT_LABELTRACK_SELECTION, SharedPointer<LabelTrack>(), {}, -1, -1
|
||||||
|
};
|
||||||
|
ProcessEvent( evt );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
double LabelTrack::GetOffset() const
|
double LabelTrack::GetOffset() const
|
||||||
{
|
{
|
||||||
return mOffset;
|
return mOffset;
|
||||||
|
@ -97,6 +97,8 @@ class AUDACITY_DLL_API LabelTrack final
|
|||||||
|
|
||||||
void SetOffset(double dOffset) override;
|
void SetOffset(double dOffset) override;
|
||||||
|
|
||||||
|
void SetSelected(bool s) override;
|
||||||
|
|
||||||
double GetOffset() const override;
|
double GetOffset() const override;
|
||||||
double GetStartTime() const override;
|
double GetStartTime() const override;
|
||||||
double GetEndTime() const override;
|
double GetEndTime() const override;
|
||||||
@ -192,12 +194,13 @@ struct LabelTrackEvent : TrackListEvent
|
|||||||
// wxWidgets will own the event object
|
// wxWidgets will own the event object
|
||||||
return safenew LabelTrackEvent(*this); }
|
return safenew LabelTrackEvent(*this); }
|
||||||
|
|
||||||
|
// invalid for selection events
|
||||||
wxString mTitle;
|
wxString mTitle;
|
||||||
|
|
||||||
// invalid for addition event
|
// invalid for addition and selection events
|
||||||
int mFormerPosition{ -1 };
|
int mFormerPosition{ -1 };
|
||||||
|
|
||||||
// invalid for deletion event
|
// invalid for deletion and selection events
|
||||||
int mPresentPosition{ -1 };
|
int mPresentPosition{ -1 };
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -212,4 +215,8 @@ wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
|||||||
// Posted when a label is repositioned in the sequence of labels.
|
// Posted when a label is repositioned in the sequence of labels.
|
||||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||||
EVT_LABELTRACK_PERMUTED, LabelTrackEvent);
|
EVT_LABELTRACK_PERMUTED, LabelTrackEvent);
|
||||||
|
|
||||||
|
// Posted when the track is selected or unselected.
|
||||||
|
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||||
|
EVT_LABELTRACK_SELECTION, LabelTrackEvent);
|
||||||
#endif
|
#endif
|
||||||
|
@ -341,7 +341,7 @@ private:
|
|||||||
|
|
||||||
bool GetSelected() const { return mSelected; }
|
bool GetSelected() const { return mSelected; }
|
||||||
|
|
||||||
void SetSelected(bool s);
|
virtual void SetSelected(bool s);
|
||||||
|
|
||||||
// The argument tells whether the last undo history state should be
|
// The argument tells whether the last undo history state should be
|
||||||
// updated for the appearance change
|
// updated for the appearance change
|
||||||
|
@ -78,6 +78,8 @@ void LabelTrackView::BindTo( LabelTrack *pParent )
|
|||||||
EVT_LABELTRACK_DELETION, &LabelTrackView::OnLabelDeleted, this );
|
EVT_LABELTRACK_DELETION, &LabelTrackView::OnLabelDeleted, this );
|
||||||
pParent->Bind(
|
pParent->Bind(
|
||||||
EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
|
EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
|
||||||
|
pParent->Bind(
|
||||||
|
EVT_LABELTRACK_SELECTION, &LabelTrackView::OnSelectionChange, this );
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTrackView::UnbindFrom( LabelTrack *pParent )
|
void LabelTrackView::UnbindFrom( LabelTrack *pParent )
|
||||||
@ -1912,6 +1914,16 @@ void LabelTrackView::OnLabelPermuted( LabelTrackEvent &e )
|
|||||||
++ mSelIndex;
|
++ mSelIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LabelTrackView::OnSelectionChange( LabelTrackEvent &e )
|
||||||
|
{
|
||||||
|
e.Skip();
|
||||||
|
if ( e.mpTrack.lock() != FindTrack() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( !FindTrack()->GetSelected() )
|
||||||
|
mSelIndex = -1;
|
||||||
|
}
|
||||||
|
|
||||||
wxBitmap & LabelTrackView::GetGlyph( int i)
|
wxBitmap & LabelTrackView::GetGlyph( int i)
|
||||||
{
|
{
|
||||||
return theTheme.Bitmap( i + bmpLabelGlyph0);
|
return theTheme.Bitmap( i + bmpLabelGlyph0);
|
||||||
|
@ -222,6 +222,7 @@ private:
|
|||||||
void OnLabelAdded( LabelTrackEvent& );
|
void OnLabelAdded( LabelTrackEvent& );
|
||||||
void OnLabelDeleted( LabelTrackEvent& );
|
void OnLabelDeleted( LabelTrackEvent& );
|
||||||
void OnLabelPermuted( LabelTrackEvent& );
|
void OnLabelPermuted( LabelTrackEvent& );
|
||||||
|
void OnSelectionChange( LabelTrackEvent& );
|
||||||
|
|
||||||
std::shared_ptr<LabelTrack> FindLabelTrack();
|
std::shared_ptr<LabelTrack> FindLabelTrack();
|
||||||
std::shared_ptr<const LabelTrack> FindLabelTrack() const;
|
std::shared_ptr<const LabelTrack> FindLabelTrack() const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user