1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Fix Big Time TimerToolBar, Stage II

- Naming (Time Toolbar, not TimerToolBar Toolbar)
- Default time format hhmmss
- Lower dock
- Enabled by default
- Sensible min and max font size
- Sensible min and initial width
- Omit Audio Time from Selection Toolbar
This commit is contained in:
James Crook 2020-02-06 09:37:57 +00:00
parent f0e3ee2cde
commit a09885e995
9 changed files with 58 additions and 23 deletions

View File

@ -52,12 +52,12 @@ void OnShowTransportToolBar(const CommandContext &context)
MenuManager::Get(project).ModifyToolbarMenus(project);
}
void OnShowTimerToolBar(const CommandContext &context)
void OnShowTimeToolBar(const CommandContext &context)
{
auto &project = context.project;
auto &toolManager = ToolManager::Get( project );
toolManager.ShowHide( TimerBarID );
toolManager.ShowHide( TimeBarID );
MenuManager::Get(project).ModifyToolbarMenus(project);
}
@ -341,9 +341,9 @@ BaseItemSharedPtr ToolbarsMenu()
,
/* i18n-hint: Clicking this menu item shows the toolbar
for viewing actual time of the cursor*/
Command( wxT("ShowTimerToolBarTB"), XXO("&Timer Toolbar"),
FN(OnShowTimerToolBar), AlwaysEnabledFlag,
Options{}.CheckTest( ToolbarCheckFn( TimerBarID ) ) )
Command( wxT("ShowTimeToolBarTB"), XXO("&Time Toolbar"),
FN(OnShowTimeToolBar), AlwaysEnabledFlag,
Options{}.CheckTest( ToolbarCheckFn( TimeBarID ) ) )
#endif
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
,

View File

