21#include "../../../widgets/BasicMenu.h"
23#include "../../../HitTestResult.h"
29#include "../../../ProjectWindows.h"
30#include "../../../RefreshCode.h"
33#include "../../../TrackArt.h"
34#include "../../../TrackArtist.h"
36#include "../../../TrackPanel.h"
37#include "../../../TrackPanelMouseEvent.h"
44#include <wx/clipbrd.h>
45#include <wx/dcclient.h>
64 if (index != mIndex) {
85LabelTrackView::Index::operator int()
const
109 BindTo( pLabelTrack.get() );
117 const std::shared_ptr<Track> &parent,
size_t iChannel)
121 auto newParent = track_cast<LabelTrack*>(parent.get());
122 if (oldParent.get() != newParent)
132 case LabelTrackEvent::Addition:
133 return OnLabelAdded(e);
134 case LabelTrackEvent::Deletion:
135 return OnLabelDeleted(e);
136 case LabelTrackEvent::Permutation:
137 return OnLabelPermuted(e);
138 case LabelTrackEvent::Selection:
139 return OnSelectionChange(e);
151 if (
const auto pOther =
dynamic_cast<const LabelTrackView*
>(&other)) {
172 return FindChannel<LabelTrack>();
185 std::vector<UIHandlePtr> results;
186 const wxMouseState &state = st.
state;
192 results.push_back(result);
197 results.push_back(result);
245 wxFontEncoding encoding;
246 if (faceName.empty())
247 encoding = wxFONTENCODING_DEFAULT;
249 encoding = wxFONTENCODING_SYSTEM;
251 auto fontInfo =
size == 0 ? wxFontInfo() : wxFontInfo(
size);
256 return wxFont(fontInfo);
283 const auto &mLabels = pTrack->GetLabels();
285 const auto &labelStruct = mLabels[index];
290 int x = labelStruct.x;
291 int x1 = labelStruct.x1;
292 int width = labelStruct.width;
297 bool bTooWideForScreen = width > (r.width-2*xExtra);
299 bool bSimpleCentering =
false;
317 if( bSimpleCentering )
320 xText = (x+x1-width)/2;
329 int rx0,rx1,xText0,xText1;
334 if( bTooWideForScreen )
339 xText1=x1-(width+xExtra);
344 rx0=x-r.width+width+2*xExtra;
348 rx1=x1-(width+2*xExtra);
350 xText1=x1-(width+xExtra);
365 xText = xText0 + (int)((xText1-xText0)*(((float)(r.x-rx0))/(rx1-rx0)));
376 xText = (x+x1-width)/2;
381 bool bOffLeft = xText < r.x+xExtra;
382 bool bOffRight = xText > r.x+r.width-width-xExtra;
386 if( bOffLeft == bOffRight )
394 else if( bOffLeft != bTooWideForScreen)
406 xText =r.x+r.width-width-xExtra;
416 if( xText > (x1-width-xExtra))
417 xText=(x1-width-xExtra);
418 if( xText < x+xExtra )
421 labelStruct.xText = xText;
442 const int nRows = wxMin((r.height / yRowHeight) + 1,
MAX_NUM_ROWS);
448 const int xStart = INT_MIN;
449 for (
auto &x : xUsed)
455 const auto &mLabels = pTrack->GetLabels();
457 {
int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
468 while( (iRow<nRowsUsed) && (xUsed[iRow] != x ))
473 if( iRow >= nRowsUsed )
476 while( (iRow<nRows) && (xUsed[iRow] > x ))
483 if( iRow >= nRowsUsed )
486 y= r.y + iRow * yRowHeight +(yRowHeight/2)+1;
491 xUsed[iRow]=x+labelStruct.width+xExtra;
492 if( xUsed[iRow] < x1 ) xUsed[iRow]=x1;
503 wxDC & dc,
const LabelStruct &ls,
const wxRect & r)
529 if((x >= r.x) && (x <= (r.x+r.width)))
535 if((x1 >= r.x) && (x1 <= (r.x+r.width)))
554 wxDC & dc,
const LabelStruct &ls,
const wxRect & r,
555 int GlyphLeft,
int GlyphRight)
569 if((x >= r.x) && (x <= (r.x+r.width)))
570 dc.DrawBitmap(
GetGlyph(GlyphLeft), x-xHalfWidth,yStart,
true);
573 if((x1 >= r.x) && (x1 <= (r.x+r.width)) )
574 dc.DrawBitmap(
GetGlyph(GlyphRight), x1-xHalfWidth,yStart,
true);
602 auto &xText = ls.
xText;
603 const int xStart=wxMax(r.x,xText-
mIconWidth/2);
605 const int xWidth = xEnd-xStart;
607 if( (xStart < (r.x+r.width)) && (xEnd > r.x) && (xWidth>0))
611 (yFrameHeight -
mFontHeight) / 2 + dc.GetFontMetrics().ascent;
612 dc.DrawText(ls.
title, xText, pos);
619 wxDC & dc,
const LabelStruct &ls,
const wxRect & r)
631 auto& xText = ls.
xText;
632 const int xStart = wxMax(r.x, xText -
mIconWidth / 2);
633 const int xEnd = wxMin(r.x + r.width, xText + ls.
width +
mIconWidth / 2);
634 const int xWidth = xEnd - xStart;
636 if ((xStart < (r.x + r.width)) && (xEnd > r.x) && (xWidth > 0))
640 xWidth, textFrameHeight);
641 dc.DrawRectangle(frame);
656 const int xStart = wxMax(r.x, x + xBarShorten / 2);
657 const int xEnd = wxMin(r.x + r.width, x1 - xBarShorten / 2);
658 const int xWidth = xEnd - xStart;
660 if ((xStart < (r.x + r.width)) && (xEnd > r.x) && (xWidth > 0))
664 if (x1 > x + xBarShorten)
665 dc.DrawRectangle(bar);
671 int xPos1,
int xPos2,
int charHeight)
675 dc.SetPen(*wxTRANSPARENT_PEN);
676 wxBrush curBrush = dc.GetBrush();
677 curBrush.SetColour(wxString(
wxT(
"BLUE")));
680 dc.DrawRectangle(xPos1-1, top, xPos2-xPos1+1, charHeight);
682 dc.DrawRectangle(xPos2-1, top, xPos1-xPos2+1, charHeight);
693 dc.GetTextExtent(ls.
title.Left(cursorPos), &partWidth, NULL);
709 const auto &mLabels = pTrack->GetLabels();
732 const auto &mLabels = pTrack->GetLabels();
736 getXPos(labelStruct, dc, x1, pos1);
738 getXPos(labelStruct, dc, x2, pos2);
749 auto target = pPanel->
Target();
753 return &*handle->
mpHit;
759#include "../../../TrackPanelDrawingContext.h"
768 auto &dc = context.
dc;
770 const auto &zoomInfo = *artist->pZoomInfo;
771 const auto &pendingTracks = *artist->pPendingTracks;
773 auto pHit =
findHit( artist->parent );
783 const auto &track =
static_cast<const LabelTrack&
>(
784 pendingTracks.SubstitutePendingChangedChannel(*
FindChannel()));
791 wxCoord textWidth, textHeight;
796 for (
const auto &labelStruct : mLabels) {
797 dc.GetTextExtent(labelStruct.title, &textWidth, &textHeight);
798 labelStruct.width = textWidth;
807 mTextHeight = dc.GetFontMetrics().ascent + dc.GetFontMetrics().descent;
812 dc.SetBackgroundMode(wxTRANSPARENT);
821 for (
const auto &labelStruct : mLabels)
825 {
int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
828 if( pHit && i == pHit->mMouseOverLabelLeft )
829 GlyphLeft = (pHit->mEdge & 4) ? 6:9;
830 if( pHit && i == pHit->mMouseOverLabelRight )
831 GlyphRight = (pHit->mEdge & 4) ? 7:4;
832 DrawGlyphs( dc, labelStruct, r, GlyphLeft, GlyphRight );
835 auto &
project = *artist->parent->GetProject();
839#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
840 bool highlightTrack =
false;
842 highlightTrack = target &&
845 int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
846 bool highlight =
false;
847#ifdef EXPERIMENTAL_TRACK_PANEL_HIGHLIGHTING
848 highlight = highlightTrack && target->GetLabelNum() == i;
875 xpos1, xpos2, dc.GetFontMetrics().ascent + dc.GetFontMetrics().descent);
879 {
int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
891 int xPos = labelStruct.xText;
901 wxPen currentPen = dc.GetPen();
902 const int CursorWidth=2;
903 currentPen.SetWidth(CursorWidth);
908 currentPen.SetWidth(1);
914 const wxRect &rect,
unsigned iPass )
917 Draw( context, rect );
931 bool finished =
false;
939 const auto &mLabels = pTrack->GetLabels();
940 const auto &labelStruct = mLabels[labelIndex];
941 const auto &
title = labelStruct.title;
942 const int length =
title.length();
943 while (!finished && (charIndex < length + 1))
945 int unichar = (int)
title.at( charIndex-1 );
946 if( (0xDC00 <= unichar) && (unichar <= 0xDFFF)){
950 subString =
title.Left(charIndex);
952 dc.GetTextExtent(subString, &partWidth, NULL);
955 dc.GetTextExtent(subString.Right(1), &oneWidth, NULL);
956 bound = labelStruct.xText + partWidth - oneWidth * 0.5;
961 result = charIndex - 1;
1016 dc.GetTextExtent(
wxT(
"(Test String)|[yp]"), NULL, &
mFontHeight, &charDescent, &charLeading);
1024 const int CursorExtraHeight=2;
1025 mFontHeight += CursorExtraHeight - (charLeading+charDescent);
1035 return index >= 0 && index < static_cast<int>(track->GetLabels().size());
1052 const auto &mLabels = pTrack->GetLabels();
1054 wxString left, right;
1056 auto &text = labelStruct.title;
1068 wxString data = text.Mid(init, cur - init);
1072 left = text.Left(init);
1075 if (cur < (
int)text.length())
1076 right = text.Mid(cur);
1079 text = left + right;
1084 if (wxTheClipboard->Open()) {
1086 wxTheClipboard->SetData(
safenew wxTextDataObject(data));
1087 wxTheClipboard->Close();
1105 const auto &mLabels = pTrack->GetLabels();
1118 wxString data = labelStruct.title.Mid(init, cur-init);
1121 if (wxTheClipboard->Open()) {
1123 wxTheClipboard->SetData(
safenew wxTextDataObject(data));
1124 wxTheClipboard->Close();
1141 wxString text, left, right;
1145 if (wxTheClipboard->Open()) {
1146 wxTextDataObject data;
1147 wxTheClipboard->GetData(data);
1148 wxTheClipboard->Close();
1149 text = data.GetText();
1157 for (
int i = 0; i < (int)text.length(); i++) {
1158 if (wxIscntrl(text[i])) {
1164 const auto &mLabels = pTrack->GetLabels();
1166 auto &
title = labelStruct.title;
1170 left =
title.Left(init);
1171 if (cur < (
int)
title.length())
1172 right =
title.Mid(cur);
1174 title = left + text + right;
1191 const auto& mLabels = pTrack->GetLabels();
1193 auto&
title = labelStruct.title;
1204 return wxTheClipboard->IsSupported(wxDF_UNICODETEXT);
1224 const auto pTrack = &track;
1225 const auto &mLabels = pTrack->
GetLabels();
1226 {
int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
1241 if( abs(labelStruct.y - (y - (
mTextHeight+3)/2)) < d1 &&
1242 abs(labelStruct.x1 - d2 -x) < d1)
1245 if(abs(labelStruct.x1 - x) < d2 )
1250 if( abs(labelStruct.x1-labelStruct.x) < 5.0 )
1260 else if( abs(labelStruct.y - (y - (
mTextHeight+3)/2)) < d1 &&
1261 abs(labelStruct.x + d2 - x) < d1 )
1264 if(abs(labelStruct.x - x) < d2 )
1268 else if (x >= labelStruct.x && x <= labelStruct.x1 &&
1280 const auto pTrack = &track;
1281 const auto &mLabels = pTrack->
GetLabels();
1282 for (
int nn = (
int)mLabels.size(); nn--;) {
1283 const auto &labelStruct = mLabels[nn];
1306 int keyCode = evt.GetKeyCode();
1307 return (keyCode < WXK_START
1308 && keyCode != WXK_SPACE && keyCode != WXK_DELETE && keyCode != WXK_RETURN) ||
1309 (keyCode >= WXK_NUMPAD0 && keyCode <= WXK_DIVIDE) ||
1310 (keyCode >= WXK_NUMPAD_EQUAL && keyCode <= WXK_NUMPAD_DIVIDE) ||
1311#if defined(__WXMAC__)
1312 (keyCode > WXK_RAW_CONTROL) ||
1314 (keyCode > WXK_WINDOWS_MENU);
1320 int keyCode = evt.GetKeyCode();
1325 return keyCode < WXK_START ||
1326 (keyCode >= WXK_END && keyCode < WXK_UP) ||
1327 (keyCode == WXK_RIGHT) ||
1328 (keyCode >= WXK_NUMPAD0 && keyCode <= WXK_DIVIDE) ||
1329 (keyCode >= WXK_NUMPAD_SPACE && keyCode <= WXK_NUMPAD_ENTER) ||
1330 (keyCode >= WXK_NUMPAD_HOME && keyCode <= WXK_NUMPAD_END) ||
1331 (keyCode >= WXK_NUMPAD_DELETE && keyCode <= WXK_NUMPAD_DIVIDE) ||
1332#if defined(__WXMAC__)
1333 (keyCode > WXK_RAW_CONTROL) ||
1335 (keyCode > WXK_WINDOWS_MENU);
1342 int mods =
event.GetModifiers();
1343 auto code =
event.GetKeyCode();
1345 const auto& mLabels = pTrack->GetLabels();
1349 if (code == WXK_F2 && mods == wxMOD_CONTROL && !mLabels.empty()) {
1354 if (mods != wxMOD_NONE && mods != wxMOD_SHIFT) {
1359 if ((code == WXK_TAB || code == WXK_NUMPAD_TAB) &&
1369 bool typeToCreateLabel;
1370 gPrefs->
Read(
wxT(
"/GUI/TypeToCreateLabel"), &typeToCreateLabel,
false);
1382 if (pProj->GetAudioIOToken() > 0 &&
1383 gAudioIO->IsStreamActive(pProj->GetAudioIOToken()))
1386 pProj->GetPlayRegion(&t0, &t1);
1387 if (pProj->mViewInfo.selectedRegion.t0() == t0 &&
1388 pProj->mViewInfo.selectedRegion.t1() == t1) {
1397 selectedRegion.t1()) != wxNOT_FOUND ) {
1416 wxKeyEvent & event,
ViewInfo &viewInfo, wxWindow *WXUNUSED(pParent),
1424 const auto &mLabels = pTrack->GetLabels();
1426 auto &
title = labelStruct.title;
1454 else if (!event.GetSkipped())
1470 const auto &mLabels = pTrack->GetLabels();
1472 auto &
title = labelStruct.title;
1493 else if (!event.GetSkipped())
1504 bool updated =
false;
1507 int keyCode =
event.GetKeyCode();
1508 const int mods =
event.GetModifiers();
1513 if ((keyCode != WXK_F2 && mods != wxMOD_NONE && mods != wxMOD_SHIFT)
1514 || (keyCode == WXK_F2 && mods != wxMOD_CONTROL)) {
1521 const auto &mLabels = pTrack->GetLabels();
1525 auto &
title = labelStruct.title;
1533 int len =
title.length();
1548 if( ((
int)wchar > 0xDFFF) || ((
int)wchar <0xDC00)){
1567 case WXK_NUMPAD_DELETE:
1569 int len =
title.length();
1583 if( ((
int)wchar > 0xDBFF) || ((
int)wchar <0xD800)){
1602 case WXK_NUMPAD_HOME:
1605 if (mods == wxMOD_SHIFT)
1612 case WXK_NUMPAD_END:
1615 if (mods == wxMOD_SHIFT)
1622 case WXK_NUMPAD_LEFT:
1632 more = !(((int)wchar > 0xDFFF) || ((int)wchar < 0xDC00));
1636 if (mods != wxMOD_SHIFT)
1643 case WXK_NUMPAD_RIGHT:
1653 more = !(((int)wchar > 0xDBFF) || ((int)wchar < 0xD800));
1657 if (mods != wxMOD_SHIFT)
1673 case WXK_NUMPAD_ENTER:
1687 case WXK_WINDOWS_MENU:
1707 case WXK_NUMPAD_TAB:
1708 if (!mLabels.empty()) {
1709 int len = (int) mLabels.size();
1716 if (event.ShiftDown()) {
1726 if (event.ShiftDown()) {
1729 if (newSel.
t0() > mLabels[0].getT0()) {
1739 if (newSel.
t0() < mLabels[len - 1].getT0()) {
1753 newSel = labelStruct.selectedRegion;
1762 auto message =
XO(
"%s %d of %d")
1799 const int mods =
event.GetModifiers();
1800 if (mods != wxMOD_NONE && mods != wxMOD_SHIFT) {
1809 wxChar charCode =
event.GetUnicodeKey();
1812 if (charCode == 0 || wxIscntrl(charCode)) {
1821 if (wxIsspace(charCode)) {
1826 gPrefs->
Read(
wxT(
"/GUI/DialogForNameNewLabel"), &useDialog,
false);
1835 pTrack->SetSelected(
true);
1836 pTrack->AddLabel(selectedRegion,
title);
1842 pTrack->SetSelected(
true);
1860 const auto& mLabels = pTrack->GetLabels();
1862 auto&
title = labelStruct.title;
1906 menu.Bind(wxEVT_MENU,
1907 [
this, &
project]( wxCommandEvent &event ){
1930 wxClientDC dc(parent);
1940 static_cast<void>(success);
1963 switch (evt.GetId())
1983 project, selectedRegion.t0(), selectedRegion.t1() ))
2015 wxString left, right;
2023 const auto &mLabels = pTrack->GetLabels();
2025 auto &
title = labelStruct.title;
2028 left =
title.Left(init);
2030 if (cur < (
int)
title.length())
2031 right =
title.Mid(cur);
2033 title = left + right;
2052 const double delta = 1.0e-7;
2054 const auto &mLabels = pTrack->GetLabels();
2055 {
int i = -1;
for (
const auto &labelStruct : mLabels) { ++i;
2056 if( fabs( labelStruct.getT0() - t ) > delta )
2058 if( fabs( labelStruct.getT1() - t1 ) > delta )
2072 const wxString &
title,
int restoreFocus)
2076 auto pos = pTrack->AddLabel( selectedRegion,
title );
2127 auto fix = [&](
Index& index) {
2128 if (index == former)
2130 else if (former < index && index <= present)
2132 else if (former > index && index >= present)
2216 const int nSpecRows =
2218 const char *XmpBmp[nSpecRows];
2234 if( iHighlight==1 ) XmpBmp[5]=
"5 c #FFFFFF";
2235 if( iHighlight==2 ) XmpBmp[6]=
"6 c #FFFFFF";
2236 if( iHighlight==3 ) XmpBmp[7]=
"7 c #FFFFFF";
2239 if( iConfig==0) { XmpBmp[3]=
"3 c none"; XmpBmp[5]=
"5 c none"; }
2240 if( iConfig==1) { XmpBmp[4]=
"4 c none"; XmpBmp[7]=
"7 c none"; }
2259#include "../../../LabelDialog.h"
2265 auto format = formats.GetSelectionFormat(),
2266 freqFormat = formats.GetFrequencySelectionFormatName();
2279 if (dlg.ShowModal() == wxID_OK) {
2287 const SelectedRegion& region,
const wxString& initialValue, wxString& value)
2294 trackPanel.FindTrackRect( trackFocus.Get() ).GetBottomLeft();
2301 position = trackPanel.ClientToScreen(position);
2311 wxRect dialogScreenRect = dialog.GetScreenRect();
2312 wxRect projScreenRect = window.GetScreenRect();
2313 wxPoint max = projScreenRect.GetBottomRight() + wxPoint{ -dialogScreenRect.width, -dialogScreenRect.height };
2314 if (dialogScreenRect.x > max.x) {
2316 dialog.Move(position);
2318 if (dialogScreenRect.y > max.y) {
2320 dialog.Move(position);
2323 dialog.SetInsertionPointEnd();
2324 int status = dialog.ShowModal();
2325 if (status != wxID_CANCEL) {
2326 value = dialog.GetValue();
2327 value.Trim(
true).Trim(
false);
2336 return std::make_shared<LabelTrackView>(
2344 std::make_shared<LabelTrackVRulerControls>( shared_from_this() );
std::shared_ptr< UIHandle > UIHandlePtr
static bool IsGoodLabelEditKey(const wxKeyEvent &evt)
This returns true for keys we capture for label editing.
@ OnDeleteSelectedLabelID
DEFINE_ATTACHED_VIRTUAL_OVERRIDE(DoGetLabelTrackView)
static const char *const GlyphXpmRegionSpec[]
static bool IsGoodLabelFirstKey(const wxKeyEvent &evt)
Returns true for keys we capture to start a label.
constexpr int NUM_GLYPH_HIGHLIGHTS
constexpr int MAX_NUM_ROWS
constexpr int NUM_GLYPH_CONFIGS
audacity::BasicSettings * gPrefs
an object holding per-project preferred sample rate
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 ...
@ EndSeparator
Delimits the end of a group (of which it is a part)
static wxBrush labelSelectedBrush
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
static wxPen labelSurroundPen
static wxBrush labelTextNormalBrush
static wxBrush labelTextEditBrush
static wxBrush labelUnselectedBrush
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Wrap wxTextEntryDialog so that caption IS translatable.
static AudioIOBase * Get()
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
std::shared_ptr< ChannelType > GetChannel(size_t iChannel)
Retrieve a channel, cast to the given type.
void Reparent(const std::shared_ptr< Track > &parent, size_t iChannel) override
Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.
static ChannelView & Get(Channel &channel)
void CopyTo(Track &track, size_t iChannel) const override
Copy state, for undo/redo purposes.
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
auto FindChannel() -> std::shared_ptr< Subtype >
May return null.
Implements some hit-testing shared by many ChannelView subtypes.
std::shared_ptr< Track > FindTrack()
Dialog for editing labels.
std::shared_ptr< LabelTrackHit > mpHit
static UIHandlePtr HitTest(std::weak_ptr< LabelGlyphHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT, const wxRect &rect)
A LabelStruct holds information for ONE label in a LabelTrack.
int x1
Pixel position of left hand glyph.
int x
width of the text in pixels.
int width
Text of the label.
int xText
Pixel position of right hand glyph.
int y
Pixel position of left hand side of text box.
static UIHandlePtr HitTest(std::weak_ptr< LabelTextHandle > &holder, const wxMouseState &state, const std::shared_ptr< LabelTrack > &pLT)
std::shared_ptr< const Track > FindTrack() const override
A LabelTrack is a Track that holds labels (LabelStruct).
const LabelArray & GetLabels() const
void CalcHighlightXs(int *x1, int *x2) const
std::shared_ptr< LabelTrack > FindLabelTrack()
void ResetTextSelection()
static LabelTrackView & Get(LabelTrack &)
void Reparent(const std::shared_ptr< Track > &parent, size_t iChannel) override
Object may be shared among tracks but hold a special back-pointer to one of them; reassign it.
unsigned CaptureKey(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
bool DoCaptureKey(AudacityProject &project, wxKeyEvent &event)
static constexpr int TextFramePadding
void OnLabelAdded(const LabelTrackEvent &)
void RemoveSelectedText()
static constexpr int LabelBarHeight
static void DrawLines(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.
bool CopySelectedText(AudacityProject &project)
static void calculateFontHeight(wxDC &dc)
static wxBitmap mBoundaryGlyphs[NUM_GLYPH_CONFIGS *NUM_GLYPH_HIGHLIGHTS]
void OnSelectionChange(const LabelTrackEvent &)
~LabelTrackView() override
static void DrawGlyphs(wxDC &dc, const LabelStruct &ls, const wxRect &r, int GlyphLeft, int GlyphRight)
static int DialogForLabelName(AudacityProject &project, const SelectedRegion ®ion, const wxString &initialValue, wxString &value)
int AddLabel(const SelectedRegion ®ion, const wxString &title={}, int restoreFocus=-1)
bool IsValidIndex(const Index &index, AudacityProject &project) const
void BindTo(LabelTrack *pParent)
static bool mbGlyphsReady
void ComputeLayout(const wxRect &r, const ZoomInfo &zoomInfo) const
int mRestoreFocus
initial cursor position
static void DrawBar(wxDC &dc, const LabelStruct &ls, const wxRect &r)
static wxFont GetFont(const wxString &faceName, int size=DefaultFontSize)
void ShowContextMenu(AudacityProject &project)
bool CalcCursorX(AudacityProject &project, int *x) const
int GetLabelIndex(double t, double t1)
void ComputeTextPosition(const wxRect &r, int index) const
int mInitialCursorPos
current cursor position
void OnLabelDeleted(const LabelTrackEvent &)
void OnContextMenu(AudacityProject &project, wxCommandEvent &evt)
unsigned KeyDown(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
LabelTrackView(const LabelTrackView &)=delete
void CopyTo(Track &track, size_t iChannel) const override
Copy state, for undo/redo purposes.
Index mTextEditIndex
Index of the current label text being edited.
bool DoChar(AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
void SetTextSelection(int labelIndex, int start=1, int end=1)
bool PasteSelectedText(AudacityProject &project, double sel0, double sel1)
static void DoEditLabels(AudacityProject &project, LabelTrack *lt=nullptr, int index=-1)
bool SelectAllText(AudacityProject &project)
std::weak_ptr< LabelTextHandle > mTextHandle
bool DoKeyDown(AudacityProject &project, NotifyingSelectedRegion &sel, wxKeyEvent &event)
KeyEvent is called for every keypress when over the label track.
static void DrawText(wxDC &dc, const LabelStruct &ls, const wxRect &r)
void CreateCustomGlyphs()
static wxBitmap & GetGlyph(int i)
int FindCursorPosition(int labelIndex, wxCoord xPos)
convert pixel coordinate to character position in text box
static int GetTextFrameHeight()
std::weak_ptr< LabelGlyphHandle > mGlyphHandle
std::shared_ptr< ChannelVRulerControls > DoGetVRulerControls() override
void Draw(TrackPanelDrawingContext &context, const wxRect &r) const
void RestoreFlags(const Flags &flags)
void OnLabelPermuted(const LabelTrackEvent &)
unsigned Char(wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
bool CutSelectedText(AudacityProject &project)
bool IsTextSelected(AudacityProject &project) const
static bool OverTextBox(const LabelStruct *pLabel, int x, int y)
static bool IsTextClipSupported()
Observer::Subscription mSubscription
int GetTextEditIndex(AudacityProject &project) const
void SetNavigationIndex(int index)
static void OverGlyph(const LabelTrack &track, LabelTrackHit &hit, int x, int y)
static void DrawTextBox(wxDC &dc, const LabelStruct &ls, const wxRect &r)
static int OverATextBox(const LabelTrack &track, int xx, int yy)
std::vector< UIHandlePtr > DetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
static constexpr int TextFrameYOffset
void SetCurrentCursorPosition(int pos)
int GetNavigationIndex(AudacityProject &project) const
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
void PushState(const TranslatableString &desc, const TranslatableString &shortDesc)
static ProjectHistory & Get(AudacityProject &project)
Defines a selected portion of a project.
static bool IsSelectedOrSyncLockSelected(const Track &track)
wxColour & Colour(int iIndex)
wxBitmap & Bitmap(int iIndex)
static TrackArtist * Get(TrackPanelDrawingContext &)
Abstract base class for an object holding data associated with points on a time axis.
std::shared_ptr< Subclass > SharedPointer()
auto Any() -> TrackIterRange< TrackType >
static TrackList & Get(AudacityProject &project)
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
The TrackPanel class coordinates updates and operations on the main part of the screen which contains...
static TrackPanel & Get(AudacityProject &project)
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
static Viewport & Get(AudacityProject &project)
void ScrollIntoView(double pos)
Center view horizontally at the given time, if it was not in bounds.
int64 TimeToPosition(double time, int64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
int GetLeftOffset() const
virtual bool Read(const wxString &key, bool *value) const =0
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Channel &channel, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true, bool useBeatsAlternateColor=false)
Helper: draws background with selection rect.
void getXPos(const LabelStruct &ls, wxDC &dc, int *xPos1, int cursorPos)
LabelTrackHit * findHit(TrackPanel *pPanel)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
const char * end(const char *str) noexcept
For defining overrides of the method.
const std::weak_ptr< Track > mpTrack
enum LabelTrackEvent::Type type
int mMouseOverLabelRight
Keeps track of which left label the mouse is currently over.
int mMouseOverLabelLeft
Keeps track of which (ranged) label the mouse is currently over.
void SetModified(bool modified)
Index & operator=(int index)