41#include <wx/checkbox.h>
42#include <wx/combobox.h>
43#include <wx/settings.h>
45#include <wx/valtext.h>
46#include <wx/stattext.h>
48#include <wx/statline.h>
53#include "../KeyboardCapture.h"
57#include "../ProjectSettings.h"
62#include "../widgets/auStaticText.h"
64#if wxUSE_ACCESSIBILITY
110 return wxT(
"Selection");
114:
ToolBar(project,
XO(
"Selection"), ID()),
115 mListener(NULL), mRate(0.0),
116 mStart(0.0), mEnd(0.0), mLength(0.0), mCenter(0.0), mAudio(0.0),
119 mStartTime(NULL), mCenterTime(NULL), mLengthTime(NULL), mEndTime(NULL),
143#ifdef EXPERIMENTAL_DA
179 pTitle->SetForegroundColour(
theTheme.
Colour( clrTrackPanelText ) );
180 pSizer->Add( pTitle, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
192 pCtrl->SetName( Name );
193 pSizer->Add(pCtrl, 0, wxALIGN_TOP | wxRIGHT, 5);
198 pSizer->Add(
safenew wxStaticLine(
this, -1, wxDefaultPosition,
201 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5);
215 Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
219 wxColour clrText2 = *wxBLUE;
224#ifdef TIME_IN_SELECT_TOOLBAR
230 const wxString choices[4] = {
231 _(
"Start and End of Selection"),
232 _(
"Start and Length of Selection"),
233 _(
"Length and End of Selection"),
234 _(
"Length and Center of Selection"),
237 (
this,
ChoiceID, wxDefaultPosition, wxDefaultSize, 4, choices,
238 0, wxDefaultValidator,
_(
"Show"));
240#if wxUSE_ACCESSIBILITY
244 mainSizer->Add(
mChoice, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 6);
250 wxDefaultPosition, wxDefaultSize);
251#if wxUSE_ACCESSIBILITY
255 mRateBox->SetName(
_(
"Project Rate (Hz)"));
257 wxTextValidator vld(wxFILTER_INCLUDE_CHAR_LIST);
258 vld.SetIncludes(wxArrayString(10,
numbers));
268#if defined(__WXMAC__)
272 wxWindowList kids =
mRateBox->GetChildren();
273 for (
unsigned int i = 0; i < kids.size(); i++) {
274 wxClassInfo *ci = kids[i]->GetClassInfo();
275 if (ci->IsKindOf(CLASSINFO(wxTextCtrl))) {
289 mainSizer->Add(
mRateBox, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
294 wxDefaultPosition, wxDefaultSize,
295 transform_container< wxArrayStringEx >(
299#if wxUSE_ACCESSIBILITY
310 mSnapTo->Bind(wxEVT_KILL_FOCUS,
314 mainSizer->Add(
mSnapTo, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
318#ifdef TIME_IN_SELECT_TOOLBAR
332 auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
338 mainSizer->Add(hSizer.release(), 0, wxALIGN_TOP | wxRIGHT, 0);
341#if defined(__WXGTK3__)
343#elif defined(__WXGTK__)
345 wxFont font =
mChoice->GetFont();
348 rateLabel->SetFont(font);
349 snapLabel->SetFont(font);
418 _(
"Snap Clicks/Selections to %s"), formatName.Translation() ));
502 wxFAIL_MSG(
"Illegal sequence of selection changes");
555 (*Ctrls[i])->SetFormatName(
format );
583 for(
int i=0;i<4;i++){
587 const auto &Temp = Text[i];
592 ?
XO(
"%s - driven").Format( Temp )
597 XO(
"Selection %s. %s won't change.").Format( Temp, Text[
fixed] );
606 int mode =
mChoice->GetSelection();
620 if ( projectAudioIO.IsAudioActive() ){
622 audioTime = gAudioIO->GetStreamTime();
629 SetTimes(selectedRegion.t0(), selectedRegion.t1(), audioTime);
638 wxSize sz = GetMinSize();
653 const int maxMode = 3;
683 int mask = masks[mode];
686 for(
int i=0;i<4;i++){
688 (*Ctrls[i])->Show( (mask & (1<<i))!=0 );
689 (*Ctrls[i])->Refresh();
701 (*Ctrls[i])->SetValue( Values[i] );
734 e.SetString(
format.Internal());
744 mRateBox->SetValue(wxString::Format(
wxT(
"%d"), (
int)rate));
751 (*Ctrls[i])->SetSampleRate( rate );
759 if (value.ToDouble(&
mRate) &&
766 (*Ctrls[i])->SetSampleRate(
mRate );
780 wxString oldValue =
mRateBox->GetValue();
796 wxKeyEvent *kevent = (wxKeyEvent *)event.GetEventObject();
798 int keyCode = kevent->GetKeyCode();
801 if ((keyCode >= WXK_NUMPAD0) && (keyCode <= WXK_NUMPAD9)) {
802 keyCode -= WXK_NUMPAD0 -
'0';
805 if (keyCode >=
'0' && keyCode <=
'9') {
@ Internal
Indicates internal failure from Audacity.
XXO("&Cut/Copy/Paste Toolbar")
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
An explicitly nonlocalized string, not meant for the user to see.
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)
bool ShownByDefault() const override
Whether the toolbar should be shown by default. Default implementation returns true.
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)
SelectionBar(AudacityProject &project)
void ModifySelection(int newDriver, bool done=false)
DockID DefaultDockID() const override
Which dock the toolbar defaults into. Default implementation chooses the top dock.
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 SetFocus(const WindowPlacement &focus)
Set the window that accepts keyboard input.
std::unique_ptr< WindowPlacement > FindFocus()
Find the window that is accepting keyboard input, if any.
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