Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TimeToolBar Class Referencefinal

#include <TimeToolBar.h>

Inheritance diagram for TimeToolBar:
[legend]
Collaboration diagram for TimeToolBar:
[legend]

Public Member Functions

 TimeToolBar (AudacityProject &project)
 
virtual ~TimeToolBar ()
 
DockID DefaultDockID () const override
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
void Populate () override
 
void Repaint (wxDC *WXUNUSED(dc)) override
 
void EnableDisableButtons () override
 
void UpdatePrefs () override
 
void RegenerateTooltips () override
 
int GetInitialWidth () override
 Resizable toolbars should implement these. More...
 
int GetMinToolbarWidth () override
 
void SetToDefaultSize () override
 
wxSize GetDockedSize () override
 
void SetDocked (ToolDock *dock, bool pushed) override
 
void SetAudioTimeFormat (const NumericFormatID &format)
 
void ResizingDone () override
 
- Public Member Functions inherited from ToolBar
 ToolBar (AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
 
virtual ~ToolBar ()
 
virtual bool ShownByDefault () const
 Whether the toolbar should be shown by default. Default implementation returns true. More...
 
virtual bool HideAfterReset () const
 Default implementation returns false. More...
 
virtual DockID DefaultDockID () const
 Which dock the toolbar defaults into. Default implementation chooses the top dock. More...
 
bool AcceptsFocus () const override
 
bool AcceptsFocusFromKeyboard () const override
 
virtual void SetToDefaultSize ()
 
virtual void Create (wxWindow *parent)
 
virtual void EnableDisableButtons ()=0
 
virtual void ReCreateButtons ()
 
void UpdatePrefs () override
 
virtual void RegenerateTooltips ()=0
 
int GetIndex () const
 Get a value used for computing cascading positions of undocked bars. More...
 
void SetIndex (int index)
 Set a value used for computing cascading positions of undocked bars. More...
 
TranslatableString GetTitle ()
 
TranslatableString GetLabel ()
 
Identifier GetSection ()
 
ToolDockGetDock ()
 
void SetPreferredNeighbors (Identifier left, Identifier top={})
 
void SetLabel (const TranslatableString &label)
 
virtual void SetDocked (ToolDock *dock, bool pushed)
 
std::pair< Identifier, IdentifierPreferredNeighbors () const noexcept
 Defaults to (NoBarID, NoBarId) More...
 
virtual bool Expose (bool show=true)
 
bool IsResizable () const
 
bool IsVisible () const
 
bool IsDocked () const
 
bool IsPositioned ()
 
void SetVisible (bool bVisible)
 
void SetPositioned ()
 
virtual int GetInitialWidth ()
 Resizable toolbars should implement these. More...
 
virtual int GetMinToolbarWidth ()
 
virtual wxSize GetDockedSize ()
 
wxSize GetSmartDockedSize ()
 
virtual void ResizingDone ()
 
- Public Member Functions inherited from wxPanelWrapper
 wxPanelWrapper ()
 
 wxPanelWrapper (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
bool Create (wxWindow *parent, wxWindowID winid=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxTAB_TRAVERSAL|wxNO_BORDER, const TranslatableString &name=XO("Panel"))
 
void SetLabel (const TranslatableString &label)
 
void SetName (const TranslatableString &name)
 
void SetToolTip (const TranslatableString &toolTip)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxPanel >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Static Public Member Functions

static Identifier ID ()
 
static TimeToolBarGet (AudacityProject &project)
 
static const TimeToolBarGet (const AudacityProject &project)
 
- Static Public Member Functions inherited from ToolBar
static AButtonMakeButton (wxWindow *parent, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxWindowID id, wxPoint placement, bool processdownevents, wxSize size)
 
static AButtonMakeButton (ToolBar *parent, teBmps eEnabledUp, teBmps eEnabledDown, teBmps eDisabled, int id, bool processdownevents, const TranslatableString &label)
 
static void MakeAlternateImages (AButton &button, int idx, teBmps eUp, teBmps eDown, teBmps eHilite, teBmps eDownHi, teBmps eStandardUp, teBmps eStandardDown, teBmps eDisabled, wxSize size)
 
static void SetButtonToolTip (AudacityProject &project, AButton &button, const ComponentInterfaceSymbol commands[], size_t nCommands)
 
static void MakeButtonBackgroundsSmall ()
 
static void MakeButtonBackgroundsLarge ()
 

Private Member Functions

void SetResizingLimits ()
 
wxSize ComputeSizing (int digitH)
 
void OnFormatsChanged (ProjectNumericFormatsEvent)
 
void OnUpdate (wxCommandEvent &evt)
 
void OnSize (wxSizeEvent &evt)
 
void OnIdle (wxIdleEvent &evt)
 

Private Attributes

NumericTextCtrlmAudioTime
 
float mDigitRatio
 
bool mSettingInitialSize = true
 
Observer::Subscription mFormatChangedToFitValueSubscription
 
Observer::Subscription mFormatsSubscription
 

Static Private Attributes

static const int minDigitH = 17
 
static const int maxDigitH = 100
 

Additional Inherited Members

- Public Types inherited from ToolBar
enum  DockID { TopDockID = 1 , BotDockID = 2 }
 Identifies one of the docking areas for toolbars. More...
 
using Holder = wxWindowPtr< ToolBar >
 
- Protected Member Functions inherited from ToolBar
void SetButton (bool down, AButton *button)
 
wxBoxSizer * GetSizer ()
 
void Add (wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
 
void Add (wxSizer *sizer, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void Add (int width, int height, int proportion=0, int flag=0, int border=0, wxObject *userData=NULL)
 
void AddSpacer (int size=14)
 
void AddStretchSpacer (int prop=1)
 
void Detach (wxWindow *window)
 
void Detach (wxSizer *sizer)
 
void Updated ()
 
int GetResizeGrabberWidth ()
 Returns the width in pixels of the resizer element. More...
 
virtual void Populate ()=0
 
virtual void Repaint (wxDC *dc)=0
 
void OnErase (wxEraseEvent &event)
 
void OnPaint (wxPaintEvent &event)
 
void OnMouseEvents (wxMouseEvent &event)
 
- Protected Member Functions inherited from PrefsListener
virtual void UpdateSelectedPrefs (int id)
 
 PrefsListener ()
 
virtual ~PrefsListener ()
 
virtual void UpdatePrefs ()=0
 
- Static Protected Member Functions inherited from ToolBar
static void MakeMacRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeMacRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
static void MakeRecoloredImage (teBmps eBmpOut, teBmps eBmpIn)
 
static void MakeRecoloredImageSize (teBmps eBmpOut, teBmps eBmpIn, const wxSize &size)
 
- Static Protected Member Functions inherited from PrefsListener
static void Broadcast (int id=0)
 Call this static function to notify all PrefsListener objects. More...
 
- Protected Attributes inherited from ToolBar
AudacityProjectmProject
 
TranslatableString mLabel
 
Identifier mSection
 
int mIndex {0}
 

Detailed Description

Definition at line 23 of file TimeToolBar.h.

Constructor & Destructor Documentation

◆ TimeToolBar()

TimeToolBar::TimeToolBar ( AudacityProject project)

Definition at line 58 of file TimeToolBar.cpp.

59 : ToolBar(project, XO("Time"), ID(), true)
60 , mAudioTime{ nullptr }
61{
64}
XO("Cut/Copy/Paste")
const auto project
Subscription Subscribe(Callback callback)
Connect a callback to the Publisher; later-connected are called earlier.
Definition: Observer.h:199
static ProjectNumericFormats & Get(AudacityProject &project)
Observer::Subscription mFormatsSubscription
Definition: TimeToolBar.h:65
void OnFormatsChanged(ProjectNumericFormatsEvent)
NumericTextCtrl * mAudioTime
Definition: TimeToolBar.h:57
static Identifier ID()
Definition: TimeToolBar.cpp:53
ToolBar(AudacityProject &project, const TranslatableString &label, const Identifier &section, bool resizable=false)
Definition: ToolBar.cpp:328

References ProjectNumericFormats::Get(), mFormatsSubscription, OnFormatsChanged(), project, and Observer::Publisher< Message, NotifyAll >::Subscribe().

Here is the call graph for this function:

◆ ~TimeToolBar()

TimeToolBar::~TimeToolBar ( )
virtual

Definition at line 66 of file TimeToolBar.cpp.

67{
68}

Member Function Documentation

◆ ComputeSizing()

wxSize TimeToolBar::ComputeSizing ( int  digitH)
private

Definition at line 391 of file TimeToolBar.cpp.

392{
393 return mAudioTime->ComputeSizing(false, digitH * mDigitRatio, digitH);
394}
wxSize ComputeSizing(bool update=true, wxCoord digitW=0, wxCoord digitH=0)
float mDigitRatio
Definition: TimeToolBar.h:58

References NumericTextCtrl::ComputeSizing(), mAudioTime, and mDigitRatio.

Referenced by OnSize(), and SetResizingLimits().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DefaultDockID()

ToolBar::DockID TimeToolBar::DefaultDockID ( ) const
overridevirtual

Which dock the toolbar defaults into. Default implementation chooses the top dock.

Reimplemented from ToolBar.

Definition at line 70 of file TimeToolBar.cpp.

71{
72 return BotDockID;
73}
@ BotDockID
Definition: ToolBar.h:94

References ToolBar::BotDockID.

◆ EnableDisableButtons()

void TimeToolBar::EnableDisableButtons ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 38 of file TimeToolBar.h.

38{};

◆ Get() [1/2]

TimeToolBar & TimeToolBar::Get ( AudacityProject project)
static

Definition at line 75 of file TimeToolBar.cpp.

76{
77 auto &toolManager = ToolManager::Get(project);
78 return *static_cast<TimeToolBar*>(toolManager.GetToolBar(ID()));
79}
static ToolManager & Get(AudacityProject &project)

References ToolManager::Get(), ID(), and project.

Referenced by Get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Get() [2/2]

const TimeToolBar & TimeToolBar::Get ( const AudacityProject project)
static

Definition at line 81 of file TimeToolBar.cpp.

82{
83 return Get(const_cast<AudacityProject&>(project)) ;
84}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static TimeToolBar & Get(AudacityProject &project)
Definition: TimeToolBar.cpp:75

References Get(), and project.

Here is the call graph for this function:

◆ GetDockedSize()

wxSize TimeToolBar::GetDockedSize ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 166 of file TimeToolBar.cpp.

167{
168 wxSize sz = GetSize();
169
170 // Anything less than a single height bar becomes single height
171 if (sz.y <= toolbarSingle) {
172 sz.y = toolbarSingle;
173 }
174 // Otherwise it will be a double height bar
175 else {
176 sz.y = 2 * toolbarSingle + toolbarGap;
177 }
178
179 return sz;
180}
#define toolbarSingle
Definition: ToolBar.h:59
#define toolbarGap
Definition: ToolBar.h:64

References toolbarGap, and toolbarSingle.

◆ GetInitialWidth()

int TimeToolBar::GetInitialWidth ( )
inlineoverridevirtual

Resizable toolbars should implement these.

Reimplemented from ToolBar.

Definition at line 41 of file TimeToolBar.h.

41{return 250;}

Referenced by SetToDefaultSize().

Here is the caller graph for this function:

◆ GetMinToolbarWidth()

int TimeToolBar::GetMinToolbarWidth ( )
inlineoverridevirtual

Reimplemented from ToolBar.

Definition at line 42 of file TimeToolBar.h.

42{return 50;}

◆ ID()

Identifier TimeToolBar::ID ( )
static

Definition at line 53 of file TimeToolBar.cpp.

54{
55 return wxT("Time");
56}
wxT("CloseDown"))

References wxT().

Referenced by Get().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnFormatsChanged()

void TimeToolBar::OnFormatsChanged ( ProjectNumericFormatsEvent  evt)
private

Definition at line 277 of file TimeToolBar.cpp.

278{
280 switch (evt.type) {
282 SetAudioTimeFormat(settings.GetAudioTimeFormat());
283 break;
284 default:
285 break;
286 }
287}
static Settings & settings()
Definition: TrackInfo.cpp:47
void SetAudioTimeFormat(const NumericFormatID &format)
AudacityProject & mProject
Definition: ToolBar.h:248
enum ProjectNumericFormatsEvent::Type type

References ProjectNumericFormatsEvent::ChangedAudioTimeFormat, ProjectNumericFormats::Get(), ToolBar::mProject, SetAudioTimeFormat(), settings(), and ProjectNumericFormatsEvent::type.

Referenced by TimeToolBar().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnIdle()

void TimeToolBar::OnIdle ( wxIdleEvent &  evt)
private

Definition at line 372 of file TimeToolBar.cpp.

373{
374 evt.Skip();
375
376 double audioTime;
377
378 auto &projectAudioIO = ProjectAudioIO::Get(mProject);
379 if (projectAudioIO.IsAudioActive()) {
380 auto gAudioIO = AudioIO::Get();
381 audioTime = gAudioIO->GetStreamTime();
382 }
383 else {
384 const auto &playRegion = ViewInfo::Get(mProject).playRegion;
385 audioTime = playRegion.GetStart();
386 }
387
388 mAudioTime->SetValue(wxMax(0.0, audioTime));
389}
static AudioIO * Get()
Definition: AudioIO.cpp:126
void SetValue(double newValue)
double GetStart() const
Definition: ViewInfo.h:128
static ProjectAudioIO & Get(AudacityProject &project)
PlayRegion playRegion
Definition: ViewInfo.h:216
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235

References AudioIO::Get(), ProjectAudioIO::Get(), ViewInfo::Get(), PlayRegion::GetStart(), mAudioTime, ToolBar::mProject, ViewInfo::playRegion, and NumericTextCtrl::SetValue().

Here is the call graph for this function:

◆ OnSize()

void TimeToolBar::OnSize ( wxSizeEvent &  evt)
private

Definition at line 326 of file TimeToolBar.cpp.

327{
328 evt.Skip();
329
330 // Can fire before we're ready
331 if (!mAudioTime) {
332 return;
333 }
334
335 // Make sure everything is where it's supposed to be
336 Layout();
337
338 // Get the sizer's size and remove any borders the time control might have.
339 wxSize sizerBR = GetSizer()->GetSize() - (mAudioTime->GetSize() - mAudioTime->GetClientSize());
340
341 // Get the content size of the time control. This can be different than the
342 // control itself due to borders and sizer enduced changes.
343 wxSize timeBR = mAudioTime->GetDimensions();
344
345 // Get the current digit box height
346 int h = mAudioTime->GetDigitSize().y;
347
348 // Increase current size to find the best fit within the new size
349 if (sizerBR.x >= timeBR.x && sizerBR.y >= timeBR.y) {
350 do {
351 h++;
352 timeBR = ComputeSizing(h);
353 } while (h < maxDigitH && sizerBR.x >= timeBR.x && sizerBR.y >= timeBR.y);
354 h--;
355 }
356 // In all other cases, we need to decrease current size to fit within new size
357 else if (sizerBR.x < timeBR.x || sizerBR.y < timeBR.y) {
358 do {
359 h--;
360 timeBR = ComputeSizing(h);
361 } while (h >= minDigitH && (sizerBR.x < timeBR.x || sizerBR.y < timeBR.y));
362 }
363
364 if (h != mAudioTime->GetDigitSize().y) {
366 }
367
368 // Redraw the display immediately to smooth out resizing
369 Update();
370}
wxSize GetDimensions()
void SetDigitSize(int width, int height)
static const int minDigitH
Definition: TimeToolBar.h:61
wxSize ComputeSizing(int digitH)
wxBoxSizer * GetSizer()
Definition: ToolBar.cpp:701

References ComputeSizing(), NumericTextCtrl::GetDigitSize(), NumericTextCtrl::GetDimensions(), ToolBar::GetSizer(), mAudioTime, mDigitRatio, minDigitH, and NumericTextCtrl::SetDigitSize().

Referenced by Populate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ OnUpdate()

void TimeToolBar::OnUpdate ( wxCommandEvent &  evt)
private

Definition at line 291 of file TimeToolBar.cpp.

292{
293 evt.Skip(false);
294
296
297 // Reset to allow resizing to work
298 SetMinSize(wxDefaultSize);
299 SetMaxSize(wxDefaultSize);
300
301 // Save format name before recreating the controls so they resize properly
302 auto &formats = ProjectNumericFormats::Get(mProject);
303 formats.SetAudioTimeFormat(evt.GetString());
304 // Then my subscription is called
305
306 // During initialization, the desired size will have already been set at this point
307 // and the "best" size" would override it, so we simply send a size event to force
308 // the content to fit inside the toolbar.
310 mSettingInitialSize = false;
311 SendSizeEvent();
312 }
313 // Otherwise we want the toolbar to resize to fit around the content
314 else {
315 // Fit() while retaining height
316 SetSize(GetBestSize().x, GetSize().y);
317 }
318
319 // Go set the new size limits
321
322 // Inform others the toobar has changed
323 Updated();
324}
void SetResizingLimits()
bool mSettingInitialSize
Definition: TimeToolBar.h:59
virtual void ReCreateButtons()
Definition: ToolBar.cpp:533
void Updated()
Definition: ToolBar.cpp:684

References ProjectNumericFormats::Get(), ToolBar::mProject, mSettingInitialSize, ToolBar::ReCreateButtons(), SetResizingLimits(), and ToolBar::Updated().

Referenced by Populate(), SetAudioTimeFormat(), and UpdatePrefs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Populate()

void TimeToolBar::Populate ( )
overridevirtual

Implements ToolBar.

Definition at line 86 of file TimeToolBar.cpp.

87{
88 const auto &formats = ProjectNumericFormats::Get(mProject);
89
90 // Get the default time format
91 auto format = formats.GetAudioTimeFormat();
92
93 // Create the read-only time control
95 mAudioTime->SetName(XO("Audio Position"));
97
98 // Add it to the toolbar
99 Add(mAudioTime, 0, wxALIGN_CENTER, 0);
100
101 // Calculate the width to height ratio
102 wxSize digitSize = mAudioTime->GetDigitSize();
103 mDigitRatio = (float)digitSize.x / digitSize.y;
104
105 // During initialization, we need to bypass some resizing to prevent the "best size"
106 // from being used as we want to ensure the saved size is used instead. See SetDocked()
107 // and OnUpdate() for more info.
108 mSettingInitialSize = true;
109 CallAfter([this]{
110 auto &formats = ProjectNumericFormats::Get(mProject);
111 // Get (and set) the saved time format
112 SetAudioTimeFormat(formats.GetAudioTimeFormat());
113
114 // During initialization, if the saved format is the same as the default,
115 // OnUpdate() will not otherwise be called but we need it to set the
116 // initial size.
118 wxCommandEvent e;
119 e.SetString(mAudioTime->GetFormatName().GET());
120 OnUpdate(e);
121 }
122 });
123
124 // Establish initial resizing limits
125 // SetResizingLimits();
127 [this](auto)
128 {
129 wxSizeEvent e;
130 OnSize(e);
131 });
132}
#define safenew
Definition: MemoryX.h:10
const NumericConverterType & NumericConverterType_TIME()
@ AudioPositionID
Definition: TimeToolBar.cpp:44
static FormatterContext ProjectContext(const AudacityProject &project)
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
NumericFormatID GetFormatName() const
void SetReadOnly(bool readOnly=true)
void SetName(const TranslatableString &name)
void OnSize(wxSizeEvent &evt)
void OnUpdate(wxCommandEvent &evt)
Observer::Subscription mFormatChangedToFitValueSubscription
Definition: TimeToolBar.h:64
void Add(wxWindow *window, int proportion=0, int flag=wxALIGN_TOP, int border=0, wxObject *userData=NULL)
Definition: ToolBar.cpp:709
void CallAfter(Action action)
Schedule an action to be done later, and in the main thread.
Definition: BasicUI.cpp:214

