Audacity  3.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
LabelTrackView Class Referencefinal

#include <LabelTrackView.h>

Inheritance diagram for LabelTrackView:
[legend]
Collaboration diagram for LabelTrackView:
[legend]

Classes

struct  Flags
 
struct  Index
 

Public Types

enum  : int { DefaultFontSize = 0 }
 
- Public Types inherited from TrackView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >
 
- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 

Public Member Functions

 LabelTrackView (const std::shared_ptr< Track > &pTrack)
 
 ~LabelTrackView () override
 
bool DoCaptureKey (AudacityProject &project, wxKeyEvent &event)
 
bool DoKeyDown (AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
 KeyEvent is called for every keypress when over the label track. More...
 
bool DoChar (AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
 
int AddLabel (const SelectedRegion &region, const wxString &title={}, int restoreFocus=-1)
 
bool IsTextSelected (AudacityProject &project) const
 
void Draw (TrackPanelDrawingContext &context, const wxRect &r) const
 
bool CutSelectedText (AudacityProject &project)
 
bool CopySelectedText (AudacityProject &project)
 
bool PasteSelectedText (AudacityProject &project, double sel0, double sel1)
 
void ResetFlags ()
 
Flags SaveFlags () const
 
void RestoreFlags (const Flags &flags)
 
void AddedLabel (const wxString &title, int pos)
 
void DeletedLabel (int index)
 
bool CalcCursorX (AudacityProject &project, int *x) const
 
void ShowContextMenu (AudacityProject &project)
 
int FindCursorPosition (int labelIndex, wxCoord xPos)
 convert pixel coordinate to character position in text box More...
 
int GetCurrentCursorPosition () const
 
void SetCurrentCursorPosition (int pos)
 
int GetInitialCursorPosition () const
 
void SetTextSelection (int labelIndex, int start=1, int end=1)
 
int GetTextEditIndex (AudacityProject &project) const
 
void ResetTextSelection ()
 
void SetNavigationIndex (int index)
 
int GetNavigationIndex (AudacityProject &project) const
 
- Public Member Functions inherited from CommonTrackView
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final override
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 TrackView (const std::shared_ptr< Track > &pTrack)
 
- Public Member Functions inherited from TrackView
 TrackView (const std::shared_ptr< Track > &pTrack)
 
virtual ~TrackView ()=0
 
void CopyTo (Track &track) const override
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
int GetHeight () const
 
void SetCumulativeHeightBefore (int y)
 Set cached value dependent on position within the track list. More...
 
void SetExpandedHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &) const override
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value) override
 
virtual Refinement GetSubViews (const wxRect &rect)
 
virtual bool IsSpectral () const
 
virtual void DoSetMinimized (bool isMinimized)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Member Functions

static LabelTrackViewGet (LabelTrack &)
 
static const LabelTrackViewGet (const LabelTrack &)
 
static void DoEditLabels (AudacityProject &project, LabelTrack *lt=nullptr, int index=-1)
 
static int DialogForLabelName (AudacityProject &project, const SelectedRegion &region, const wxString &initialValue, wxString &value)
 
static wxFont GetFont (const wxString &faceName, int size=DefaultFontSize)
 
static void ResetFont ()
 
static void OverGlyph (const LabelTrack &track, LabelTrackHit &hit, int x, int y)
 
static int OverATextBox (const LabelTrack &track, int xx, int yy)
 
static bool OverTextBox (const LabelStruct *pLabel, int x, int y)
 
- Static Public Member Functions inherited from TrackView
static int GetTrackHeight (const Track *pTrack)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
static TrackViewGet (Track &)
 
static const TrackViewGet (const Track &)
 
- Static Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Static Public Attributes

static constexpr int TextFramePadding { 2 }
 
static constexpr int TextFrameYOffset { -1 }
 
static constexpr int LabelBarHeight { 6 }
 

Private Member Functions

 LabelTrackView (const LabelTrackView &)=delete
 
LabelTrackViewoperator= (const LabelTrackView &)=delete
 
void Reparent (const std::shared_ptr< Track > &parent) override
 
void BindTo (LabelTrack *pParent)
 
void UnbindFrom (LabelTrack *pParent)
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 
unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
std::shared_ptr< TrackVRulerControlsDoGetVRulerControls () override
 
void CopyTo (Track &track) const override
 
void CreateCustomGlyphs ()
 
int GetLabelIndex (double t, double t1)
 
void CalcHighlightXs (int *x1, int *x2) const
 
void OnContextMenu (AudacityProject &project, wxCommandEvent &evt)
 
void ComputeTextPosition (const wxRect &r, int index) const
 
void ComputeLayout (const wxRect &r, const ZoomInfo &zoomInfo) const
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
bool IsValidIndex (const Index &index, AudacityProject &project) const
 
void RemoveSelectedText ()
 
void OnLabelAdded (LabelTrackEvent &)
 
void OnLabelDeleted (LabelTrackEvent &)
 
void OnLabelPermuted (LabelTrackEvent &)
 
void OnSelectionChange (LabelTrackEvent &)
 
std::shared_ptr< LabelTrackFindLabelTrack ()
 
std::shared_ptr< const LabelTrackFindLabelTrack () const
 

Static Private Member Functions

static wxBitmap & GetGlyph (int i)
 
static bool IsTextClipSupported ()
 
static void DrawLines (wxDC &dc, const LabelStruct &ls, const wxRect &r)
 
static void DrawGlyphs (wxDC &dc, const LabelStruct &ls, const wxRect &r, int GlyphLeft, int GlyphRight)
 
static int GetTextFrameHeight ()
 
static void DrawText (wxDC &dc, const LabelStruct &ls, const wxRect &r)
 
static void DrawTextBox (wxDC &dc, const LabelStruct &ls, const wxRect &r)
 
static void DrawBar (wxDC &dc, const LabelStruct &ls, const wxRect &r)
 
static void DrawHighlight (wxDC &dc, const LabelStruct &ls, int xPos1, int xPos2, int charHeight)
 Draws text-selected region within the label. More...
 
static void calculateFontHeight (wxDC &dc)
 

Private Attributes

Index mNavigationIndex { -1 }
 
Index mTextEditIndex { -1 }
 Index of the current label text beeing edited. More...
 
wxString mUndoLabel
 
int mCurrentCursorPos
 
int mInitialCursorPos
 current cursor position More...
 
int mRestoreFocus {-2}
 initial cursor position More...
 
std::weak_ptr< LabelGlyphHandlemGlyphHandle
 
std::weak_ptr< LabelTextHandlemTextHandle
 
int mEditIndex
 

Static Private Attributes

static int mIconHeight
 
static int mIconWidth
 
static int mTextHeight
 
static bool mbGlyphsReady =false
 
static wxBitmap mBoundaryGlyphs [NUM_GLYPH_CONFIGS *NUM_GLYPH_HIGHLIGHTS]
 
static int mFontHeight =-1
 
static wxFont msFont
 

Additional Inherited Members

- Public Attributes inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 
- Protected Member Functions inherited from CommonTrackPanelCell
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Detailed Description

Definition at line 39 of file LabelTrackView.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum : int
Enumerator
DefaultFontSize 

Definition at line 47 of file LabelTrackView.h.

47 : int { DefaultFontSize = 0 }; //system preferred

Constructor & Destructor Documentation

◆ LabelTrackView() [1/2]

LabelTrackView::LabelTrackView ( const LabelTrackView )
privatedelete

◆ LabelTrackView() [2/2]

LabelTrackView::LabelTrackView ( const std::shared_ptr< Track > &  pTrack)
explicit

Definition at line 97 of file LabelTrackView.cpp.

98  : CommonTrackView{ pTrack }
99 {
100  ResetFont();
102  ResetFlags();
103 
104  // Events will be emitted by the track
105  const auto pLabelTrack = FindLabelTrack();
106  BindTo( pLabelTrack.get() );
107 }

◆ ~LabelTrackView()

LabelTrackView::~LabelTrackView ( )
override

Definition at line 109 of file LabelTrackView.cpp.

110 {
111 }

Member Function Documentation

◆ AddedLabel()

void LabelTrackView::AddedLabel ( const wxString &  title,
int  pos 
)

◆ AddLabel()

int LabelTrackView::AddLabel ( const SelectedRegion region,
const wxString &  title = {},
int  restoreFocus = -1 
)

Definition at line 2059 of file LabelTrackView.cpp.

2061 {
2062  const auto pTrack = FindLabelTrack();
2063  mRestoreFocus = restoreFocus;
2064  auto pos = pTrack->AddLabel( selectedRegion, title );
2065  return pos;
2066 }

References FindLabelTrack(), mRestoreFocus, and title.

Referenced by anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), DoChar(), and PasteSelectedText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BindTo()

void LabelTrackView::BindTo ( LabelTrack pParent)
private

Definition at line 124 of file LabelTrackView.cpp.

