From a0648142f507351ac731fbeb0c649642d33cee06 Mon Sep 17 00:00:00 2001 From: Dmitry Vedenko Date: Mon, 25 Sep 2023 17:30:59 +0300 Subject: [PATCH] Use a different predicate for the "Render clip stretching" menu --- .../ui/WaveTrackAffordanceControls.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp index 71c44157afa2..5e0f7325c410 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackAffordanceControls.cpp @@ -387,6 +387,21 @@ const ReservedCommandFlag &SomeClipIsSelectedFlag() return flag; } +const ReservedCommandFlag &StretchedClipIsSelectedFlag() +{ + static ReservedCommandFlag flag{ + [](const AudacityProject &project){ + // const_cast isn't pretty but not harmful in this case + auto result = SelectedIntervalOfFocusedTrack( + const_cast(project)); + + auto interval = *result.second; + return interval != nullptr && !interval->StretchRatioEquals(1.0); + } + }; + return flag; +} + } unsigned WaveTrackAffordanceControls::CaptureKey(wxKeyEvent& event, ViewInfo& viewInfo, wxWindow* pParent, AudacityProject* project) @@ -703,6 +718,6 @@ AttachedItem sAttachment2{ wxT("Edit/Other/Clip"), AttachedItem sAttachment3{ wxT("Edit/Other/Clip"), Command( L"RenderClipStretching", XXO("Render Clip Stretching"), - OnRenderClipStretching, SomeClipIsSelectedFlag()) + OnRenderClipStretching, StretchedClipIsSelectedFlag()) }; }