References ToolBar::Add(), AudioPositionID, BasicUI::CallAfter(), anonymous_namespace{ExportPCM.cpp}::format, Identifier::GET(), ProjectNumericFormats::Get(), NumericTextCtrl::GetDigitSize(), NumericConverter::GetFormatName(), mAudioTime, mDigitRatio, mFormatChangedToFitValueSubscription, ToolBar::mProject, mSettingInitialSize, NumericConverterType_TIME(), OnSize(), OnUpdate(), FormatterContext::ProjectContext(), safenew, SetAudioTimeFormat(), NumericTextCtrl::SetName(), NumericTextCtrl::SetReadOnly(), Observer::Publisher< Message, NotifyAll >::Subscribe(), and XO().

Here is the call graph for this function:

◆ RegenerateTooltips()

void TimeToolBar::RegenerateTooltips ( )
inlineoverridevirtual

Implements ToolBar.

Definition at line 40 of file TimeToolBar.h.

40{};

◆ Repaint()

void TimeToolBar::Repaint ( wxDC *  WXUNUSEDdc)
inlineoverride

Definition at line 37 of file TimeToolBar.h.

37{};

◆ ResizingDone()

void TimeToolBar::ResizingDone ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 220 of file TimeToolBar.cpp.

221{
222 // Fit() while retaining height
223 SetSize(GetBestSize().x, GetSize().y);
224
225 // Inform others the toobar has changed
226 Updated();
227}

