1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-07-29 23:19:28 +02:00

No more LabelTrack::HasSelection...

... eliminating the last dependency of LabelTrack.cpp on LabelTrackView.h
This commit is contained in:
Paul Licameli 2019-06-20 09:16:41 -04:00
parent f2869597b6
commit 5240c42cb6
4 changed files with 4 additions and 14 deletions

View File

@ -33,8 +33,6 @@ for drawing different aspects of the label and its text box.
#include "Experimental.h" #include "Experimental.h"
#include "tracks/labeltrack/ui/LabelTrackView.h"
#include <stdio.h> #include <stdio.h>
#include <algorithm> #include <algorithm>
#include <limits.h> #include <limits.h>
@ -475,12 +473,6 @@ auto LabelStruct::RegionRelation(
} }
} }
bool LabelTrack::HasSelection() const
{
const auto selIndex = LabelTrackView::Get( *this ).GetSelectedIndex();
return (selIndex >= 0 && selIndex < (int)mLabels.size());
}
/// Export labels including label start and end-times. /// Export labels including label start and end-times.
void LabelTrack::Export(wxTextFile & f) const void LabelTrack::Export(wxTextFile & f) const
{ {

View File

@ -127,9 +127,6 @@ public:
void Import(wxTextFile & f); void Import(wxTextFile & f);
void Export(wxTextFile & f) const; void Export(wxTextFile & f) const;
// Whether any label box is selected -- not, whether the track is selected.
bool HasSelection() const;
int GetNumLabels() const; int GetNumLabels() const;
const LabelStruct *GetLabel(int index) const; const LabelStruct *GetLabel(int index) const;
const LabelArray &GetLabels() const { return mLabels; } const LabelArray &GetLabels() const { return mLabels; }

View File

@ -47,7 +47,7 @@ bool DoPasteText(AudacityProject &project)
for (auto pLabelTrack : tracks.Any<LabelTrack>()) for (auto pLabelTrack : tracks.Any<LabelTrack>())
{ {
// Does this track have an active label? // Does this track have an active label?
if (pLabelTrack->HasSelection()) { if (LabelTrackView::Get( *pLabelTrack ).HasSelection()) {
// Yes, so try pasting into it // Yes, so try pasting into it
auto &view = LabelTrackView::Get( *pLabelTrack ); auto &view = LabelTrackView::Get( *pLabelTrack );

View File

@ -333,9 +333,10 @@ bool LabelGlyphHandle::HandleGlyphDragRelease
MayAdjustLabel( hit, hit.mMouseOverLabelRight, +1, bAllowSwapping, fNewX ); MayAdjustLabel( hit, hit.mMouseOverLabelRight, +1, bAllowSwapping, fNewX );
} }
if( pTrack->HasSelection() ) const auto &view = LabelTrackView::Get( *pTrack );
if( view.HasSelection() )
{ {
auto selIndex = LabelTrackView::Get( *pTrack ).GetSelectedIndex(); auto selIndex = view.GetSelectedIndex();
//Set the selection region to be equal to //Set the selection region to be equal to
//the NEW size of the label. //the NEW size of the label.
*newSel = mLabels[ selIndex ].selectedRegion; *newSel = mLabels[ selIndex ].selectedRegion;