mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-03 09:29:30 +02:00
A convenience function in LabelTrackShifter eliminates repetition
This commit is contained in:
parent
3fcda6fc3c
commit
9b1901c971
@ -2153,6 +2153,18 @@ public:
|
|||||||
}
|
}
|
||||||
Track &GetTrack() const override { return *mpTrack; }
|
Track &GetTrack() const override { return *mpTrack; }
|
||||||
|
|
||||||
|
static inline size_t& GetIndex(TrackInterval &interval)
|
||||||
|
{
|
||||||
|
auto pExtra =
|
||||||
|
static_cast<LabelTrack::IntervalData*>( interval.Extra() );
|
||||||
|
return pExtra->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline size_t GetIndex(const TrackInterval &interval)
|
||||||
|
{
|
||||||
|
return GetIndex( const_cast<TrackInterval&>(interval) );
|
||||||
|
}
|
||||||
|
|
||||||
HitTestResult HitTest(
|
HitTestResult HitTest(
|
||||||
double time, const ViewInfo &viewInfo, HitTestParams *pParams ) override
|
double time, const ViewInfo &viewInfo, HitTestParams *pParams ) override
|
||||||
{
|
{
|
||||||
@ -2171,9 +2183,7 @@ public:
|
|||||||
iLabel = LabelTrackView::Get(*mpTrack).GetSelectedIndex(mProject);
|
iLabel = LabelTrackView::Get(*mpTrack).GetSelectedIndex(mProject);
|
||||||
if (iLabel != -1) {
|
if (iLabel != -1) {
|
||||||
UnfixIntervals([&](const auto &myInterval){
|
UnfixIntervals([&](const auto &myInterval){
|
||||||
auto pData =
|
return GetIndex( myInterval ) == iLabel;
|
||||||
static_cast<LabelTrack::IntervalData*>(myInterval.Extra());
|
|
||||||
return pData->index == iLabel;
|
|
||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2201,9 +2211,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto &labels = mpTrack->GetLabels();
|
auto &labels = mpTrack->GetLabels();
|
||||||
for ( auto &interval : MovingIntervals() ) {
|
for ( auto &interval : MovingIntervals() ) {
|
||||||
auto pExtra =
|
auto index = GetIndex( interval );
|
||||||
static_cast<LabelTrack::IntervalData*>( interval.Extra() );
|
|
||||||
auto index = pExtra->index;
|
|
||||||
auto labelStruct = labels[index];
|
auto labelStruct = labels[index];
|
||||||
labelStruct.selectedRegion.move(offset);
|
labelStruct.selectedRegion.move(offset);
|
||||||
mpTrack->SetLabel( index, labelStruct );
|
mpTrack->SetLabel( index, labelStruct );
|
||||||
@ -2222,9 +2230,14 @@ private:
|
|||||||
auto former = e.mFormerPosition;
|
auto former = e.mFormerPosition;
|
||||||
auto present = e.mPresentPosition;
|
auto present = e.mPresentPosition;
|
||||||
|
|
||||||
|
// Avoid signed-unsigned comparison below!
|
||||||
|
if (former < 0 || present < 0) {
|
||||||
|
wxASSERT(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto update = [=]( TrackInterval &interval ){
|
auto update = [=]( TrackInterval &interval ){
|
||||||
auto pExtra = static_cast<LabelTrack::IntervalData*>(interval.Extra());
|
auto &index = GetIndex( interval );
|
||||||
auto &index = pExtra->index;
|
|
||||||
if ( index == former )
|
if ( index == former )
|
||||||
index = present;
|
index = present;
|
||||||
else if ( former < index && index <= present )
|
else if ( former < index && index <= present )
|
||||||
|
Loading…
x
Reference in New Issue
Block a user