@ -216,8 +216,10 @@ void SelectionBar::Populate()
AddVLine( mainSizer );
AddTitle( _("Snap-To"), mainSizer );
AddVLine( mainSizer );
#ifdef TIME_IN_SELECT_TOOLBAR
AddTitle( _("Audio Position"), mainSizer );
AddVLine( mainSizer );
#endif
{
const wxString choices[4] = {
@ -328,6 +330,7 @@ void SelectionBar::Populate()
AddVLine( mainSizer );
#ifdef TIME_IN_SELECT_TOOLBAR
mAudioTime = AddTime( XO("Audio Position"), AudioTimeID, mainSizer );
// This vertical line is NOT just for decoration!
// It works around a wxWidgets-on-Windows RadioButton bug, where tabbing
@ -338,6 +341,7 @@ void SelectionBar::Populate()
// More about the bug here:
// https://forums.wxwidgets.org/viewtopic.php?t=41120
AddVLine( mainSizer );
#endif
{
auto hSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
@ -543,10 +547,12 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
auto format = mStartTime->GetBuiltinFormat(index);
for( i=0;i<5;i++)
(*Ctrls[i])->SetFormatString( format );
if( *Ctrls[i] )
(*Ctrls[i])->SetFormatString( format );
if( iFocus >=0 )
(*Ctrls[iFocus])->SetFocus();
if( *Ctrls[iFocus] )
(*Ctrls[iFocus])->SetFocus();
Updated();
}

View File

@ -24,7 +24,12 @@
// Vertical Line
// Cursor position
#ifdef TIME_IN_SELECT_TOOLBAR
#define SIZER_COLS 7
#else
#define SIZER_COLS 5
#endif
class wxChoice;
class wxComboBox;

View File

@ -68,7 +68,7 @@ BEGIN_EVENT_TABLE(TimerToolBar, ToolBar)
END_EVENT_TABLE()
TimerToolBar::TimerToolBar( AudacityProject &project )
: ToolBar(project, TimerBarID, XO("TimerToolBar"), wxT("TimerToolBar"),true),
: ToolBar(project, TimeBarID, XO("TimeToolBar"), wxT("TimeToolBar"),true),
mListener(NULL), mAudioTime(NULL)
{
mRate = (double) gPrefs->Read(wxT("/SamplingRate/DefaultProjectSampleRate"),
@ -82,7 +82,7 @@ TimerToolBar::~TimerToolBar()
TimerToolBar &TimerToolBar::Get( AudacityProject &project )
{
auto &toolManager = ToolManager::Get( project );
return *static_cast<TimerToolBar*>( toolManager.GetToolBar(TimerBarID) );
return *static_cast<TimerToolBar*>( toolManager.GetToolBar(TimeBarID) );
}
const TimerToolBar &TimerToolBar::Get( const AudacityProject &project )
@ -99,11 +99,13 @@ void TimerToolBar::Create(wxWindow * parent)
NumericTextCtrl * TimerToolBar::AddTime(
const TranslatableString &Name, int id)
{
auto formatName = mListener ? mListener->AS_GetSelectionFormat()
: NumericFormatSymbol{};
//auto formatName = mListener ? mListener->AS_GetSelectionFormat()
//: NumericFormatSymbol{};
auto formatName = NumericConverter::HoursMinsSecondsFormat();
auto pCtrl = safenew NumericTextCtrl(
this, id, NumericConverter::TIME, formatName, 0.0, mRate);
pCtrl->SetName(Name);
pCtrl->SetReadOnly(true);
return pCtrl;
}
@ -119,10 +121,18 @@ void TimerToolBar::Populate()
void TimerToolBar::UpdatePrefs()
{
SetLabel(XO("TimerToolBar"));
SetLabel(XO("Time"));
ToolBar::UpdatePrefs();
}
void TimerToolBar::SetToDefaultSize(){
wxSize sz;
sz.SetHeight( 80 );
sz.SetWidth( GetInitialWidth());
SetSize( sz );
}
void TimerToolBar::OnSize(wxSizeEvent & ev)
{
ev.Skip();
@ -133,7 +143,7 @@ void TimerToolBar::OnSize(wxSizeEvent & ev)
// This 'OnSize' function is also called during moving the
// toolbar.
// 10 and 40 are magic numbers to allow some space around
// 10 and 50 are magic numbers to allow some space around
// the numeric control. The horizontal space reserved
// is deliberately not quite enough. Size of font is set
// primarily by the height of the toolbar. The width
@ -143,15 +153,20 @@ void TimerToolBar::OnSize(wxSizeEvent & ev)
// size and adjust the width so that part of the control
// does not disappear.
float f = mAudioTime->GetAspectRatio();
int sh = wxMax( 5, ev.GetSize().GetHeight() - 10);
int sw = wxMax( sh, ev.GetSize().GetWidth() - 40)/f;
sh = wxMin( sh, sw );
mAudioTime->SetDigitSize( sh*0.63, sh );
int sh = ev.GetSize().GetHeight() - 10;
int sw = (ev.GetSize().GetWidth() - 50)/f;
sw = wxMin( sh, sw );
// The 22 and 77 are magic numbers setting min and max
// font sizes.
sw = wxMin( sw, 77 );
sw = wxMax( 20, sw );
sh = sw * 0.63;
mAudioTime->SetDigitSize( sh, sw );
// Refresh and update immediately, so that we don't get
// to see grot from partly redrawn toolbar during
// the resizing.
Refresh(false);
Refresh(true);
Update();
}
@ -209,7 +224,7 @@ void TimerToolBar::OnSnapTo(wxCommandEvent & WXUNUSED(event))
mListener->AS_SetSnapTo(mSnapTo->GetSelection());
}
static RegisteredToolbarFactory factory{ TimerBarID,
static RegisteredToolbarFactory factory{ TimeBarID,
[]( AudacityProject &project ){
return ToolBar::Holder{ safenew TimerToolBar{ project } }; }
};

View File

@ -37,6 +37,10 @@ public:
void SetTimes(double audio);
void RegenerateTooltips() override {};
int GetInitialWidth() override {return 250;}
int GetMinToolbarWidth() override { return 150; }
void SetToDefaultSize() override;
wxSize GetDockedSize() override {
return GetSmartDockedSize();
};

View File

@ -81,7 +81,7 @@ enum
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
SpectralSelectionBarID,
#endif
TimerBarID,
TimeBarID,
ToolBarCount
};
@ -106,7 +106,7 @@ class ToolBar /* not final */
bool AcceptsFocus() const override { return false; };
void SetToDefaultSize();
virtual void SetToDefaultSize();
//NEW virtuals:
virtual void Create(wxWindow *parent);
virtual void EnableDisableButtons() = 0;

View File

@ -528,6 +528,7 @@ static struct DefaultConfigEntry {
// Bottom dock
{ SelectionBarID, NoBarID, NoBarID },
{ TimeBarID, SelectionBarID, NoBarID },
// Hidden by default in bottom dock
{ SpectralSelectionBarID, NoBarID, NoBarID },
@ -567,6 +568,7 @@ void ToolManager::Reset()
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
|| ndx == SpectralSelectionBarID
#endif
|| ndx == TimeBarID
)
dock = mBotDock;
else
@ -737,8 +739,8 @@ void ToolManager::ReadConfig()
bShownByDefault = false;
if( ndx == ScrubbingBarID )
bShownByDefault = false;
if( ndx == TimerBarID )
bShownByDefault = false;
if( ndx == TimeBarID )
defaultDock = BotDockID;
#ifdef EXPERIMENTAL_SPECTRAL_EDITING
if( ndx == SpectralSelectionBarID ){

View File

@ -650,6 +650,8 @@ NumericFormatSymbol NumericConverter::TimeAndSampleFormat()
{ return TimeConverterFormats_[5].name; }
NumericFormatSymbol NumericConverter::SecondsFormat()
{ return TimeConverterFormats_[0].name; }
NumericFormatSymbol NumericConverter::HoursMinsSecondsFormat()
{ return TimeConverterFormats_[1].name; }
NumericFormatSymbol NumericConverter::HundredthsFormat()
{ return TimeConverterFormats_[3].name; }

View File

@ -56,6 +56,7 @@ public:
static NumericFormatSymbol DefaultSelectionFormat();
static NumericFormatSymbol TimeAndSampleFormat();
static NumericFormatSymbol SecondsFormat();
static NumericFormatSymbol HoursMinsSecondsFormat();
static NumericFormatSymbol HundredthsFormat();
static NumericFormatSymbol HertzFormat();