125 {
126  pParent->Bind(
127  EVT_LABELTRACK_ADDITION, &LabelTrackView::OnLabelAdded, this );
128  pParent->Bind(
129  EVT_LABELTRACK_DELETION, &LabelTrackView::OnLabelDeleted, this );
130  pParent->Bind(
131  EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
132  pParent->Bind(
133  EVT_LABELTRACK_SELECTION, &LabelTrackView::OnSelectionChange, this );
134 }

References OnLabelAdded(), OnLabelDeleted(), OnLabelPermuted(), and OnSelectionChange().

Referenced by Reparent().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcCursorX()

bool LabelTrackView::CalcCursorX ( AudacityProject project,
int *  x 
) const

Definition at line 719 of file LabelTrackView.cpp.

720 {
721  if (IsValidIndex(mTextEditIndex, project)) {
722  wxMemoryDC dc;
723 
724  if (msFont.Ok()) {
725  dc.SetFont(msFont);
726  }
727 
728  const auto pTrack = FindLabelTrack();
729  const auto &mLabels = pTrack->GetLabels();
730 
731  getXPos(mLabels[mTextEditIndex], dc, x, mCurrentCursorPos);
732  *x += mIconWidth / 2;
733  return true;
734  }
735 
736  return false;
737 }

References FindLabelTrack(), anonymous_namespace{LabelTrackView.cpp}::getXPos(), IsValidIndex(), mCurrentCursorPos, mIconWidth, msFont, and mTextEditIndex.

Referenced by KeyDown(), and ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CalcHighlightXs()

void LabelTrackView::CalcHighlightXs ( int *  x1,
int *  x2 
) const
private

Definition at line 739 of file LabelTrackView.cpp.

740 {
741  wxMemoryDC dc;
742 
743  if (msFont.Ok()) {
744  dc.SetFont(msFont);
745  }
746 
747  int pos1 = mInitialCursorPos, pos2 = mCurrentCursorPos;
748  if (pos1 > pos2)
749  std::swap(pos1, pos2);
750 
751  const auto pTrack = FindLabelTrack();
752  const auto &mLabels = pTrack->GetLabels();
753  const auto &labelStruct = mLabels[mTextEditIndex];
754 
755  // find the left X pos of highlighted area
756  getXPos(labelStruct, dc, x1, pos1);
757  // find the right X pos of highlighted area
758  getXPos(labelStruct, dc, x2, pos2);
759 }

References FindLabelTrack(), anonymous_namespace{LabelTrackView.cpp}::getXPos(), mCurrentCursorPos, mInitialCursorPos, msFont, mTextEditIndex, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculateFontHeight()

void LabelTrackView::calculateFontHeight ( wxDC &  dc)
staticprivate

Definition at line 1026 of file LabelTrackView.cpp.

1027 {
1028  int charDescent;
1029  int charLeading;
1030 
1031  // Calculate the width of the substring and add it to Xpos
1032  dc.GetTextExtent(wxT("(Test String)|[yp]"), NULL, &mFontHeight, &charDescent, &charLeading);
1033 
1034  // The cursor will have height charHeight. We don't include the descender as
1035  // part of the height because for phonetic fonts this leads to cursors which are
1036  // too tall. We don't include leading either - it is usually 0.
1037  // To make up for ignoring the descender height, we add one pixel above and below
1038  // using CursorExtraHeight so that the cursor is just a little taller than the
1039  // body of the characters.
1040  const int CursorExtraHeight=2;
1041  mFontHeight += CursorExtraHeight - (charLeading+charDescent);
1042 }

References mFontHeight.

Referenced by Draw().

Here is the caller graph for this function:

◆ CaptureKey()

unsigned LabelTrackView::CaptureKey ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1407 of file LabelTrackView.cpp.

1409 {
1410  event.Skip(!DoCaptureKey( *project, event ));
1411  return RefreshCode::RefreshNone;
1412 }

References DoCaptureKey(), and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ Char()

unsigned LabelTrackView::Char ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1459 of file LabelTrackView.cpp.

1461 {
1462  double bkpSel0 = viewInfo.selectedRegion.t0(),
1463  bkpSel1 = viewInfo.selectedRegion.t1();
1464  // Pass keystroke to labeltrack's handler and add to history if any
1465  // updates were done
1466 
1467  if (IsValidIndex(mTextEditIndex, *project) && !mTextEditIndex.IsModified()) {
1468  const auto pTrack = FindLabelTrack();
1469  const auto &mLabels = pTrack->GetLabels();
1470  auto labelStruct = mLabels[mTextEditIndex];
1471  auto &title = labelStruct.title;
1472  mUndoLabel = title;
1473  }
1474 
1475  if (DoChar( *project, viewInfo.selectedRegion, event )) {
1476  ProjectHistory::Get( *project ).PushState(XO("Modified Label"),
1477  XO("Label Edit"),
1479 
1481  }
1482 
1483  if (!mTextEditIndex.IsModified()) {
1484  mUndoLabel.clear();
1485  }
1486 
1487  // If selection modified, refresh
1488  // Otherwise, refresh track display if the keystroke was handled
1489  if (bkpSel0 != viewInfo.selectedRegion.t0() ||
1490  bkpSel1 != viewInfo.selectedRegion.t1())
1491  return RefreshCode::RefreshAll;
1492  else if (!event.GetSkipped())
1493  return RefreshCode::RefreshCell;
1494 
1495  return RefreshCode::RefreshNone;
1496 }

References CONSOLIDATE, DoChar(), FindLabelTrack(), ProjectHistory::Get(), LabelTrackView::Index::IsModified(), IsValidIndex(), mTextEditIndex, mUndoLabel, NONE, ProjectHistory::PushState(), RefreshCode::RefreshAll, RefreshCode::RefreshCell, RefreshCode::RefreshNone, ViewInfo::selectedRegion, LabelTrackView::Index::SetModified(), NotifyingSelectedRegion::t0(), NotifyingSelectedRegion::t1(), title, and XO.

Here is the call graph for this function:

◆ ComputeLayout()

void LabelTrackView::ComputeLayout ( const wxRect &  r,
const ZoomInfo zoomInfo 
) const
private

ComputeLayout determines which row each label should be placed on, and reserves space for it. Function assumes that the labels are sorted.

Definition at line 429 of file LabelTrackView.cpp.

430 {
431  int xUsed[MAX_NUM_ROWS];
432 
433  int iRow;
434  // Rows are the 'same' height as icons or as the text,
435  // whichever is taller.
436  const int yRowHeight = wxMax(mTextHeight,mIconHeight)+3;// pixels.
437  // Extra space at end of rows.
438  // We allow space for one half icon at the start and two
439  // half icon widths for extra x for the text frame.
440  // [we don't allow half a width space for the end icon since it is
441  // allowed to be obscured by the text].
442  const int xExtra= (3 * mIconWidth)/2;
443 
444  bool bAvoidName = false;
445  const int nRows = wxMin((r.height / yRowHeight) + 1, MAX_NUM_ROWS);
446  if( nRows > 2 )
447  bAvoidName = gPrefs->ReadBool(wxT("/GUI/ShowTrackNameInWaveform"), false);
448  // Initially none of the rows have been used.
449  // So set a value that is less than any valid value.
450  {
451  // Bug 502: With dragging left of zeros, labels can be in
452  // negative space. So set least possible value as starting point.
453  const int xStart = INT_MIN;
454  for (auto &x : xUsed)
455  x = xStart;
456  }
457  int nRowsUsed=0;
458 
459  const auto pTrack = FindLabelTrack();
460  const auto &mLabels = pTrack->GetLabels();
461 
462  { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
463  const int x = zoomInfo.TimeToPosition(labelStruct.getT0(), r.x);
464  const int x1 = zoomInfo.TimeToPosition(labelStruct.getT1(), r.x);
465  int y = r.y;
466 
467  labelStruct.x=x;
468  labelStruct.x1=x1;
469  labelStruct.y=-1;// -ve indicates nothing doing.
470  iRow=0;
471  // Our first preference is a row that ends where we start.
472  // (This is to encourage merging of adjacent label boundaries).
473  while( (iRow<nRowsUsed) && (xUsed[iRow] != x ))
474  iRow++;
475 
476  // IF we didn't find one THEN
477  // find any row that can take a span starting at x.
478  if( iRow >= nRowsUsed )
479  {
480  iRow=0;
481  while( (iRow<nRows) && (xUsed[iRow] > x ))
482  iRow++;
483  }
484  // IF we found such a row THEN record a valid position.
485  if( iRow<nRows )
486  {
487  // Logic to ameliorate case where first label is under the
488  // (on track) track name. For later labels it does not matter
489  // as we can scroll left or right and/or zoom.
490  // A possible alternative idea would be to (instead) increase the
491  // translucency of the track name, when the mouse is inside it.
492  if( (i==0 ) && (iRow==0) && bAvoidName ){
493  // reserve some space in first row.
494  // reserve max of 200px or t1, or text box right edge.
495  const int x2 = zoomInfo.TimeToPosition(0.0, r.x) + 200;
496  xUsed[iRow]=x+labelStruct.width+xExtra;
497  if( xUsed[iRow] < x1 ) xUsed[iRow]=x1;
498  if( xUsed[iRow] < x2 ) xUsed[iRow]=x2;
499  iRow=1;
500  }
501 
502  // Possibly update the number of rows actually used.
503  if( iRow >= nRowsUsed )
504  nRowsUsed=iRow+1;
505  // Record the position for this label
506  y= r.y + iRow * yRowHeight +(yRowHeight/2)+1;
507  labelStruct.y=y;
508  // On this row we have used up to max of end marker and width.
509  // Plus also allow space to show the start icon and
510  // some space for the text frame.
511  xUsed[iRow]=x+labelStruct.width+xExtra;
512  if( xUsed[iRow] < x1 ) xUsed[iRow]=x1;
513  ComputeTextPosition( r, i );
514  }
515  }}
516 }

References ComputeTextPosition(), FindLabelTrack(), gPrefs, MAX_NUM_ROWS, mIconHeight, mIconWidth, mTextHeight, and ZoomInfo::TimeToPosition().

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ComputeTextPosition()

void LabelTrackView::ComputeTextPosition ( const wxRect &  r,
int  index 
) const
private

Restore focus to this track when done editing

ComputeTextPosition is 'smart' about where to display the label text.

The text must be displayed between its endpoints x and x1 We'd also like it centered between them, and we'd like it on screen. It isn't always possible to achieve all of this, so we do the best we can.

This function has a number of tests and adjustments to the text start position. The tests later in the function will take priority over the ones earlier, so because centering is the first thing we do, it's the first thing we lose if we can't do everything we want to.

Definition at line 282 of file LabelTrackView.cpp.

283 {
284  const auto pTrack = FindLabelTrack();
285  const auto &mLabels = pTrack->GetLabels();
286 
287  const auto &labelStruct = mLabels[index];
288 
289  // xExtra is extra space
290  // between the text and the endpoints.
291  const int xExtra=mIconWidth;
292  int x = labelStruct.x; // left endpoint
293  int x1 = labelStruct.x1; // right endpoint.
294  int width = labelStruct.width;
295 
296  int xText; // This is where the text will end up.
297 
298  // Will the text all fit at this zoom?
299  bool bTooWideForScreen = width > (r.width-2*xExtra);
300 // bool bSimpleCentering = !bTooWideForScreen;
301  bool bSimpleCentering = false;
302 
303  //TODO (possibly):
304  // Add configurable options as to when to use simple
305  // and when complex centering.
306  //
307  // Simple centering does its best to keep the text
308  // centered between the label limits.
309  //
310  // Complex centering positions the text proportionally
311  // to how far we are through the label.
312  //
313  // If we add preferences for this, we want to be able to
314  // choose separately whether:
315  // a) Wide text labels centered simple/complex.
316  // b) Other text labels centered simple/complex.
317  //
318 
319  if( bSimpleCentering )
320  {
321  // Center text between the two end points.
322  xText = (x+x1-width)/2;
323  }
324  else
325  {
326  // Calculate xText position to make text line
327  // scroll sideways evenly as r moves right.
328 
329  // xText is a linear function of r.x.
330  // These variables are used to compute that function.
331  int rx0,rx1,xText0,xText1;
332 
333  // Since we will be using a linear function,
334  // we should blend smoothly between left and right
335  // aligned text as r, the 'viewport' moves.
336  if( bTooWideForScreen )
337  {
338  rx0=x; // when viewport at label start.
339  xText0=x+xExtra; // text aligned left.
340  rx1=x1-r.width; // when viewport end at label end
341  xText1=x1-(width+xExtra); // text aligned right.
342  }
343  else
344  {
345  // when label start + width + extra spacing at viewport end..
346  rx0=x-r.width+width+2*xExtra;
347  // ..text aligned left.
348  xText0=x+xExtra;
349  // when viewport start + width + extra spacing at label end..
350  rx1=x1-(width+2*xExtra);
351  // ..text aligned right.
352  xText1=x1-(width+xExtra);
353  }
354 
355  if( rx1 > rx0 ) // Avoid divide by zero case.
356  {
357  // Compute the blend between left and right aligned.
358 
359  // Don't use:
360  //
361  // xText = xText0 + ((xText1-xText0)*(r.x-rx0))/(rx1-rx0);
362  //
363  // The problem with the above is that it integer-oveflows at
364  // high zoom.
365 
366  // Instead use:
367  xText = xText0 + (int)((xText1-xText0)*(((float)(r.x-rx0))/(rx1-rx0)));
368  }
369  else
370  {
371  // Avoid divide by zero by reverting to
372  // simple centering.
373  //
374  // We could also fall into this case if x and x1
375  // are swapped, in which case we'll end up
376  // left aligned anyway because code later on
377  // will catch that.
378  xText = (x+x1-width)/2;
379  }
380  }
381 
382  // Is the text now appearing partly outside r?
383  bool bOffLeft = xText < r.x+xExtra;
384  bool bOffRight = xText > r.x+r.width-width-xExtra;
385 
386  // IF any part of the text is offscreen
387  // THEN we may bring it back.
388  if( bOffLeft == bOffRight )
389  {
390  //IF both sides on screen, THEN nothing to do.
391  //IF both sides off screen THEN don't do
392  //anything about it.
393  //(because if we did, you'd never get to read
394  //all the text by scrolling).
395  }
396  else if( bOffLeft != bTooWideForScreen)
397  {
398  // IF we're off on the left, OR we're
399  // too wide for the screen and off on the right
400  // (only) THEN align left.
401  xText = r.x+xExtra;
402  }
403  else
404  {
405  // We're off on the right, OR we're
406  // too wide and off on the left (only)
407  // SO align right.
408  xText =r.x+r.width-width-xExtra;
409  }
410 
411  // But if we've taken the text out from its endpoints
412  // we must move it back so that it's between the endpoints.
413 
414  // We test the left end point last because the
415  // text might not even fit between the endpoints (at this
416  // zoom factor), and in that case we'd like to position
417  // the text at the left end point.
418  if( xText > (x1-width-xExtra))
419  xText=(x1-width-xExtra);
420  if( xText < x+xExtra )
421  xText=x+xExtra;
422 
423  labelStruct.xText = xText;
424 }

References FindLabelTrack(), and mIconWidth.

Referenced by ComputeLayout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopySelectedText()

bool LabelTrackView::CopySelectedText ( AudacityProject project)

Copy the selected text in the text box

Returns
true if text is selected in text box, false otherwise

Definition at line 1115 of file LabelTrackView.cpp.

1116 {
1117  if (!IsTextSelected(project))
1118  return false;
1119 
1120  const auto pTrack = FindLabelTrack();
1121  const auto &mLabels = pTrack->GetLabels();
1122 
1123  const auto &labelStruct = mLabels[mTextEditIndex];
1124 
1125  int init = mInitialCursorPos;
1126  int cur = mCurrentCursorPos;
1127  if (init > cur)
1128  std::swap(init, cur);
1129 
1130  if (init == cur)
1131  return false;
1132 
1133  // data for copying
1134  wxString data = labelStruct.title.Mid(init, cur-init);
1135 
1136  // copy the data on clipboard
1137  if (wxTheClipboard->Open()) {
1138  // Clipboard owns the data you give it
1139  wxTheClipboard->SetData(safenew wxTextDataObject(data));
1140  wxTheClipboard->Close();
1141  }
1142 
1143  return true;
1144 }

References FindLabelTrack(), IsTextSelected(), mCurrentCursorPos, mInitialCursorPos, mTextEditIndex, safenew, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by OnContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CopyTo()

void LabelTrackView::CopyTo ( Track track) const
overrideprivatevirtual

Reimplemented from CommonTrackCell.

Definition at line 148 of file LabelTrackView.cpp.

149 {
150  TrackView::CopyTo( track );
151  auto &other = TrackView::Get( track );
152 
153  if ( const auto pOther = dynamic_cast< const LabelTrackView* >( &other ) ) {
154  pOther->mNavigationIndex = mNavigationIndex;
155  pOther->mInitialCursorPos = mInitialCursorPos;
156  pOther->mCurrentCursorPos = mCurrentCursorPos;
157  pOther->mTextEditIndex = mTextEditIndex;
158  pOther->mUndoLabel = mUndoLabel;
159  }
160 }

References TrackView::CopyTo(), TrackView::Get(), mCurrentCursorPos, mInitialCursorPos, mNavigationIndex, mTextEditIndex, and mUndoLabel.

Here is the call graph for this function:

◆ CreateCustomGlyphs()

void LabelTrackView::CreateCustomGlyphs ( )
private

CreateCustomGlyphs() creates the mBoundaryGlyph array. It's a bit like painting by numbers!

Schematically the glyphs we want will 'look like': <O, O> and <O> for a left boundary to a label, a right boundary and both. we're creating all three glyphs using the one Xpm Spec.

When we hover over a glyph we highlight the inside of either the '<', the 'O' or the '>' or none, giving 3 x 4 = 12 combinations.

Two of those combinations aren't used, but treating them specially would make other code more complicated.

Definition at line 2203 of file LabelTrackView.cpp.

2204 {
2205  int iConfig;
2206  int iHighlight;
2207  int index;
2208  const int nSpecRows =
2209  sizeof( GlyphXpmRegionSpec )/sizeof( GlyphXpmRegionSpec[0]);
2210  const char *XmpBmp[nSpecRows];
2211 
2212  // The glyphs are declared static wxIcon; so we only need
2213  // to create them once, no matter how many LabelTracks.
2214  if( mbGlyphsReady )
2215  return;
2216 
2217  // We're about to tweak the basic color spec to get 12 variations.
2218  for( iConfig=0;iConfig<NUM_GLYPH_CONFIGS;iConfig++)
2219  {
2220  for( iHighlight=0;iHighlight<NUM_GLYPH_HIGHLIGHTS;iHighlight++)
2221  {
2222  index = iConfig + NUM_GLYPH_CONFIGS * iHighlight;
2223  // Copy the basic spec...
2224  memcpy( XmpBmp, GlyphXpmRegionSpec, sizeof( GlyphXpmRegionSpec ));
2225  // The highlighted region (if any) is white...
2226  if( iHighlight==1 ) XmpBmp[5]="5 c #FFFFFF";
2227  if( iHighlight==2 ) XmpBmp[6]="6 c #FFFFFF";
2228  if( iHighlight==3 ) XmpBmp[7]="7 c #FFFFFF";
2229  // For left or right arrow the other side of the glyph
2230  // is the transparent color.
2231  if( iConfig==0) { XmpBmp[3]="3 c none"; XmpBmp[5]="5 c none"; }
2232  if( iConfig==1) { XmpBmp[4]="4 c none"; XmpBmp[7]="7 c none"; }
2233  // Create the icon from the tweaked spec.
2234  mBoundaryGlyphs[index] = wxBitmap(XmpBmp);
2235  // Create the mask
2236  // SetMask takes ownership
2237  mBoundaryGlyphs[index].SetMask(safenew wxMask(mBoundaryGlyphs[index], wxColour(192, 192, 192)));
2238  }
2239  }
2240 
2241  mIconWidth = mBoundaryGlyphs[0].GetWidth();
2242  mIconHeight = mBoundaryGlyphs[0].GetHeight();
2243  mTextHeight = mIconHeight; // until proved otherwise...
2244  // The icon should have an odd width so that the
2245  // line goes exactly down the middle.
2246  wxASSERT( (mIconWidth %2)==1);
2247 
2248  mbGlyphsReady=true;
2249 }

References GlyphXpmRegionSpec, mbGlyphsReady, mBoundaryGlyphs, mIconHeight, mIconWidth, mTextHeight, NUM_GLYPH_CONFIGS, NUM_GLYPH_HIGHLIGHTS, and safenew.

◆ CutSelectedText()

bool LabelTrackView::CutSelectedText ( AudacityProject project)

Cut the selected text in the text box

Returns
true if text is selected in text box, false otherwise

Definition at line 1062 of file LabelTrackView.cpp.

1063 {
1064  if (!IsTextSelected( project ))
1065  return false;
1066 
1067  const auto pTrack = FindLabelTrack();
1068  const auto &mLabels = pTrack->GetLabels();
1069 
1070  wxString left, right;
1071  auto labelStruct = mLabels[mTextEditIndex];
1072  auto &text = labelStruct.title;
1073 
1074  if (!mTextEditIndex.IsModified()) {
1075  mUndoLabel = text;
1076  }
1077 
1078  int init = mInitialCursorPos;
1079  int cur = mCurrentCursorPos;
1080  if (init > cur)
1081  std::swap(init, cur);
1082 
1083  // data for cutting
1084  wxString data = text.Mid(init, cur - init);
1085 
1086  // get left-remaining text
1087  if (init > 0)
1088  left = text.Left(init);
1089 
1090  // get right-remaining text
1091  if (cur < (int)text.length())
1092  right = text.Mid(cur);
1093 
1094  // set title to the combination of the two remainders
1095  text = left + right;
1096 
1097  pTrack->SetLabel( mTextEditIndex, labelStruct );
1098 
1099  // copy data onto clipboard
1100  if (wxTheClipboard->Open()) {
1101  // Clipboard owns the data you give it
1102  wxTheClipboard->SetData(safenew wxTextDataObject(data));
1103  wxTheClipboard->Close();
1104  }
1105 
1106  // set cursor positions
1107  mInitialCursorPos = mCurrentCursorPos = left.length();
1108 
1110  return true;
1111 }

References FindLabelTrack(), LabelTrackView::Index::IsModified(), IsTextSelected(), mCurrentCursorPos, mInitialCursorPos, mTextEditIndex, mUndoLabel, safenew, LabelTrackView::Index::SetModified(), and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by OnContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DeletedLabel()

void LabelTrackView::DeletedLabel ( int  index)

◆ DetailedHitTest()

std::vector< UIHandlePtr > LabelTrackView::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overrideprivatevirtual

Implements CommonTrackView.

Definition at line 182 of file LabelTrackView.cpp.

185 {
186  UIHandlePtr result;
187  std::vector<UIHandlePtr> results;
188  const wxMouseState &state = st.state;
189 
190  const auto pTrack = FindLabelTrack();
191  result = LabelGlyphHandle::HitTest(
192  mGlyphHandle, state, pTrack, st.rect);
193  if (result)
194  results.push_back(result);
195 
196  result = LabelTextHandle::HitTest(
197  mTextHandle, state, pTrack);
198  if (result)
199  results.push_back(result);
200 
201  return results;
202 }

References FindLabelTrack(), LabelGlyphHandle::HitTest(), LabelTextHandle::HitTest(), mGlyphHandle, mTextHandle, TrackPanelMouseState::rect, and TrackPanelMouseState::state.

Here is the call graph for this function:

◆ DialogForLabelName()

int LabelTrackView::DialogForLabelName ( AudacityProject project,
const SelectedRegion region,
const wxString &  initialValue,
wxString &  value 
)
static

Definition at line 2278 of file LabelTrackView.cpp.

2281 {
2282  auto &trackFocus = TrackFocus::Get( project );
2283  auto &trackPanel = TrackPanel::Get( project );
2284  auto &viewInfo = ViewInfo::Get( project );
2285 
2286  wxPoint position =
2287  trackPanel.FindTrackRect( trackFocus.Get() ).GetBottomLeft();
2288  // The start of the text in the text box will be roughly in line with the label's position
2289  // if it's a point label, or the start of its region if it's a region label.
2290  position.x +=
2291  + std::max(0, static_cast<int>(viewInfo.TimeToPosition(
2292  viewInfo.GetLeftOffset(), region.t0())))
2293  - 39;
2294  position.y += 2; // just below the bottom of the track
2295  position = trackPanel.ClientToScreen(position);
2296  auto &window = GetProjectFrame( project );
2297  AudacityTextEntryDialog dialog{ &window,
2298  XO("Name:"),
2299  XO("New label"),
2300  initialValue,
2301  wxOK | wxCANCEL,
2302  position };
2303 
2304  // keep the dialog within Audacity's window, so that the dialog is always fully visible
2305  wxRect dialogScreenRect = dialog.GetScreenRect();
2306  wxRect projScreenRect = window.GetScreenRect();
2307  wxPoint max = projScreenRect.GetBottomRight() + wxPoint{ -dialogScreenRect.width, -dialogScreenRect.height };
2308  if (dialogScreenRect.x > max.x) {
2309  position.x = max.x;
2310  dialog.Move(position);
2311  }
2312  if (dialogScreenRect.y > max.y) {
2313  position.y = max.y;
2314  dialog.Move(position);
2315  }
2316 
2317  dialog.SetInsertionPointEnd(); // because, by default, initial text is selected
2318  int status = dialog.ShowModal();
2319  if (status != wxID_CANCEL) {
2320  value = dialog.GetValue();
2321  value.Trim(true).Trim(false);
2322  }
2323 
2324  return status;
2325 }

References TrackFocus::Get(), ViewInfo::Get(), TrackPanel::Get(), ZoomInfo::GetLeftOffset(), GetProjectFrame(), SelectedRegion::t0(), ZoomInfo::TimeToPosition(), and XO.

Referenced by anonymous_namespace{LabelMenus.cpp}::DoAddLabel(), and DoChar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoCaptureKey()

bool LabelTrackView::DoCaptureKey ( AudacityProject project,
wxKeyEvent &  event 
)

Definition at line 1338 of file LabelTrackView.cpp.

1340 {
1341  int mods = event.GetModifiers();
1342  auto code = event.GetKeyCode();
1343  const auto pTrack = FindLabelTrack();
1344  const auto& mLabels = pTrack->GetLabels();
1345 
1346  // Allow hardcoded Ctrl+F2 for renaming the selected label,
1347  // if we have any labels
1348  if (code == WXK_F2 && mods == wxMOD_CONTROL && !mLabels.empty()) {
1349  return true;
1350  }
1351 
1352  // Check for modifiers and only allow shift
1353  if (mods != wxMOD_NONE && mods != wxMOD_SHIFT) {
1354  return false;
1355  }
1356 
1357  // Always capture the navigation keys, if we have any labels
1358  if ((code == WXK_TAB || code == WXK_NUMPAD_TAB) &&
1359  !mLabels.empty())
1360  return true;
1361 
1362  if (IsValidIndex(mTextEditIndex, project)) {
1363  if (IsGoodLabelEditKey(event)) {
1364  return true;
1365  }
1366  }
1367  else {
1368  bool typeToCreateLabel;
1369  gPrefs->Read(wxT("/GUI/TypeToCreateLabel"), &typeToCreateLabel, false);
1370  if (IsGoodLabelFirstKey(event) && typeToCreateLabel) {
1371 
1372 
1373 // The commented out code can prevent label creation, causing bug 1551
1374 // We should only be in DoCaptureKey IF this label track has focus,
1375 // and in that case creating a Label is the expected/intended thing.
1376 #if 0
1377  // If we're playing, don't capture if the selection is the same as the
1378  // playback region (this helps prevent label track creation from
1379  // stealing unmodified kbd. shortcuts)
1380  auto gAudioIO = AudioIOBase::Get();
1381  if (pProj->GetAudioIOToken() > 0 &&
1382  gAudioIO->IsStreamActive(pProj->GetAudioIOToken()))
1383  {
1384  double t0, t1;
1385  pProj->GetPlayRegion(&t0, &t1);
1386  if (pProj->mViewInfo.selectedRegion.t0() == t0 &&
1387  pProj->mViewInfo.selectedRegion.t1() == t1) {
1388  return false;
1389  }
1390  }
1391 #endif
1392 
1393  // If there's a label there already don't capture
1394  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
1395  if( GetLabelIndex(selectedRegion.t0(),
1396  selectedRegion.t1()) != wxNOT_FOUND ) {
1397  return false;
1398  }
1399 
1400  return true;
1401  }
1402  }
1403 
1404  return false;
1405 }

References FindLabelTrack(), AudioIOBase::Get(), ViewInfo::Get(), GetLabelIndex(), gPrefs, IsGoodLabelEditKey(), IsGoodLabelFirstKey(), IsValidIndex(), mTextEditIndex, and ViewInfo::selectedRegion.

Referenced by CaptureKey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoChar()

bool LabelTrackView::DoChar ( AudacityProject project,
NotifyingSelectedRegion sel,
wxKeyEvent &  event 
)

OnChar is called for incoming characters – that's any keypress not handled by OnKeyDown.

Definition at line 1780 of file LabelTrackView.cpp.

1783 {
1784  // Check for modifiers and only allow shift.
1785  //
1786  // We still need to check this or we will eat the top level menu accelerators
1787  // on Windows if our capture or key down handlers skipped the event.
1788  const int mods = event.GetModifiers();
1789  if (mods != wxMOD_NONE && mods != wxMOD_SHIFT) {
1790  event.Skip();
1791  return false;
1792  }
1793 
1794  // Only track true changes to the label
1795  //bool updated = false;
1796 
1797  // Cache the character
1798  wxChar charCode = event.GetUnicodeKey();
1799 
1800  // Skip if it's not a valid unicode character or a control character
1801  if (charCode == 0 || wxIscntrl(charCode)) {
1802  event.Skip();
1803  return false;
1804  }
1805 
1806  // If we've reached this point and aren't currently editing, add NEW label
1807  const auto pTrack = FindLabelTrack();
1808  if (!IsValidIndex(mTextEditIndex, project)) {
1809  // Don't create a NEW label for a space
1810  if (wxIsspace(charCode)) {
1811  event.Skip();
1812  return false;
1813  }
1814  bool useDialog;
1815  gPrefs->Read(wxT("/GUI/DialogForNameNewLabel"), &useDialog, false);
1816  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
1817  if (useDialog) {
1818  wxString title;
1819  if (DialogForLabelName(
1820  project, selectedRegion, charCode, title) ==
1821  wxID_CANCEL) {
1822  return false;
1823  }
1824  pTrack->SetSelected(true);
1825  pTrack->AddLabel(selectedRegion, title);
1826  ProjectHistory::Get( project )
1827  .PushState(XO("Added label"), XO("Label"));
1828  return false;
1829  }
1830  else {
1831  pTrack->SetSelected(true);
1832  AddLabel( selectedRegion );
1833  ProjectHistory::Get( project )
1834  .PushState(XO("Added label"), XO("Label"));
1835  }
1836  }
1837 
1838  if (!IsValidIndex(mTextEditIndex, project))
1839  return false;
1840 
1841  //
1842  // Now we are definitely in a label; append the incoming character
1843  //
1844 
1845  // Test if cursor is in the end of string or not
1848 
1849  const auto& mLabels = pTrack->GetLabels();
1850  auto labelStruct = mLabels[mTextEditIndex];
1851  auto& title = labelStruct.title;
1852 
1853  if (mCurrentCursorPos < (int)title.length()) {
1854  // Get substring on the righthand side of cursor
1855  wxString rightPart = title.Mid(mCurrentCursorPos);
1856  // Set title to substring on the lefthand side of cursor
1857  title = title.Left(mCurrentCursorPos);
1858  //append charcode
1859  title += charCode;
1860  //append the right part substring
1861  title += rightPart;
1862  }
1863  else
1864  //append charCode
1865  title += charCode;
1866 
1867  pTrack->SetLabel(mTextEditIndex, labelStruct );
1868 
1869  //moving cursor position forward
1871 
1872  return true;
1873 }

References AddLabel(), DialogForLabelName(), FindLabelTrack(), ViewInfo::Get(), ProjectHistory::Get(), gPrefs, IsValidIndex(), mCurrentCursorPos, mInitialCursorPos, mTextEditIndex, ProjectHistory::PushState(), RemoveSelectedText(), ViewInfo::selectedRegion, title, and XO.

Referenced by Char().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoEditLabels()

void LabelTrackView::DoEditLabels ( AudacityProject project,
LabelTrack lt = nullptr,
int  index = -1 
)
static

Definition at line 2253 of file LabelTrackView.cpp.

2255 {
2256  const auto &settings = ProjectSettings::Get( project );
2257  auto format = settings.GetSelectionFormat(),
2258  freqFormat = settings.GetFrequencySelectionFormatName();
2259  auto &tracks = TrackList::Get( project );
2260  auto rate = ProjectRate::Get( project ).GetRate();
2261  auto &viewInfo = ViewInfo::Get( project );
2262  auto &window = ProjectWindow::Get( project );
2263 
2264  LabelDialog dlg(&window, project, &tracks,
2265  lt, index,
2266  viewInfo, rate,
2267  format, freqFormat);
2268 #ifdef __WXGTK__
2269  dlg.Raise();
2270 #endif
2271 
2272  if (dlg.ShowModal() == wxID_OK) {
2273  ProjectHistory::Get( project )
2274  .PushState(XO("Edited labels"), XO("Label"));
2275  }
2276 }

References format, ProjectRate::Get(), ViewInfo::Get(), ProjectHistory::Get(), ProjectSettings::Get(), ProjectWindow::Get(), TrackList::Get(), ProjectRate::GetRate(), ProjectHistory::PushState(), settings(), and XO.

Referenced by LabelEditActions::Handler::OnEditLabels(), and ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoGetVRulerControls()

std::shared_ptr< TrackVRulerControls > LabelTrackView::DoGetVRulerControls ( )
overrideprivatevirtual

Implements TrackView.

Definition at line 2334 of file LabelTrackView.cpp.

2335 {
2336  return
2337  std::make_shared<LabelTrackVRulerControls>( shared_from_this() );
2338 }

◆ DoKeyDown()

bool LabelTrackView::DoKeyDown ( AudacityProject project,
NotifyingSelectedRegion sel,
wxKeyEvent &  event 
)

KeyEvent is called for every keypress when over the label track.

Definition at line 1499 of file LabelTrackView.cpp.

1501 {
1502  // Only track true changes to the label
1503  bool updated = false;
1504 
1505  // Cache the keycode
1506  int keyCode = event.GetKeyCode();
1507  const int mods = event.GetModifiers();
1508 
1509  // Check for modifiers and only allow shift
1510  // except in the case of Ctrl + F2, so hardcoded Ctrl+F2 can
1511  // be used for renaming a label
1512  if ((keyCode != WXK_F2 && mods != wxMOD_NONE && mods != wxMOD_SHIFT)
1513  || (keyCode == WXK_F2 && mods != wxMOD_CONTROL)) {
1514  event.Skip();
1515  return updated;
1516  }
1517 
1518  // All editing keys are only active if we're currently editing a label
1519  const auto pTrack = FindLabelTrack();
1520  const auto &mLabels = pTrack->GetLabels();
1521  if (IsValidIndex(mTextEditIndex, project)) {
1522  // Do label text changes
1523  auto labelStruct = mLabels[mTextEditIndex];
1524  auto &title = labelStruct.title;
1525  wxUniChar wchar;
1526  bool more=true;
1527 
1528  switch (keyCode) {
1529 
1530  case WXK_BACK:
1531  {
1532  int len = title.length();
1533 
1534  //IF the label is not blank THEN get rid of a letter or letters according to cursor position
1535  if (len > 0)
1536  {
1537  // IF there are some highlighted letters, THEN DELETE them
1540  else
1541  {
1542  // DELETE one codepoint leftwards
1543  while ((mCurrentCursorPos > 0) && more) {
1544  wchar = title.at( mCurrentCursorPos-1 );
1545  title.erase(mCurrentCursorPos-1, 1);
1547  if( ((int)wchar > 0xDFFF) || ((int)wchar <0xDC00)){
1548  pTrack->SetLabel(mTextEditIndex, labelStruct);
1549  more = false;
1550  }
1551  }
1552  }
1553  }
1554  else
1555  {
1556  // ELSE no text in text box, so DELETE whole label.
1557  pTrack->DeleteLabel(mTextEditIndex);
1559  }
1561  updated = true;
1562  }
1563  break;
1564 
1565  case WXK_DELETE:
1566  case WXK_NUMPAD_DELETE:
1567  {
1568  int len = title.length();
1569 
1570  //If the label is not blank get rid of a letter according to cursor position
1571  if (len > 0)
1572  {
1573  // if there are some highlighted letters, DELETE them
1576  else
1577  {
1578  // DELETE one codepoint rightwards
1579  while ((mCurrentCursorPos < len) && more) {
1580  wchar = title.at( mCurrentCursorPos );
1581  title.erase(mCurrentCursorPos, 1);
1582  if( ((int)wchar > 0xDBFF) || ((int)wchar <0xD800)){
1583  pTrack->SetLabel(mTextEditIndex, labelStruct);
1584  more = false;
1585  }
1586  }
1587  }
1588  }
1589  else
1590  {
1591  // DELETE whole label if no text in text box
1592  pTrack->DeleteLabel(mTextEditIndex);
1594  }
1596  updated = true;
1597  }
1598  break;
1599 
1600  case WXK_HOME:
1601  case WXK_NUMPAD_HOME:
1602  // Move cursor to beginning of label
1603  mCurrentCursorPos = 0;
1604  if (mods == wxMOD_SHIFT)
1605  ;
1606  else
1608  break;
1609 
1610  case WXK_END:
1611  case WXK_NUMPAD_END:
1612  // Move cursor to end of label
1613  mCurrentCursorPos = (int)title.length();
1614  if (mods == wxMOD_SHIFT)
1615  ;
1616  else
1618  break;
1619 
1620  case WXK_LEFT:
1621  case WXK_NUMPAD_LEFT:
1622  // Moving cursor left
1623  while ((mCurrentCursorPos > 0) && more) {
1624  wchar = title.at( mCurrentCursorPos-1 );
1625  more = !( ((int)wchar > 0xDFFF) || ((int)wchar <0xDC00));
1626 
1628  if (mods == wxMOD_SHIFT)
1629  ;
1630  else
1633  }
1634  break;
1635 
1636  case WXK_RIGHT:
1637  case WXK_NUMPAD_RIGHT:
1638  // Moving cursor right
1639  while ((mCurrentCursorPos < (int)title.length())&& more) {
1640  wchar = title.at( mCurrentCursorPos );
1641  more = !( ((int)wchar > 0xDBFF) || ((int)wchar <0xD800));
1642 
1644  if (mods == wxMOD_SHIFT)
1645  ;
1646  else
1649  }
1650  break;
1651 
1652  case WXK_ESCAPE:
1653  if (mTextEditIndex.IsModified()) {
1654  title = mUndoLabel;
1655  pTrack->SetLabel(mTextEditIndex, labelStruct);
1656 
1657  ProjectHistory::Get( project ).PushState(XO("Modified Label"),
1658  XO("Label Edit"),
1660  }
1661 
1662  case WXK_RETURN:
1663  case WXK_NUMPAD_ENTER:
1664  case WXK_TAB:
1665  if (mRestoreFocus >= 0) {
1666  auto track = *TrackList::Get( project ).Any()
1667  .begin().advance(mRestoreFocus);
1668  if (track)
1669  TrackFocus::Get( project ).Set(track);
1670  mRestoreFocus = -2;
1671  }
1674  break;
1675  case '\x10': // OSX
1676  case WXK_MENU:
1677  case WXK_WINDOWS_MENU:
1678  ShowContextMenu( project );
1679  break;
1680 
1681  default:
1682  if (!IsGoodLabelEditKey(event)) {
1683  event.Skip();
1684  }
1685  break;
1686  }
1687  }
1688  else
1689  {
1690  // Do navigation
1691  switch (keyCode) {
1692 
1693  case WXK_ESCAPE:
1694  mNavigationIndex = -1;
1695  break;
1696  case WXK_TAB:
1697  case WXK_NUMPAD_TAB:
1698  if (!mLabels.empty()) {
1699  int len = (int) mLabels.size();
1700  // The case where the start of selection is the same as the
1701  // start of a label is handled separately so that if some labels
1702  // have the same start time, all labels are navigated.
1703  if (IsValidIndex(mNavigationIndex, project)
1704  && mLabels[mNavigationIndex].getT0() == newSel.t0())
1705  {
1706  if (event.ShiftDown()) {
1707  --mNavigationIndex;
1708  }
1709  else {
1710  ++mNavigationIndex;
1711  }
1712  mNavigationIndex = (mNavigationIndex + (int)mLabels.size()) % (int)mLabels.size(); // wrap round if necessary
1713  }
1714  else
1715  {
1716  if (event.ShiftDown()) {
1717  //search for the first label starting from the end (and before selection)
1718  mNavigationIndex = len - 1;
1719  if (newSel.t0() > mLabels[0].getT0()) {
1720  while (mNavigationIndex >= 0 &&
1721  mLabels[mNavigationIndex].getT0() > newSel.t0()) {
1722  --mNavigationIndex;
1723  }
1724  }
1725  }
1726  else {
1727  //search for the first label starting from the beginning (and after selection)
1728  mNavigationIndex = 0;
1729  if (newSel.t0() < mLabels[len - 1].getT0()) {
1730  while (mNavigationIndex < len &&
1731  mLabels[mNavigationIndex].getT0() < newSel.t0()) {
1732  ++mNavigationIndex;
1733  }
1734  }
1735  }
1736  }
1737 
1738  if (mNavigationIndex >= 0 && mNavigationIndex < len) {
1739  const auto &labelStruct = mLabels[mNavigationIndex];
1740  mCurrentCursorPos = labelStruct.title.length();
1742  //Set the selection region to be equal to the selection bounds of the tabbed-to label.
1743  newSel = labelStruct.selectedRegion;
1744  // message for screen reader
1745  /* i18n-hint:
1746  String is replaced by the name of a label,
1747  first number gives the position of that label in a sequence
1748  of labels,
1749  and the last number is the total number of labels in the sequence.
1750  */
1751  auto message = XO("%s %d of %d")
1752  .Format(labelStruct.title, mNavigationIndex + 1, pTrack->GetNumLabels());
1753  TrackFocus::Get(project).MessageForScreenReader(message);
1754  }
1755  else {
1756  mNavigationIndex = -1;
1757  }
1758  }
1759  break;
1760  case WXK_F2: // Must be Ctrl + F2 to have reached here
1761  // Hardcoded Ctrl+F2 activates editing of the label
1762  // pointed to by mNavigationIndex (if valid)
1763  if (IsValidIndex(mNavigationIndex, project)) {
1765  }
1766  break;
1767  default:
1768  if (!IsGoodLabelFirstKey(event)) {
1769  event.Skip();
1770  }
1771  break;
1772  }
1773  }
1774 
1775  return updated;
1776 }

References TrackList::Any(), CONSOLIDATE, FindLabelTrack(), TrackFocus::Get(), ProjectHistory::Get(), TrackList::Get(), IsGoodLabelEditKey(), IsGoodLabelFirstKey(), LabelTrackView::Index::IsModified(), IsValidIndex(), mCurrentCursorPos, min(), mInitialCursorPos, mNavigationIndex, mRestoreFocus, mTextEditIndex, mUndoLabel, NONE, ProjectHistory::PushState(), RemoveSelectedText(), ResetTextSelection(), SetNavigationIndex(), SetTextSelection(), ShowContextMenu(), NotifyingSelectedRegion::t0(), title, and XO.

Referenced by KeyDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw() [1/2]

void LabelTrackView::Draw ( TrackPanelDrawingContext context,
const wxRect &  r 
) const

Draw calls other functions to draw the LabelTrack.

Parameters
dcthe device context
rthe LabelTrack rectangle.

Definition at line 785 of file LabelTrackView.cpp.

787 {
788  auto &dc = context.dc;
789  const auto artist = TrackArtist::Get( context );
790  const auto &zoomInfo = *artist->pZoomInfo;
791 
792  auto pHit = findHit( artist->parent );
793 
794  if(msFont.Ok())
795  dc.SetFont(msFont);
796 
797  if (mFontHeight == -1)
799 
800  const auto pTrack = std::static_pointer_cast< const LabelTrack >(
801  FindTrack()->SubstitutePendingChangedTrack());
802  const auto &mLabels = pTrack->GetLabels();
803 
804  TrackArt::DrawBackgroundWithSelection( context, r, pTrack.get(),
806  ( pTrack->GetSelected() || pTrack->IsSyncLockSelected() ) );
807 
808  wxCoord textWidth, textHeight;
809 
810  // Get the text widths.
811  // TODO: Make more efficient by only re-computing when a
812  // text label title changes.
813  for (const auto &labelStruct : mLabels) {
814  dc.GetTextExtent(labelStruct.title, &textWidth, &textHeight);
815  labelStruct.width = textWidth;
816  }
817 
818  // TODO: And this only needs to be done once, but we
819  // do need the dc to do it.
820  // We need to set mTextHeight to something sensible,
821  // guarding against the case where there are no
822  // labels or all are empty strings, which for example
823  // happens with a NEW label track.
824  mTextHeight = dc.GetFontMetrics().ascent + dc.GetFontMetrics().descent;
825  const int yFrameHeight = mTextHeight + TextFramePadding * 2;
826 
827  ComputeLayout( r, zoomInfo );
828  dc.SetTextForeground(theTheme.Colour( clrLabelTrackText));
829  dc.SetBackgroundMode(wxTRANSPARENT);
830  dc.SetBrush(AColor::labelTextNormalBrush);
831  dc.SetPen(AColor::labelSurroundPen);
832  int GlyphLeft;
833  int GlyphRight;
834  // Now we draw the various items in this order,
835  // so that the correct things overpaint each other.
836 
837  // Draw vertical lines that show where the end positions are.
838  for (const auto &labelStruct : mLabels)
839  DrawLines( dc, labelStruct, r );
840 
841  // Draw the end glyphs.
842  { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
843  GlyphLeft=0;
844  GlyphRight=1;
845  if( pHit && i == pHit->mMouseOverLabelLeft )
846  GlyphLeft = (pHit->mEdge & 4) ? 6:9;
847  if( pHit && i == pHit->mMouseOverLabelRight )
848  GlyphRight = (pHit->mEdge & 4) ? 7:4;
849  DrawGlyphs( dc, labelStruct, r, GlyphLeft, GlyphRight );
850  }}
851 
852  auto &project = *artist->parent->GetProject();
853 
854  // Draw the label boxes.
855  {
856 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
857  bool highlightTrack = false;
858  auto target = dynamic_cast<LabelTextHandle*>(context.target.get());
859  highlightTrack = target && target->GetTrack().get() == this;
860 #endif
861  int i = -1; for (const auto &labelStruct : mLabels) { ++i;
862  bool highlight = false;
863 #ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
864  highlight = highlightTrack && target->GetLabelNum() == i;
865 #endif
866 
867  dc.SetBrush(mNavigationIndex == i || (pHit && pHit->mMouseOverLabel == i)
869  DrawBar(dc, labelStruct, r);
870 
871  bool selected = mTextEditIndex == i;
872 
873  if (selected)
874  dc.SetBrush(AColor::labelTextEditBrush);
875  else if (highlight)
876  dc.SetBrush(AColor::uglyBrush);
877  else
878  dc.SetBrush(AColor::labelTextNormalBrush);
879  DrawTextBox(dc, labelStruct, r);
880 
881  dc.SetBrush(AColor::labelTextNormalBrush);
882  }
883  }
884 
885  // Draw highlights
887  {
888  int xpos1, xpos2;
889  CalcHighlightXs(&xpos1, &xpos2);
890  DrawHighlight(dc, mLabels[mTextEditIndex],
891  xpos1, xpos2, dc.GetFontMetrics().ascent + dc.GetFontMetrics().descent);
892  }
893 
894  // Draw the text and the label boxes.
895  { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
896  if(mTextEditIndex == i )
897  dc.SetBrush(AColor::labelTextEditBrush);
898  DrawText( dc, labelStruct, r );
899  if(mTextEditIndex == i )
900  dc.SetBrush(AColor::labelTextNormalBrush);
901  }}
902 
903  // Draw the cursor, if there is one.
905  {
906  const auto &labelStruct = mLabels[mTextEditIndex];
907  int xPos = labelStruct.xText;
908 
909  if( mCurrentCursorPos > 0)
910  {
911  // Calculate the width of the substring and add it to Xpos
912  int partWidth;
913  dc.GetTextExtent(labelStruct.title.Left(mCurrentCursorPos), &partWidth, NULL);
914  xPos += partWidth;
915  }
916 
917  wxPen currentPen = dc.GetPen();
918  const int CursorWidth=2;
919  currentPen.SetWidth(CursorWidth);
920  const auto top = labelStruct.y - (LabelBarHeight + yFrameHeight) / 2 + (yFrameHeight - mFontHeight) / 2 + TextFrameYOffset;
921  AColor::Line(dc,
922  xPos-1, top,
923  xPos-1, top + mFontHeight);
924  currentPen.SetWidth(1);
925  }
926 }

References CalcHighlightXs(), calculateFontHeight(), ThemeBase::Colour(), ComputeLayout(), TrackPanelDrawingContext::dc, TrackArt::DrawBackgroundWithSelection(), DrawBar(), DrawGlyphs(), DrawHighlight(), DrawLines(), DrawText(), DrawTextBox(), anonymous_namespace{LabelTrackView.cpp}::findHit(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), LabelTextHandle::GetTrack(), IsValidIndex(), LabelBarHeight, AColor::labelSelectedBrush, AColor::labelSurroundPen, AColor::labelTextEditBrush, AColor::labelTextNormalBrush, AColor::labelUnselectedBrush, AColor::Line(), mCurrentCursorPos, mFontHeight, mInitialCursorPos, mNavigationIndex, msFont, mTextEditIndex, mTextHeight, TrackPanelDrawingContext::target, TextFramePadding, TextFrameYOffset, theTheme, and AColor::uglyBrush.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Draw() [2/2]

void LabelTrackView::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 928 of file LabelTrackView.cpp.

931 {
932  if ( iPass == TrackArtist::PassTracks )
933  Draw( context, rect );
934  CommonTrackView::Draw( context, rect, iPass );
935 }

References Draw(), TrackPanelDrawable::Draw(), and TrackArtist::PassTracks.

Here is the call graph for this function:

◆ DrawBar()

void LabelTrackView::DrawBar ( wxDC &  dc,
const LabelStruct ls,
const wxRect &  r 
)
staticprivate

Definition at line 665 of file LabelTrackView.cpp.

666 {
667  //If y is positive then it is the center line for the
668  //text we are about to draw.
669  const int xBarShorten = mIconWidth + 4;
670  auto& y = ls.y;
671  if (y == -1)
672  return;
673 
674  auto& x = ls.x;
675  auto& x1 = ls.x1;
676  const int xStart = wxMax(r.x, x + xBarShorten / 2);
677  const int xEnd = wxMin(r.x + r.width, x1 - xBarShorten / 2);
678  const int xWidth = xEnd - xStart;
679 
680  if ((xStart < (r.x + r.width)) && (xEnd > r.x) && (xWidth > 0))
681  {
682  wxRect bar(xStart, y - (LabelBarHeight - GetTextFrameHeight()) / 2,
683  xWidth, LabelBarHeight);
684  if (x1 > x + xBarShorten)
685  dc.DrawRectangle(bar);
686  }
687 }

References GetTextFrameHeight(), LabelBarHeight, mIconWidth, LabelStruct::x, LabelStruct::x1, and LabelStruct::y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawGlyphs()

void LabelTrackView::DrawGlyphs ( wxDC &  dc,
const LabelStruct ls,
const wxRect &  r,
int  GlyphLeft,
int  GlyphRight 
)
staticprivate

DrawGlyphs draws the wxIcons at the start and end of a label.

Parameters
dcthe device context
rthe LabelTrack rectangle.

Definition at line 573 of file LabelTrackView.cpp.

576 {
577  auto &y = ls.y;
578 
579  const int xHalfWidth=mIconWidth/2;
580  const int yStart=y-mIconHeight/2+(mTextHeight+3)/2;
581 
582  // If y == -1, nothing to draw
583  if( y == -1 )
584  return;
585 
586  auto &x = ls.x;
587  auto &x1 = ls.x1;
588 
589  if((x >= r.x) && (x <= (r.x+r.width)))
590  dc.DrawBitmap(GetGlyph(GlyphLeft), x-xHalfWidth,yStart, true);
591  // The extra test commented out here would suppress right hand markers
592  // when they overlap the left hand marker (e.g. zoomed out) or to the left.
593  if((x1 >= r.x) && (x1 <= (r.x+r.width)) /*&& (x1>x+mIconWidth)*/)
594  dc.DrawBitmap(GetGlyph(GlyphRight), x1-xHalfWidth,yStart, true);
595 }

References GetGlyph(), mIconHeight, mIconWidth, mTextHeight, LabelStruct::x, LabelStruct::x1, and LabelStruct::y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawHighlight()

void LabelTrackView::DrawHighlight ( wxDC &  dc,
const LabelStruct ls,
int  xPos1,
int  xPos2,
int  charHeight 
)
staticprivate

Draws text-selected region within the label.

Definition at line 690 of file LabelTrackView.cpp.

692 {
693  const int yFrameHeight = mTextHeight + TextFramePadding * 2;
694 
695  dc.SetPen(*wxTRANSPARENT_PEN);
696  wxBrush curBrush = dc.GetBrush();
697  curBrush.SetColour(wxString(wxT("BLUE")));
698  auto top = ls.y + TextFrameYOffset - (LabelBarHeight + yFrameHeight) / 2 + (yFrameHeight - charHeight) / 2;
699  if (xPos1 < xPos2)
700  dc.DrawRectangle(xPos1-1, top, xPos2-xPos1+1, charHeight);
701  else
702  dc.DrawRectangle(xPos2-1, top, xPos1-xPos2+1, charHeight);
703 }

References LabelBarHeight, mTextHeight, TextFramePadding, TextFrameYOffset, and LabelStruct::y.

Referenced by Draw().

Here is the caller graph for this function:

◆ DrawLines()

void LabelTrackView::DrawLines ( wxDC &  dc,
const LabelStruct ls,
const wxRect &  r 
)
staticprivate

Draw vertical lines that go exactly through the position of the start or end of a label.

Parameters
dcthe device context
rthe LabelTrack rectangle.

Definition at line 522 of file LabelTrackView.cpp.

524 {
525  auto &x = ls.x;
526  auto &x1 = ls.x1;
527  auto &y = ls.y;
528 
529  // Bug 2388 - Point label and range label can appear identical
530  // If the start and end times are not actually the same, but they
531  // would appear so when drawn as lines at current zoom, be sure to draw
532  // two lines - i.e. displace the second line slightly.
533  if (ls.getT0() != ls.getT1()) {
534  if (x == x1)
535  x1++;
536  }
537 
538  // How far out from the centre line should the vertical lines
539  // start, i.e. what is the y position of the icon?
540  // We adjust this so that the line encroaches on the icon
541  // slightly (there is white space in the design).
542  const int yIconStart = y - (mIconHeight /2)+1+(mTextHeight+3)/2;
543  const int yIconEnd = yIconStart + mIconHeight-2;
544 
545  // If y is positive then it is the center line for the
546  // Label.
547  if( y >= 0 )
548  {
549  if((x >= r.x) && (x <= (r.x+r.width)))
550  {
551  // Draw line above and below left dragging widget.
552  AColor::Line(dc, x, r.y, x, yIconStart - 1);
553  AColor::Line(dc, x, yIconEnd, x, r.y + r.height);
554  }
555  if((x1 >= r.x) && (x1 <= (r.x+r.width)))
556  {
557  // Draw line above and below right dragging widget.
558  AColor::Line(dc, x1, r.y, x1, yIconStart - 1);
559  AColor::Line(dc, x1, yIconEnd, x1, r.y + r.height);
560  }
561  }
562  else
563  {
564  // Draw the line, even though the widget is off screen
565  AColor::Line(dc, x, r.y, x, r.y + r.height);
566  AColor::Line(dc, x1, r.y, x1, r.y + r.height);
567  }
568 }

References LabelStruct::getT0(), LabelStruct::getT1(), AColor::Line(), mIconHeight, mTextHeight, LabelStruct::x, LabelStruct::x1, and LabelStruct::y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DrawText()

void LabelTrackView::DrawText ( wxDC &  dc,
const LabelStruct ls,
const wxRect &  r 
)
staticprivate

Draw the text of the label and also draw a long thin rectangle for its full extent from x to x1 and a rectangular frame behind the text itself.

Parameters
dcthe device context
rthe LabelTrack rectangle.

Definition at line 608 of file LabelTrackView.cpp.

609 {
610  const int yFrameHeight = mTextHeight + TextFramePadding * 2;
611  //If y is positive then it is the center line for the
612  //text we are about to draw.
613  //if it isn't, nothing to draw.
614 
615  auto &y = ls.y;
616  if( y == -1 )
617  return;
618 
619  // Draw frame for the text...
620  // We draw it half an icon width left of the text itself.
621  {
622  auto &xText = ls.xText;
623  const int xStart=wxMax(r.x,xText-mIconWidth/2);
624  const int xEnd=wxMin(r.x+r.width,xText+ls.width+mIconWidth/2);
625  const int xWidth = xEnd-xStart;
626 
627  if( (xStart < (r.x+r.width)) && (xEnd > r.x) && (xWidth>0))
628  {
629  // Now draw the text itself.
630  auto pos = y - LabelBarHeight - yFrameHeight + TextFrameYOffset +
631  (yFrameHeight - mFontHeight) / 2 + dc.GetFontMetrics().ascent;
632  dc.DrawText(ls.title, xText, pos);
633  }
634  }
635 
636 }

References LabelBarHeight, mFontHeight, mIconWidth, mTextHeight, TextFramePadding, TextFrameYOffset, LabelStruct::title, LabelStruct::width, LabelStruct::xText, and LabelStruct::y.

Referenced by Draw().

Here is the caller graph for this function:

◆ DrawTextBox()

void LabelTrackView::DrawTextBox ( wxDC &  dc,
const LabelStruct ls,
const wxRect &  r 
)
staticprivate

Definition at line 638 of file LabelTrackView.cpp.

640 {
641  // In drawing the bar and the frame, we compute the clipping
642  // to the viewport ourselves. Under Win98 the GDI does its
643  // calculations in 16 bit arithmetic, and so gets it completely
644  // wrong at higher zooms where the bar can easily be
645  // more than 65536 pixels wide.
646 
647  // Draw bar for label extent...
648  // We don't quite draw from x to x1 because we allow
649  // half an icon width at each end.
650  const auto textFrameHeight = GetTextFrameHeight();
651  auto& xText = ls.xText;
652  const int xStart = wxMax(r.x, xText - mIconWidth / 2);
653  const int xEnd = wxMin(r.x + r.width, xText + ls.width + mIconWidth / 2);
654  const int xWidth = xEnd - xStart;
655 
656  if ((xStart < (r.x + r.width)) && (xEnd > r.x) && (xWidth > 0))
657  {
658  wxRect frame(
659  xStart, ls.y - (textFrameHeight + LabelBarHeight) / 2 + TextFrameYOffset,
660  xWidth, textFrameHeight);
661  dc.DrawRectangle(frame);
662  }
663 }

References GetTextFrameHeight(), LabelBarHeight, mIconWidth, TextFrameYOffset, LabelStruct::width, LabelStruct::xText, and LabelStruct::y.

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindCursorPosition()

int LabelTrackView::FindCursorPosition ( int  labelIndex,
wxCoord  xPos 
)

convert pixel coordinate to character position in text box

uses GetTextExtent to find the character position corresponding to the x pixel position.

Definition at line 939 of file LabelTrackView.cpp.

940 {
941  int result = -1;
942  wxMemoryDC dc;
943  if(msFont.Ok())
944  dc.SetFont(msFont);
945 
946  // A bool indicator to see if set the cursor position or not
947  bool finished = false;
948  int charIndex = 1;
949  int partWidth;
950  int oneWidth;
951  double bound;
952  wxString subString;
953 
954  const auto pTrack = FindLabelTrack();
955  const auto &mLabels = pTrack->GetLabels();
956  const auto &labelStruct = mLabels[labelIndex];
957  const auto &title = labelStruct.title;
958  const int length = title.length();
959  while (!finished && (charIndex < length + 1))
960  {
961  int unichar = (int)title.at( charIndex-1 );
962  if( (0xDC00 <= unichar) && (unichar <= 0xDFFF)){
963  charIndex++;
964  continue;
965  }
966  subString = title.Left(charIndex);
967  // Get the width of substring
968  dc.GetTextExtent(subString, &partWidth, NULL);
969 
970  // Get the width of the last character
971  dc.GetTextExtent(subString.Right(1), &oneWidth, NULL);
972  bound = labelStruct.xText + partWidth - oneWidth * 0.5;
973 
974  if (xPos <= bound)
975  {
976  // Found
977  result = charIndex - 1;
978  finished = true;
979  }
980  else
981  {
982  // Advance
983  charIndex++;
984  }
985  }
986  if (!finished)
987  // Cursor should be in the last position
988  result = length;
989 
990  return result;
991 }

References FindLabelTrack(), msFont, and title.

Here is the call graph for this function:

◆ FindLabelTrack() [1/2]

std::shared_ptr< LabelTrack > LabelTrackView::FindLabelTrack ( )
private

Definition at line 172 of file LabelTrackView.cpp.

173 {
174  return std::static_pointer_cast<LabelTrack>( FindTrack() );
175 }

References CommonTrackPanelCell::FindTrack().

Referenced by AddLabel(), CalcCursorX(), CalcHighlightXs(), Char(), ComputeLayout(), ComputeTextPosition(), CopySelectedText(), CutSelectedText(), DetailedHitTest(), DoCaptureKey(), DoChar(), DoKeyDown(), FindCursorPosition(), FindLabelTrack(), GetLabelIndex(), IsValidIndex(), KeyDown(), OnContextMenu(), PasteSelectedText(), RemoveSelectedText(), Reparent(), and ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FindLabelTrack() [2/2]

std::shared_ptr< const LabelTrack > LabelTrackView::FindLabelTrack ( ) const
private

Definition at line 177 of file LabelTrackView.cpp.

178 {
179  return const_cast<LabelTrackView*>(this)->FindLabelTrack();
180 }

References FindLabelTrack().

Here is the call graph for this function:

◆ Get() [1/2]

const LabelTrackView & LabelTrackView::Get ( const LabelTrack track)
static

Definition at line 167 of file LabelTrackView.cpp.

168 {
169  return static_cast< const LabelTrackView& >( TrackView::Get( track ) );
170 }

References TrackView::Get().

Here is the call graph for this function:

◆ Get() [2/2]

LabelTrackView & LabelTrackView::Get ( LabelTrack track)
static

◆ GetCurrentCursorPosition()

int LabelTrackView::GetCurrentCursorPosition ( ) const
inline

Definition at line 222 of file LabelTrackView.h.

222 { return mCurrentCursorPos; }

◆ GetFont()

wxFont LabelTrackView::GetFont ( const wxString &  faceName,
int  size = DefaultFontSize 
)
static

Definition at line 245 of file LabelTrackView.cpp.

246 {
247  wxFontEncoding encoding;
248  if (faceName.empty())
249  encoding = wxFONTENCODING_DEFAULT;
250  else
251  encoding = wxFONTENCODING_SYSTEM;
252 
253  auto fontInfo = size == 0 ? wxFontInfo() : wxFontInfo(size);
254  fontInfo
255  .Encoding(encoding)
256  .FaceName(faceName);
257 
258  return wxFont(fontInfo);
259 }

References size.

Referenced by LabelTrackMenuTable::OnSetFont(), and ResetFont().

Here is the caller graph for this function:

◆ GetGlyph()

wxBitmap & LabelTrackView::GetGlyph ( int  i)
staticprivate

Definition at line 2143 of file LabelTrackView.cpp.

2144 {
2145  return theTheme.Bitmap( i + bmpLabelGlyph0);
2146 }

References ThemeBase::Bitmap(), and theTheme.

Referenced by DrawGlyphs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetInitialCursorPosition()

int LabelTrackView::GetInitialCursorPosition ( ) const
inline

Definition at line 224 of file LabelTrackView.h.

224 { return mInitialCursorPos; }

◆ GetLabelIndex()

int LabelTrackView::GetLabelIndex ( double  t,
double  t1 
)
private

Definition at line 2034 of file LabelTrackView.cpp.

2035 {
2036  //We'd have liked to have times in terms of samples,
2037  //because then we're doing an intrger comparison.
2038  //Never mind. Instead we look for near enough.
2039  //This level of (in)accuracy is only a problem if we
2040  //deal with sounds in the MHz range.
2041  const double delta = 1.0e-7;
2042  const auto pTrack = FindLabelTrack();
2043  const auto &mLabels = pTrack->GetLabels();
2044  { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
2045  if( fabs( labelStruct.getT0() - t ) > delta )
2046  continue;
2047  if( fabs( labelStruct.getT1() - t1 ) > delta )
2048  continue;
2049  return i;
2050  }}
2051 
2052  return wxNOT_FOUND;
2053 }

