mirror of
https://github.com/cookiengineer/audacity
synced 2025-08-16 08:34:10 +02:00
Rework Selection toolbar for wx313
This commit is contained in:
parent
11a527c1ec
commit
ea689f7d24
@ -158,7 +158,8 @@ auStaticText * SelectionBar::AddTitle(
|
|||||||
auStaticText * pTitle = safenew auStaticText(this, translated );
|
auStaticText * pTitle = safenew auStaticText(this, translated );
|
||||||
pTitle->SetBackgroundColour( theTheme.Colour( clrMedium ));
|
pTitle->SetBackgroundColour( theTheme.Colour( clrMedium ));
|
||||||
pTitle->SetForegroundColour( theTheme.Colour( clrTrackPanelText ) );
|
pTitle->SetForegroundColour( theTheme.Colour( clrTrackPanelText ) );
|
||||||
pSizer->Add( pTitle,0, wxALIGN_CENTER_VERTICAL | wxRIGHT, (translated.length() == 1 ) ? 0:5);
|
pSizer->Add( pTitle, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL | wxRIGHT, 5 );
|
||||||
|
|
||||||
return pTitle;
|
return pTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,28 +188,12 @@ void SelectionBar::Populate()
|
|||||||
|
|
||||||
mStartTime = mEndTime = mLengthTime = mCenterTime = mAudioTime = nullptr;
|
mStartTime = mEndTime = mLengthTime = mCenterTime = mAudioTime = nullptr;
|
||||||
|
|
||||||
// This will be inherited by all children:
|
|
||||||
SetFont(wxFont(
|
|
||||||
#ifdef __WXMAC__
|
|
||||||
12
|
|
||||||
#else
|
|
||||||
9
|
|
||||||
#endif
|
|
||||||
,
|
|
||||||
wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
|
||||||
|
|
||||||
wxFlexGridSizer *mainSizer;
|
|
||||||
|
|
||||||
/* we don't actually need a control yet, but we want to use its methods
|
|
||||||
* to do some look-ups, so we'll have to create one. We can't make the
|
|
||||||
* look-ups static because they depend on translations which are done at
|
|
||||||
* runtime */
|
|
||||||
|
|
||||||
// Outer sizer has space top and left.
|
// Outer sizer has space top and left.
|
||||||
// Inner sizers have space on right only.
|
// Inner sizers have space on right only.
|
||||||
// This choice makes for a nice border and internal spacing and places clear responsibility
|
// This choice makes for a nice border and internal spacing and places clear responsibility
|
||||||
// on each sizer as to what spacings it creates.
|
// on each sizer as to what spacings it creates.
|
||||||
Add((mainSizer = safenew wxFlexGridSizer(SIZER_COLS, 1, 1)), 0, wxALIGN_TOP | wxLEFT | wxTOP, 5);
|
wxFlexGridSizer *mainSizer = safenew wxFlexGridSizer(SIZER_COLS, 1, 1);
|
||||||
|
Add(mainSizer, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 5);
|
||||||
|
|
||||||
// Top row (mostly labels)
|
// Top row (mostly labels)
|
||||||
wxColour clrText = theTheme.Colour( clrTrackPanelText );
|
wxColour clrText = theTheme.Colour( clrTrackPanelText );
|
||||||
@ -237,20 +222,13 @@ void SelectionBar::Populate()
|
|||||||
// so that name can be set on a standard control
|
// so that name can be set on a standard control
|
||||||
mChoice->SetAccessible(safenew WindowAccessible(mChoice));
|
mChoice->SetAccessible(safenew WindowAccessible(mChoice));
|
||||||
#endif
|
#endif
|
||||||
#ifdef __WXGTK__
|
mainSizer->Add(mChoice, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 6);
|
||||||
// Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
|
|
||||||
// be three units high.
|
|
||||||
wxSize sz = mChoice->GetBestSize();
|
|
||||||
sz.SetHeight( sz.y-4);
|
|
||||||
mChoice->SetMinSize( sz );
|
|
||||||
#endif
|
|
||||||
mainSizer->Add(mChoice, 0, wxALIGN_TOP | wxEXPAND | wxRIGHT, 6);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom row, (mostly time controls)
|
// Bottom row, (mostly time controls)
|
||||||
mRateBox = safenew wxComboBox(this, RateID,
|
mRateBox = safenew wxComboBox(this, RateID,
|
||||||
wxT(""),
|
wxT(""),
|
||||||
wxDefaultPosition, wxSize(80, -1));
|
wxDefaultPosition, wxDefaultSize);
|
||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
// so that name can be set on a standard control
|
// so that name can be set on a standard control
|
||||||
mRateBox->SetAccessible(safenew WindowAccessible(mRateBox));
|
mRateBox->SetAccessible(safenew WindowAccessible(mRateBox));
|
||||||
@ -289,15 +267,8 @@ void SelectionBar::Populate()
|
|||||||
&SelectionBar::OnFocus,
|
&SelectionBar::OnFocus,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
mainSizer->Add(mRateBox, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
|
||||||
// Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
|
|
||||||
// be three units high.
|
|
||||||
wxSize sz = mRateBox->GetBestSize();
|
|
||||||
sz.SetHeight( sz.y-4);
|
|
||||||
mRateBox->SetMinSize( sz );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mainSizer->Add(mRateBox, 0, wxALIGN_TOP | wxRIGHT, 5);
|
|
||||||
AddVLine( mainSizer );
|
AddVLine( mainSizer );
|
||||||
|
|
||||||
mSnapTo = safenew wxChoice(this, SnapToID,
|
mSnapTo = safenew wxChoice(this, SnapToID,
|
||||||
@ -306,16 +277,6 @@ void SelectionBar::Populate()
|
|||||||
SnapManager::GetSnapLabels(),
|
SnapManager::GetSnapLabels(),
|
||||||
std::mem_fn( &TranslatableString::Translation ) ) );
|
std::mem_fn( &TranslatableString::Translation ) ) );
|
||||||
|
|
||||||
#ifdef __WXGTK__
|
|
||||||
// Combo boxes are taller on Linux, and if we don't do the following, the selection toolbar will
|
|
||||||
// be three units high.
|
|
||||||
sz = mSnapTo->GetBestSize();
|
|
||||||
sz.SetHeight( sz.y-4);
|
|
||||||
mSnapTo->SetMinSize( sz );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
mainSizer->Add(mSnapTo,
|
|
||||||
0, wxALIGN_TOP | wxRIGHT, 5);
|
|
||||||
#if wxUSE_ACCESSIBILITY
|
#if wxUSE_ACCESSIBILITY
|
||||||
// so that name can be set on a standard control
|
// so that name can be set on a standard control
|
||||||
mSnapTo->SetAccessible(safenew WindowAccessible(mSnapTo));
|
mSnapTo->SetAccessible(safenew WindowAccessible(mSnapTo));
|
||||||
@ -331,6 +292,8 @@ void SelectionBar::Populate()
|
|||||||
&SelectionBar::OnFocus,
|
&SelectionBar::OnFocus,
|
||||||
this);
|
this);
|
||||||
|
|
||||||
|
mainSizer->Add(mSnapTo, 0, wxEXPAND | wxALIGN_TOP | wxRIGHT, 5);
|
||||||
|
|
||||||
AddVLine( mainSizer );
|
AddVLine( mainSizer );
|
||||||
|
|
||||||
#ifdef TIME_IN_SELECT_TOOLBAR
|
#ifdef TIME_IN_SELECT_TOOLBAR
|
||||||
@ -356,6 +319,17 @@ void SelectionBar::Populate()
|
|||||||
mainSizer->Add(hSizer.release(), 0, wxALIGN_TOP | wxRIGHT, 0);
|
mainSizer->Add(hSizer.release(), 0, wxALIGN_TOP | wxRIGHT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Make sure they are fully expanded to the longest item
|
||||||
|
#if defined(__WXGTK3__)
|
||||||
|
mChoice->SetMinSize(wxSize(mChoice->GetBestSize().x, toolbarSingle));
|
||||||
|
mRateBox->SetMinSize(wxSize(mRateBox->GetBestSize().x, toolbarSingle));
|
||||||
|
mSnapTo->SetMinSize(wxSize(mSnapTo->GetBestSize().x, toolbarSingle));
|
||||||
|
#else
|
||||||
|
mChoice->SetMinSize(wxSize(mChoice->GetBestSize().x, wxDefaultCoord));
|
||||||
|
mRateBox->SetMinSize(wxSize(mRateBox->GetBestSize().x, wxDefaultCoord));
|
||||||
|
mSnapTo->SetMinSize(wxSize(mSnapTo->GetBestSize().x, wxDefaultCoord));
|
||||||
|
#endif
|
||||||
|
|
||||||
mChoice->MoveBeforeInTabOrder( mStartTime );
|
mChoice->MoveBeforeInTabOrder( mStartTime );
|
||||||
// This shows/hides controls.
|
// This shows/hides controls.
|
||||||
// Do this before layout so that we are sized right.
|
// Do this before layout so that we are sized right.
|
||||||
@ -363,8 +337,6 @@ void SelectionBar::Populate()
|
|||||||
mainSizer->Layout();
|
mainSizer->Layout();
|
||||||
RegenerateTooltips();
|
RegenerateTooltips();
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
SetMinSize( GetSizer()->GetMinSize() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SelectionBar::UpdatePrefs()
|
void SelectionBar::UpdatePrefs()
|
||||||
@ -528,23 +500,24 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||||||
evt.Skip(false);
|
evt.Skip(false);
|
||||||
|
|
||||||
// Save format name before recreating the controls so they resize properly
|
// Save format name before recreating the controls so they resize properly
|
||||||
|
if (mStartTime)
|
||||||
{
|
{
|
||||||
auto format = mStartTime->GetBuiltinName(index);
|
auto format = mStartTime->GetBuiltinName(index);
|
||||||
if (mListener)
|
if (mListener)
|
||||||
mListener->AS_SetSelectionFormat(format);
|
mListener->AS_SetSelectionFormat(format);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegenerateTooltips();
|
|
||||||
|
|
||||||
// ReCreateButtons() will get rid of our sizers and controls
|
// ReCreateButtons() will get rid of our sizers and controls
|
||||||
// so reset pointers first.
|
// so reset pointers first.
|
||||||
for( i=0;i<5;i++)
|
for( i=0;i<5;i++)
|
||||||
*Ctrls[i]=NULL;
|
*Ctrls[i]=NULL;
|
||||||
|
|
||||||
|
mChoice = NULL;
|
||||||
mRateBox = NULL;
|
mRateBox = NULL;
|
||||||
mRateText = NULL;
|
mRateText = NULL;
|
||||||
|
mSnapTo = NULL;
|
||||||
|
|
||||||
ReCreateButtons();
|
ToolBar::ReCreateButtons();
|
||||||
|
|
||||||
ValuesToControls();
|
ValuesToControls();
|
||||||
|
|
||||||
@ -556,6 +529,9 @@ void SelectionBar::OnUpdate(wxCommandEvent &evt)
|
|||||||
if( iFocus >=0 )
|
if( iFocus >=0 )
|
||||||
if( *Ctrls[iFocus] )
|
if( *Ctrls[iFocus] )
|
||||||
(*Ctrls[iFocus])->SetFocus();
|
(*Ctrls[iFocus])->SetFocus();
|
||||||
|
|
||||||
|
RegenerateTooltips();
|
||||||
|
|
||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user