mirror of
https://github.com/cookiengineer/audacity
synced 2025-11-21 16:37:12 +01:00
Addition, deletion, sort of Labels communicated by events...
... and LabelTrack listens to its own events, to update certain state. This is roundabout for now, but that state is view-related and will move into another class.
This commit is contained in:
@@ -31,6 +31,7 @@ class DirManager;
|
||||
class TimeWarper;
|
||||
class ZoomInfo;
|
||||
|
||||
class LabelTrackEvent;
|
||||
|
||||
struct LabelTrackHit;
|
||||
struct TrackPanelDrawingContext;
|
||||
@@ -102,7 +103,9 @@ const int NUM_GLYPH_CONFIGS = 3;
|
||||
const int NUM_GLYPH_HIGHLIGHTS = 4;
|
||||
const int MAX_NUM_ROWS =80;
|
||||
|
||||
class AUDACITY_DLL_API LabelTrack final : public Track
|
||||
class AUDACITY_DLL_API LabelTrack final
|
||||
: public Track
|
||||
, public wxEvtHandler
|
||||
{
|
||||
friend class LabelTrackView;
|
||||
friend class LabelStruct;
|
||||
@@ -253,7 +256,8 @@ public:
|
||||
int FindPrevLabel(const SelectedRegion& currentSelection);
|
||||
|
||||
public:
|
||||
void SortLabels(LabelTrackHit *pHit = nullptr);
|
||||
void SortLabels();
|
||||
|
||||
private:
|
||||
TrackKind GetKind() const override { return TrackKind::Label; }
|
||||
|
||||
@@ -296,6 +300,10 @@ private:
|
||||
void calculateFontHeight(wxDC & dc) const;
|
||||
void RemoveSelectedText();
|
||||
|
||||
void OnLabelAdded( LabelTrackEvent& );
|
||||
void OnLabelDeleted( LabelTrackEvent& );
|
||||
void OnLabelPermuted( LabelTrackEvent& );
|
||||
|
||||
static wxFont msFont;
|
||||
|
||||
protected:
|
||||
@@ -303,4 +311,44 @@ protected:
|
||||
std::shared_ptr<TrackControls> DoGetControls() override;
|
||||
};
|
||||
|
||||
struct LabelTrackEvent : TrackListEvent
|
||||
{
|
||||
explicit
|
||||
LabelTrackEvent(
|
||||
wxEventType commandType, const std::shared_ptr<LabelTrack> &pTrack,
|
||||
const wxString &title,
|
||||
int formerPosition,
|
||||
int presentPosition
|
||||
)
|
||||
: TrackListEvent{ commandType, pTrack }
|
||||
, mTitle{ title }
|
||||
, mFormerPosition{ formerPosition }
|
||||
, mPresentPosition{ presentPosition }
|
||||
{}
|
||||
|
||||
LabelTrackEvent( const LabelTrackEvent& ) = default;
|
||||
wxEvent *Clone() const override {
|
||||
// wxWidgets will own the event object
|
||||
return safenew LabelTrackEvent(*this); }
|
||||
|
||||
wxString mTitle;
|
||||
|
||||
// invalid for addition event
|
||||
int mFormerPosition{ -1 };
|
||||
|
||||
// invalid for deletion event
|
||||
int mPresentPosition{ -1 };
|
||||
};
|
||||
|
||||
// Posted when a label is added.
|
||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||
EVT_LABELTRACK_ADDITION, LabelTrackEvent);
|
||||
|
||||
// Posted when a label is deleted.
|
||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||
EVT_LABELTRACK_DELETION, LabelTrackEvent);
|
||||
|
||||
// Posted when a label is repositioned in the sequence of labels.
|
||||
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
|
||||
EVT_LABELTRACK_PERMUTED, LabelTrackEvent);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user