References FindLabelTrack().

Referenced by DoCaptureKey().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetNavigationIndex()

int LabelTrackView::GetNavigationIndex ( AudacityProject project) const

Definition at line 1019 of file LabelTrackView.cpp.

1020 {
1021  if (IsValidIndex(mNavigationIndex, project))
1022  return mNavigationIndex;
1023  return -1;
1024 }

References IsValidIndex(), and mNavigationIndex.

Referenced by LabelTrackShifter::HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTextEditIndex()

int LabelTrackView::GetTextEditIndex ( AudacityProject project) const

Definition at line 1003 of file LabelTrackView.cpp.

1004 {
1005  if (IsValidIndex(mTextEditIndex, project))
1006  return mTextEditIndex;
1007  return -1;
1008 }

References IsValidIndex(), and mTextEditIndex.

Referenced by anonymous_namespace{EditMenus.cpp}::DoPasteText().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTextFrameHeight()

int LabelTrackView::GetTextFrameHeight ( )
staticprivate

Definition at line 597 of file LabelTrackView.cpp.

598 {
599  return mTextHeight + TextFramePadding * 2;
600 }

References mTextHeight, and TextFramePadding.

Referenced by DrawBar(), and DrawTextBox().

Here is the caller graph for this function:

◆ IsTextClipSupported()

