mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-24 16:20:05 +02:00
Fix Time toolbar initial size setting
This commit is contained in:
parent
383000557e
commit
bacf6becdc
@ -82,6 +82,11 @@ void TimerToolBar::Populate()
|
|||||||
wxSize digitSize = mAudioTime->GetDigitSize();
|
wxSize digitSize = mAudioTime->GetDigitSize();
|
||||||
mDigitRatio = (float)digitSize.x / digitSize.y;
|
mDigitRatio = (float)digitSize.x / digitSize.y;
|
||||||
|
|
||||||
|
// During initialization, we need to bypass some resizing to prevent the "best size"
|
||||||
|
// from being used as we want to ensure the saved size is used instead. See SetDocked()
|
||||||
|
// and OnUpdate() for more info.
|
||||||
|
mSettingInitialSize = true;
|
||||||
|
|
||||||
// Establish initial resizing limits
|
// Establish initial resizing limits
|
||||||
// SetResizingLimits();
|
// SetResizingLimits();
|
||||||
}
|
}
|
||||||
@ -146,11 +151,15 @@ void TimerToolBar::SetDocked(ToolDock *dock, bool pushed)
|
|||||||
// When moving from floater to dock, fit to toolbar since the resizer will
|
// When moving from floater to dock, fit to toolbar since the resizer will
|
||||||
// be mispositioned
|
// be mispositioned
|
||||||
if (dock) {
|
if (dock) {
|
||||||
// Fit() while retaining height
|
// During initialization, the desired size is already set, so do not
|
||||||
SetSize(GetBestSize().x, GetSize().y);
|
// override it with the "best size". See OnUpdate for further info.
|
||||||
|
if (!mSettingInitialSize) {
|
||||||
|
// Fit() while retaining height
|
||||||
|
SetSize(GetBestSize().x, GetSize().y);
|
||||||
|
|
||||||
// Inform others the toolbar has changed
|
// Inform others the toolbar has changed
|
||||||
Updated();
|
Updated();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +205,7 @@ void TimerToolBar::SetResizingLimits()
|
|||||||
int minH = IsDocked() ? GetSize().y : toolbarSingle;
|
int minH = IsDocked() ? GetSize().y : toolbarSingle;
|
||||||
|
|
||||||
// Get the content size given the smallest digit height we allow
|
// Get the content size given the smallest digit height we allow
|
||||||
wxSize minSize = ComputeSizing(17);
|
wxSize minSize = ComputeSizing(minDigitH);
|
||||||
|
|
||||||
// Account for any borders added by the window manager
|
// Account for any borders added by the window manager
|
||||||
minSize.x += (mAudioTime->GetSize().x - mAudioTime->GetClientSize().x);
|
minSize.x += (mAudioTime->GetSize().x - mAudioTime->GetClientSize().x);
|
||||||
@ -216,7 +225,7 @@ void TimerToolBar::SetResizingLimits()
|
|||||||
|
|
||||||
// Get the content size using the digit height, if docked. Otherwise use the
|
// Get the content size using the digit height, if docked. Otherwise use the
|
||||||
// maximum digit height we allow.
|
// maximum digit height we allow.
|
||||||
wxSize maxSize = ComputeSizing(IsDocked() ? digH : 100);
|
wxSize maxSize = ComputeSizing(IsDocked() ? digH : maxDigitH);
|
||||||
|
|
||||||
// Account for the other controls and sizer borders within this toolbar
|
// Account for the other controls and sizer borders within this toolbar
|
||||||
maxSize.x += outer.x;
|
maxSize.x += outer.x;
|
||||||
@ -248,12 +257,22 @@ void TimerToolBar::OnUpdate(wxCommandEvent &evt)
|
|||||||
mListener->TT_SetAudioTimeFormat(mAudioTime->GetBuiltinName(evt.GetInt()));
|
mListener->TT_SetAudioTimeFormat(mAudioTime->GetBuiltinName(evt.GetInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// During initialization, the desired size will have already been set at this point
|
||||||
|
// and the "best" size" would override it, so we simply send a size event to force
|
||||||
|
// the content to fit inside the toolbar.
|
||||||
|
if (mSettingInitialSize) {
|
||||||
|
mSettingInitialSize = false;
|
||||||
|
SendSizeEvent();
|
||||||
|
}
|
||||||
|
// Otherwise we want the toolbar to resize to fit around the content
|
||||||
|
else {
|
||||||
|
// Fit() while retaining height
|
||||||
|
SetSize(GetBestSize().x, GetSize().y);
|
||||||
|
}
|
||||||
|
|
||||||
// Go set the new size limits
|
// Go set the new size limits
|
||||||
SetResizingLimits();
|
SetResizingLimits();
|
||||||
|
|
||||||
// Fit() while retaining height
|
|
||||||
SetSize(GetBestSize().x, GetSize().y);
|
|
||||||
|
|
||||||
// Inform others the toobar has changed
|
// Inform others the toobar has changed
|
||||||
Updated();
|
Updated();
|
||||||
}
|
}
|
||||||
@ -281,11 +300,11 @@ void TimerToolBar::OnSize(wxSizeEvent &evt)
|
|||||||
int h = mAudioTime->GetDigitSize().y;
|
int h = mAudioTime->GetDigitSize().y;
|
||||||
|
|
||||||
// Increase current size to find the best fit within the new size
|
// Increase current size to find the best fit within the new size
|
||||||
if (sizerBR.x > timeBR.x && sizerBR.y > timeBR.y) {
|
if (sizerBR.x >= timeBR.x && sizerBR.y >= timeBR.y) {
|
||||||
do {
|
do {
|
||||||
h++;
|
h++;
|
||||||
timeBR = ComputeSizing(h);
|
timeBR = ComputeSizing(h);
|
||||||
} while (h < 150 && sizerBR.x > timeBR.x && sizerBR.y > timeBR.y);
|
} while (h < maxDigitH && sizerBR.x >= timeBR.x && sizerBR.y >= timeBR.y);
|
||||||
h--;
|
h--;
|
||||||
}
|
}
|
||||||
// In all other cases, we need to decrease current size to fit within new size
|
// In all other cases, we need to decrease current size to fit within new size
|
||||||
@ -293,7 +312,7 @@ void TimerToolBar::OnSize(wxSizeEvent &evt)
|
|||||||
do {
|
do {
|
||||||
h--;
|
h--;
|
||||||
timeBR = ComputeSizing(h);
|
timeBR = ComputeSizing(h);
|
||||||
} while (h > 8 && (sizerBR.x < timeBR.x || sizerBR.y < timeBR.y));
|
} while (h >= minDigitH && (sizerBR.x < timeBR.x || sizerBR.y < timeBR.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (h != mAudioTime->GetDigitSize().y) {
|
if (h != mAudioTime->GetDigitSize().y) {
|
||||||
|
@ -53,6 +53,10 @@ private:
|
|||||||
TimerToolBarListener *mListener;
|
TimerToolBarListener *mListener;
|
||||||
NumericTextCtrl *mAudioTime;
|
NumericTextCtrl *mAudioTime;
|
||||||
float mDigitRatio;
|
float mDigitRatio;
|
||||||
|
bool mSettingInitialSize;
|
||||||
|
|
||||||
|
static const int minDigitH = 17;
|
||||||
|
static const int maxDigitH = 100;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user