42#include <wx/checkbox.h>
43#include <wx/combobox.h>
45#include <wx/radiobut.h>
46#include <wx/settings.h>
48#include <wx/valtext.h>
49#include <wx/stattext.h>
51#include <wx/statline.h>
54#include "../AudioIO.h"
56#include "../KeyboardCapture.h"
59#include "../ProjectAudioIO.h"
60#include "../ProjectSettings.h"
65#include "../widgets/auStaticText.h"
67#if wxUSE_ACCESSIBILITY
68#include "../widgets/WindowAccessible.h"
75 wxT(
"0"), wxT(
"1"), wxT(
"2"), wxT(
"3"), wxT(
"4"),
76 wxT(
"5"), wxT(
"6"), wxT(
"7"), wxT(
"8"), wxT(
"9")
113 mListener(NULL), mRate(0.0),
114 mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0),
117 mStartTime(NULL), mCenterTime(NULL), mLengthTime(NULL), mEndTime(NULL),
131 mSelectionMode =
gPrefs->ReadLong(wxT(
"/SelectionToolbarMode"), 0);
161 pTitle->SetForegroundColour(
theTheme.
Colour( clrTrackPanelText ) );
162 pSizer->Add( pTitle, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
174 pCtrl->SetName( Name );
175 pSizer->Add(pCtrl, 0, wxALIGN_TOP | wxRIGHT, 5);
180 pSizer->Add(
safenew wxStaticLine(
this, -1, wxDefaultPosition,
183 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
197 Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
201 wxColour clrText2 = *wxBLUE;
206#ifdef TIME_IN_SELECT_TOOLBAR
212 const wxString choices[4] = {
213 _(
"Start and End of Selection"),
214 _(
"Start and Length of Selection"),
215 _(
"Length and End of Selection"),
216 _(
"Length and Center of Selection"),
219 (
this,
ChoiceID, wxDefaultPosition, wxDefaultSize, 4, choices,
220 0, wxDefaultValidator,
_(
"Show"));
222#if wxUSE_ACCESSIBILITY
226 mainSizer->Add(
mChoice, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 6);
232 wxDefaultPosition, wxDefaultSize);
233#if wxUSE_ACCESSIBILITY
237 mRateBox->SetName(
_(
"Project Rate (Hz)"));
239 wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST);
240 vld.SetIncludes(wxArrayString(10,
numbers));
250#if defined(__WXMAC__)
254 wxWindowList kids =
mRateBox->GetChildren();
255 for (
unsigned int i = 0; i < kids.size(); i++) {
256 wxClassInfo *ci = kids[i]->GetClassInfo();
257 if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) {
271 mainSizer->Add(
mRateBox, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
276 wxDefaultPosition, wxDefaultSize,
277 transform_container< wxArrayStringEx >(
281#if wxUSE_ACCESSIBILITY
292 mSnapTo->Bind(wxEVT_KILL_FOCUS,
296 mainSizer->Add(
mSnapTo, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
300#ifdef TIME_IN_SELECT_TOOLBAR
314 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
320 mainSizer->Add(hSizer.release(), 0, wxALIGN_TOP | wxRIGHT, 0);
323#if defined(__WXGTK3__)
325#elif defined(__WXGTK__)
327 wxFont font =
mChoice->GetFont();
330 rateLabel->SetFont(font);
331 snapLabel->SetFont(font);
400 _(
"Snap Clicks/Selections to %s"), formatName.Translation() ));
484 wxFAIL_MSG(
"Illegal sequence of selection changes");
502 wxWindow *w = FindFocus();
537 (*Ctrls[i])->SetFormatName(
format );
541 (*Ctrls[iFocus])->SetFocus();
565 for(
int i=0;i<4;i++){
569 const auto &Temp = Text[i];
574 ?
XO(
"%s - driven").Format( Temp )
579 XO(
"Selection %s. %s won't change.").Format( Temp, Text[
fixed] );
588 int mode =
mChoice->GetSelection();
602 if ( projectAudioIO.IsAudioActive() ){
604 audioTime = gAudioIO->GetStreamTime();
611 SetTimes(selectedRegion.t0(), selectedRegion.t1(), audioTime);
620 wxSize sz = GetMinSize();
635 const int maxMode = 3;
665 int mask = masks[mode];
668 for(
int i=0;i<4;i++){
670 (*Ctrls[i])->Show( (mask & (1<<i))!=0 );
671 (*Ctrls[i])->Refresh();
683 (*Ctrls[i])->SetValue( Values[i] );
716 e.SetString(
format.Internal());
726 mRateBox->SetValue(wxString::Format(wxT(
"%d"), (
int)rate));
733 (*Ctrls[i])->SetSampleRate( rate );
741 if (value.ToDouble(&
mRate) &&
748 (*Ctrls[i])->SetSampleRate(
mRate );
762 wxString oldValue =
mRateBox->GetValue();
778 wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
779 wxWindow *w = FindFocus();
780 int keyCode = kevent->GetKeyCode();
783 if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) {
784 keyCode -= WXK_NUMPAD0 -
'0';
787 if (keyCode >=
'0' && keyCode <=
'9') {
@ Internal
Indicates internal failure from Audacity.
EVT_COMMAND(wxID_ANY, EVT_FREQUENCYTEXTCTRL_UPDATED, LabelDialog::OnFreqUpdate) LabelDialog
gPrefs Read(wxT("/GUI/VerticalZooming"), &bVZoom, false)
IMPLEMENT_CLASS(SelectionBar, ToolBar)
static RegisteredToolbarFactory factory
static const wxChar * numbers[]
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
static const int StandardRates[]
Array of common audio sample rates.
static const int NumStandardRates
How many standard sample rates there are.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
FormatStrings GetBuiltinFormat(const int index)
static NumericFormatSymbol LookupFormat(Type type, const wxString &id)
bool SetFormatString(const FormatStrings &formatString)
static ProjectAudioIO & Get(AudacityProject &project)
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
void OnIdle(wxIdleEvent &evt)
NumericTextCtrl * mStartTime
void SetSelectionFormat(const NumericFormatSymbol &format)
auStaticText * AddTitle(const TranslatableString &Title, wxSizer *pSizer)
NumericTextCtrl * AddTime(const TranslatableString &Name, int id, wxSizer *pSizer)
void OnRate(wxCommandEvent &event)
void OnSnapTo(wxCommandEvent &event)
void SelectionModeUpdated()
void RegenerateTooltips() override
void SetRate(double rate)
void SetSelectionMode(int mode)
void ShowHideControls(int mode)
NumericTextCtrl * mAudioTime
NumericTextCtrl * mLengthTime
void Create(wxWindow *parent) override
void OnFocus(wxFocusEvent &event)
void OnSize(wxSizeEvent &evt)
void OnUpdate(wxCommandEvent &evt)
void SetListener(SelectionBarListener *l)
void AddVLine(wxSizer *pSizer)
void SetDrivers(int driver1, int driver2)
static SelectionBar & Get(AudacityProject &project)
NumericTextCtrl * mEndTime
void OnCaptureKey(wxCommandEvent &event)
void OnChoice(wxCommandEvent &event)
void ModifySelection(int newDriver, bool done=false)
void UpdatePrefs() override
NumericTextCtrl * mCenterTime
void SetTimes(double start, double end, double audio)
SelectionBarListener * mListener
void OnChangedTime(wxCommandEvent &evt)
A parent class of SelectionBar, used to forward events to do with changes in the SelectionBar.
virtual const NumericFormatSymbol & AS_GetSelectionFormat()=0
virtual void AS_SetRate(double rate)=0
virtual void AS_ModifySelection(double &start, double &end, bool done)=0
virtual void AS_SetSnapTo(int snap)=0
virtual int AS_GetSnapTo()=0
virtual double AS_GetRate()=0
virtual void AS_SetSelectionFormat(const NumericFormatSymbol &format)=0
static const TranslatableStrings & GetSnapLabels()
wxColour & Colour(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
NotifyingSelectedRegion selectedRegion
static ViewInfo & Get(AudacityProject &project)
An alternative to using wxWindowAccessible, which in wxWidgets 3.1.1 contained GetParent() which was ...
is like wxStaticText, except it can be themed. wxStaticText can't be.
void OnFocus(wxWindow &window, wxFocusEvent &event)
a function useful to implement a focus event handler The window releases the keyboard if the event is...
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
PROJECT_RATE_API IntSetting DefaultSampleRate
AttachedToolBarMenuItem sAttachment