bool LabelTrackView::IsTextClipSupported ( )
staticprivate
Returns
true if the text data is available in the clipboard, false otherwise

Definition at line 1201 of file LabelTrackView.cpp.

1202 {
1203  return wxTheClipboard->IsSupported(wxDF_UNICODETEXT);
1204 }

Referenced by PasteSelectedText(), and ShowContextMenu().

Here is the caller graph for this function:

◆ IsTextSelected()

bool LabelTrackView::IsTextSelected ( AudacityProject project) const

Definition at line 1055 of file LabelTrackView.cpp.

1056 {
1058 }

References IsValidIndex(), mCurrentCursorPos, mInitialCursorPos, and mTextEditIndex.

Referenced by CopySelectedText(), CutCopyAvailableFlag(), CutSelectedText(), and ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValidIndex()

bool LabelTrackView::IsValidIndex ( const Index index,
AudacityProject project 
) const
private

Definition at line 1044 of file LabelTrackView.cpp.

1045 {
1046  if (index == -1)
1047  return false;
1048  // may make delayed update of mutable mSelIndex after track selection change
1049  auto track = FindLabelTrack();
1050  if (track->GetSelected() || (TrackFocus::Get(project).Get() == track.get()))
1051  return index >= 0 && index < static_cast<int>(track->GetLabels().size());
1052  return false;
1053 }

