Audacity  2.2.2
SelectionBar.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  SelectionBar.cpp
6 
7  Copyright 2005 Dominic Mazzoni
8 
9  This program is free software; you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation; either version 2 of the License, or
12  (at your option) any later version.
13 
14 *******************************************************************//****************************************************************//*******************************************************************/
27 
28 
29 #include "../Audacity.h"
30 
31 // For compilers that support precompilation, includes "wx/wx.h".
32 #include <wx/wxprec.h>
33 
34 #ifndef WX_PRECOMP
35 #include <wx/button.h>
36 #include <wx/checkbox.h>
37 #include <wx/combobox.h>
38 #include <wx/intl.h>
39 #include <wx/radiobut.h>
40 #include <wx/settings.h>
41 #include <wx/sizer.h>
42 #include <wx/valtext.h>
43 #include <wx/stattext.h>
44 #endif
45 #include <wx/statline.h>
46 
47 
48 #include "SelectionBarListener.h"
49 #include "SelectionBar.h"
50 
51 #include "../widgets/AButton.h"
52 #include "../AudioIO.h"
53 #include "../AColor.h"
54 #include "../Prefs.h"
55 #include "../Project.h"
56 #include "../Snap.h"
57 #include "../widgets/NumericTextCtrl.h"
58 #include "../AllThemeResources.h"
59 
60 #if wxUSE_ACCESSIBILITY
61 #include "../widgets/WindowAccessible.h"
62 #endif
63 
65 
66 const static wxChar *numbers[] =
67 {
68  wxT("0"), wxT("1"), wxT("2"), wxT("3"), wxT("4"),
69  wxT("5"), wxT("6"), wxT("7"), wxT("8"), wxT("9")
70 };
71 
72 enum {
77 
79 
84 
86 };
87 
88 BEGIN_EVENT_TABLE(SelectionBar, ToolBar)
89  EVT_SIZE(SelectionBar::OnSize)
90  EVT_TEXT(StartTimeID, SelectionBar::OnChangedTime)
91  EVT_TEXT(LengthTimeID, SelectionBar::OnChangedTime)
92  EVT_TEXT(CenterTimeID, SelectionBar::OnChangedTime)
93  EVT_TEXT(EndTimeID, SelectionBar::OnChangedTime)
94  EVT_CHOICE(SnapToID, SelectionBar::OnSnapTo)
95  EVT_CHOICE(ChoiceID, SelectionBar::OnChoice )
96  EVT_COMBOBOX(RateID, SelectionBar::OnRate)
97  EVT_TEXT(RateID, SelectionBar::OnRate)
98 
99  EVT_COMMAND(wxID_ANY, EVT_TIMETEXTCTRL_UPDATED, SelectionBar::OnUpdate)
100  EVT_COMMAND(wxID_ANY, EVT_CAPTURE_KEY, SelectionBar::OnCaptureKey)
102 
104 : ToolBar(SelectionBarID, _("Selection"), wxT("Selection")),
105  mListener(NULL), mRate(0.0),
106  mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0),
107  mDrive1( StartTimeID), mDrive2( EndTimeID ),
108  mSelectionMode(0),
109  mStartTime(NULL), mCenterTime(NULL), mLengthTime(NULL), mEndTime(NULL),
110  mAudioTime(NULL),
111  mChoice(NULL)
112 {
113  // Make sure we have a valid rate as the NumericTextCtrl()s
114  // created in Populate()
115  // depend on it. Otherwise, division-by-zero floating point exceptions
116  // will occur.
117  // Refer to bug #462 for a scenario where the division-by-zero causes
118  // Audacity to fail.
119  mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
121 
122  // Selection mode of 0 means showing 'start' and 'end' only.
123  mSelectionMode = gPrefs->ReadLong(wxT("/SelectionToolbarMode"), 0);
124 }
125 
127 {
128 }
129 
130 void SelectionBar::Create(wxWindow * parent)
131 {
132  ToolBar::Create(parent);
133 }
134 
135 
136 auStaticText * SelectionBar::AddTitle( const wxString & Title, wxSizer * pSizer ){
137  auStaticText * pTitle = safenew auStaticText(this, Title );
138  pTitle->SetBackgroundColour( theTheme.Colour( clrMedium ));
139  pTitle->SetForegroundColour( theTheme.Colour( clrTrackPanelText ) );
140  pSizer->Add( pTitle,0, wxALIGN_CENTER_VERTICAL | wxRIGHT, (Title.Length() == 1 ) ? 0:5);
141  return pTitle;
142 }
143 
144 
145 NumericTextCtrl * SelectionBar::AddTime( const wxString Name, int id, wxSizer * pSizer ){
146  auto formatName = mListener ? mListener->AS_GetSelectionFormat()
147  : NumericFormatId{};
148  auto pCtrl = safenew NumericTextCtrl(
149  this, id, NumericConverter::TIME, formatName, 0.0, mRate);
150  pCtrl->SetName(Name);
151  pSizer->Add(pCtrl, 0, wxALIGN_TOP | wxRIGHT, 5);
152  return pCtrl;
153 }
154 
155 void SelectionBar::AddVLine( wxSizer * pSizer ){
156  pSizer->Add(safenew wxStaticLine(this, -1, wxDefaultPosition,
157  wxSize(1, toolbarSingle-10),
158  wxLI_VERTICAL),
159  0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
160 }
161 
163 {
164  SetBackgroundColour( theTheme.Colour( clrMedium ) );
165 
167 
168  // This will be inherited by all children:
169  SetFont(wxFont(
170 #ifdef __WXMAC__
171  12
172 #else
173  9
174 #endif
175  ,
176  wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
177 
178  wxFlexGridSizer *mainSizer;
179 
180  /* we don't actually need a control yet, but we want to use its methods
181  * to do some look-ups, so we'll have to create one. We can't make the
182  * look-ups static because they depend on translations which are done at
183  * runtime */
184 
185  // Outer sizer has space top and left.
186  // Inner sizers have space on right only.
187  // This choice makes for a nice border and internal spacing and places clear responsibility
188  // on each sizer as to what spacings it creates.
189  Add((mainSizer = safenew wxFlexGridSizer(SIZER_COLS, 1, 1)), 0, wxALIGN_TOP | wxLEFT | wxTOP, 5);
190 
191  // Top row (mostly labels)
192  wxColour clrText = theTheme.Colour( clrTrackPanelText );
193  wxColour clrText2 = *wxBLUE;
194  AddTitle( _("Project Rate (Hz)"), mainSizer );
195  AddVLine( mainSizer );
196  AddTitle( _("Snap-To"), mainSizer );
197  AddVLine( mainSizer );
198  AddTitle( _("Audio Position"), mainSizer );
199  AddVLine( mainSizer );
200 
201  {
202  const wxString choices[4] = {
203  _("Start and End of Selection"),
204  _("Start and Length of Selection"),
205  _("Length and End of Selection"),
206  _("Length and Center of Selection"),
207  };
208  mChoice = safenew wxChoice
209  (this, ChoiceID, wxDefaultPosition, wxDefaultSize, 4, choices,
210  0, wxDefaultValidator, _("Show"));
211  mChoice->SetSelection(0);
212 #if wxUSE_ACCESSIBILITY
213  // so that name can be set on a standard control
214  mChoice->SetAccessible(safenew WindowAccessible(mChoice));
215 #endif
216 #ifdef __WXGTK__
217  // Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
218  // be three units high.
219  wxSize sz = mChoice->GetBestSize();
220  sz.SetHeight( sz.y-4);
221  mChoice->SetMinSize( sz );
222 #endif
223  mainSizer->Add(mChoice, 0, wxALIGN_TOP | wxEXPAND | wxRIGHT, 6);
224  }
225 
226  // Botton row, (mostly time controls)
227  mRateBox = safenew wxComboBox(this, RateID,
228  wxT(""),
229  wxDefaultPosition, wxSize(80, -1));
230 #if wxUSE_ACCESSIBILITY
231  // so that name can be set on a standard control
232  mRateBox->SetAccessible(safenew WindowAccessible(mRateBox));
233 #endif
234  mRateBox->SetName(_("Project Rate (Hz)"));
235  //mRateBox->SetForegroundColour( clrText2 );
236  wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST);
237  vld.SetIncludes(wxArrayString(10, numbers));
238  mRateBox->SetValidator(vld);
239  mRateBox->SetValue(wxString::Format(wxT("%d"), (int)mRate));
240  UpdateRates(); // Must be done _after_ setting value on mRateBox!
241 
242  // We need to capture the SetFocus and KillFocus events to set up
243  // for keyboard capture. On Windows and GTK it's easy since the
244  // combobox is presented as one control to hook into.
246 
247 #if defined(__WXMAC__)
248  // The Mac uses a standard wxTextCtrl for the edit portion and that's
249  // the control that gets the focus events. So we have to find the
250  // textctrl.
251  wxWindowList kids = mRateBox->GetChildren();
252  for (unsigned int i = 0; i < kids.GetCount(); i++) {
253  wxClassInfo *ci = kids[i]->GetClassInfo();
254  if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) {
255  mRateText = kids[i];
256  break;
257  }
258  }
259 #endif
260 
261  mRateText->Bind(wxEVT_SET_FOCUS,
263  this);
264  mRateText->Bind(wxEVT_KILL_FOCUS,
266  this);
267 
268 #ifdef __WXGTK__
269  // Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
270  // be three units high.
271  wxSize sz = mRateBox->GetBestSize();
272  sz.SetHeight( sz.y-4);
273  mRateBox->SetMinSize( sz );
274 #endif
275 
276  mainSizer->Add(mRateBox, 0, wxALIGN_TOP | wxRIGHT, 5);
277  AddVLine( mainSizer );
278 
279  mSnapTo = safenew wxChoice(this, SnapToID,
280  wxDefaultPosition, wxDefaultSize,
282 
283 #ifdef __WXGTK__
284  // Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
285  // be three units high.
286  sz = mSnapTo->GetBestSize();
287  sz.SetHeight( sz.y-4);
288  mSnapTo->SetMinSize( sz );
289 #endif
290 
291  mainSizer->Add(mSnapTo,
292  0, wxALIGN_TOP | wxRIGHT, 5);
293 #if wxUSE_ACCESSIBILITY
294  // so that name can be set on a standard control
295  mSnapTo->SetAccessible(safenew WindowAccessible(mSnapTo));
296 #endif
297  mSnapTo->SetName(_("Snap To"));
298  //mSnapTo->SetForegroundColour( clrText2 );
299  mSnapTo->SetSelection(mListener ? mListener->AS_GetSnapTo() : SNAP_OFF);
300 
301  mSnapTo->Bind(wxEVT_SET_FOCUS,
303  this);
304  mSnapTo->Bind(wxEVT_KILL_FOCUS,
306  this);
307 
308  AddVLine( mainSizer );
309 
310  mAudioTime = AddTime(_("Audio Position"), AudioTimeID, mainSizer );
311  // This vertical line is NOT just for decoration!
312  // It works around a wxWidgets-on-Windows RadioButton bug, where tabbing
313  // into the radiobutton group jumps to selecting the first item in the
314  // group even if some other item had been selected.
315  // It is an important bug to work around for sceen reader users, who use TAB
316  // a lot in navigation.
317  // More about the bug here:
318  // https://forums.wxwidgets.org/viewtopic.php?t=41120
319  AddVLine( mainSizer );
320 
321  {
322  auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
323 
324  mStartTime = AddTime(_("Start"), StartTimeID, hSizer.get() );
325  mLengthTime = AddTime(_("Length"), LengthTimeID, hSizer.get() );
326  mCenterTime = AddTime(_("Center"), CenterTimeID, hSizer.get() );
327  mEndTime = AddTime(_("End"), EndTimeID, hSizer.get() );
328  mainSizer->Add(hSizer.release(), 0, wxALIGN_TOP | wxRIGHT, 0);
329  }
330 
331  mChoice->MoveBeforeInTabOrder( mStartTime );
332  // This shows/hides controls.
333  // Do this before layout so that we are sized right.
335  mainSizer->Layout();
337  Layout();
338 
339  SetMinSize( GetSizer()->GetMinSize() );
340 }
341 
343 {
344  mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"), AudioIO::GetOptimalSupportedSampleRate());
345 
346  wxCommandEvent e;
347  e.SetInt(mStartTime->GetFormatIndex());
348  OnUpdate(e);
349 
350  // Set label to pull in language change
351  SetLabel(_("Selection"));
352 
354  // Give base class a chance
356 }
357 
359 {
360  mListener = l;
364 };
365 
367 {
368 #if wxUSE_TOOLTIPS
369  auto formatName =
370  mListener
372  : NumericFormatId{};
373  mSnapTo->SetToolTip(
374  wxString::Format(
375  _("Snap Clicks/Selections to %s"), formatName.Translation() ));
376 #endif
377 }
378 
379 void SelectionBar::OnSize(wxSizeEvent &evt)
380 {
381  Refresh( true );
382 
383  evt.Skip();
384 }
385 
386 // When a control value is changed, this function is called.
387 // It determines the values for the other controls.
388 void SelectionBar::ModifySelection(int newDriver, bool done)
389 {
390  // If the user moved to a different control, then update which
391  // two controls drive the others.
392  if( newDriver != mDrive2 )
393  SetDrivers( mDrive2, newDriver);
394 
395  // Only update a value if user typed something in.
396  // The reason is the controls may be less accurate than
397  // the values.
398  if( newDriver == StartTimeID )
400  if( newDriver == EndTimeID )
401  mEnd = mEndTime->GetValue();
402  if( newDriver == LengthTimeID )
404  if( newDriver == CenterTimeID )
406 
407  // There are four controls, and two constraints, which are:
408  // mid = (start+end)/2
409  // length = (end-start)
410  // Therefore we can select any two controls as 'drivers' of
411  // the other two.
412  // Here we compute 'i' which combines the identity of the two
413  // driving controls, to use it as an index.
414  // The order of the two drivers generally does not matter much,
415  // except that we have want:
416  // start < end
417  // and preserve that by adjusting the least dominant driving
418  // control.
419  int i = mDrive1 + 4 * mDrive2;
420  switch(i){
421  case StartTimeID + 4 * EndTimeID:
422  if( mEnd < mStart )
423  mStart = mEnd;
424  case StartTimeID * 4 + EndTimeID:
425  if( mStart > mEnd )
426  mEnd = mStart;
427  mLength = mEnd - mStart;
428  mCenter = (mStart+mEnd)/2.0;
429  break;
430  case StartTimeID + 4 * LengthTimeID:
431  case StartTimeID * 4 + LengthTimeID:
432  if( mLength < 0 )
433  mLength = 0;
434  mEnd = mStart+mLength;
435  mCenter = (mStart+mEnd)/2.0;
436  break;
437  case StartTimeID + 4 * CenterTimeID:
438  if( mCenter < mStart )
439  mCenter = mStart;
440  case StartTimeID * 4 + CenterTimeID:
441  if( mStart > mCenter )
442  mStart = mCenter;
443  mEnd = mCenter * 2 - mStart;
444  mLength = mStart - mEnd;
445  break;
446  case EndTimeID + 4 * LengthTimeID:
447  case EndTimeID * 4 + LengthTimeID:
448  if( mLength < 0 )
449  mLength = 0;
450  mStart = mEnd - mLength;
451  mCenter = (mStart+mEnd)/2.0;
452  break;
453  case EndTimeID + 4 * CenterTimeID:
454  if( mCenter > mEnd )
455  mCenter = mEnd;
456  case EndTimeID * 4 + CenterTimeID:
457  if( mEnd < mCenter )
458  mEnd = mCenter;
459  mStart = mCenter * 2.0 - mEnd;
460  mLength = mEnd - mStart;
461  break;
462  case LengthTimeID + 4 * CenterTimeID:
463  case LengthTimeID * 4 + CenterTimeID:
464  if( mLength < 0 )
465  mLength = 0;
466  mStart = mCenter - mLength/2.0;
467  mEnd = mCenter + mLength/2.0;
468  break;
469  default:
470  // The above should cover all legal combinations of two distinct controls.
471  wxFAIL_MSG( "Illegal sequence of selection changes");
472  }
473 
474  // Places the start-end mrkers on the track panel.
476 }
477 
478 void SelectionBar::OnChangedTime(wxCommandEvent & event)
479 {
480  ModifySelection(event.GetId(), event.GetInt() != 0);
481 }
482 
483 // Called when one of the format drop downs is changed.
484 void SelectionBar::OnUpdate(wxCommandEvent &evt)
485 {
486  int index = evt.GetInt();
487  wxWindow *w = FindFocus();
489  int i;
490  int iFocus = -1;
491  for(i=0;i<5;i++)
492  if( w == *Ctrls[i] )
493  iFocus = i;
494 
495  evt.Skip(false);
496 
497  // Save format name before recreating the controls so they resize properly
498  {
499  auto format = mStartTime->GetBuiltinName(index);
501  }
502 
504 
505  // ToolBar::ReCreateButtons() will get rid of our sizers and controls
506  // so reset pointers first.
507  for( i=0;i<5;i++)
508  *Ctrls[i]=NULL;
509 
510  mRateBox = NULL;
511  mRateText = NULL;
512 
514 
516 
517  auto format = mStartTime->GetBuiltinFormat(index);
518  for( i=0;i<5;i++)
519  (*Ctrls[i])->SetFormatString( format );
520 
521  if( iFocus >=0 )
522  (*Ctrls[iFocus])->SetFocus();
523  Updated();
524 }
525 
526 // The two drivers are the numbers of the two controls which drive the other ones.
527 // The user gets to see which controls are drivers and which driven.
528 void SelectionBar::SetDrivers( int driver1, int driver2 )
529 {
530  mDrive1 = driver1;
531  mDrive2 = driver2;
532 
534  wxString Text[4] = { _("Start"), _("Center"), _("Length"), _("End") };
535 
536  for(int i=0;i<4;i++){
537  int id = i + StartTimeID;
538  int fixed = (( id == mDrive2 )?mDrive1:mDrive2)-StartTimeID;
539 
540  wxString Temp = Text[i];
541  // i18n-hint: %s is replaced e.g by 'Length', to indicate that it will be calculated from other parameters.
542  wxString Format = ( (id!=mDrive1) && (id!=mDrive2 ) ) ? _("%s - driven") : "%s";
543  wxString Title= wxString::Format( Format, Temp );
544  // i18n-hint: %s1 is replaced e.g by 'Length', %s2 e.g by 'Center'.
545  wxString VoiceOverText = wxString::Format(_("Selection %s. %s won't change."), Temp, Text[fixed]);
546  if( *Ctrls[i] ){
547  (*Ctrls[i])->SetName( Temp );
548  }
549  }
550 }
551 
552 void SelectionBar::OnChoice(wxCommandEvent & WXUNUSED(event))
553 {
554  int mode = mChoice->GetSelection();
555  SetSelectionMode( mode );
557 }
558 
560 {
561  // We just changed the mode. Remember it.
562  gPrefs->Write(wxT("/SelectionToolbarMode"), mSelectionMode);
563  gPrefs->Flush();
564 
565  wxSize sz = GetMinSize();
566  sz.SetWidth( 10 );
567  SetMinSize( sz );
568  Fit();
569  Layout();
570  Updated();
571 }
572 
573 // We used to have 8 modes which showed different combinations of the
574 // length, start, end, center controls.
575 // Mode 7 for example showed all four at the same time.
577 {
578  // Only modes 0 to 3 are now supported,
579  // so fix up a mode that could have come from the config.
580  const int maxMode = 3;
581 
582  if( mode > maxMode )
583  mode = 0;
584  if( mode < 0 )
585  mode = 0;
586  mSelectionMode = mode;
587  mChoice->SetSelection( mode );
588 
589  // First decide which two controls drive the others...
590  // For example the last option is with all controls shown, and in that mode we
591  // initially have start and end driving.
592  int Drive2[] = { StartTimeID, StartTimeID, LengthTimeID, LengthTimeID,
593  StartTimeID, StartTimeID, StartTimeID, StartTimeID};
594  int Drive1[] = { EndTimeID, LengthTimeID, EndTimeID, CenterTimeID,
595  EndTimeID, LengthTimeID, EndTimeID, EndTimeID};
596 
597  SetDrivers( Drive1[mode], Drive2[mode] );
598  // Then show/hide the relevant controls.
599  ShowHideControls( mode );
600 }
601 
602 // Our mode determines which controls are visible.
604 {
605  // The bits in these say which controls are visible.
606  int masks[8]= {
607  9, 5, 12, 6, // 2 items shown
608  13, 7, 11,// 3 items shown
609  15};
610  int mask = masks[mode];
611 
613  for(int i=0;i<4;i++){
614  if( *Ctrls[i])
615  (*Ctrls[i])->Show( (mask & (1<<i))!=0 );
616  }
617 }
618 
620 {
622  double Values[5] = {mStart, mEnd, mLength, mCenter, mAudio };
623  int i;
624  for(i=0;i<5;i++)
625  if( *Ctrls[i] )
626  (*Ctrls[i])->SetValue( Values[i] );
627 }
628 
629 // A time has been set. Update the control values.
630 void SelectionBar::SetTimes(double start, double end, double audio)
631 {
632  mStart = start;
633  mEnd = end;
634  mLength = end-start;
635  mCenter = (end+start)/2.0;
636  mAudio = audio;
637 
639 }
640 
642 {
643  mSnapTo->SetSelection(snap);
644 }
645 
647 {
649 
650  wxCommandEvent e;
651  e.SetInt(mStartTime->GetFormatIndex());
652  OnUpdate(e);
653 }
654 
655 void SelectionBar::SetRate(double rate)
656 {
657  if (rate != mRate) {
658  // if the rate is actually being changed
659  mRate = rate; // update the stored rate
660  mRateBox->SetValue(wxString::Format(wxT("%d"), (int)rate));
661  // update the TimeTextCtrls if they exist
663  int i;
664  for(i=0;i<5;i++)
665  if( *Ctrls[i] )
666  (*Ctrls[i])->SetSampleRate( rate );
667  }
668 }
669 
670 void SelectionBar::OnRate(wxCommandEvent & WXUNUSED(event))
671 {
672  if (mRateBox->GetValue().ToDouble(&mRate) && // is a numeric value
673  (mRate != 0.0))
674  {
676  int i;
677  for(i=0;i<5;i++)
678  if( *Ctrls[i] )
679  (*Ctrls[i])->SetSampleRate( mRate );
681  }
682 }
683 
685 {
686  wxString oldValue = mRateBox->GetValue();
687  mRateBox->Clear();
688  for (int i = 0; i < AudioIO::NumStandardRates; i++) {
689  mRateBox->Append(wxString::Format(wxT("%d"), AudioIO::StandardRates[i]));
690  }
691  mRateBox->SetValue(oldValue);
692 }
693 
694 void SelectionBar::OnFocus(wxFocusEvent &event)
695 {
696  if (event.GetEventType() == wxEVT_KILL_FOCUS) {
698  }
699  else {
701  }
702 
703  Refresh(false);
704  event.Skip();
705 }
706 
707 void SelectionBar::OnCaptureKey(wxCommandEvent &event)
708 {
709  wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
710  wxWindow *w = FindFocus();
711  int keyCode = kevent->GetKeyCode();
712 
713  // Convert numeric keypad entries.
714  if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) {
715  keyCode -= WXK_NUMPAD0 - '0';
716  }
717 
718  if (keyCode >= '0' && keyCode <= '9') {
719  return;
720  }
721 
722  // UP/DOWN/LEFT/RIGHT for mRateText
723  if (w == mRateText) {
724  switch (keyCode)
725  {
726  case WXK_LEFT:
727  case WXK_RIGHT:
728  case WXK_UP:
729  case WXK_DOWN:
730  case WXK_DELETE:
731  case WXK_BACK:
732  return;
733  }
734  }
735 
736  event.Skip();
737 }
738 
739 void SelectionBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
740 {
741  mListener->AS_SetSnapTo(mSnapTo->GetSelection());
742 }
virtual void AS_SetSnapTo(int snap)=0
static const wxChar * numbers[]
void RegenerateTooltips() override
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
NumericTextCtrl * AddTime(const wxString Name, int id, wxSizer *pSizer)
wxWindow * mRateText
Definition: SelectionBar.h:106
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
void SetRate(double rate)
wxComboBox * mRateBox
Definition: SelectionBar.h:104
NumericTextCtrl * mLengthTime
Definition: SelectionBar.h:99
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
Definition: LabelDialog.cpp:89
virtual void UpdatePrefs()
Definition: ToolBar.cpp:535
void OnChangedTime(wxCommandEvent &evt)
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:374
Abstract base class used in importing a file.
Definition: Import.h:32
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:603
virtual int AS_GetSnapTo()=0
static void CaptureKeyboard(wxWindow *handler)
Definition: Project.cpp:5954
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
Definition: SelectionBar.h:42
SelectionBarListener * mListener
Definition: SelectionBar.h:86
virtual void ReCreateButtons()
Definition: ToolBar.cpp:459
void SetTimes(double start, double end, double audio)
virtual void AS_SetSelectionFormat(const NumericFormatId &format)=0
void SetSelectionFormat(const NumericFormatId &format)
void OnSnapTo(wxCommandEvent &event)
A parent class of SelectionBar, used to forward events to do with changes in the SelectionBar.
virtual void AS_SetRate(double rate)=0
void ModifySelection(int newDriver, bool done=false)
void OnSize(wxSizeEvent &evt)
is like wxStaticText, except it can be themed. wxStaticText can't be.
Definition: Theme.h:177
#define toolbarSingle
Definition: ToolBar.h:54
double mAudio
Definition: SelectionBar.h:88
void SetFormatString(const wxString &formatString)
void Populate() override
static int GetOptimalSupportedSampleRate()
Get a supported sample rate which can be used a an optimal default.
Definition: AudioIO.cpp:3127
NumericTextCtrl * mCenterTime
Definition: SelectionBar.h:98
Definition: Snap.h:52
#define safenew
Definition: Audacity.h:230
void SetSnapTo(int)
double mLength
Definition: SelectionBar.h:88
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
double mCenter
Definition: SelectionBar.h:88
void SelectionModeUpdated()
int format
Definition: ExportPCM.cpp:56
void UpdateRates()
void SetListener(SelectionBarListener *l)
void SetDrivers(int driver1, int driver2)
void OnFocus(wxFocusEvent &event)
wxChoice * mSnapTo
Definition: SelectionBar.h:105
wxChoice * mChoice
Definition: SelectionBar.h:102
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:611
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:438
virtual const NumericFormatId & AS_GetSelectionFormat()=0
double mStart
Definition: SelectionBar.h:88
virtual double AS_GetRate()=0
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
void OnRate(wxCommandEvent &event)
NumericTextCtrl * mAudioTime
Definition: SelectionBar.h:101
wxString GetBuiltinFormat(const int index)
void ShowHideControls(int mode)
void Updated()
Definition: ToolBar.cpp:592
int mSelectionMode
Definition: SelectionBar.h:95
static void ReleaseKeyboard(wxWindow *handler)
Definition: Project.cpp:5965
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
NumericFormatId GetBuiltinName(const int index)
IMPLEMENT_CLASS(SelectionBar, ToolBar)
void OnCaptureKey(wxCommandEvent &event)
void OnUpdate(wxCommandEvent &evt)
void ValuesToControls()
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIO.h:385
static wxArrayString GetSnapLabels()
Definition: Snap.cpp:364
#define SIZER_COLS
Definition: SelectionBar.h:27
static const int StandardRates[]
Array of common audio sample rates.
Definition: AudioIO.h:383
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1225
END_EVENT_TABLE()
void AddVLine(wxSizer *pSizer)
void OnChoice(wxCommandEvent &event)
void SetSelectionMode(int mode)
virtual ~SelectionBar()
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed...
Definition: ToolBar.h:87
double mRate
Definition: SelectionBar.h:87
auStaticText * AddTitle(const wxString &Title, wxSizer *pSizer)
NumericTextCtrl * mStartTime
Definition: SelectionBar.h:97
void UpdatePrefs() override
virtual void AS_ModifySelection(double &start, double &end, bool done)=0
void Create(wxWindow *parent) override
NumericTextCtrl * mEndTime
Definition: SelectionBar.h:100