1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-23 17:11:13 +01:00

Make Transcription ToolBar resizable.

I moved 'Fit()' from ToolBars into MeterToolBar, because it is a workaround for an incorrect size calculation by MeterToolBar.  MeterToolBar is sized as if there is no resizer, so when there is one, the toolbar needs to be expanded (using Fit) to accommodate the resizer.

I also set the min size of MeterToolBar to 150, so that some meter will appear, even if Toolbar shrunk to the minimum.
This commit is contained in:
James Crook
2018-07-21 16:41:32 +01:00
parent f5999954c4
commit 132986de1a
6 changed files with 21 additions and 6 deletions

View File

@@ -234,6 +234,7 @@ void MeterToolBar::OnSize( wxSizeEvent & event) //WXUNUSED(event) )
// And make it happen
Layout();
Fit();
}
bool MeterToolBar::Expose( bool show )
@@ -274,3 +275,11 @@ wxSize MeterToolBar::GetDockedSize()
return sz;
}
// The meter's sizing code does not take account of the resizer
// Hence after docking we need to enlarge the bar (using fit)
// so that the resizer can be reached.
void MeterToolBar::SetDocked(ToolDock *dock, bool pushed) {
ToolBar::SetDocked(dock, pushed);
Fit();
}

View File

@@ -49,8 +49,9 @@ class MeterToolBar final : public ToolBar {
int GetInitialWidth() override {return (mWhichMeters ==
(kWithRecordMeter + kWithPlayMeter)) ? 338 : 460;} // Separate bars used to be smaller.
int GetMinToolbarWidth() override { return 50; }
int GetMinToolbarWidth() override { return 150; }
wxSize GetDockedSize() override;
virtual void SetDocked(ToolDock *dock, bool pushed)override;
private:
void RegenerateTooltips() override;

View File

@@ -586,7 +586,6 @@ void ToolBar::SetDocked( ToolDock *dock, bool pushed )
{
mResizer->Show(dock != NULL);
Layout();
Fit();
}
}

View File

@@ -110,7 +110,7 @@ class ToolBar /* not final */ : public wxPanelWrapper
ToolDock *GetDock();
void SetLabel(const wxString & label) override;
void SetDocked(ToolDock *dock, bool pushed);
virtual void SetDocked(ToolDock *dock, bool pushed);
// NEW virtual:
virtual bool Expose(bool show = true);

View File

@@ -90,7 +90,7 @@ END_EVENT_TABLE()
////Standard Constructor
TranscriptionToolBar::TranscriptionToolBar()
: ToolBar(TranscriptionBarID, _("Transcription"), wxT("Transcription"))
: ToolBar(TranscriptionBarID, _("Transcription"), wxT("Transcription"),true)
{
mPlaySpeed = 1.0 * 100.0;
#ifdef EXPERIMENTAL_VOICE_DETECTION
@@ -133,6 +133,11 @@ void TranscriptionToolBar::Create(wxWindow * parent)
//then stop Audio if it is playing, so we can be playing
//audio and open a second project.
mPlaySpeed = (mPlaySpeedSlider->Get()) * 100;
// Simulate a size event to set initial placement/size
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
GetEventHandler()->ProcessEvent(event);
}
/// This is a convenience function that allows for button creation in
@@ -199,9 +204,10 @@ void TranscriptionToolBar::Populate()
.Line( 0.16667f )
.Page( 0.16667f )
);
mPlaySpeedSlider->SetSizeHints(wxSize(100, 25), wxSize(1000, 25));
mPlaySpeedSlider->Set(mPlaySpeed / 100.0);
mPlaySpeedSlider->SetLabel(_("Playback Speed"));
Add( mPlaySpeedSlider, 0, wxALIGN_CENTER );
Add( mPlaySpeedSlider, 1, wxALIGN_CENTER );
mPlaySpeedSlider->Bind(wxEVT_SET_FOCUS,
&TranscriptionToolBar::OnFocus,
this);
@@ -322,7 +328,6 @@ void TranscriptionToolBar::RegenerateTooltips()
ToolBar::SetButtonToolTip( *mButtons[entry.tool], commands, 2u );
}
#ifdef EXPERIMENTAL_VOICE_DETECTION
mButtons[TTB_StartOn]->SetToolTip(TRANSLATABLE("Left-to-On"));
mButtons[TTB_EndOn]->SetToolTip( TRANSLATABLE("Right-to-Off"));

View File

@@ -82,6 +82,7 @@ class TranscriptionToolBar final : public ToolBar {
void Repaint(wxDC * WXUNUSED(dc)) override {};
void EnableDisableButtons() override;
void UpdatePrefs() override;
int GetMinToolbarWidth() override { return 125; }
void OnFocus(wxFocusEvent &event);
void OnCaptureKey(wxCommandEvent &event);