References ToolBar::Updated().

Here is the call graph for this function:

◆ SetAudioTimeFormat()

void TimeToolBar::SetAudioTimeFormat ( const NumericFormatID format)

Definition at line 207 of file TimeToolBar.cpp.

208{
209 // Set the format if it's different from previous
211 // Simulate an update since the format has changed.
212 wxCommandEvent e;
213 e.SetString(format.GET());
214 OnUpdate(e);
215 }
216}
bool SetFormatName(const NumericFormatID &formatName)

References anonymous_namespace{ExportPCM.cpp}::format, mAudioTime, OnUpdate(), and NumericTextCtrl::SetFormatName().

Referenced by OnFormatsChanged(), Populate(), and SetToDefaultSize().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDocked()

void TimeToolBar::SetDocked ( ToolDock dock,
bool  pushed 
)
overridevirtual

Reimplemented from ToolBar.

Definition at line 182 of file TimeToolBar.cpp.

183{
184 // It's important to call this FIRST since it unhides the resizer control.
185 // Not doing so causes the calculated best size to be off by the width
186 // of the resizer.
187 ToolBar::SetDocked(dock, pushed);
188
189 // Recalculate the min and max limits
191
192 // When moving from floater to dock, fit to toolbar since the resizer will
193 // be mispositioned
194 if (dock) {
195 // During initialization, the desired size is already set, so do not
196 // override it with the "best size". See OnUpdate for further info.
197 if (!mSettingInitialSize) {
198 // Fit() while retaining height
199 SetSize(GetBestSize().x, GetSize().y);
200
201 // Inform others the toolbar has changed
202 Updated();
203 }
204 }
205}
virtual void SetDocked(ToolDock *dock, bool pushed)
Definition: ToolBar.cpp:661

