16#include "../../../HitTestResult.h"
17#include "../../../LabelTrack.h"
20#include "../../../RefreshCode.h"
22#include "../../../TrackPanelMouseEvent.h"
24#include "../../../../images/Cursors.h"
26#include <wx/clipbrd.h>
29(
const std::shared_ptr<LabelTrack> &pLT,
int labelNum )
31 , mLabelNum{ labelNum }
37#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
44 static auto ibeamCursor =
47 XO(
"Click to edit label text"),
53(std::weak_ptr<LabelTextHandle> &holder,
54 const wxMouseState &state,
const std::shared_ptr<LabelTrack> &pLT)
58 if (!state.ControlDown() &&
61 auto result = std::make_shared<LabelTextHandle>( pLT, labelNum );
75 auto pTrack =
mpLT.lock();
83 if ( selIndex != -1 ) {
87 auto position = view.FindCursorPosition(selIndex, evt.m_x );
93 auto initial = view.GetInitialCursorPosition();
94 if (evt.ShiftDown()) {
98 const auto current = view.GetCurrentCursorPosition();
99 if ( abs( position - current ) > abs( position - initial ) )
108 view.SetTextSelection(selIndex, initial, position );
112 if (!view.IsTextSelected(project))
114 auto position = view.FindCursorPosition(selIndex, evt.m_x);
115 view.SetTextSelection(selIndex, position, position);
121#if defined(__WXGTK__) && (HAVE_GTK)
122 if (evt.MiddleDown()) {
127 view.ResetTextSelection();
128 double t = zoomInfo.PositionToTime(evt.m_x, r.x);
133#if defined(__WXGTK__) && (HAVE_GTK)
134 if (evt.MiddleDown()) {
136 wxTheClipboard->UsePrimarySelection(
true);
137 view.PasteSelectedText(project, newSel.t0(), newSel.t1());
138 wxTheClipboard->UsePrimarySelection(
false);
152 auto pLT =
mpLT.lock();
158 const wxMouseEvent &
event = evt.
event;
169 auto pTrack =
mpLT.lock();
181#if defined (__WXGTK__) && defined (HAVE_GTK)
184 if (mInitialCursorPos != mCurrentCursorPos) {
185 wxTheClipboard->UsePrimarySelection(
true);
187 wxTheClipboard->UsePrimarySelection(
false);
197 auto index = view.GetTextEditIndex(project);
200 view.SetCurrentCursorPosition(view.FindCursorPosition(index, evt.m_x ));
206 auto index = view.GetTextEditIndex(project);
212 view.ShowContextMenu( project );
222 auto &project = *pProject;
226 const wxMouseEvent &
event = evt.
event;
232 if (event.LeftIsDown()) {
238 if (pLT && (pView->GetTextEditIndex( project ) != -1) &&
240 pLT->GetLabel(pView->GetTextEditIndex( project )),
269 const wxMouseEvent &
event = evt.
event;
std::shared_ptr< UIHandle > UIHandlePtr
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)
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
Result Cancel(AudacityProject *pProject) override
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
Result Cancel(AudacityProject *pProject) override
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void HandleTextDragRelease(AudacityProject &project, const wxMouseEvent &evt)
virtual ~LabelTextHandle()
static UIHandlePtr HitTest(std::weak_ptr< LabelTextHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT)
void HandleTextClick(AudacityProject &project, const wxMouseEvent &evt)
bool mRightDragging
flag to tell if it's a valid dragging
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void Enter(bool forward, AudacityProject *) override
LabelTextHandle(const std::shared_ptr< LabelTrack > &pLT, int labelNum)
bool HandlesRightClick() override
Whether the handle has any special right-button handling.
static HitTestPreview HitPreview()
std::weak_ptr< LabelTrack > mpLT
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
static LabelTrackView & Get(LabelTrack &)
static bool OverTextBox(const LabelStruct *pLabel, int x, int y)
static int OverATextBox(const LabelTrack &track, int xx, int yy)
Defines a selected portion of a project.
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
static TrackList & Get(AudacityProject &project)
static ViewInfo & Get(AudacityProject &project)
Namespace containing an enum 'what to do on a refresh?'.