mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 16:40:07 +02:00
Move declarations again, to LabelGlyphHandle; remove a friend
This commit is contained in:
parent
5eb5e24ab0
commit
6af9187003
@ -1525,13 +1525,13 @@ auto LabelStruct::RegionRelation(
|
|||||||
/// @iEdge - which edge is requested to move, -1 for left +1 for right.
|
/// @iEdge - which edge is requested to move, -1 for left +1 for right.
|
||||||
/// @bAllowSwapping - if we can switch which edge is being dragged.
|
/// @bAllowSwapping - if we can switch which edge is being dragged.
|
||||||
/// fNewTime - the NEW time for this edge of the label.
|
/// fNewTime - the NEW time for this edge of the label.
|
||||||
void LabelTrackView::MayAdjustLabel
|
void LabelGlyphHandle::MayAdjustLabel
|
||||||
( LabelTrackHit &hit, int iLabel, int iEdge, bool bAllowSwapping, double fNewTime)
|
( LabelTrackHit &hit, int iLabel, int iEdge, bool bAllowSwapping, double fNewTime)
|
||||||
{
|
{
|
||||||
if( iLabel < 0 )
|
if( iLabel < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto pTrack = FindLabelTrack();
|
const auto pTrack = mpLT;
|
||||||
const auto &mLabels = pTrack->GetLabels();
|
const auto &mLabels = pTrack->GetLabels();
|
||||||
auto labelStruct = mLabels[ iLabel ];
|
auto labelStruct = mLabels[ iLabel ];
|
||||||
|
|
||||||
@ -1559,12 +1559,12 @@ void LabelTrackView::MayAdjustLabel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the index is for a real label, adjust its left and right boundary.
|
// If the index is for a real label, adjust its left and right boundary.
|
||||||
void LabelTrackView::MayMoveLabel( int iLabel, int iEdge, double fNewTime)
|
void LabelGlyphHandle::MayMoveLabel( int iLabel, int iEdge, double fNewTime)
|
||||||
{
|
{
|
||||||
if( iLabel < 0 )
|
if( iLabel < 0 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const auto pTrack = FindLabelTrack();
|
const auto pTrack = mpLT;
|
||||||
const auto &mLabels = pTrack->GetLabels();
|
const auto &mLabels = pTrack->GetLabels();
|
||||||
auto labelStruct = mLabels[ iLabel ];
|
auto labelStruct = mLabels[ iLabel ];
|
||||||
labelStruct.MoveLabel( iEdge, fNewTime );
|
labelStruct.MoveLabel( iEdge, fNewTime );
|
||||||
@ -1584,12 +1584,12 @@ static int Constrain( int value, int min, int max )
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LabelTrackView::HandleGlyphDragRelease
|
bool LabelGlyphHandle::HandleGlyphDragRelease
|
||||||
(LabelTrackHit &hit, const wxMouseEvent & evt,
|
(LabelTrackHit &hit, const wxMouseEvent & evt,
|
||||||
wxRect & r, const ZoomInfo &zoomInfo,
|
wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
SelectedRegion *newSel)
|
SelectedRegion *newSel)
|
||||||
{
|
{
|
||||||
const auto pTrack = FindLabelTrack();
|
const auto pTrack = mpLT;
|
||||||
const auto &mLabels = pTrack->GetLabels();
|
const auto &mLabels = pTrack->GetLabels();
|
||||||
if(evt.LeftUp())
|
if(evt.LeftUp())
|
||||||
{
|
{
|
||||||
@ -1643,11 +1643,12 @@ bool LabelTrackView::HandleGlyphDragRelease
|
|||||||
MayAdjustLabel( hit, hit.mMouseOverLabelRight, +1, bAllowSwapping, fNewX );
|
MayAdjustLabel( hit, hit.mMouseOverLabelRight, +1, bAllowSwapping, fNewX );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( HasSelection() )
|
if( pTrack->HasSelection() )
|
||||||
{
|
{
|
||||||
|
auto selIndex = LabelTrackView::Get( *pTrack ).GetSelectedIndex();
|
||||||
//Set the selection region to be equal to
|
//Set the selection region to be equal to
|
||||||
//the NEW size of the label.
|
//the NEW size of the label.
|
||||||
*newSel = mLabels[mSelIndex].selectedRegion;
|
*newSel = mLabels[ selIndex ].selectedRegion;
|
||||||
}
|
}
|
||||||
pTrack->SortLabels();
|
pTrack->SortLabels();
|
||||||
}
|
}
|
||||||
@ -1701,7 +1702,7 @@ void LabelTrackView::HandleTextDragRelease(const wxMouseEvent & evt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LabelTrackView::HandleGlyphClick
|
void LabelGlyphHandle::HandleGlyphClick
|
||||||
(LabelTrackHit &hit, const wxMouseEvent & evt,
|
(LabelTrackHit &hit, const wxMouseEvent & evt,
|
||||||
const wxRect & r, const ZoomInfo &zoomInfo,
|
const wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
SelectedRegion *WXUNUSED(newSel))
|
SelectedRegion *WXUNUSED(newSel))
|
||||||
@ -1709,8 +1710,8 @@ void LabelTrackView::HandleGlyphClick
|
|||||||
if (evt.ButtonDown())
|
if (evt.ButtonDown())
|
||||||
{
|
{
|
||||||
//OverGlyph sets mMouseOverLabel to be the chosen label.
|
//OverGlyph sets mMouseOverLabel to be the chosen label.
|
||||||
const auto pTrack = FindLabelTrack();
|
const auto pTrack = mpLT;
|
||||||
OverGlyph(*pTrack, hit, evt.m_x, evt.m_y);
|
LabelTrackView::OverGlyph(*pTrack, hit, evt.m_x, evt.m_y);
|
||||||
hit.mIsAdjustingLabel = evt.Button(wxMOUSE_BTN_LEFT) &&
|
hit.mIsAdjustingLabel = evt.Button(wxMOUSE_BTN_LEFT) &&
|
||||||
( hit.mEdge & 3 ) != 0;
|
( hit.mEdge & 3 ) != 0;
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ UIHandle::Result LabelGlyphHandle::Click
|
|||||||
const wxMouseEvent &event = evt.event;
|
const wxMouseEvent &event = evt.event;
|
||||||
|
|
||||||
auto &viewInfo = ViewInfo::Get( *pProject );
|
auto &viewInfo = ViewInfo::Get( *pProject );
|
||||||
LabelTrackView::Get( *mpLT ).HandleGlyphClick(
|
HandleGlyphClick(
|
||||||
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
|
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
|
||||||
|
|
||||||
if (! mpHit->mIsAdjustingLabel )
|
if (! mpHit->mIsAdjustingLabel )
|
||||||
@ -159,7 +159,7 @@ UIHandle::Result LabelGlyphHandle::Drag
|
|||||||
|
|
||||||
const wxMouseEvent &event = evt.event;
|
const wxMouseEvent &event = evt.event;
|
||||||
auto &viewInfo = ViewInfo::Get( *pProject );
|
auto &viewInfo = ViewInfo::Get( *pProject );
|
||||||
LabelTrackView::Get( *mpLT ).HandleGlyphDragRelease(
|
HandleGlyphDragRelease(
|
||||||
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
|
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion);
|
||||||
|
|
||||||
// Refresh all so that the change of selection is redrawn in all tracks
|
// Refresh all so that the change of selection is redrawn in all tracks
|
||||||
@ -180,7 +180,7 @@ UIHandle::Result LabelGlyphHandle::Release
|
|||||||
|
|
||||||
const wxMouseEvent &event = evt.event;
|
const wxMouseEvent &event = evt.event;
|
||||||
auto &viewInfo = ViewInfo::Get( *pProject );
|
auto &viewInfo = ViewInfo::Get( *pProject );
|
||||||
if (LabelTrackView::Get( *mpLT ).HandleGlyphDragRelease(
|
if (HandleGlyphDragRelease(
|
||||||
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion)) {
|
*mpHit, event, mRect, viewInfo, &viewInfo.selectedRegion)) {
|
||||||
ProjectHistory::Get( *pProject ).PushState(_("Modified Label"),
|
ProjectHistory::Get( *pProject ).PushState(_("Modified Label"),
|
||||||
_("Label Edit"),
|
_("Label Edit"),
|
||||||
|
@ -16,6 +16,8 @@ Paul Licameli split from TrackPanel.cpp
|
|||||||
class wxMouseState;
|
class wxMouseState;
|
||||||
class LabelTrack;
|
class LabelTrack;
|
||||||
class LabelTrackEvent;
|
class LabelTrackEvent;
|
||||||
|
class SelectedRegion;
|
||||||
|
class ZoomInfo;
|
||||||
|
|
||||||
/// mEdge:
|
/// mEdge:
|
||||||
/// 0 if not over a glyph,
|
/// 0 if not over a glyph,
|
||||||
@ -87,8 +89,25 @@ public:
|
|||||||
(const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState);
|
(const LabelGlyphHandle &oldState, const LabelGlyphHandle &newState);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void HandleGlyphClick
|
||||||
|
(LabelTrackHit &hit,
|
||||||
|
const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
|
SelectedRegion *newSel);
|
||||||
|
bool HandleGlyphDragRelease
|
||||||
|
(LabelTrackHit &hit,
|
||||||
|
const wxMouseEvent & evt, wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
|
SelectedRegion *newSel);
|
||||||
|
|
||||||
|
void MayAdjustLabel
|
||||||
|
( LabelTrackHit &hit,
|
||||||
|
int iLabel, int iEdge, bool bAllowSwapping, double fNewTime);
|
||||||
|
void MayMoveLabel( int iLabel, int iEdge, double fNewTime);
|
||||||
|
|
||||||
std::shared_ptr<LabelTrack> mpLT {};
|
std::shared_ptr<LabelTrack> mpLT {};
|
||||||
wxRect mRect {};
|
wxRect mRect {};
|
||||||
|
|
||||||
|
/// Displacement of mouse cursor from the centre being dragged.
|
||||||
|
int mxMouseDisplacement;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -139,17 +139,9 @@ public:
|
|||||||
private:
|
private:
|
||||||
static bool IsTextClipSupported();
|
static bool IsTextClipSupported();
|
||||||
|
|
||||||
void HandleGlyphClick
|
|
||||||
(LabelTrackHit &hit,
|
|
||||||
const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
|
||||||
SelectedRegion *newSel);
|
|
||||||
void HandleTextClick
|
void HandleTextClick
|
||||||
(const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
(const wxMouseEvent & evt, const wxRect & r, const ZoomInfo &zoomInfo,
|
||||||
SelectedRegion *newSel);
|
SelectedRegion *newSel);
|
||||||
bool HandleGlyphDragRelease
|
|
||||||
(LabelTrackHit &hit,
|
|
||||||
const wxMouseEvent & evt, wxRect & r, const ZoomInfo &zoomInfo,
|
|
||||||
SelectedRegion *newSel);
|
|
||||||
void HandleTextDragRelease(const wxMouseEvent & evt);
|
void HandleTextDragRelease(const wxMouseEvent & evt);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -168,16 +160,10 @@ public:
|
|||||||
private:
|
private:
|
||||||
void CalcHighlightXs(int *x1, int *x2) const;
|
void CalcHighlightXs(int *x1, int *x2) const;
|
||||||
|
|
||||||
void MayAdjustLabel
|
|
||||||
( LabelTrackHit &hit,
|
|
||||||
int iLabel, int iEdge, bool bAllowSwapping, double fNewTime);
|
|
||||||
void MayMoveLabel( int iLabel, int iEdge, double fNewTime);
|
|
||||||
|
|
||||||
void ShowContextMenu();
|
void ShowContextMenu();
|
||||||
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
|
||||||
int mxMouseDisplacement; /// Displacement of mouse cursor from the centre being dragged.
|
|
||||||
|
|
||||||
static int mIconHeight;
|
static int mIconHeight;
|
||||||
static int mIconWidth;
|
static int mIconWidth;
|
||||||
@ -226,7 +212,6 @@ private:
|
|||||||
static wxFont msFont;
|
static wxFont msFont;
|
||||||
|
|
||||||
friend LabelDefaultClickHandle;
|
friend LabelDefaultClickHandle;
|
||||||
friend LabelGlyphHandle;
|
|
||||||
friend LabelTextHandle;
|
friend LabelTextHandle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user