References FindLabelTrack(), TrackFocus::Get(), and ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get().

Referenced by CalcCursorX(), Char(), DoCaptureKey(), DoChar(), DoKeyDown(), Draw(), GetNavigationIndex(), GetTextEditIndex(), IsTextSelected(), KeyDown(), OnContextMenu(), PasteSelectedText(), and ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ KeyDown()

unsigned LabelTrackView::KeyDown ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1414 of file LabelTrackView.cpp.

1417 {
1418  double bkpSel0 = viewInfo.selectedRegion.t0(),
1419  bkpSel1 = viewInfo.selectedRegion.t1();
1420 
1421  if (IsValidIndex(mTextEditIndex, *project) && !mTextEditIndex.IsModified()) {
1422  const auto pTrack = FindLabelTrack();
1423  const auto &mLabels = pTrack->GetLabels();
1424  auto labelStruct = mLabels[mTextEditIndex];
1425  auto &title = labelStruct.title;
1426  mUndoLabel = title;
1427  }
1428 
1429  // Pass keystroke to labeltrack's handler and add to history if any
1430  // updates were done
1431  if (DoKeyDown( *project, viewInfo.selectedRegion, event )) {
1432  ProjectHistory::Get( *project ).PushState(XO("Modified Label"),
1433  XO("Label Edit"),
1435 
1437  }
1438 
1439  if (!mTextEditIndex.IsModified()) {
1440  mUndoLabel.clear();
1441  }
1442 
1443  // Make sure caret is in view
1444  int x;
1445  if (CalcCursorX( *project, &x ))
1446  ProjectWindow::Get( *project ).ScrollIntoView(x);
1447 
1448  // If selection modified, refresh
1449  // Otherwise, refresh track display if the keystroke was handled
1450  if (bkpSel0 != viewInfo.selectedRegion.t0() ||
1451  bkpSel1 != viewInfo.selectedRegion.t1())
1452  return RefreshCode::RefreshAll;
1453  else if (!event.GetSkipped())
1454  return RefreshCode::RefreshCell;
1455 
1456  return RefreshCode::RefreshNone;
1457 }

References CalcCursorX(), CONSOLIDATE, DoKeyDown(), FindLabelTrack(), ProjectHistory::Get(), ProjectWindow::Get(), LabelTrackView::Index::IsModified(), IsValidIndex(), mTextEditIndex, mUndoLabel, NONE, ProjectHistory::PushState(), RefreshCode::RefreshAll, RefreshCode::RefreshCell, RefreshCode::RefreshNone, ProjectWindow::ScrollIntoView(), ViewInfo::selectedRegion, LabelTrackView::Index::SetModified(), NotifyingSelectedRegion::t0(), NotifyingSelectedRegion::t1(), title, and XO.

Here is the call graph for this function:

◆ OnContextMenu()

void LabelTrackView::OnContextMenu ( AudacityProject project,
wxCommandEvent &  evt 
)
private

Cut selected text if cut menu item is selected

Copy selected text if copy menu item is selected

paste selected text if paste menu item is selected

DELETE selected label

Definition at line 1947 of file LabelTrackView.cpp.

1949 {
1950  auto &selectedRegion = ViewInfo::Get( project ).selectedRegion;
1951 
1952  switch (evt.GetId())
1953  {
1955  case OnCutSelectedTextID:
1956  if (CutSelectedText( project ))
1957  {
1958  ProjectHistory::Get( project ).PushState(XO("Modified Label"),
1959  XO("Label Edit"),
1961  }
1962  break;
1963 
1965  case OnCopySelectedTextID:
1966  CopySelectedText( project );
1967  break;
1968 
1970  case OnPasteSelectedTextID:
1971  if (PasteSelectedText(
1972  project, selectedRegion.t0(), selectedRegion.t1() ))
1973  {
1974  ProjectHistory::Get( project ).PushState(XO("Modified Label"),
1975  XO("Label Edit"),
1977  }
1978  break;
1979 
1981  case OnDeleteSelectedLabelID: {
1982  if (IsValidIndex(mTextEditIndex, project))
1983  {
1984  const auto pTrack = FindLabelTrack();
1985  pTrack->DeleteLabel(mTextEditIndex);
1986  ProjectHistory::Get( project ).PushState(XO("Deleted Label"),
1987  XO("Label Edit"),
1989  }
1990  }
1991  break;
1992 
1993  case OnEditSelectedLabelID: {
1994  // Bug #2571: See above
1995  if (IsValidIndex(mTextEditIndex, project))
1997  }
1998  break;
1999  }
2000 }

References CONSOLIDATE, CopySelectedText(), CutSelectedText(), FindLabelTrack(), ViewInfo::Get(), ProjectHistory::Get(), LabelTrackView::Index::IsModified(), IsValidIndex(), mEditIndex, mTextEditIndex, NONE, OnCopySelectedTextID, OnCutSelectedTextID, OnDeleteSelectedLabelID, OnEditSelectedLabelID, OnPasteSelectedTextID, PasteSelectedText(), ProjectHistory::PushState(), ViewInfo::selectedRegion, and XO.

Referenced by ShowContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnLabelAdded()

void LabelTrackView::OnLabelAdded ( LabelTrackEvent e)
private

Definition at line 2068 of file LabelTrackView.cpp.

2069 {
2070  e.Skip();
2071  if ( e.mpTrack.lock() != FindTrack() )
2072  return;
2073 
2074  const auto &title = e.mTitle;
2075  const auto pos = e.mPresentPosition;
2076 
2078 
2079  // restoreFocus is -2 e.g. from Nyquist label creation, when we should not
2080  // even lose the focus and open the label to edit in the first place.
2081  // -1 means we don't need to restore it to anywhere.
2082  // 0 or above is the track to restore to after editing the label is complete.
2083  if( mRestoreFocus >= -1 )
2084  mTextEditIndex = pos;
2085 
2086  if( mRestoreFocus < 0 )
2087  mRestoreFocus = -2;
2088 }

References CommonTrackPanelCell::FindTrack(), mCurrentCursorPos, mInitialCursorPos, LabelTrackEvent::mPresentPosition, TrackListEvent::mpTrack, mRestoreFocus, mTextEditIndex, LabelTrackEvent::mTitle, and title.

Referenced by BindTo(), and UnbindFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnLabelDeleted()

void LabelTrackView::OnLabelDeleted ( LabelTrackEvent e)
private

Definition at line 2090 of file LabelTrackView.cpp.

2091 {
2092  e.Skip();
2093  if ( e.mpTrack.lock() != FindTrack() )
2094  return;
2095 
2096  auto index = e.mFormerPosition;
2097 
2098  // IF we've deleted the selected label
2099  // THEN set no label selected.
2100  if (mTextEditIndex == index)
2102 
2103  // IF we removed a label before the selected label
2104  // THEN the NEW selected label number is one less.
2105  else if( index < mTextEditIndex)
2106  --mTextEditIndex;//NB: Keep cursor selection region
2107 }

References CommonTrackPanelCell::FindTrack(), LabelTrackEvent::mFormerPosition, TrackListEvent::mpTrack, mTextEditIndex, and ResetTextSelection().

Referenced by BindTo(), and UnbindFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnLabelPermuted()

void LabelTrackView::OnLabelPermuted ( LabelTrackEvent e)
private

Definition at line 2109 of file LabelTrackView.cpp.

2110 {
2111  e.Skip();
2112  if ( e.mpTrack.lock() != FindTrack() )
2113  return;
2114 
2115  auto former = e.mFormerPosition;
2116  auto present = e.mPresentPosition;
2117 
2118  auto fix = [&](Index& index) {
2119  if (index == former)
2120  index = present;
2121  else if (former < index && index <= present)
2122  --index;
2123  else if (former > index && index >= present)
2124  ++index;
2125  };
2126  fix(mNavigationIndex);
2127  fix(mTextEditIndex);
2128 }

References CommonTrackPanelCell::FindTrack(), LabelTrackEvent::mFormerPosition, mNavigationIndex, LabelTrackEvent::mPresentPosition, TrackListEvent::mpTrack, and mTextEditIndex.

Referenced by BindTo(), and UnbindFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnSelectionChange()

void LabelTrackView::OnSelectionChange ( LabelTrackEvent e)
private

Definition at line 2130 of file LabelTrackView.cpp.

2131 {
2132  e.Skip();
2133  if ( e.mpTrack.lock() != FindTrack() )
2134  return;
2135 
2136  if (!FindTrack()->GetSelected())
2137  {
2138  SetNavigationIndex(-1);
2140  }
2141 }

References CommonTrackPanelCell::FindTrack(), TrackListEvent::mpTrack, ResetTextSelection(), and SetNavigationIndex().

Referenced by BindTo(), and UnbindFrom().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

LabelTrackView& LabelTrackView::operator= ( const LabelTrackView )
privatedelete

◆ OverATextBox()

int LabelTrackView::OverATextBox ( const LabelTrack track,
int  xx,
int  yy 
)
static

Definition at line 1277 of file LabelTrackView.cpp.

1278 {
1279  const auto pTrack = &track;
1280  const auto &mLabels = pTrack->GetLabels();
1281  for (int nn = (int)mLabels.size(); nn--;) {
1282  const auto &labelStruct = mLabels[nn];
1283  if ( OverTextBox( &labelStruct, xx, yy ) )
1284  return nn;
1285  }
1286 
1287  return -1;
1288 }

References LabelTrack::GetLabels(), and OverTextBox().

Referenced by LabelTextHandle::HandleTextClick(), LabelTrackShifter::HitTest(), and LabelTextHandle::HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OverGlyph()

void LabelTrackView::OverGlyph ( const LabelTrack track,
LabelTrackHit hit,
int  x,
int  y 
)
static

TODO: Investigate what happens with large numbers of labels, might need a binary search rather than a linear one.

Definition at line 1209 of file LabelTrackView.cpp.

1211 {
1212  //Determine the NEW selection.
1213  int result=0;
1214  const int d1=10; //distance in pixels, used for have we hit drag handle.
1215  const int d2=5; //distance in pixels, used for have we hit drag handle center.
1216 
1217  //If not over a label, reset it
1218  hit.mMouseOverLabelLeft = -1;
1219  hit.mMouseOverLabelRight = -1;
1220  hit.mMouseOverLabel = -1;
1221  hit.mEdge = 0;
1222 
1223  const auto pTrack = &track;
1224  const auto &mLabels = pTrack->GetLabels();
1225  { int i = -1; for (const auto &labelStruct : mLabels) { ++i;
1226  // give text box better priority for selecting
1227  // reset selection state
1228  if (OverTextBox(&labelStruct, x, y))
1229  {
1230  result = 0;
1231  hit.mMouseOverLabel = -1;
1232  hit.mMouseOverLabelLeft = -1;
1233  hit.mMouseOverLabelRight = -1;
1234  break;
1235  }
1236 
1237  //over left or right selection bound
1238  //Check right bound first, since it is drawn after left bound,
1239  //so give it precedence for matching/highlighting.
1240  if( abs(labelStruct.y - (y - (mTextHeight+3)/2)) < d1 &&
1241  abs(labelStruct.x1 - d2 -x) < d1)
1242  {
1243  hit.mMouseOverLabelRight = i;
1244  if(abs(labelStruct.x1 - x) < d2 )
1245  {
1246  result |= 4;
1247  // If left and right co-incident at this resolution, then we drag both.
1248  // We were more stringent about co-incidence here in the past.
1249  if( abs(labelStruct.x1-labelStruct.x) < 5.0 )
1250  {
1251  result |=1;
1252  hit.mMouseOverLabelLeft = i;
1253  }
1254  }
1255  result |= 2;
1256  }
1257  // Use else-if here rather than else to avoid detecting left and right
1258  // of the same label.
1259  else if( abs(labelStruct.y - (y - (mTextHeight+3)/2)) < d1 &&
1260  abs(labelStruct.x + d2 - x) < d1 )
1261  {
1262  hit.mMouseOverLabelLeft = i;
1263  if(abs(labelStruct.x - x) < d2 )
1264  result |= 4;
1265  result |= 1;
1266  }
1267  else if (x >= labelStruct.x && x <= labelStruct.x1 &&
1268  abs(y - (labelStruct.y + mTextHeight / 2)) < d1)
1269  {
1270  hit.mMouseOverLabel = i;
1271  result = 3;
1272  }
1273  }}
1274  hit.mEdge = result;
1275 }

References LabelTrack::GetLabels(), LabelTrackHit::mEdge, LabelTrackHit::mMouseOverLabel, LabelTrackHit::mMouseOverLabelLeft, LabelTrackHit::mMouseOverLabelRight, mTextHeight, and OverTextBox().

Referenced by LabelGlyphHandle::HandleGlyphClick(), and LabelGlyphHandle::HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OverTextBox()

bool LabelTrackView::OverTextBox ( const LabelStruct pLabel,
int  x,
int  y 
)
static

Definition at line 1291 of file LabelTrackView.cpp.

1292 {
1293  if( (pLabel->xText-(mIconWidth/2) < x) &&
1294  (x<pLabel->xText+pLabel->width+(mIconWidth/2)) &&
1295  (abs(pLabel->y-y)<mIconHeight/2))
1296  {
1297  return true;
1298  }
1299  return false;
1300 }

References mIconHeight, mIconWidth, LabelStruct::width, LabelStruct::xText, and LabelStruct::y.

Referenced by LabelTextHandle::Drag(), LabelTextHandle::HandleTextClick(), LabelTextHandle::HandleTextDragRelease(), OverATextBox(), and OverGlyph().

Here is the caller graph for this function:

◆ PasteSelectedText()

bool LabelTrackView::PasteSelectedText ( AudacityProject project,
double  sel0,
double  sel1 
)

Paste the text on the clipboard to text box

Returns
true if mouse is clicked in text box, false otherwise

Definition at line 1149 of file LabelTrackView.cpp.

1151 {
1152  const auto pTrack = FindLabelTrack();
1153 
1154  if (!IsValidIndex(mTextEditIndex, project))
1156 
1157  wxString text, left, right;
1158 
1159  // if text data is available
1160  if (IsTextClipSupported()) {
1161  if (wxTheClipboard->Open()) {
1162  wxTextDataObject data;
1163  wxTheClipboard->GetData(data);
1164  wxTheClipboard->Close();
1165  text = data.GetText();
1166  }
1167 
1168  if (!mTextEditIndex.IsModified()) {
1169  mUndoLabel = text;
1170  }
1171 
1172  // Convert control characters to blanks
1173  for (int i = 0; i < (int)text.length(); i++) {
1174  if (wxIscntrl(text[i])) {
1175  text[i] = wxT(' ');
1176  }
1177  }
1178  }
1179 
1180  const auto &mLabels = pTrack->GetLabels();
1181  auto labelStruct = mLabels[mTextEditIndex];
1182  auto &title = labelStruct.title;
1183  int cur = mCurrentCursorPos, init = mInitialCursorPos;
1184  if (init > cur)
1185  std::swap(init, cur);
1186  left = title.Left(init);
1187  if (cur < (int)title.length())
1188  right = title.Mid(cur);
1189 
1190  title = left + text + right;
1191 
1192  pTrack->SetLabel(mTextEditIndex, labelStruct );
1193 
1194  mInitialCursorPos = mCurrentCursorPos = left.length() + text.length();
1195 
1197  return true;
1198 }

References AddLabel(), FindLabelTrack(), LabelTrackView::Index::IsModified(), IsTextClipSupported(), IsValidIndex(), mCurrentCursorPos, mInitialCursorPos, mTextEditIndex, mUndoLabel, LabelTrackView::Index::SetModified(), SetTextSelection(), anonymous_namespace{NoteTrack.cpp}::swap(), and title.

Referenced by OnContextMenu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RemoveSelectedText()

void LabelTrackView::RemoveSelectedText ( )
private

Definition at line 2002 of file LabelTrackView.cpp.

2003 {
2004  wxString left, right;
2005 
2006  int init = mInitialCursorPos;
2007  int cur = mCurrentCursorPos;
2008  if (init > cur)
2009  std::swap(init, cur);
2010 
2011  const auto pTrack = FindLabelTrack();
2012  const auto &mLabels = pTrack->GetLabels();
2013  auto labelStruct = mLabels[mTextEditIndex];
2014  auto &title = labelStruct.title;
2015 
2016  if (init > 0)
2017  left = title.Left(init);
2018 
2019  if (cur < (int)title.length())
2020  right = title.Mid(cur);
2021 
2022  title = left + right;
2023  pTrack->SetLabel( mTextEditIndex, labelStruct );
2024  mInitialCursorPos = mCurrentCursorPos = left.length();
2025 }

References FindLabelTrack(), mCurrentCursorPos, mInitialCursorPos, mTextEditIndex, anonymous_namespace{NoteTrack.cpp}::swap(), and title.

Referenced by DoChar(), and DoKeyDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Reparent()

void LabelTrackView::Reparent ( const std::shared_ptr< Track > &  parent)
overrideprivatevirtual

Reimplemented from CommonTrackCell.

Definition at line 113 of file LabelTrackView.cpp.

114 {
115  auto oldParent = FindLabelTrack();
116  auto newParent = track_cast<LabelTrack*>(parent.get());
117  if (oldParent.get() != newParent) {
118  UnbindFrom( oldParent.get() );
119  BindTo( newParent );
120  }
121  CommonTrackView::Reparent( parent );
122 }

References BindTo(), FindLabelTrack(), CommonTrackCell::Reparent(), and UnbindFrom().

Here is the call graph for this function:

◆ ResetFlags()

void LabelTrackView::ResetFlags ( )

Definition at line 221 of file LabelTrackView.cpp.

222 {
223  mInitialCursorPos = 1;
224  mCurrentCursorPos = 1;
225  mTextEditIndex = -1;
226  mNavigationIndex = -1;
227 }

References mCurrentCursorPos, mInitialCursorPos, mNavigationIndex, and mTextEditIndex.

◆ ResetFont()

void LabelTrackView::ResetFont ( )
static

Definition at line 261 of file LabelTrackView.cpp.

262 {
263  mFontHeight = -1;
264  wxString facename = gPrefs->Read(wxT("/GUI/LabelFontFacename"), wxT(""));
265  int size = gPrefs->Read(wxT("/GUI/LabelFontSize"), DefaultFontSize);
266  msFont = GetFont(facename, size);
267 }

References DefaultFontSize, GetFont(), gPrefs, mFontHeight, msFont, and size.

Referenced by LabelTrackMenuTable::OnSetFont().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ResetTextSelection()

void LabelTrackView::ResetTextSelection ( )

Definition at line 1009 of file LabelTrackView.cpp.

1010 {
1011  mTextEditIndex = -1;
1012  mCurrentCursorPos = 1;
1013  mInitialCursorPos = 1;
1014 }

References mCurrentCursorPos, mInitialCursorPos, and mTextEditIndex.

Referenced by DoKeyDown(), OnLabelDeleted(), LabelEditActions::Handler::OnPasteNewLabel(), OnSelectionChange(), and LabelDialog::TransferDataFromWindow().

Here is the caller graph for this function:

◆ RestoreFlags()

void LabelTrackView::RestoreFlags ( const Flags flags)

Definition at line 237 of file LabelTrackView.cpp.

238 {
239  mInitialCursorPos = flags.mInitialCursorPos;
240  mCurrentCursorPos = flags.mCurrentCursorPos;
241  mNavigationIndex = flags.mNavigationIndex;
242  mTextEditIndex = flags.mTextEditIndex;
243 }

References LabelTrackView::Flags::mCurrentCursorPos, mCurrentCursorPos, LabelTrackView::Flags::mInitialCursorPos, mInitialCursorPos, LabelTrackView::Flags::mNavigationIndex, mNavigationIndex, LabelTrackView::Flags::mTextEditIndex, and mTextEditIndex.

◆ SaveFlags()

LabelTrackView::Flags LabelTrackView::SaveFlags ( ) const

Definition at line 229 of file LabelTrackView.cpp.

230 {
231  return {
234  };
235 }

References mCurrentCursorPos, mInitialCursorPos, mNavigationIndex, mTextEditIndex, and mUndoLabel.

◆ SetCurrentCursorPosition()

void LabelTrackView::SetCurrentCursorPosition ( int  pos)

Definition at line 993 of file LabelTrackView.cpp.

994 {
995  mCurrentCursorPos = pos;
996 }

References mCurrentCursorPos.

◆ SetNavigationIndex()

void LabelTrackView::SetNavigationIndex ( int  index)

Definition at line 1015 of file LabelTrackView.cpp.

1016 {
1017  mNavigationIndex = index;
1018 }

References mNavigationIndex.

Referenced by DoKeyDown(), and OnSelectionChange().

Here is the caller graph for this function:

◆ SetTextSelection()

void LabelTrackView::SetTextSelection ( int  labelIndex,
int  start = 1,
int  end = 1 
)

Sets the label with specified index for editing, optionaly selection may be specified with [start, end]

Definition at line 997 of file LabelTrackView.cpp.

998 {
999  mTextEditIndex = labelIndex;
1000  mInitialCursorPos = start;
1001  mCurrentCursorPos = end;
1002 }

References mCurrentCursorPos, mInitialCursorPos, and mTextEditIndex.

Referenced by DoKeyDown(), and PasteSelectedText().

Here is the caller graph for this function:

◆ ShowContextMenu()

void LabelTrackView::ShowContextMenu ( AudacityProject project)

Definition at line 1884 of file LabelTrackView.cpp.

1885 {
1886  wxWindow *parent = wxWindow::FindFocus();
1887 
1888  // Bug 2044. parent can be nullptr after a context switch.
1889  if( !parent )
1890  parent = &GetProjectFrame( project );
1891 
1892  if( parent )
1893  {
1894  wxMenu menu;
1895  menu.Bind(wxEVT_MENU,
1896  [this, &project]( wxCommandEvent &event ){
1897  OnContextMenu( project, event ); }
1898  );
1899 
1900  menu.Append(OnCutSelectedTextID, _("Cu&t Label text"));
1901  menu.Append(OnCopySelectedTextID, _("&Copy Label text"));
1902  menu.Append(OnPasteSelectedTextID, _("&Paste"));
1903  menu.Append(OnDeleteSelectedLabelID, _("&Delete Label"));
1904  menu.Append(OnEditSelectedLabelID, _("&Edit Label..."));
1905 
1906  menu.Enable(OnCutSelectedTextID, IsTextSelected( project ));
1907  menu.Enable(OnCopySelectedTextID, IsTextSelected( project ));
1909  menu.Enable(OnDeleteSelectedLabelID, true);
1910  menu.Enable(OnEditSelectedLabelID, true);
1911 
1912  if(!IsValidIndex(mTextEditIndex, project)) {
1913  return;
1914  }
1915 
1916  const auto pTrack = FindLabelTrack();
1917  const LabelStruct *ls = pTrack->GetLabel(mTextEditIndex);
1918 
1919  wxClientDC dc(parent);
1920 
1921  if (msFont.Ok())
1922  {
1923  dc.SetFont(msFont);
1924  }
1925 
1926  int x = 0;
1927  bool success = CalcCursorX( project, &x );
1928  wxASSERT(success);
1929  static_cast<void>(success); // Suppress unused variable warning if debug mode is disabled
1930 
1931  // Bug #2571: Hackage alert! For some reason wxGTK does not like
1932  // displaying the LabelDialog from within the PopupMenu "context".
1933  // So, workaround it by editing the label AFTER the popup menu is
1934  // closed. It's really ugly, but it works. :-(
1935  mEditIndex = -1;
1936  BasicMenu::Handle{ &menu }.Popup(
1937  wxWidgetsWindowPlacement{ parent },
1938  { x, ls->y + (mIconHeight / 2) - 1 }
1939  );
1940  if (mEditIndex >= 0)
1941  {
1942  DoEditLabels( project, FindLabelTrack().get(), mEditIndex );
1943  }
1944  }
1945 }

References _, CalcCursorX(), DoEditLabels(), FindLabelTrack(), GetProjectFrame(), IsTextClipSupported(), IsTextSelected(), IsValidIndex(), mEditIndex, mIconHeight, msFont, mTextEditIndex, OnContextMenu(), OnCopySelectedTextID, OnCutSelectedTextID, OnDeleteSelectedLabelID, OnEditSelectedLabelID, OnPasteSelectedTextID, BasicMenu::Handle::Popup(), and LabelStruct::y.

Referenced by DoKeyDown().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ UnbindFrom()

void LabelTrackView::UnbindFrom ( LabelTrack pParent)
private

Definition at line 136 of file LabelTrackView.cpp.

137 {
138  pParent->Unbind(
139  EVT_LABELTRACK_ADDITION, &LabelTrackView::OnLabelAdded, this );
140  pParent->Unbind(
141  EVT_LABELTRACK_DELETION, &LabelTrackView::OnLabelDeleted, this );
142  pParent->Unbind(
143  EVT_LABELTRACK_PERMUTED, &LabelTrackView::OnLabelPermuted, this );
144  pParent->Unbind(
145  EVT_LABELTRACK_SELECTION, &LabelTrackView::OnSelectionChange, this );
146 }

References OnLabelAdded(), OnLabelDeleted(), OnLabelPermuted(), and OnSelectionChange().

Referenced by Reparent().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ LabelBarHeight

constexpr int LabelTrackView::LabelBarHeight { 6 }
staticconstexpr

Definition at line 50 of file LabelTrackView.h.

Referenced by Draw(), DrawBar(), DrawHighlight(), DrawText(), and DrawTextBox().

◆ mbGlyphsReady

bool LabelTrackView::mbGlyphsReady =false
staticprivate

Definition at line 196 of file LabelTrackView.h.

Referenced by CreateCustomGlyphs().

◆ mBoundaryGlyphs

wxBitmap LabelTrackView::mBoundaryGlyphs
staticprivate

We have several variants of the icons (highlighting). The icons are draggable, and you can drag one boundary or all boundaries at the same timecode depending on whether you click the centre (for all) or the arrow part (for one). Currently we have twelve variants but we're only using six.

Definition at line 197 of file LabelTrackView.h.

Referenced by CreateCustomGlyphs().

◆ mCurrentCursorPos

int LabelTrackView::mCurrentCursorPos
mutableprivate

◆ mEditIndex

int LabelTrackView::mEditIndex
private

Definition at line 263 of file LabelTrackView.h.

Referenced by OnContextMenu(), and ShowContextMenu().

◆ mFontHeight

int LabelTrackView::mFontHeight =-1
staticprivate

Definition at line 199 of file LabelTrackView.h.

Referenced by calculateFontHeight(), Draw(), DrawText(), and ResetFont().

◆ mGlyphHandle

std::weak_ptr<LabelGlyphHandle> LabelTrackView::mGlyphHandle
private

Definition at line 257 of file LabelTrackView.h.

Referenced by DetailedHitTest().

◆ mIconHeight

int LabelTrackView::mIconHeight
staticprivate

◆ mIconWidth

int LabelTrackView::mIconWidth
staticprivate

◆ mInitialCursorPos

int LabelTrackView::mInitialCursorPos
mutableprivate

◆ mNavigationIndex

Index LabelTrackView::mNavigationIndex { -1 }
mutableprivate

Keeps track of the currently selected label (not same as selection region) used for navigation between labels

Definition at line 186 of file LabelTrackView.h.

Referenced by CopyTo(), DoKeyDown(), Draw(), GetNavigationIndex(), OnLabelPermuted(), ResetFlags(), RestoreFlags(), SaveFlags(), and SetNavigationIndex().

◆ mRestoreFocus

int LabelTrackView::mRestoreFocus {-2}
private

initial cursor position

Definition at line 204 of file LabelTrackView.h.

Referenced by AddLabel(), DoKeyDown(), and OnLabelAdded().

◆ msFont

wxFont LabelTrackView::msFont
staticprivate

◆ mTextEditIndex

Index LabelTrackView::mTextEditIndex { -1 }
mutableprivate

◆ mTextHandle

std::weak_ptr<LabelTextHandle> LabelTrackView::mTextHandle
private

Definition at line 258 of file LabelTrackView.h.

Referenced by DetailedHitTest().

◆ mTextHeight

int LabelTrackView::mTextHeight
staticprivate

◆ mUndoLabel

wxString LabelTrackView::mUndoLabel
mutableprivate

◆ TextFramePadding

constexpr int LabelTrackView::TextFramePadding { 2 }
staticconstexpr

Definition at line 48 of file LabelTrackView.h.

Referenced by Draw(), DrawHighlight(), DrawText(), and GetTextFrameHeight().

◆ TextFrameYOffset

constexpr int LabelTrackView::TextFrameYOffset { -1 }
staticconstexpr

Definition at line 49 of file LabelTrackView.h.

Referenced by Draw(), DrawHighlight(), DrawText(), and DrawTextBox().


The documentation for this class was generated from the following files:
size
size_t size
Definition: ffmpeg-2.3.6-single-header.h:412
LabelTrackView::OnLabelPermuted
void OnLabelPermuted(LabelTrackEvent &)
Definition: LabelTrackView.cpp:2109
LabelStruct::x1
int x1
Pixel position of left hand glyph.
Definition: LabelTrack.h:76
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:241
IsGoodLabelEditKey
static bool IsGoodLabelEditKey(const wxKeyEvent &evt)
This returns true for keys we capture for label editing.
Definition: LabelTrackView.cpp:1317
LabelTrackView::DrawGlyphs
static void DrawGlyphs(wxDC &dc, const LabelStruct &ls, const wxRect &r, int GlyphLeft, int GlyphRight)
Definition: LabelTrackView.cpp:573
LabelTextHandle
Definition: LabelTextHandle.h:24
LabelTrackView::ResetFlags
void ResetFlags()
Definition: LabelTrackView.cpp:221
LabelTrackView::mGlyphHandle
std::weak_ptr< LabelGlyphHandle > mGlyphHandle
Definition: LabelTrackView.h:257
CommonTrackView
Definition: CommonTrackView.h:20
AColor::labelUnselectedBrush
static wxBrush labelUnselectedBrush
Definition: AColor.h:110
LabelTrackView::IsTextClipSupported
static bool IsTextClipSupported()
Definition: LabelTrackView.cpp:1201
LabelTrackView::ComputeTextPosition
void ComputeTextPosition(const wxRect &r, int index) const
Definition: LabelTrackView.cpp:282
LabelTrackView::CopySelectedText
bool CopySelectedText(AudacityProject &project)
Definition: LabelTrackView.cpp:1115
LabelDialog
Dialog for editing labels.
Definition: LabelDialog.h:36
LabelTrackView::CalcCursorX
bool CalcCursorX(AudacityProject &project, int *x) const
Definition: LabelTrackView.cpp:719
LabelTrackView::mCurrentCursorPos
int mCurrentCursorPos
Definition: LabelTrackView.h:200
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
LabelStruct::width
int width
Text of the label.
Definition: LabelTrack.h:72
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
LabelStruct::title
wxString title
Definition: LabelTrack.h:71
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
LabelStruct::x
int x
width of the text in pixels.
Definition: LabelTrack.h:75
LabelTrackView::CreateCustomGlyphs
void CreateCustomGlyphs()
Definition: LabelTrackView.cpp:2203
LabelTrackView::mTextEditIndex
Index mTextEditIndex
Index of the current label text beeing edited.
Definition: LabelTrackView.h:188
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
LabelTrackView::mTextHeight
static int mTextHeight
Definition: LabelTrackView.h:194
ClientData::Site::Get
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
NUM_GLYPH_HIGHLIGHTS
constexpr int NUM_GLYPH_HIGHLIGHTS
Definition: LabelTrackView.h:34
LabelTrackView::FindLabelTrack
std::shared_ptr< LabelTrack > FindLabelTrack()
Definition: LabelTrackView.cpp:172
AudacityTextEntryDialog
Wrap wxTextEntryDialog so that caption IS translatable.
Definition: AudacityTextEntryDialog.h:23
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
LabelTrackView::mIconHeight
static int mIconHeight
Definition: LabelTrackView.h:192
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:109
LabelTrackView::SetTextSelection
void SetTextSelection(int labelIndex, int start=1, int end=1)
Definition: LabelTrackView.cpp:997
LabelTrackView::DrawTextBox
static void DrawTextBox(wxDC &dc, const LabelStruct &ls, const wxRect &r)
Definition: LabelTrackView.cpp:638
LabelTrackView::DrawLines
static void DrawLines(wxDC &dc, const LabelStruct &ls, const wxRect &r)
Definition: LabelTrackView.cpp:522
LabelTrackEvent::mFormerPosition
int mFormerPosition
Definition: LabelTrack.h:207
LabelTrackView::Index::SetModified
void SetModified(bool modified)
Definition: LabelTrackView.cpp:92
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
UndoPush::NONE
@ NONE
XO
#define XO(s)
Definition: Internat.h:31
LabelTrackView::GetFont
static wxFont GetFont(const wxString &faceName, int size=DefaultFontSize)
Definition: LabelTrackView.cpp:245
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:44
AColor::uglyBrush
static wxBrush uglyBrush
Definition: AColor.h:131
LabelTrackView::msFont
static wxFont msFont
Definition: LabelTrackView.h:260
LabelTrackView::mRestoreFocus
int mRestoreFocus
initial cursor position
Definition: LabelTrackView.h:204
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
LabelGlyphHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< LabelGlyphHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect)
Definition: LabelGlyphHandle.cpp:91
OnPasteSelectedTextID
@ OnPasteSelectedTextID
Definition: LabelTrackView.cpp:1879
GlyphXpmRegionSpec
static const char *const GlyphXpmRegionSpec[]
Definition: LabelTrackView.cpp:2151
anonymous_namespace{LabelTrackView.cpp}::getXPos
void getXPos(const LabelStruct &ls, wxDC &dc, int *xPos1, int cursorPos)
Definition: LabelTrackView.cpp:706
LabelTrackView::ComputeLayout
void ComputeLayout(const wxRect &r, const ZoomInfo &zoomInfo) const
Definition: LabelTrackView.cpp:429
LabelTrackView::TextFramePadding
static constexpr int TextFramePadding
Definition: LabelTrackView.h:48
NUM_GLYPH_CONFIGS
constexpr int NUM_GLYPH_CONFIGS
Definition: LabelTrackView.h:33
LabelTrackView::OverTextBox
static bool OverTextBox(const LabelStruct *pLabel, int x, int y)
Definition: LabelTrackView.cpp:1291
LabelTrackEvent::mPresentPosition
int mPresentPosition
Definition: LabelTrack.h:210
LabelTrackView::PasteSelectedText
bool PasteSelectedText(AudacityProject &project, double sel0, double sel1)
Definition: LabelTrackView.cpp:1149
LabelStruct
A LabelStruct holds information for ONE label in a LabelTrack.
Definition: LabelTrack.h:30
ZoomInfo::TimeToPosition
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ZoomInfo.cpp:49
LabelTrackView::mbGlyphsReady
static bool mbGlyphsReady
Definition: LabelTrackView.h:196
LabelTrackView::mIconWidth
static int mIconWidth
Definition: LabelTrackView.h:193
LabelTrackHit::mEdge
int mEdge
Definition: LabelGlyphHandle.h:37
NotifyingSelectedRegion::t1
double t1() const
Definition: ViewInfo.h:48
wxWidgetsWindowPlacement
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.
Definition: wxWidgetsWindowPlacement.h:22
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1209
LabelTrackView::calculateFontHeight
static void calculateFontHeight(wxDC &dc)
Definition: LabelTrackView.cpp:1026
AColor::labelTextEditBrush
static wxBrush labelTextEditBrush
Definition: AColor.h:109
LabelTrackView::BindTo
void BindTo(LabelTrack *pParent)
Definition: LabelTrackView.cpp:124
LabelTextHandle::GetTrack
std::shared_ptr< LabelTrack > GetTrack() const
Definition: LabelTextHandle.h:38
LabelStruct::y
int y
Pixel position of left hand side of text box.
Definition: LabelTrack.h:78
ProjectWindow::ScrollIntoView
void ScrollIntoView(double pos)
Definition: ProjectWindow.cpp:786
LabelTrackView
Definition: LabelTrackView.h:40
ViewInfo::selectedRegion
NotifyingSelectedRegion selectedRegion
Definition: ViewInfo.h:229
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
LabelTextHandle::HitTest
static UIHandlePtr HitTest(std::weak_ptr< LabelTextHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT)
Definition: LabelTextHandle.cpp:53
LabelTrackView::GetTextFrameHeight
static int GetTextFrameHeight()
Definition: LabelTrackView.cpp:597
LabelTrackView::mFontHeight
static int mFontHeight
Definition: LabelTrackView.h:199
LabelTrackView::CutSelectedText
bool CutSelectedText(AudacityProject &project)
Definition: LabelTrackView.cpp:1062
LabelStruct::getT0
double getT0() const
Definition: LabelTrack.h:40
LabelTrackView::mBoundaryGlyphs
static wxBitmap mBoundaryGlyphs[NUM_GLYPH_CONFIGS *NUM_GLYPH_HIGHLIGHTS]
Definition: LabelTrackView.h:197
LabelTrackView::DefaultFontSize
@ DefaultFontSize
Definition: LabelTrackView.h:47
LabelTrackView::OnLabelDeleted
void OnLabelDeleted(LabelTrackEvent &)
Definition: LabelTrackView.cpp:2090
LabelTrackView::mEditIndex
int mEditIndex
Definition: LabelTrackView.h:263
LabelTrackView::OnSelectionChange
void OnSelectionChange(LabelTrackEvent &)
Definition: LabelTrackView.cpp:2130
AColor::labelSelectedBrush
static wxBrush labelSelectedBrush
Definition: AColor.h:111
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
LabelTrack::GetLabels
const LabelArray & GetLabels() const
Definition: LabelTrack.h:130
LabelTrackHit::mMouseOverLabelRight
int mMouseOverLabelRight
Keeps track of which left label the mouse is currently over.
Definition: LabelGlyphHandle.h:41
LabelTrackEvent::mTitle
wxString mTitle
Definition: LabelTrack.h:204
format
int format
Definition: ExportPCM.cpp:56
AudioIOBase::Get
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:89
LabelTrackView::ShowContextMenu
void ShowContextMenu(AudacityProject &project)
Definition: LabelTrackView.cpp:1884
LabelTrackView::UnbindFrom
void UnbindFrom(LabelTrack *pParent)
Definition: LabelTrackView.cpp:136
LabelTrackHit::mMouseOverLabel
int mMouseOverLabel
Definition: LabelGlyphHandle.h:39
TrackFocus::Get
Track * Get()
Definition: TrackPanelAx.cpp:755
LabelTrackView::Index::IsModified
bool IsModified() const
Definition: LabelTrackView.cpp:87
anonymous_namespace{NoteTrack.cpp}::swap
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:735
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
RefreshCode::RefreshCell
@ RefreshCell
Definition: RefreshCode.h:24
LabelTrackView::Draw
void Draw(TrackPanelDrawingContext &context, const wxRect &r) const
Definition: LabelTrackView.cpp:786
theTheme
THEME_API Theme theTheme
Definition: Theme.cpp:79
LabelTrackView::mUndoLabel
wxString mUndoLabel
Definition: LabelTrackView.h:190
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
ProjectHistory::PushState
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
Definition: ProjectHistory.cpp:90
LabelTrackView::GetGlyph
static wxBitmap & GetGlyph(int i)
Definition: LabelTrackView.cpp:2143
SelectedRegion::t0
double t0() const
Definition: SelectedRegion.h:91
LabelTrackView::mInitialCursorPos
int mInitialCursorPos
current cursor position
Definition: LabelTrackView.h:201
title
static const auto title
Definition: NoUpdatesAvailableDialog.cpp:22
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:528
LabelTrackView::ResetFont
static void ResetFont()
Definition: LabelTrackView.cpp:261
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
anonymous_namespace{LabelTrackView.cpp}::findHit
LabelTrackHit * findHit(TrackPanel *pPanel)
Definition: LabelTrackView.cpp:763
LabelTrackView::DoEditLabels
static void DoEditLabels(AudacityProject &project, LabelTrack *lt=nullptr, int index=-1)
Definition: LabelTrackView.cpp:2254
_
#define _(s)
Definition: Internat.h:75
LabelTrackView::DoChar
bool DoChar(AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
Definition: LabelTrackView.cpp:1780
LabelTrackView::TextFrameYOffset
static constexpr int TextFrameYOffset
Definition: LabelTrackView.h:49
LabelTrackView::OnContextMenu
void OnContextMenu(AudacityProject &project, wxCommandEvent &evt)
Definition: LabelTrackView.cpp:1947
AColor::labelTextNormalBrush
static wxBrush labelTextNormalBrush
Definition: AColor.h:108
OnDeleteSelectedLabelID
@ OnDeleteSelectedLabelID
Definition: LabelTrackView.cpp:1880
LabelTrackView::DrawHighlight
static void DrawHighlight(wxDC &dc, const LabelStruct &ls, int xPos1, int xPos2, int charHeight)
Draws text-selected region within the label.
Definition: LabelTrackView.cpp:690
GetProjectFrame
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 ...
Definition: ProjectWindows.cpp:72
LabelTrackView::mNavigationIndex
Index mNavigationIndex
Definition: LabelTrackView.h:186
LabelTrackView::RemoveSelectedText
void RemoveSelectedText()
Definition: LabelTrackView.cpp:2002
TrackView::CopyTo
void CopyTo(Track &track) const override
Definition: TrackView.cpp:52
TrackPanelDrawingContext::target
UIHandlePtr target
Definition: TrackPanelDrawingContext.h:24
UndoPush::CONSOLIDATE
@ CONSOLIDATE
LabelTrackView::LabelBarHeight
static constexpr int LabelBarHeight
Definition: LabelTrackView.h:50
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1189
CommonTrackCell::Reparent
virtual void Reparent(const std::shared_ptr< Track > &parent)
Definition: CommonTrackPanelCell.cpp:142
OnCutSelectedTextID
@ OnCutSelectedTextID
Definition: LabelTrackView.cpp:1877
LabelTrackView::mTextHandle
std::weak_ptr< LabelTextHandle > mTextHandle
Definition: LabelTrackView.h:258
TrackArtist::PassTracks
@ PassTracks
Definition: TrackArtist.h:81
LabelTrackView::DoKeyDown
bool DoKeyDown(AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
KeyEvent is called for every keypress when over the label track.
Definition: LabelTrackView.cpp:1499
LabelTrackView::CalcHighlightXs
void CalcHighlightXs(int *x1, int *x2) const
Definition: LabelTrackView.cpp:739
LabelTrackView::SetNavigationIndex
void SetNavigationIndex(int index)
Definition: LabelTrackView.cpp:1015
LabelTrackView::DialogForLabelName
static int DialogForLabelName(AudacityProject &project, const SelectedRegion &region, const wxString &initialValue, wxString &value)
Definition: LabelTrackView.cpp:2278
LabelTrackView::IsValidIndex
bool IsValidIndex(const Index &index, AudacityProject &project) const
Definition: LabelTrackView.cpp:1044
NotifyingSelectedRegion::t0
double t0() const
Definition: ViewInfo.h:47
LabelTrackView::DoCaptureKey
bool DoCaptureKey(AudacityProject &project, wxKeyEvent &event)
Definition: LabelTrackView.cpp:1338
OnEditSelectedLabelID
@ OnEditSelectedLabelID
Definition: LabelTrackView.cpp:1881
TrackListEvent::mpTrack
std::weak_ptr< Track > mpTrack
Definition: Track.h:1238
TrackList::Any
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1371
safenew
#define safenew
Definition: MemoryX.h:10
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
LabelTrackHit::mMouseOverLabelLeft
int mMouseOverLabelLeft
Keeps track of which (ranged) label the mouse is currently over.
Definition: LabelGlyphHandle.h:40
LabelTrackView::DrawBar
static void DrawBar(wxDC &dc, const LabelStruct &ls, const wxRect &r)
Definition: LabelTrackView.cpp:665
BasicMenu::Handle::Popup
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
Definition: BasicMenu.cpp:207
LabelStruct::xText
int xText
Pixel position of right hand glyph.
Definition: LabelTrack.h:77
IsGoodLabelFirstKey
static bool IsGoodLabelFirstKey(const wxKeyEvent &evt)
Returns true for keys we capture to start a label.
Definition: LabelTrackView.cpp:1303
LabelTrackView::OnLabelAdded
void OnLabelAdded(LabelTrackEvent &)
Definition: LabelTrackView.cpp:2068
LabelTrackView::DrawText
static void DrawText(wxDC &dc, const LabelStruct &ls, const wxRect &r)
Definition: LabelTrackView.cpp:608
OnCopySelectedTextID
@ OnCopySelectedTextID
Definition: LabelTrackView.cpp:1878
MAX_NUM_ROWS
constexpr int MAX_NUM_ROWS
Definition: LabelTrackView.h:35
LabelTrackView::AddLabel
int AddLabel(const SelectedRegion &region, const wxString &title={}, int restoreFocus=-1)
Definition: LabelTrackView.cpp:2059
LabelStruct::getT1
double getT1() const
Definition: LabelTrack.h:41
LabelTrackView::GetLabelIndex
int GetLabelIndex(double t, double t1)
Definition: LabelTrackView.cpp:2034
LabelTrackView::IsTextSelected
bool IsTextSelected(AudacityProject &project) const
Definition: LabelTrackView.cpp:1055
TrackPanelMouseState::state
wxMouseState & state
Definition: TrackPanelMouseEvent.h:38
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
LabelTrackView::ResetTextSelection
void ResetTextSelection()
Definition: LabelTrackView.cpp:1009
AColor::labelSurroundPen
static wxPen labelSurroundPen
Definition: AColor.h:116
BasicMenu::Handle
Definition: BasicMenu.h:26
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:35
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17