mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-21 14:50:06 +02:00
Better choice of font size for time ruler pushbuttons
This commit is contained in:
parent
24bb190e21
commit
d3c0c94e17
@ -1827,8 +1827,7 @@ AdornedRulerPanel::AdornedRulerPanel(AudacityProject* parent,
|
|||||||
mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false;
|
mPlayRegionDragsSelection = (gPrefs->Read(wxT("/QuickPlay/DragSelection"), 0L) == 1)? true : false;
|
||||||
mQuickPlayEnabled = !!gPrefs->Read(wxT("/QuickPlay/QuickPlayEnabled"), 1L);
|
mQuickPlayEnabled = !!gPrefs->Read(wxT("/QuickPlay/QuickPlayEnabled"), 1L);
|
||||||
|
|
||||||
int fontSize = 10;
|
mButtonFont.Create(10, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||||
mButtonFont.Create(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
|
||||||
|
|
||||||
UpdatePrefs();
|
UpdatePrefs();
|
||||||
|
|
||||||
@ -1897,6 +1896,38 @@ void AdornedRulerPanel::UpdatePrefs()
|
|||||||
UpdateRects();
|
UpdateRects();
|
||||||
|
|
||||||
RegenerateTooltips();
|
RegenerateTooltips();
|
||||||
|
|
||||||
|
mButtonFontSize = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFont &AdornedRulerPanel::GetButtonFont() const
|
||||||
|
{
|
||||||
|
if (mButtonFontSize < 0) {
|
||||||
|
mButtonFontSize = 10;
|
||||||
|
|
||||||
|
bool done;
|
||||||
|
do {
|
||||||
|
done = true;
|
||||||
|
mButtonFont.SetPointSize(mButtonFontSize);
|
||||||
|
wxCoord width, height;
|
||||||
|
for (unsigned ii = 0;
|
||||||
|
done && ii < static_cast<unsigned>(Button::NumButtons); ++ii) {
|
||||||
|
auto button = static_cast<Button>(ii);
|
||||||
|
auto allowableWidth = GetButtonRect(button).GetWidth() - 2;
|
||||||
|
// 2 corresponds with the Inflate(-1, -1)
|
||||||
|
GetParent()->GetTextExtent(PushbuttonLabels[ii],
|
||||||
|
&width,
|
||||||
|
&height,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
&mButtonFont);
|
||||||
|
done = width < allowableWidth;
|
||||||
|
}
|
||||||
|
mButtonFontSize--;
|
||||||
|
} while (mButtonFontSize > 0 && !done);
|
||||||
|
}
|
||||||
|
|
||||||
|
return mButtonFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AdornedRulerPanel::InvalidateRuler()
|
void AdornedRulerPanel::InvalidateRuler()
|
||||||
@ -2857,16 +2888,17 @@ void AdornedRulerPanel::ToggleButtonState( Button button )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wxString AdornedRulerPanel::PushbuttonLabels
|
||||||
|
[static_cast<size_t>(AdornedRulerPanel::Button::NumButtons)] {
|
||||||
|
XO("Quick-Play"),
|
||||||
|
/* i18n-hint: A long screen area (bar) controlling variable speed play (scrubbing) */
|
||||||
|
XO("Scrub Bar"),
|
||||||
|
};
|
||||||
|
|
||||||
void AdornedRulerPanel::DoDrawPushbutton(wxDC *dc, Button button, bool down) const
|
void AdornedRulerPanel::DoDrawPushbutton(wxDC *dc, Button button, bool down) const
|
||||||
{
|
{
|
||||||
// Adapted from TrackInfo::DrawMuteSolo()
|
// Adapted from TrackInfo::DrawMuteSolo()
|
||||||
|
|
||||||
static const wxString labels[static_cast<size_t>(Button::NumButtons)] {
|
|
||||||
XO("Quick-Play"),
|
|
||||||
/* i18n-hint: A long screen area (bar) controlling variable speed play (scrubbing) */
|
|
||||||
XO("Scrub Bar"),
|
|
||||||
};
|
|
||||||
|
|
||||||
auto bev = GetButtonRect( button );
|
auto bev = GetButtonRect( button );
|
||||||
|
|
||||||
// This part corresponds to part of TrackInfo::DrawBordersWithin() :
|
// This part corresponds to part of TrackInfo::DrawBordersWithin() :
|
||||||
@ -2884,8 +2916,8 @@ void AdornedRulerPanel::DoDrawPushbutton(wxDC *dc, Button button, bool down) con
|
|||||||
dc->SetTextForeground(theTheme.Colour(clrTrackPanelText));
|
dc->SetTextForeground(theTheme.Colour(clrTrackPanelText));
|
||||||
|
|
||||||
wxCoord textWidth, textHeight;
|
wxCoord textWidth, textHeight;
|
||||||
wxString str = wxGetTranslation(labels[static_cast<unsigned>(button)]);
|
wxString str = wxGetTranslation(PushbuttonLabels[static_cast<unsigned>(button)]);
|
||||||
dc->SetFont(mButtonFont);
|
dc->SetFont(GetButtonFont());
|
||||||
dc->GetTextExtent(str, &textWidth, &textHeight);
|
dc->GetTextExtent(str, &textWidth, &textHeight);
|
||||||
dc->DrawText(str, bev.x + (bev.width - textWidth) / 2,
|
dc->DrawText(str, bev.x + (bev.width - textWidth) / 2,
|
||||||
bev.y + (bev.height - textHeight) / 2);
|
bev.y + (bev.height - textHeight) / 2);
|
||||||
|
@ -356,6 +356,8 @@ private:
|
|||||||
NumButtons,
|
NumButtons,
|
||||||
NoButton = -1
|
NoButton = -1
|
||||||
};
|
};
|
||||||
|
static const wxString PushbuttonLabels[];
|
||||||
|
|
||||||
wxRect GetButtonRect( Button button ) const;
|
wxRect GetButtonRect( Button button ) const;
|
||||||
bool InButtonRect( Button button ) const;
|
bool InButtonRect( Button button ) const;
|
||||||
bool GetButtonState( Button button ) const;
|
bool GetButtonState( Button button ) const;
|
||||||
@ -364,6 +366,8 @@ private:
|
|||||||
void DoDrawPushbuttons(wxDC *dc) const;
|
void DoDrawPushbuttons(wxDC *dc) const;
|
||||||
void HandlePushbuttonEvent(wxMouseEvent &evt);
|
void HandlePushbuttonEvent(wxMouseEvent &evt);
|
||||||
|
|
||||||
|
wxFont &GetButtonFont() const;
|
||||||
|
|
||||||
double Pos2Time(int p, bool ignoreFisheye = false);
|
double Pos2Time(int p, bool ignoreFisheye = false);
|
||||||
int Time2Pos(double t, bool ignoreFisheye = false);
|
int Time2Pos(double t, bool ignoreFisheye = false);
|
||||||
|
|
||||||
@ -451,7 +455,8 @@ private:
|
|||||||
StatusChoice mPrevZone { StatusChoice::NoChange };
|
StatusChoice mPrevZone { StatusChoice::NoChange };
|
||||||
bool mShowScrubbing { true };
|
bool mShowScrubbing { true };
|
||||||
|
|
||||||
wxFont mButtonFont;
|
mutable int mButtonFontSize { -1 };
|
||||||
|
mutable wxFont mButtonFont;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user