References mSettingInitialSize, ToolBar::SetDocked(), SetResizingLimits(), and ToolBar::Updated().

Here is the call graph for this function:

◆ SetResizingLimits()

void TimeToolBar::SetResizingLimits ( )
private

Definition at line 229 of file TimeToolBar.cpp.

230{
231 // Reset limits
232 SetMinSize(wxDefaultSize);
233 SetMaxSize(wxDefaultSize);
234
235 // If docked we use the current bar height since it's always a single or double height
236 // toolbar. For floaters, single height toolbar is the minimum height.
237 int minH = IsDocked() ? GetSize().y : toolbarSingle;
238
239 // Get the content size given the smallest digit height we allow
240 wxSize minSize = ComputeSizing(minDigitH);
241
242 // Account for any borders added by the window manager
243 minSize.x += (mAudioTime->GetSize().x - mAudioTime->GetClientSize().x);
244
245 // Calculate the space used by other controls and sizer borders with this toolbar
246 wxSize outer = (GetSize() - GetSizer()->GetSize());
247
248 // And account for them in the width
249 minSize.x += outer.x;
250
251 // Override the height
252 minSize.y = minH;
253
254 // Get the maximum digit height we can use. This is restricted to the toolbar's
255 // current height minus any control borders
256 int digH = minH - (mAudioTime->GetSize().y - mAudioTime->GetClientSize().y);
257
258 // Get the content size using the digit height, if docked. Otherwise use the
259 // maximum digit height we allow.
260 wxSize maxSize = ComputeSizing(IsDocked() ? digH : maxDigitH);
261
262 // Account for the other controls and sizer borders within this toolbar
263 maxSize.x += outer.x;
264
265 // Account for any borders added by the window manager and +1 to keep toolbar
266 // from dropping to next smaller size when grabbing the resizer.
267 maxSize.x += (mAudioTime->GetSize().x - mAudioTime->GetClientSize().x) + 1;
268
269 // Override the height
270 maxSize.y = IsDocked() ? minH : wxDefaultCoord;
271
272 // And finally set them both
273 SetMinSize(minSize);
274 SetMaxSize(maxSize);
275}
static const wxPoint2DDouble outer[]
Definition: ASlider.cpp:400
static const int maxDigitH
Definition: TimeToolBar.h:62
bool IsDocked() const
Definition: ToolBar.cpp:433

