Skip to content

Commit

Permalink
Rename font globals
Browse files Browse the repository at this point in the history
In a review of #580 @jsakkine pointed out that the font global
names were not clear as to their purpose and unlike everything
else, prefixed with "surge_". This commit renames the 3 global
fonts to more descriptive names.
  • Loading branch information
baconpaul committed Feb 23, 2019
1 parent e20a2a6 commit 3705d7f
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions src/common/gui/CEffectLabel.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#pragma once
#include "vstcontrols.h"

extern VSTGUI::CFontRef surge_minifont;
extern VSTGUI::CFontRef displayFont;

class CEffectLabel : public VSTGUI::CControl
{
Expand All @@ -22,7 +22,7 @@ class CEffectLabel : public VSTGUI::CControl
dc->drawRect(bl, VSTGUI::kDrawFilled);
dc->setFontColor(gray);
// dc->setFont(kNormalFontSmaller,8,kBoldFace);
dc->setFont(surge_minifont);
dc->setFont(displayFont);
dc->drawString(label.c_str(), size, VSTGUI::kLeftText, false);
setDirty(false);
}
Expand Down
10 changes: 5 additions & 5 deletions src/common/gui/CLFOGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
using namespace VSTGUI;
using namespace std;

extern CFontRef surge_minifont;
extern CFontRef surge_patchfont;
extern CFontRef surge_lfofont;
extern CFontRef displayFont;
extern CFontRef patchNameFont;
extern CFontRef lfoTypeFont;

void drawtri(CRect r, CDrawContext* context, int orientation)
{
Expand Down Expand Up @@ -297,7 +297,7 @@ void CLFOGui::draw(CDrawContext* dc)
tr.y2 = tr.y + 50;
CColor ctext = {224,126,0,0xff};
dc->setFontColor(ctext);
dc->setFont(surge_patchfont);
dc->setFont(patchNameFont);
dc->drawString("LFO 1",tr,false,kCenterText);
}*/

Expand All @@ -306,7 +306,7 @@ void CLFOGui::draw(CDrawContext* dc)
CColor cselected = {0xfe, 0x98, 0x15, 0xff};
// CColor blackColor (0, 0, 0, 0);
dc->setFrameColor(cskugga);
dc->setFont(surge_lfofont);
dc->setFont(lfoTypeFont);

rect_shapes = leftpanel;
for (int i = 0; i < n_lfoshapes; i++)
Expand Down
4 changes: 2 additions & 2 deletions src/common/gui/CModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using namespace VSTGUI;
using namespace std;

extern CFontRef surge_minifont;
extern CFontRef displayFont;

