mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-17 17:17:40 +02:00
Group ruler fonts and lead into a structure
This commit is contained in:
parent
80f884b0b7
commit
3876031669
@ -110,9 +110,9 @@ Ruler::Ruler()
|
|||||||
fontSize = 8;
|
fontSize = 8;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mMinorMinorFont = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
mFonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
||||||
mMinorFont = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
mFonts.minor = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
||||||
mMajorFont = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
|
mFonts.major = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
|
||||||
|
|
||||||
mUserFonts = false;
|
mUserFonts = false;
|
||||||
|
|
||||||
@ -261,9 +261,9 @@ void Ruler::SetMinor(bool value)
|
|||||||
|
|
||||||
void Ruler::SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont)
|
void Ruler::SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont)
|
||||||
{
|
{
|
||||||
mMinorMinorFont = minorMinorFont;
|
mFonts.minorMinor = minorMinorFont;
|
||||||
mMinorFont = minorFont;
|
mFonts.minor = minorFont;
|
||||||
mMajorFont = majorFont;
|
mFonts.major = majorFont;
|
||||||
|
|
||||||
// Won't override these fonts
|
// Won't override these fonts
|
||||||
mUserFonts = true;
|
mUserFonts = true;
|
||||||
@ -853,9 +853,9 @@ bool Ruler::Tick(
|
|||||||
const auto result = MakeTick(
|
const auto result = MakeTick(
|
||||||
lab,
|
lab,
|
||||||
dc,
|
dc,
|
||||||
(major? mMajorFont: minor? mMinorFont : mMinorMinorFont),
|
(major? mFonts.major: minor? mFonts.minor : mFonts.minorMinor),
|
||||||
mBits,
|
mBits,
|
||||||
mLeft, mTop, mSpacing, mLead,
|
mLeft, mTop, mSpacing, mFonts.lead,
|
||||||
mFlip,
|
mFlip,
|
||||||
mOrientation );
|
mOrientation );
|
||||||
|
|
||||||
@ -891,9 +891,9 @@ bool Ruler::TickCustom( wxDC &dc, int labelIdx, bool major, bool minor )
|
|||||||
lab,
|
lab,
|
||||||
|
|
||||||
dc,
|
dc,
|
||||||
(major? mMajorFont: minor? mMinorFont : mMinorMinorFont),
|
(major? mFonts.major: minor? mFonts.minor : mFonts.minorMinor),
|
||||||
mBits,
|
mBits,
|
||||||
mLeft, mTop, mSpacing, mLead,
|
mLeft, mTop, mSpacing, mFonts.lead,
|
||||||
mFlip,
|
mFlip,
|
||||||
mOrientation );
|
mOrientation );
|
||||||
|
|
||||||
@ -968,13 +968,13 @@ void Ruler::Update(
|
|||||||
fontSize--;
|
fontSize--;
|
||||||
dc.SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
dc.SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
|
||||||
dc.GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
|
dc.GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
|
||||||
mLead = strL;
|
mFonts.lead = strL;
|
||||||
|
|
||||||
mMajorFont = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
|
mFonts.major = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
|
||||||
|
|
||||||
mMinorFont = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
mFonts.minor = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
||||||
|
|
||||||
mMinorMinorFont = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
mFonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
|
||||||
}
|
}
|
||||||
|
|
||||||
// If ruler is being resized, we could end up with it being too small.
|
// If ruler is being resized, we could end up with it being too small.
|
||||||
@ -1305,7 +1305,7 @@ void Ruler::Draw(wxDC& dc, const Envelope* envelope)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.SetFont(mMajorFont);
|
dc.SetFont(mFonts.major);
|
||||||
|
|
||||||
// We may want to not show the ticks at the extremes,
|
// We may want to not show the ticks at the extremes,
|
||||||
// though still showing the labels.
|
// though still showing the labels.
|
||||||
@ -1343,12 +1343,12 @@ void Ruler::Draw(wxDC& dc, const Envelope* envelope)
|
|||||||
drawLabel( label, 4 );
|
drawLabel( label, 4 );
|
||||||
|
|
||||||
if( mbMinor ) {
|
if( mbMinor ) {
|
||||||
dc.SetFont(mMinorFont);
|
dc.SetFont(mFonts.minor);
|
||||||
for( const auto &label : mMinorLabels )
|
for( const auto &label : mMinorLabels )
|
||||||
drawLabel( label, 2 );
|
drawLabel( label, 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.SetFont(mMinorMinorFont);
|
dc.SetFont(mFonts.minorMinor);
|
||||||
|
|
||||||
for( const auto &label : mMinorMinorLabels )
|
for( const auto &label : mMinorMinorLabels )
|
||||||
if ( !label.text.empty() )
|
if ( !label.text.empty() )
|
||||||
|
@ -98,9 +98,12 @@ class AUDACITY_DLL_API Ruler {
|
|||||||
|
|
||||||
// Good defaults are provided, but you can override here
|
// Good defaults are provided, but you can override here
|
||||||
void SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont);
|
void SetFonts(const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont);
|
||||||
struct Fonts { wxFont major, minor, minorMinor; };
|
struct Fonts {
|
||||||
|
wxFont major, minor, minorMinor;
|
||||||
|
int lead;
|
||||||
|
};
|
||||||
Fonts GetFonts() const
|
Fonts GetFonts() const
|
||||||
{ return { mMajorFont, mMinorFont, mMinorMinorFont }; }
|
{ return mFonts; }
|
||||||
|
|
||||||
// Copies *pScale if it is not NULL
|
// Copies *pScale if it is not NULL
|
||||||
void SetNumberScale(const NumberScale *pScale);
|
void SetNumberScale(const NumberScale *pScale);
|
||||||
@ -171,10 +174,10 @@ private:
|
|||||||
wxColour mTickColour;
|
wxColour mTickColour;
|
||||||
wxPen mPen;
|
wxPen mPen;
|
||||||
|
|
||||||
int mLeft, mTop, mRight, mBottom, mLead;
|
int mLeft, mTop, mRight, mBottom;
|
||||||
int mLength;
|
int mLength;
|
||||||
|
|
||||||
wxFont mMinorFont, mMajorFont, mMinorMinorFont;
|
Fonts mFonts;
|
||||||
bool mUserFonts;
|
bool mUserFonts;
|
||||||
|
|
||||||
double mMin, mMax;
|
double mMin, mMax;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user