17#include "../../../../commands/CommandContext.h"
18#include "../../../../commands/CommandFlag.h"
19#include "../../../../commands/CommandFunctors.h"
20#include "../../../../commands/CommandManager.h"
21#include "../../../../TrackPanelMouseEvent.h"
22#include "../../../../TrackArt.h"
23#include "../../../../TrackArtist.h"
24#include "../../../../TrackPanelDrawingContext.h"
25#include "../../../../TrackPanelResizeHandle.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"
47#include "../../../../TrackPanelAx.h"
49#include "../WaveTrackUtils.h"
68 S.StartMultiColumn(2, wxALIGN_CENTER);
79{
XO(
"Set Wave Clip Name") };
111 static auto ibeamCursor =
114 XO(
"Click and drag to select text"),
140 if (
auto trackList = pTrack->GetOwner())
144 if(
auto project = trackList->GetOwner())
148 viewInfo.selectedRegion.Subscribe(
157 std::vector<UIHandlePtr> results;
159 auto px = state.
state.m_x;
160 auto py = state.
state.m_y;
162 const auto rect = state.
rect;
164 auto track = std::static_pointer_cast<WaveTrack>(
FindTrack());
174 results.push_back(handle);
177 auto trackList = track->GetOwner();
180 && !track->IsLeader())
184 auto prev = std::prev(trackList->Find(track.get()));
188 std::make_shared<TrackPanelResizeHandle>((*prev)->shared_from_this(), py)
204 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
206 for (
const auto& clip : waveTrack->GetClips())
208 if (clip == editClipLock)
216 std::make_shared<WaveTrackAffordanceHandle>(track, clip)
225 const auto currentTool =
settings.GetTool();
249 const auto waveTrack = std::static_pointer_cast<WaveTrack>(track->SubstitutePendingChangedTrack());
250 const auto& zoomInfo = *artist->pZoomInfo;
252 wxDCClipper dcClipper(context.
dc, rect);
254 context.
dc.SetTextBackground(wxTransparentColor);
261 for (
const auto& clip : waveTrack->GetClips())
273 const auto highlight = selected || affordanceRect.Contains(px, py);
293 return std::find(mLastVisibleClips.begin(),
294 mLastVisibleClips.end(),
295 &clip) != mLastVisibleClips.end();
300 bool useDialog{
false };
301 gPrefs->Read(
wxT(
"/GUI/DialogForNameNewLabel"), &useDialog,
false);
306 auto oldName = clip->GetName();
309 if (result &&
Command.mName != oldName)
313 XO(
"Clip Name Edit"));
335 return handle->Clicked() ?
mFocusClip : std::weak_ptr<WaveClip>();
345 auto pAffordance = view.GetAffordanceControls();
346 return std::dynamic_pointer_cast<WaveTrackAffordanceControls>(
350std::pair<WaveTrack *, std::shared_ptr<WaveClip>>
355 if (
auto pWaveTrack =
360 auto &clips = pChannel->GetClips();
361 auto begin = clips.begin(),
end = clips.end(),
364 return { pChannel, *iter };
368 return {
nullptr,
nullptr };
390 || !
mTextEditHelper->CaptureKey(event.GetKeyCode(), event.GetModifiers()))
399 auto keyCode =
event.GetKeyCode();
403 if (!
mTextEditHelper->OnKeyDown(keyCode, event.GetModifiers(), project)
428 if (text != lock->GetName()) {
432 XO(
"Clip Name Edit"));
474 if (
auto trackList =
FindTrack()->GetOwner())
532 if (!affordanceRect.Contains(event.
event.GetPosition()))
538 if (event.
event.LeftDClick())
541 if (affordanceRect.Contains(event.
event.GetPosition()) &&
544 event.event.Skip(
false);
555 if(track ==
nullptr || track !=
FindTrack().get() || clip ==
nullptr)
562 auto helper = std::make_shared<TextEditHelper>(shared_from_this(), text,
mClipNameFont);
564 helper->SetTextSelectionColor(
theTheme.
Colour(clrClipNameTextSelection));
576 auto &project = context.
project;
582 pAffordance->StartEditSelectedClipName(project);
594 Command( L
"RenameClip",
XXO(
"Rename Clip..."),
XXO("&Cut/Copy/Paste Toolbar")
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 ...
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)
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...
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)
static ProjectHistory & Get(AudacityProject &project)
static ProjectSettings & Get(AudacityProject &project)
static UIHandlePtr HitTest(std::weak_ptr< SelectHandle > &holder, const TrackPanelMouseState &state, const AudacityProject *pProject, const std::shared_ptr< TrackView > &pTrackView)
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 auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
static TrackPanel & Get(AudacityProject &project)
void RefreshTrack(Track *trk, bool refreshbacking=true)
static TrackView & Get(Track &)
Short-lived drawing and event-handling object associated with a TrackPanelCell.
static ViewInfo & Get(AudacityProject &project)
This allows multiple clips to be a part of one WaveTrack.
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
~WaveClipTitleEditHandle()
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *project) override
WaveClipTitleEditHandle(const std::shared_ptr< TextEditHelper > &helper)
static UIHandlePtr HitAnywhere(std::weak_ptr< WaveClipTrimHandle > &holder, const std::shared_ptr< WaveTrack > &waveTrack, const AudacityProject *pProject, const TrackPanelMouseState &state)
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< TrackPanelResizeHandle > mResizeHandle
unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
std::weak_ptr< WaveClipTrimHandle > mClipTrimHandle
bool StartEditClipName(AudacityProject &project, const std::shared_ptr< WaveClip > &clip)
Starts in-place clip name editing or shows a Clip Name Edit dialog, depending on prefs.
void OnTextEditFinished(AudacityProject *project, const wxString &text) override
bool IsClipNameVisible(const WaveClip &clip) const noexcept
unsigned LoseFocus(AudacityProject *project) override
WaveTrackAffordanceControls(const std::shared_ptr< Track > &pTrack)
void OnSelectionChange(NotifyingSelectedRegionMessage)
bool OnTextSelect(AudacityProject &project)
std::weak_ptr< WaveTrackAffordanceHandle > mAffordanceHandle
Observer::Subscription mSelectionChangeSubscription
std::shared_ptr< TextEditHelper > mTextEditHelper
std::vector< const WaveClip * > mLastVisibleClips
void StartEditSelectedClipName(AudacityProject &project)
std::shared_ptr< TextEditHelper > MakeTextEditHelper(const wxString &text)
std::weak_ptr< SelectHandle > mSelectHandle
unsigned KeyDown(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
std::weak_ptr< WaveClip > GetSelectedClip() const
std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject) override
unsigned OnAffordanceClick(const TrackPanelMouseEvent &event, AudacityProject *project)
Observer::Subscription mTrackListEventSubscription
std::weak_ptr< WaveClip > mFocusClip
void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
bool OnTextCut(AudacityProject &project)
void OnTextModified(AudacityProject *project, const wxString &text) override
bool OnTextPaste(AudacityProject &project)
std::weak_ptr< WaveClip > mEditedClip
std::weak_ptr< WaveClipTitleEditHandle > mTitleEditHandle
unsigned Char(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
A Track that contains audio waveform data.
static bool HitTest(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &rect, const wxPoint &pos)
static bool ClipDetailsVisible(const WaveClip &clip, const ZoomInfo &zoomInfo, const wxRect &viewRect)
static constexpr int kChannelSeparatorThickness
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
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 DrawClipTitle(wxDC &dc, const wxRect &titleRect, const wxString &title)
Iter SelectedClip(const ViewInfo &viewInfo, Iter begin, Iter end)
std::pair< WaveTrack *, std::shared_ptr< WaveClip > > SelectedClipOfFocusedTrack(AudacityProject &project)
const ReservedCommandFlag & SomeClipIsSelectedFlag()
void OnEditClipName(const CommandContext &context)
auto FindAffordance(WaveTrack &track)
static wxRect GetClipRect(const WaveClip &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.