21#include "../../../../TrackPanelMouseEvent.h"
22#include "../../../../TrackArt.h"
23#include "../../../../TrackArtist.h"
24#include "../../../../TrackPanelDrawingContext.h"
31#include "../../../../ProjectWindows.h"
32#include "../../../../commands/AudacityCommand.h"
34#include "../../../ui/TextEditHelper.h"
35#include "../../../ui/SelectHandle.h"
40#include "../../../../ProjectSettings.h"
42#include "../../../../RefreshCode.h"
44#include "../../../../../images/Cursors.h"
45#include "../../../../HitTestResult.h"
46#include "../../../../TrackPanel.h"
49#include "../WaveTrackUtils.h"
73 S.StartMultiColumn(2, wxALIGN_CENTER);
84{
XO(
"Set Wave Clip Name") };
94 const std::shared_ptr<WaveTrack> pTrack)
124 static auto ibeamCursor =
127 XO(
"Click and drag to select text"),
152 , mClipNameFont{ wxFontInfo{} }
154 if (
auto trackList = pTrack->GetOwner())
158 if(
auto project = trackList->GetOwner())
162 viewInfo.selectedRegion.Subscribe(
171 std::vector<UIHandlePtr> results;
173 auto px = state.
state.m_x;
174 auto py = state.
state.m_y;
176 const auto rect = state.
rect;
178 auto track = std::static_pointer_cast<WaveTrack>(
FindTrack());
180 assert(track->IsLeader());
190 results.push_back(handle);
198 std::make_shared<WaveClipTitleEditHandle>(
204 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
206 const auto intervals = waveTrack->Intervals();
207 for(
auto it = intervals.begin(); it != intervals.end(); ++it)
218 std::make_shared<WaveTrackAffordanceHandle>(track, interval->GetClip(0))
227 const auto currentTool =
settings.GetTool();
251 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
252 const auto& zoomInfo = *artist->pZoomInfo;
254 wxDCClipper dcClipper(context.
dc, rect);
256 context.
dc.SetTextBackground(wxTransparentColor);
263 const auto intervals = waveTrack->Intervals();
264 for(
auto it = intervals.begin(); it != intervals.end(); ++it)
277 const auto highlight = selected || affordanceRect.Contains(px, py);
285 context.
dc, titleRect, interval->GetName(),
286 interval->GetStretchRatio());
290 context.
dc, titleRect, interval->GetName(),
291 interval->GetStretchRatio()))
303 return std::find(mVisibleIntervals.begin(),
304 mVisibleIntervals.end(),
305 it) != mVisibleIntervals.end();
310 bool useDialog{
false };
311 gPrefs->
Read(
wxT(
"/GUI/DialogForNameNewLabel"), &useDialog,
false);
320 auto oldName = interval->GetName();
323 if (result &&
Command.mName != oldName)
325 interval->SetName(
Command.mName);
327 XO(
"Clip Name Edit"));
359 auto pAffordance = view.GetAffordanceControls();
360 return std::dynamic_pointer_cast<WaveTrackAffordanceControls>(
364std::pair<WaveTrack*, ChannelGroup::IntervalIterator<WaveTrack::Interval>>
369 if (
auto pWaveTrack =
373 auto intervals = pWaveTrack->Intervals();
375 auto it = std::find_if(intervals.begin(), intervals.end(), [&](
const auto& interval)
377 return interval->Start() == viewInfo.selectedRegion.t0() &&
378 interval->End() == viewInfo.selectedRegion.t1();
381 if(it != intervals.end())
382 return { pWaveTrack, it };
408 auto interval = *result.second;
409 return interval !=
nullptr && !interval->StretchRatioEquals(1.0);
420 || !
mTextEditHelper->CaptureKey(event.GetKeyCode(), event.GetModifiers()))
429 auto keyCode =
event.GetKeyCode();
458 if (text != interval->GetName()) {
459 interval->SetName(text);
462 XO(
"Clip Name Edit"));
504 if (
auto trackList =
FindTrack()->GetOwner())
562 if (!affordanceRect.Contains(event.
event.GetPosition()))
568 if (event.
event.LeftDClick())
571 if (affordanceRect.Contains(event.
event.GetPosition()) &&
574 event.event.Skip(
false);
615 if (wxID_OK == dlg.ShowModal())
632 if (!interval || interval->StretchRatioEquals(1.0))
637 track->ApplyStretchRatio(
638 { { interval->GetPlayStartTime(), interval->GetPlayEndTime() } },
644 XO(
"Rendered time-stretched audio"),
XO(
"Render"));
651 auto helper = std::make_shared<TextEditHelper>(shared_from_this(), text,
mClipNameFont);
653 helper->SetTextSelectionColor(
theTheme.
Colour(clrClipNameTextSelection));
658 const wxRect &rect,
const wxPoint *pPosition,
AudacityProject *pProject)
659 -> std::vector<MenuItem>
678 pAffordance->StartEditSelectedClipName(
project);
694 pAffordance->StartEditSelectedClipSpeed(
project);
707 pAffordance->OnRenderClipStretching(
project);
716 Command( L
"RenameClip",
XXO(
"&Rename Clip..."),
718 wxT(
"Edit/Other/Clip")
722 Command( L
"ChangeClipSpeed",
XXO(
"Change &Speed..."),
724 wxT(
"Edit/Other/Clip")
728 Command( L
"RenderClipStretching",
XXO(
"Render Clip S&tretching"),
730 wxT(
"Edit/Other/Clip")
Toolkit-neutral facade for basic user interface services.
AttachedItem sAttachment3
AttachedItem sAttachment2
XXO("&Cut/Copy/Paste Toolbar")
audacity::BasicSettings * gPrefs
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
std::function< void(double)> ProgressReporter
static Settings & settings()
std::unique_ptr< wxCursor > MakeCursor(int WXUNUSED(CursorId), const char *const pXpm[36], int HotX, int HotY)
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
An AudacityException with no visible message.
std::vector< CommonTrackPanelCell::MenuItem > GetWaveClipMenuItems()
void PushClipSpeedChangedUndoState(AudacityProject &project, double speedInPercent)
Base class for command in Audacity.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
static ChannelView & Get(Channel &channel)
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
AudacityProject & project
std::shared_ptr< Track > FindTrack()
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
Generates classes whose instances register items at construction.
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< ChannelView > &pChannelView)
ComponentInterfaceSymbol GetSymbol() const override
static const ComponentInterfaceSymbol Symbol
void PopulateOrExchange(ShuttleGui &S) override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
static bool IsGoodEditKeyCode(int keyCode)
wxColour & Colour(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
static TrackPanel & Get(AudacityProject &project)
void RefreshTrack(Track *trk, bool refreshbacking=true)
Short-lived drawing and event-handling object associated with a TrackPanelCell.
static ViewInfo & Get(AudacityProject &project)
static bool ClipDetailsVisible(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
static bool HitTest(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
static UIHandlePtr HitAnywhere(std::weak_ptr< WaveClipAdjustBorderHandle > &holder, const std::shared_ptr< WaveTrack > &waveTrack, const AudacityProject *pProject, const TrackPanelMouseState &state)
WaveClipTitleEditHandle(const std::shared_ptr< TextEditHelper > &helper, const std::shared_ptr< WaveTrack > pTrack)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *project, wxWindow *) override
Result Click(const TrackPanelMouseEvent &event, AudacityProject *project) override
std::shared_ptr< TextEditHelper > mHelper
Result Cancel(AudacityProject *project) override
std::shared_ptr< WaveTrack > mpTrack
std::shared_ptr< const Channel > FindChannel() const override
~WaveClipTitleEditHandle()
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *project) override
double GetPlayStartTime() const
double GetPlayEndTime() const
bool OnTextCopy(AudacityProject &project)
void OnTextEditCancelled(AudacityProject *project) override
unsigned ExitTextEditing()
void OnTrackListEvent(const TrackListEvent &evt)
void OnTextContextMenu(AudacityProject *project, const wxPoint &position) override
std::weak_ptr< WaveClipAdjustBorderHandle > mClipBorderAdjustHandle
unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
std::vector< MenuItem > GetMenuItems(const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
Return a list of items for DoContextMenu() (empties for separators)
void OnTextEditFinished(AudacityProject *project, const wxString &text) override
unsigned LoseFocus(AudacityProject *project) override
bool IsIntervalVisible(const IntervalIterator &it) const noexcept
WaveTrackAffordanceControls(const std::shared_ptr< Track > &pTrack)
void OnSelectionChange(NotifyingSelectedRegionMessage)
bool OnTextSelect(AudacityProject &project)
std::vector< IntervalIterator > mVisibleIntervals
std::weak_ptr< WaveTrackAffordanceHandle > mAffordanceHandle
Observer::Subscription mSelectionChangeSubscription
std::shared_ptr< TextEditHelper > mTextEditHelper
IntervalIterator mFocusInterval
void StartEditSelectedClipName(AudacityProject &project)
std::shared_ptr< TextEditHelper > MakeTextEditHelper(const wxString &text)
bool StartEditClipName(AudacityProject &project, IntervalIterator it)
Starts in-place clip name editing or shows a Clip Name Edit dialog, depending on prefs.
void OnRenderClipStretching(AudacityProject &project)
std::weak_ptr< SelectHandle > mSelectHandle
unsigned KeyDown(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
unsigned OnAffordanceClick(const TrackPanelMouseEvent &event, AudacityProject *project)
Observer::Subscription mTrackListEventSubscription
IntervalIterator mEditedInterval
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
bool OnTextCut(AudacityProject &project)
IntervalIterator GetSelectedInterval() const
void OnTextModified(AudacityProject *project, const wxString &text) override
bool OnTextPaste(AudacityProject &project)
void StartEditSelectedClipSpeed(AudacityProject &project)
std::weak_ptr< WaveClipTitleEditHandle > mTitleEditHandle
unsigned Char(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
A Track that contains audio waveform data.
virtual bool Read(const wxString &key, bool *value) const =0
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Namespace containing an enum 'what to do on a refresh?'.
AUDACITY_DLL_API void DrawClipFolded(wxDC &dc, const wxRect &rect)
AUDACITY_DLL_API wxRect DrawClipAffordance(wxDC &dc, const wxRect &affordanceRect, bool highlight=false, bool selected=false)
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
AUDACITY_DLL_API bool DrawAudioClipTitle(wxDC &dc, const wxRect &titleRect, const wxString &title, double clipStretchRatio)
WAVE_TRACK_API void WithStretchRenderingProgress(std::function< void(const ProgressReporter &)> action, TranslatableString title=defaultStretchRenderingTitle, TranslatableString message=XO("Rendering Time-Stretched Audio"))
void SelectInterval(AudacityProject &project, const WaveTrack::Interval &interval)
void OnRenderClipStretching(const CommandContext &context)
const ReservedCommandFlag & StretchedClipIsSelectedFlag()
void OnChangeClipSpeed(const CommandContext &context)
const ReservedCommandFlag & SomeClipIsSelectedFlag()
void OnEditClipName(const CommandContext &context)
auto FindAffordance(WaveTrack &track)
std::pair< WaveTrack *, ChannelGroup::IntervalIterator< WaveTrack::Interval > > SelectedIntervalOfFocusedTrack(AudacityProject &project)
static wxRect GetClipRect(const ClipTimes &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect, bool *outShowSamples=nullptr)
Notification of changes in individual tracks of TrackList, or of TrackList's composition.
@ SELECTION_CHANGE
Posted when the set of selected tracks changes.