enum
{
Expand Down Expand Up @@ -154,7 +154,7 @@ void CModulationSourceButton::draw(CDrawContext* dc)
CRect framer(sze);
CRect fillr(framer);
fillr.inset(1, 1);
dc->setFont(surge_minifont);
dc->setFont(displayFont);
dc->setFontColor(FontCol);
dc->setFrameColor(FrameCol);
dc->setFillColor(FillCol);
Expand Down
4 changes: 2 additions & 2 deletions src/common/gui/CNumberField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
using namespace VSTGUI;

const int width = 62, margin = 6, height = 8, vmargin = 1;
extern CFontRef surge_minifont;
extern CFontRef displayFont;

using namespace std;

Expand Down Expand Up @@ -273,7 +273,7 @@ void CNumberField::draw(CDrawContext* pContext)

pContext->setFrameColor(lineColor);

pContext->setFont(surge_minifont);
pContext->setFont(displayFont);
// tempContext->fillRect(sze);
/*if(!altlook)
{
Expand Down
4 changes: 2 additions & 2 deletions src/common/gui/COscillatorDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace fs = std::experimental::filesystem;
const float disp_pitch = 90.15f - 48.f;
const int wtbheight = 12;

extern CFontRef surge_minifont;
extern CFontRef displayFont;

void COscillatorDisplay::draw(CDrawContext* dc)
{
Expand Down Expand Up @@ -189,7 +189,7 @@ void COscillatorDisplay::draw(CDrawContext* dc)
dc->setFillColor(fgcol);
dc->drawRect(rmenu, kDrawFilled);
dc->setFontColor(kBlackCColor);
dc->setFont(surge_minifont);
dc->setFont(displayFont);
// strupr(wttxt);
dc->drawString(wttxt, rmenu, kCenterText, false);

Expand Down
8 changes: 4 additions & 4 deletions src/common/gui/CPatchBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
using namespace VSTGUI;
using namespace std;

extern CFontRef surge_minifont;
extern CFontRef surge_patchfont;
extern CFontRef displayFont;
extern CFontRef patchNameFont;

void CPatchBrowser::draw(CDrawContext* dc)
{
Expand All @@ -34,10 +34,10 @@ void CPatchBrowser::draw(CDrawContext* dc)
// al.top += 2;
al.bottom = al.top + 12;
dc->setFontColor(kBlackCColor);
dc->setFont(surge_patchfont);
dc->setFont(patchNameFont);
dc->drawString(pname.c_str(), ar, kCenterText, true);

dc->setFont(surge_minifont);
dc->setFont(displayFont);
dc->drawString(category.c_str(), al, kLeftText, true);
al.offset(0, 12);
dc->drawString(author.c_str(), al, kLeftText, true);
Expand Down
4 changes: 2 additions & 2 deletions src/common/gui/CSnapshotMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

using namespace VSTGUI;

extern CFontRef surge_minifont;
extern CFontRef displayFont;

// CSnapshotMenu

Expand Down Expand Up @@ -253,7 +253,7 @@ void CFxMenu::draw(CDrawContext* dc)
// dc->fillRect(f1); dc->fillRect(f2);

dc->setFontColor(kBlackCColor);
dc->setFont(surge_minifont);
dc->setFont(displayFont);
CRect txtbox(lbox);
txtbox.inset(2, 2);
dc->setFillColor(kWhiteCColor);
Expand Down
4 changes: 2 additions & 2 deletions src/common/gui/CSurgeSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using namespace VSTGUI;
using namespace std;

extern CFontRef surge_minifont;
extern CFontRef displayFont;

enum
{
Expand Down Expand Up @@ -205,7 +205,7 @@ void CSurgeSlider::draw(CDrawContext* dc)
dc->setFontColor(kWhiteCColor);
else
dc->setFontColor(kBlackCColor);
dc->setFont(surge_minifont);
dc->setFont(displayFont);

// int a = 'a' + (rand()&31);
// label[1] = a;
Expand Down
12 changes: 6 additions & 6 deletions src/common/gui/RuntimeFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ namespace GUI
*
* The role of this function is to load a font from the bundle, dll, or some other
* source. Once the font file is loaded, it is used to create the VSTGUI 9 and 14 point
* fonts in global variables "surge_minifont" and "surge_patchfont" if they are NULL
* at calltime. The "surge_minifont" is used for most text rendering and the
* "surge_patchfont" is used for the patchname.
* fonts in global variables "displayFont" and "patchNameFont" if they are NULL
* at calltime. The "displayFont" is used for most text rendering and the
* "patchNameFont" is used for the patchname.
*
* The implementation is OS Specific.
*/
Expand All @@ -29,6 +29,6 @@ void initializeRuntimeFont();
** The two extern globals we need to initialize, which are defined/created
** in SurgeGuieditor
*/
extern VSTGUI::CFontRef surge_minifont;
extern VSTGUI::CFontRef surge_patchfont;
extern VSTGUI::CFontRef surge_lfofont;
extern VSTGUI::CFontRef displayFont;
extern VSTGUI::CFontRef patchNameFont;
extern VSTGUI::CFontRef lfoTypeFont;
22 changes: 11 additions & 11 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ using namespace std;


#if USE_RUNTIME_LOADED_FONTS
CFontRef surge_minifont = NULL;
CFontRef surge_patchfont = NULL;
CFontRef surge_lfofont = NULL;
CFontRef displayFont = NULL;
CFontRef patchNameFont = NULL;
CFontRef lfoTypeFont = NULL;
#else

#if LINUX
Expand All @@ -60,9 +60,9 @@ SharedPointer<CFontDesc> patchfont = new CFontDesc("sans-serif", 14);
SharedPointer<CFontDesc> lfofont = new CFontDesc("sans-serif", 8);
#endif

CFontRef surge_minifont = minifont;
CFontRef surge_patchfont = patchfont;
CFontRef surge_lfofont = lfofont;
CFontRef displayFont = minifont;
CFontRef patchNameFont = patchfont;
CFontRef lfoTypeFont = lfofont;
#endif


Expand Down Expand Up @@ -163,12 +163,12 @@ SurgeGUIEditor::SurgeGUIEditor(void* effect, SurgeSynthesizer* synth) : super(ef
#if USE_RUNTIME_LOADED_FONTS
/*
** As documented in RuntimeFonts.h, the contract of this function is to side-effect
** onto globals surge_minifont and surge_patchfont with valid fonts from the runtime
** onto globals displayFont and patchNameFont with valid fonts from the runtime
** distribution
*/
Surge::GUI::initializeRuntimeFont();

if (surge_minifont == NULL)
if (displayFont == NULL)
{
/*
** OK the runtime load didn't work. Fall back to
Expand All @@ -193,8 +193,8 @@ SurgeGUIEditor::SurgeGUIEditor(void* effect, SurgeSynthesizer* synth) : super(ef
SharedPointer<CFontDesc> patchfont = new CFontDesc("Arial", 14);
#endif

surge_minifont = minifont;
surge_patchfont = patchfont;
displayFont = minifont;
patchNameFont = patchfont;

}
#endif
Expand Down Expand Up @@ -662,7 +662,7 @@ void SurgeGUIEditor::openOrRecreateEditor()
CTextLabel *Comments = new
CTextLabel(CommentsRect,synth->storage.getPatch().comment.c_str());
Comments->setTransparency(true);
Comments->setFont(surge_minifont);
Comments->setFont(displayFont);
Comments->setHoriAlign(kMultiLineCenterText);
frame->addView(Comments);
}*/
Expand Down
8 changes: 4 additions & 4 deletions src/mac/RuntimeFontMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void initializeRuntimeFont()
/*
** Someone may have already initialized the globals. Don't do it twice
*/
if (surge_minifont != NULL || surge_patchfont != NULL)
if (displayFont != NULL || patchNameFont != NULL)
return;

/*
Expand All @@ -38,9 +38,9 @@ void initializeRuntimeFont()
VSTGUI::SharedPointer<VSTGUI::CFontDesc> minifont = new VSTGUI::CFontDesc("Lato", 9);
VSTGUI::SharedPointer<VSTGUI::CFontDesc> patchfont = new VSTGUI::CFontDesc("Lato", 14);
VSTGUI::SharedPointer<VSTGUI::CFontDesc> lfofont = new VSTGUI::CFontDesc("Lato", 8);
surge_minifont = minifont;
surge_patchfont = patchfont;
surge_lfofont = lfofont;
displayFont = minifont;
patchNameFont = patchfont;
lfoTypeFont = lfofont;
}

}
Expand Down
8 changes: 4 additions & 4 deletions src/windows/RuntimeFontWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void initializeRuntimeFont()
/*
** Someone may have already initialized the globals. Don't do it twice
*/
if (surge_minifont != NULL || surge_patchfont != NULL)
if (displayFont != NULL || patchNameFont != NULL)
return;

/*
Expand Down Expand Up @@ -103,9 +103,9 @@ void initializeRuntimeFont()
VSTGUI::SharedPointer<VSTGUI::CFontDesc> minifont = new VSTGUI::CFontDesc("Lato", 9);
VSTGUI::SharedPointer<VSTGUI::CFontDesc> patchfont = new VSTGUI::CFontDesc("Lato", 14);
VSTGUI::SharedPointer<VSTGUI::CFontDesc> lfofont = new VSTGUI::CFontDesc("Lato", 8);
surge_minifont = minifont;
surge_patchfont = patchfont;
surge_lfofont = lfofont;
displayFont = minifont;
patchNameFont = patchfont;
lfoTypeFont = lfofont;
}

}
Expand Down

0 comments on commit 3705d7f

Please sign in to comment.