References ComputeSizing(), ToolBar::GetSizer(), ToolBar::IsDocked(), mAudioTime, maxDigitH, minDigitH, outer, and toolbarSingle.

Referenced by OnUpdate(), and SetDocked().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetToDefaultSize()

void TimeToolBar::SetToDefaultSize ( )
overridevirtual

Reimplemented from ToolBar.

Definition at line 149 of file TimeToolBar.cpp.

150{
151 // Reset
152 SetMaxSize(wxDefaultSize);
153 SetMinSize(wxDefaultSize);
154
155 // Set the default time format
158
159 // Set the default size
160 SetSize(GetInitialWidth(), 48);
161
162 // Inform others the toobar has changed
163 Updated();
164}
@ Internal
Indicates internal failure from Audacity.
int GetInitialWidth() override
Resizable toolbars should implement these.
Definition: TimeToolBar.h:41
NUMERIC_FORMATS_API NumericFormatSymbol HoursMinsSecondsFormat()

References GetInitialWidth(), NumericConverterFormats::HoursMinsSecondsFormat(), Internal, SetAudioTimeFormat(), and ToolBar::Updated().

Here is the call graph for this function:

◆ UpdatePrefs()

void TimeToolBar::UpdatePrefs ( )
overridevirtual

Implements PrefsListener.

