Audacity 3.2.0
SelectionBar.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 SelectionBar.h
6
7 Dominic Mazzoni
8 Dmitry Vedenko
9
10**********************************************************************/
11
12#ifndef __AUDACITY_SELECTION_BAR__
13#define __AUDACITY_SELECTION_BAR__
14
15#include <wx/defs.h>
16
17#include <array>
18
19#include "ToolBar.h"
21
22#include "Observer.h"
23
24
25class wxChoice;
26class wxComboBox;
27class wxCommandEvent;
28class wxDC;
29class wxSizeEvent;
30class wxStaticText;
31
32class AudacityProject;
33class NumericTextCtrl;
34
36
37class AUDACITY_DLL_API SelectionBar final : public ToolBar {
38
39 public:
40 enum class SelectionMode
41 {
42 StartEnd,
43 StartLength,
44 LengthEnd,
45 LengthCenter
46 };
47
48 static Identifier ID();
49
51 virtual ~SelectionBar();
52
53 bool ShownByDefault() const override;
54 DockID DefaultDockID() const override;
55
57 static const SelectionBar &Get( const AudacityProject &project );
58
59 void Create(wxWindow *parent) override;
60
61 void Populate() override;
62 void Repaint(wxDC * WXUNUSED(dc)) override {};
63 void EnableDisableButtons() override {};
64 void UpdatePrefs() override;
65
66 void SetTimes(double start, double end);
67
68 void SetSelectionFormat(const NumericFormatID & format);
69 void RegenerateTooltips() override;
70
71 private:
72 AButton* MakeSetupButton();
73
74 void AddTitle( const TranslatableString & Title,
75 wxSizer * pSizer );
76 void AddTime( int id, wxSizer * pSizer );
77 void AddSelectionSetupButton(wxSizer* pSizer);
78
79 void SetSelectionMode(SelectionMode mode);
80 void ValuesToControls();
81 void OnUpdate(wxCommandEvent &evt);
82
83 void OnFocus(wxFocusEvent &event);
84 void OnCaptureKey(wxCommandEvent &event);
85 void OnSize(wxSizeEvent &evt);
86 void OnIdle( wxIdleEvent &evt );
87
88 void ModifySelection(int driver, bool done = false);
89 void SelectionModeUpdated();
90
91 void UpdateTimeControlsFormat(const NumericFormatID& format);
92
93 void FitToTimeControls();
94
95 void OnFormatsChanged(struct ProjectNumericFormatsEvent);
96
97 double mRate;
98 double mStart, mEnd, mLength, mCenter;
99
100 SelectionMode mSelectionMode {};
101 SelectionMode mLastSelectionMode {};
102
103 std::array<NumericTextCtrl*, 2> mTimeControls {};
104 AButton* mSetupButton{};
105
106 Observer::Subscription mFormatChangedToFitValueSubscription[2];
107
110
111 public:
112
113 DECLARE_CLASS(SelectionBar)
114 DECLARE_EVENT_TABLE()
115};
116
117#endif
118
IntSetting SelectionToolbarMode
const auto project
static void OnSize(wxSizeEvent &evt)
Definition: VSTEditor.cpp:224
A wxButton with mouse-over behaviour.
Definition: AButton.h:104
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
Specialization of Setting for int.
Definition: Prefs.h:356
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
(not quite a Toolbar) at foot of screen for setting and viewing the selection range.
Definition: SelectionBar.h:37
wxString mLastValidText
Definition: SelectionBar.h:108
void EnableDisableButtons() override
Definition: SelectionBar.h:63
double mRate
Definition: SelectionBar.h:97
void Repaint(wxDC *WXUNUSED(dc)) override
Definition: SelectionBar.h:62
double mCenter
Definition: SelectionBar.h:98
const Observer::Subscription mFormatsSubscription
Definition: SelectionBar.h:109
Works with ToolManager and ToolDock to provide a dockable window in which buttons can be placed.
Definition: ToolBar.h:73
virtual void Populate()=0
virtual void RegenerateTooltips()=0
void UpdatePrefs() override
Definition: ToolBar.cpp:622
virtual bool ShownByDefault() const
Whether the toolbar should be shown by default. Default implementation returns true.
Definition: ToolBar.cpp:365
virtual void Create(wxWindow *parent)
Definition: ToolBar.cpp:492
virtual DockID DefaultDockID() const
Which dock the toolbar defaults into. Default implementation chooses the top dock.
Definition: ToolBar.cpp:375
Holds a msgid for the translation catalog; may also bind format arguments.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
void OnFocus(wxWindow &window, wxFocusEvent &event)
a function useful to implement a focus event handler The window releases the keyboard if the event is...
const char * end(const char *str) noexcept
Definition: StringUtils.h:106