mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-02 17:09:26 +02:00
Move declarations again, to LabelTextHandle; remove a friend
This commit is contained in:
parent
bbc465920b
commit
c9fa8424ce
@ -279,7 +279,6 @@ void LabelTrackView::ResetFlags()
|
|||||||
{
|
{
|
||||||
mInitialCursorPos = 1;
|
mInitialCursorPos = 1;
|
||||||
mCurrentCursorPos = 1;
|
mCurrentCursorPos = 1;
|
||||||
mRightDragging = false;
|
|
||||||
mDrawCursor = false;
|
mDrawCursor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -288,7 +287,6 @@ void LabelTrackView::RestoreFlags( const Flags& flags )
|
|||||||
mInitialCursorPos = flags.mInitialCursorPos;
|
mInitialCursorPos = flags.mInitialCursorPos;
|
||||||
mCurrentCursorPos = flags.mCurrentCursorPos;
|
mCurrentCursorPos = flags.mCurrentCursorPos;
|
||||||
mSelIndex = flags.mSelIndex;
|
mSelIndex = flags.mSelIndex;
|
||||||
mRightDragging = flags.mRightDragging;
|
|
||||||
mDrawCursor = flags.mDrawCursor;
|
mDrawCursor = flags.mDrawCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1663,8 +1661,13 @@ bool LabelGlyphHandle::HandleGlyphDragRelease
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTrackView::HandleTextDragRelease(const wxMouseEvent & evt)
|
void LabelTextHandle::HandleTextDragRelease(const wxMouseEvent & evt)
|
||||||
{
|
{
|
||||||
|
auto pTrack = mpLT.lock();
|
||||||
|
if (!pTrack)
|
||||||
|
return;
|
||||||
|
auto &view = LabelTrackView::Get( *pTrack );
|
||||||
|
|
||||||
if(evt.LeftUp())
|
if(evt.LeftUp())
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
@ -1690,19 +1693,20 @@ void LabelTrackView::HandleTextDragRelease(const wxMouseEvent & evt)
|
|||||||
{
|
{
|
||||||
if (!mRightDragging)
|
if (!mRightDragging)
|
||||||
// Update drag end
|
// Update drag end
|
||||||
SetCurrentCursorPosition(FindCursorPosition(evt.m_x));
|
view.SetCurrentCursorPosition(
|
||||||
|
view.FindCursorPosition( evt.m_x ) );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt.RightUp()) {
|
if (evt.RightUp()) {
|
||||||
const auto pTrack = FindLabelTrack();
|
const auto selIndex = view.GetSelectedIndex();
|
||||||
if (HasSelection() &&
|
if ( selIndex != -1 &&
|
||||||
OverTextBox(
|
LabelTrackView::OverTextBox(
|
||||||
pTrack->GetLabel(mSelIndex), evt.m_x, evt.m_y)) {
|
pTrack->GetLabel( selIndex ), evt.m_x, evt.m_y ) ) {
|
||||||
// popup menu for editing
|
// popup menu for editing
|
||||||
// TODO: handle context menus via CellularPanel?
|
// TODO: handle context menus via CellularPanel?
|
||||||
ShowContextMenu();
|
view.ShowContextMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1767,47 +1771,50 @@ void LabelGlyphHandle::HandleGlyphClick
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTrackView::HandleTextClick(const wxMouseEvent & evt,
|
void LabelTextHandle::HandleTextClick(const wxMouseEvent & evt,
|
||||||
const wxRect & r, const ZoomInfo &zoomInfo,
|
const wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
SelectedRegion *newSel)
|
SelectedRegion *newSel)
|
||||||
{
|
{
|
||||||
|
auto pTrack = mpLT.lock();
|
||||||
|
if (!pTrack)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto &view = LabelTrackView::Get( *pTrack );
|
||||||
static_cast<void>(r);//compiler food.
|
static_cast<void>(r);//compiler food.
|
||||||
static_cast<void>(zoomInfo);//compiler food.
|
static_cast<void>(zoomInfo);//compiler food.
|
||||||
if (evt.ButtonDown())
|
if (evt.ButtonDown())
|
||||||
{
|
{
|
||||||
|
const auto selIndex = LabelTrackView::OverATextBox( *pTrack, evt.m_x, evt.m_y );
|
||||||
const auto pTrack = FindLabelTrack();
|
view.SetSelectedIndex( selIndex );
|
||||||
mSelIndex = OverATextBox( *pTrack, evt.m_x, evt.m_y );
|
if ( selIndex != -1 ) {
|
||||||
if (mSelIndex != -1) {
|
|
||||||
const auto &mLabels = pTrack->GetLabels();
|
const auto &mLabels = pTrack->GetLabels();
|
||||||
const auto &labelStruct = mLabels[mSelIndex];
|
const auto &labelStruct = mLabels[ selIndex ];
|
||||||
*newSel = labelStruct.selectedRegion;
|
*newSel = labelStruct.selectedRegion;
|
||||||
|
|
||||||
if (evt.LeftDown()) {
|
if (evt.LeftDown()) {
|
||||||
// Find the NEW drag end
|
// Find the NEW drag end
|
||||||
auto position = FindCursorPosition(evt.m_x);
|
auto position = view.FindCursorPosition( evt.m_x );
|
||||||
|
|
||||||
// Anchor shift-drag at the farther end of the previous highlight
|
// Anchor shift-drag at the farther end of the previous highlight
|
||||||
// that is farther from the click, on Mac, for consistency with
|
// that is farther from the click, on Mac, for consistency with
|
||||||
// its text editors, but on the others, re-use the previous
|
// its text editors, but on the others, re-use the previous
|
||||||
// anchor.
|
// anchor.
|
||||||
|
auto initial = view.GetInitialCursorPosition();
|
||||||
if (evt.ShiftDown()) {
|
if (evt.ShiftDown()) {
|
||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
// Set the drag anchor at the end of the previous selection
|
// Set the drag anchor at the end of the previous selection
|
||||||
// that is farther from the NEW drag end
|
// that is farther from the NEW drag end
|
||||||
if (abs(position - mCurrentCursorPos) >
|
const auto current = view.GetCurrentCursorPosition();
|
||||||
abs(position - mInitialCursorPos))
|
if ( abs( position - current ) > abs( position - initial ) )
|
||||||
mInitialCursorPos = mCurrentCursorPos;
|
initial = current;
|
||||||
#else
|
#else
|
||||||
// mInitialCursorPos remains as before
|
// initial position remains as before
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
mInitialCursorPos = position;
|
initial = position;
|
||||||
|
|
||||||
mCurrentCursorPos = position;
|
view.SetTextHighlight( initial, position );
|
||||||
|
|
||||||
mDrawCursor = true;
|
|
||||||
mRightDragging = false;
|
mRightDragging = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1820,8 +1827,8 @@ void LabelTrackView::HandleTextClick(const wxMouseEvent & evt,
|
|||||||
// Check for a click outside of the selected label's text box; in this
|
// Check for a click outside of the selected label's text box; in this
|
||||||
// case PasteSelectedText() will start a NEW label at the click
|
// case PasteSelectedText() will start a NEW label at the click
|
||||||
// location
|
// location
|
||||||
if (!OverTextBox(&labelStruct, evt.m_x, evt.m_y))
|
if (!LabelTrackView::OverTextBox(&labelStruct, evt.m_x, evt.m_y))
|
||||||
mSelIndex = -1;
|
view.SetSelectedIndex( -1 );
|
||||||
double t = zoomInfo.PositionToTime(evt.m_x, r.x);
|
double t = zoomInfo.PositionToTime(evt.m_x, r.x);
|
||||||
*newSel = SelectedRegion(t, t);
|
*newSel = SelectedRegion(t, t);
|
||||||
}
|
}
|
||||||
@ -1831,7 +1838,7 @@ void LabelTrackView::HandleTextClick(const wxMouseEvent & evt,
|
|||||||
if (evt.MiddleDown()) {
|
if (evt.MiddleDown()) {
|
||||||
// Paste text, making a NEW label if none is selected.
|
// Paste text, making a NEW label if none is selected.
|
||||||
wxTheClipboard->UsePrimarySelection(true);
|
wxTheClipboard->UsePrimarySelection(true);
|
||||||
PasteSelectedText(newSel->t0(), newSel->t1());
|
view.PasteSelectedText(newSel->t0(), newSel->t1());
|
||||||
wxTheClipboard->UsePrimarySelection(false);
|
wxTheClipboard->UsePrimarySelection(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -87,8 +87,7 @@ UIHandle::Result LabelTextHandle::Click
|
|||||||
auto &viewInfo = ViewInfo::Get( *pProject );
|
auto &viewInfo = ViewInfo::Get( *pProject );
|
||||||
|
|
||||||
mSelectedRegion = viewInfo.selectedRegion;
|
mSelectedRegion = viewInfo.selectedRegion;
|
||||||
LabelTrackView::Get( *pLT )
|
HandleTextClick( event, evt.rect, viewInfo, &viewInfo.selectedRegion );
|
||||||
.HandleTextClick( event, evt.rect, viewInfo, &viewInfo.selectedRegion );
|
|
||||||
|
|
||||||
{
|
{
|
||||||
// IF the user clicked a label, THEN select all other tracks by Label
|
// IF the user clicked a label, THEN select all other tracks by Label
|
||||||
@ -125,9 +124,8 @@ UIHandle::Result LabelTextHandle::Drag
|
|||||||
|
|
||||||
const wxMouseEvent &event = evt.event;
|
const wxMouseEvent &event = evt.event;
|
||||||
auto pLT = TrackList::Get( *pProject ).Lock(mpLT);
|
auto pLT = TrackList::Get( *pProject ).Lock(mpLT);
|
||||||
auto pView = pLT ? &LabelTrackView::Get( *pLT ) : nullptr;
|
|
||||||
if(pLT)
|
if(pLT)
|
||||||
pView->HandleTextDragRelease(event);
|
HandleTextDragRelease(event);
|
||||||
|
|
||||||
// locate the initial mouse position
|
// locate the initial mouse position
|
||||||
if (event.LeftIsDown()) {
|
if (event.LeftIsDown()) {
|
||||||
@ -135,6 +133,7 @@ UIHandle::Result LabelTextHandle::Drag
|
|||||||
mLabelTrackStartXPos = event.m_x;
|
mLabelTrackStartXPos = event.m_x;
|
||||||
mLabelTrackStartYPos = event.m_y;
|
mLabelTrackStartYPos = event.m_y;
|
||||||
|
|
||||||
|
auto pView = pLT ? &LabelTrackView::Get( *pLT ) : nullptr;
|
||||||
if (pLT &&
|
if (pLT &&
|
||||||
(pView->GetSelectedIndex() != -1) &&
|
(pView->GetSelectedIndex() != -1) &&
|
||||||
LabelTrackView::OverTextBox(
|
LabelTrackView::OverTextBox(
|
||||||
@ -175,7 +174,7 @@ UIHandle::Result LabelTextHandle::Release
|
|||||||
const wxMouseEvent &event = evt.event;
|
const wxMouseEvent &event = evt.event;
|
||||||
auto pLT = TrackList::Get( *pProject ).Lock(mpLT);
|
auto pLT = TrackList::Get( *pProject ).Lock(mpLT);
|
||||||
if (pLT)
|
if (pLT)
|
||||||
LabelTrackView::Get( *pLT ).HandleTextDragRelease(event);
|
HandleTextDragRelease(event);
|
||||||
|
|
||||||
// handle mouse left button up
|
// handle mouse left button up
|
||||||
if (event.LeftUp())
|
if (event.LeftUp())
|
||||||
|
@ -17,6 +17,7 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
class wxMouseState;
|
class wxMouseState;
|
||||||
class LabelTrack;
|
class LabelTrack;
|
||||||
class SelectionStateChanger;
|
class SelectionStateChanger;
|
||||||
|
class ZoomInfo;
|
||||||
|
|
||||||
class LabelTextHandle final : public LabelDefaultClickHandle
|
class LabelTextHandle final : public LabelDefaultClickHandle
|
||||||
{
|
{
|
||||||
@ -55,12 +56,20 @@ public:
|
|||||||
Result Cancel(AudacityProject *pProject) override;
|
Result Cancel(AudacityProject *pProject) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void HandleTextClick
|
||||||
|
(const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
|
SelectedRegion *newSel);
|
||||||
|
void HandleTextDragRelease(const wxMouseEvent & evt);
|
||||||
|
|
||||||
std::weak_ptr<LabelTrack> mpLT {};
|
std::weak_ptr<LabelTrack> mpLT {};
|
||||||
int mLabelNum{ -1 };
|
int mLabelNum{ -1 };
|
||||||
int mLabelTrackStartXPos { -1 };
|
int mLabelTrackStartXPos { -1 };
|
||||||
int mLabelTrackStartYPos { -1 };
|
int mLabelTrackStartYPos { -1 };
|
||||||
SelectedRegion mSelectedRegion{};
|
SelectedRegion mSelectedRegion{};
|
||||||
std::shared_ptr<SelectionStateChanger> mChanger;
|
std::shared_ptr<SelectionStateChanger> mChanger;
|
||||||
|
|
||||||
|
/// flag to tell if it's a valid dragging
|
||||||
|
bool mRightDragging{ false };
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -118,7 +118,7 @@ private:
|
|||||||
|
|
||||||
struct Flags {
|
struct Flags {
|
||||||
int mInitialCursorPos, mCurrentCursorPos, mSelIndex;
|
int mInitialCursorPos, mCurrentCursorPos, mSelIndex;
|
||||||
bool mRightDragging, mDrawCursor;
|
bool mDrawCursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ResetFlags();
|
void ResetFlags();
|
||||||
@ -126,7 +126,7 @@ private:
|
|||||||
{
|
{
|
||||||
return {
|
return {
|
||||||
mInitialCursorPos, mCurrentCursorPos, mSelIndex,
|
mInitialCursorPos, mCurrentCursorPos, mSelIndex,
|
||||||
mRightDragging, mDrawCursor
|
mDrawCursor
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
void RestoreFlags( const Flags& flags );
|
void RestoreFlags( const Flags& flags );
|
||||||
@ -138,11 +138,6 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
static bool IsTextClipSupported();
|
static bool IsTextClipSupported();
|
||||||
|
|
||||||
void HandleTextClick
|
|
||||||
(const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
|
||||||
SelectedRegion *newSel);
|
|
||||||
void HandleTextDragRelease(const wxMouseEvent & evt);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void AddedLabel( const wxString &title, int pos );
|
void AddedLabel( const wxString &title, int pos );
|
||||||
@ -160,7 +155,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
void CalcHighlightXs(int *x1, int *x2) const;
|
void CalcHighlightXs(int *x1, int *x2) const;
|
||||||
|
|
||||||
|
public:
|
||||||
void ShowContextMenu();
|
void ShowContextMenu();
|
||||||
|
|
||||||
|
private:
|
||||||
void OnContextMenu(wxCommandEvent & evt);
|
void OnContextMenu(wxCommandEvent & evt);
|
||||||
|
|
||||||
mutable int mSelIndex{-1}; /// Keeps track of the currently selected label
|
mutable int mSelIndex{-1}; /// Keeps track of the currently selected label
|
||||||
@ -176,7 +174,6 @@ private:
|
|||||||
int mCurrentCursorPos; /// current cursor position
|
int mCurrentCursorPos; /// current cursor position
|
||||||
int mInitialCursorPos; /// initial cursor position
|
int mInitialCursorPos; /// initial cursor position
|
||||||
|
|
||||||
bool mRightDragging; /// flag to tell if it's a valid dragging
|
|
||||||
bool mDrawCursor; /// flag to tell if drawing the
|
bool mDrawCursor; /// flag to tell if drawing the
|
||||||
/// cursor or not
|
/// cursor or not
|
||||||
int mRestoreFocus{-2}; /// Restore focus to this track
|
int mRestoreFocus{-2}; /// Restore focus to this track
|
||||||
@ -217,7 +214,6 @@ public:
|
|||||||
static wxFont msFont;
|
static wxFont msFont;
|
||||||
|
|
||||||
friend LabelDefaultClickHandle;
|
friend LabelDefaultClickHandle;
|
||||||
friend LabelTextHandle;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user