Definition at line 134 of file TimeToolBar.cpp.

135{
136 // Since the language may have changed, we need to force an update to accommodate
137 // different length text
138 wxCommandEvent e;
139 e.SetString(mAudioTime->GetFormatName().GET());
140 OnUpdate(e);
141
142 // Language may have changed so reset label
143 SetLabel(XO("Time"));
144
145 // Give the toolbar a chance
147}
void SetLabel(const wxString &label) override
Definition: ToolBar.cpp:408
void UpdatePrefs() override
Definition: ToolBar.cpp:622

References Identifier::GET(), NumericConverter::GetFormatName(), mAudioTime, OnUpdate(), ToolBar::SetLabel(), ToolBar::UpdatePrefs(), and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mAudioTime

NumericTextCtrl* TimeToolBar::mAudioTime
private

◆ maxDigitH

const int TimeToolBar::maxDigitH = 100
staticprivate

Definition at line 62 of file TimeToolBar.h.

Referenced by SetResizingLimits().

◆ mDigitRatio

float TimeToolBar::mDigitRatio
private

Definition at line 58 of file TimeToolBar.h.

Referenced by ComputeSizing(), OnSize(), and Populate().

◆ mFormatChangedToFitValueSubscription

Observer::Subscription TimeToolBar::mFormatChangedToFitValueSubscription
private

Definition at line 64 of file TimeToolBar.h.

Referenced by Populate().

◆ mFormatsSubscription

Observer::Subscription TimeToolBar::mFormatsSubscription
private

Definition at line 65 of file TimeToolBar.h.

Referenced by TimeToolBar().

◆ minDigitH

const int TimeToolBar::minDigitH = 17
staticprivate

Definition at line 61 of file TimeToolBar.h.

Referenced by OnSize(), and SetResizingLimits().

◆ mSettingInitialSize

bool TimeToolBar::mSettingInitialSize = true
private

Definition at line 59 of file TimeToolBar.h.

Referenced by OnUpdate(), Populate(), and SetDocked().


The documentation for this class was generated from the following files: