Skip to content

Commit

Permalink
Use FontOptions instead of Font
Browse files Browse the repository at this point in the history
  • Loading branch information
jsiegle committed May 16, 2024
1 parent e86afd1 commit 59089de
Show file tree
Hide file tree
Showing 17 changed files with 37 additions and 44 deletions.
4 changes: 2 additions & 2 deletions Source/Processors/AudioNode/AudioEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void AudioWindowButton::paintButton (Graphics& g, bool isMouseOver, bool isButto

const bool isLatencyLabelVisible = getParentComponent()->getWidth() >= 450;
auto textToDraw = isLatencyLabelVisible ? textString : textString.fromLastOccurrenceOf (":", false, true);
g.setFont (Font("Silkscreen", "Regular", 14));
g.setFont (FontOptions("Silkscreen", "Regular", 14));
g.drawSingleLineText (textToDraw, 0, 15);
}

Expand Down Expand Up @@ -249,7 +249,7 @@ void AudioEditor::paint (Graphics& g)
{
const int margin = getWidth() * 0.03;
g.setColour (findColour(ThemeColors::defaultText));
g.setFont(Font("Silkscreen", "Regular", 14));
g.setFont(FontOptions("Silkscreen", "Regular", 14));
g.drawSingleLineText ("GATE:", volumeSlider->getBounds().getRight() + margin, 20);

muteButton->updateImages();
Expand Down
7 changes: 2 additions & 5 deletions Source/Processors/Editors/DelayMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@
DelayMonitor::DelayMonitor() :
delay(0.0f),
isEnabled(true),
colour(Colours::white),
font("Fira Sans", "SemiBold", 12)
colour(Colours::white)
{
setInterceptsMouseClicks(false, false);
}

DelayMonitor::~DelayMonitor()
{
//std::cout << "DELAY MONITOR DELETING" << std::endl;
}

void DelayMonitor::setDelay(float delayMs)
{
//std::cout << "Delay monitor::setDelay " << delayMs << std::endl;
delay = delayMs;
}

Expand Down Expand Up @@ -76,7 +73,7 @@ void DelayMonitor::paint(Graphics& g)
{

g.setColour(findColour(ThemeColors::defaultText));
g.setFont(font);
g.setFont(FontOptions("Fira Sans", "SemiBold", 12));
g.drawText(String(delay, 2) + " ms", 0, 0, 60, 20, Justification::centredLeft);

}
Expand Down
1 change: 0 additions & 1 deletion Source/Processors/Editors/DelayMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class PLUGIN_API DelayMonitor :
bool isEnabled;
Colour colour;
float delay;
Font font;
bool canRepaint = true;
};

Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/Editors/ElectrodeButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ ElectrodeEditorButton::~ElectrodeEditorButton() {}

void ElectrodeEditorButton::paintButton(Graphics& g, bool isMouseOver, bool isButtonDown)
{
g.setFont(Font("Silkscreen", "Regular", 14));
g.setFont(FontOptions("Silkscreen", "Regular", 14));

if (getToggleState() == true)
g.setColour(Colours::darkgrey);
Expand Down
8 changes: 4 additions & 4 deletions Source/Processors/Editors/GenericEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GenericEditor::GenericEditor(GenericProcessor* owner) : AudioProcessorEditor(own

nodeId = owner->getNodeId();

titleFont = Font("CP Mono", "Plain", 14);
titleFont = FontOptions("CP Mono", "Plain", 14);

drawerButton = std::make_unique<DrawerButton>(getNameAndId() + " Drawer Button");
drawerButton->addListener(&drawerButtonListener);
Expand Down Expand Up @@ -537,16 +537,16 @@ void GenericEditor::paint(Graphics& g)
if (!isCollapsed)
{
g.setColour(isEnabled ? Colours::white : findColour(ThemeColors::defaultText).withAlpha(0.5f));
g.setFont( Font("Fira Mono", "Plain", 13) );
g.setFont(FontOptions("Fira Mono", "Plain", 13));
g.drawText (String(nodeId), 8, 5, 30, 15, Justification::left, false);
g.setFont (Font("CP Mono", "Plain", 16));
g.setFont (FontOptions("CP Mono", "Plain", 16));
g.drawText (displayName.toUpperCase(), 35, 4, 500, 15, Justification::left, false);
}
else
{
g.addTransform(AffineTransform::rotation(-M_PI/2.0));
g.setColour(isEnabled ? Colours::white : findColour(ThemeColors::defaultText).withAlpha(0.5f));
g.setFont (Font("CP Mono", "Plain", 14));
g.setFont (FontOptions("CP Mono", "Plain", 14));
g.drawText (displayName.toUpperCase(), - getHeight() + 6, 5, 500, 15, Justification::left, false);
g.addTransform(AffineTransform::rotation(M_PI/2.0));
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/Editors/StreamSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ void StreamSelectorTable::paint(Graphics& g)
g.setColour(findColour(ThemeColors::widgetBackground));
g.fillRoundedRectangle(1.0f, 1.0f, (float)getWidth() - 6.0f, (float)getHeight() - 2.0f, 5.0f);
g.setColour(findColour(ThemeColors::defaultText));
g.setFont(Font("Inter", "Medium", 13));
g.setFont(FontOptions("Inter", "Medium", 13));
g.drawText(" Available data streams: ", Rectangle<float>(150.0f, 20.0f), Justification::left);

g.setColour(findColour(ThemeColors::outline).withAlpha(0.8f));
Expand Down
4 changes: 2 additions & 2 deletions Source/Processors/EmptyProcessor/EmptyProcessorEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void EmptyProcessorEditor::paint(Graphics& g)
g.drawRoundedRectangle(2, 2, getWidth() - 4, getHeight() - 4, 5.0f, 2.0f);
g.drawHorizontalLine(23, 2, getWidth() - 2);

g.setFont( Font("CP Mono", "Plain", 16.0f) );
g.setFont( FontOptions("CP Mono", "Plain", 16.0f) );
g.drawFittedText("NO SOURCE", 10, 6, getWidth() - 12, 16, Justification::centredLeft, 1);

}
}
4 changes: 2 additions & 2 deletions Source/Processors/MessageCenter/MessageCenterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ MessageCenterEditor::MessageCenterEditor(MessageCenter* owner) :
//addAndMakeVisible(incomingMessageLog);
//addAndMakeVisible(outgoingMessageLog);

sendMessageButton = new UtilityButton("Save", Font("Small Text", 0, Font::plain));
sendMessageButton = new UtilityButton("Save", FontOptions("Small Text", 0, Font::plain));
sendMessageButton->addListener(this);
sendMessageButton->setTooltip("Send a message to be saved by the record node");
addAndMakeVisible(sendMessageButton);
Expand Down Expand Up @@ -321,7 +321,7 @@ MessageLabel::MessageLabel(const String& componentName, const String& labelText)
: Label(componentName,labelText)
{
setJustificationType(Justification::bottomLeft);
setFont(Font("CP Mono", "Plain", 16));
setFont(FontOptions("CP Mono", "Plain", 16));
setBorderSize(BorderSize<int>(0, 7, 2, 0));
setMinimumHorizontalScale (1.0f);

Expand Down
14 changes: 7 additions & 7 deletions Source/Processors/Parameter/ParameterEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ TextBoxParameterEditor::TextBoxParameterEditor(Parameter* param, int rowHeightPi
|| param->getType() == Parameter::STRING_PARAM);

label = std::make_unique<Label>("Parameter name", param->getDisplayName() == "" ? param->getName().replace("_", " ") : param->getDisplayName());
Font labelFont = Font("Inter", "Regular", int(0.75*rowHeightPixels));
Font labelFont = FontOptions("Inter", "Regular", int(0.75*rowHeightPixels));
int width = rowWidthPixels;
label->setFont(labelFont);
addAndMakeVisible(label.get());
Expand All @@ -137,7 +137,7 @@ TextBoxParameterEditor::TextBoxParameterEditor(Parameter* param, int rowHeightPi
else
valueTextBox = std::make_unique<CustomTextBox>(param->getKey(), param->getValue().toString(), "");

valueTextBox->setFont(Font("CP Mono", "Plain", int(0.75*rowHeightPixels)));
valueTextBox->setFont(FontOptions("CP Mono", "Plain", int(0.75*rowHeightPixels)));
valueTextBox->setName(param->getKey());
// valueTextBox->setColour(Label::textColourId, Colours::black);
// valueTextBox->setColour(Label::backgroundColourId, Colours::lightgrey);
Expand Down Expand Up @@ -211,7 +211,7 @@ void CustomToggleButton::paintButton(juce::Graphics& g, bool shouldDrawButtonAsH
g.drawRoundedRectangle(getLocalBounds().toFloat(), 3.0f, 1.0f);

// Set the text font
g.setFont(Font("Inter", "Regular", int(0.75*getHeight())));
g.setFont(FontOptions("Inter", "Regular", int(0.75*getHeight())));
g.setColour(findColour(ThemeColors::defaultText));

// Set the text based on the button state
Expand All @@ -231,7 +231,7 @@ ToggleParameterEditor:: ToggleParameterEditor(Parameter* param, int rowHeightPix
jassert(param->getType() == Parameter::BOOLEAN_PARAM);

label = std::make_unique<Label>("Parameter name", param->getDisplayName() == "" ? param->getName().replace("_", " ") : param->getDisplayName());
label->setFont(Font("Inter", "Regular", int(0.75*rowHeightPixels)));
label->setFont(FontOptions("Inter", "Regular", int(0.75*rowHeightPixels)));
addAndMakeVisible(label.get());

toggleButton = std::make_unique<CustomToggleButton>();
Expand Down Expand Up @@ -279,7 +279,7 @@ ComboBoxParameterEditor::ComboBoxParameterEditor(Parameter* param, int rowHeight
|| param->getType() == Parameter::INT_PARAM);

label = std::make_unique<Label>("Parameter name", param->getDisplayName()); // == "" ? param->getName().replace("_", " ") : param->getDisplayName());
label->setFont(Font("Inter", "Regular", int(0.75*rowHeightPixels)));
label->setFont(FontOptions("Inter", "Regular", int(0.75*rowHeightPixels)));
addAndMakeVisible(label.get());

valueComboBox = std::make_unique<ComboBox>();
Expand Down Expand Up @@ -498,7 +498,7 @@ BoundedValueParameterEditor::BoundedValueParameterEditor(Parameter* param, int r
valueEditor->setText(String(p->getIntValue()), dontSendNotification);
}
valueEditor->setName(param->getKey());
valueEditor->setFont(Font("Inter", "Regular", int(0.75*rowHeightPixels)));
valueEditor->setFont(FontOptions("Inter", "Regular", int(0.75*rowHeightPixels)));
valueEditor->setJustificationType(Justification::centred);
valueEditor->addListener(this);
valueEditor->setTooltip(param->getDescription());
Expand Down Expand Up @@ -587,7 +587,7 @@ SelectedChannelsParameterEditor::SelectedChannelsParameterEditor(Parameter* para
addAndMakeVisible(button.get());

label = std::make_unique<Label>("Parameter name", param->getDisplayName() == "" ? param->getName().replace("_", " ") : param->getDisplayName());
Font labelFont = Font("Inter", "Regular", int(0.75*rowHeightPixels));
Font labelFont = FontOptions("Inter", "Regular", int(0.75*rowHeightPixels));
label->setFont(labelFont);
label->setJustificationType(Justification::left);
addAndMakeVisible(label.get());
Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/RecordNode/EngineConfigWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ EngineParameterComponent::EngineParameterComponent(EngineParameter& param)
else
{
Label* lab = new Label();
lab->setFont(Font("Silkscreen", "Regular", 10));
lab->setFont(FontOptions("Silkscreen", "Regular", 10));
name = param.name;

switch (param.type)
Expand Down
2 changes: 1 addition & 1 deletion Source/Processors/RecordNode/RecordNodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ RecordToggleParameterEditor::RecordToggleParameterEditor(Parameter* param) : Par
{

label = std::make_unique<Label>("Parameter name", param->getDisplayName());
label->setFont(Font("Small Text", 12.0f, Font::plain));
label->setFont(FontOptions("Small Text", 12.0f, Font::plain));
addAndMakeVisible(label.get());

toggleButton = std::make_unique<RecordToggleButton>(param->getDisplayName());//param->getDisplayName());
Expand Down
10 changes: 5 additions & 5 deletions Source/Processors/Visualization/InteractivePlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ InteractivePlot::InteractivePlot() :
addAndMakeVisible(drawComponent.get());

titleLabel = std::make_unique<Label>("Title Label", "Title");
titleLabel->setFont(Font("Fira Code", "Bold", 15.0f));
titleLabel->setFont(FontOptions("Fira Code", "Bold", 15.0f));
titleLabel->setColour(Label::textColourId, axisColour);
titleLabel->setJustificationType(Justification::centred);
addAndMakeVisible(titleLabel.get());

xLabel = std::make_unique<Label>("X-Axis Label", "X Label");
xLabel->setFont(Font("Fira Code", "Regular", 15.0f));
xLabel->setFont(FontOptions("Fira Code", "Regular", 15.0f));
xLabel->setColour(Label::textColourId, axisColour);
xLabel->setJustificationType(Justification::centred);
addAndMakeVisible(xLabel.get());

yLabel = std::make_unique<Label>("Y-Axis Label", "Y Label");
yLabel->setFont(Font("Fira Code", "Regular", 15.0f));
yLabel->setFont(FontOptions("Fira Code", "Regular", 15.0f));
yLabel->setColour(Label::textColourId, axisColour);
yLabel->setJustificationType(Justification::centred);
addAndMakeVisible(yLabel.get());

autoRescaleButton = std::make_unique<UtilityButton>("Rescale",Font("Default", 15, Font::plain));
autoRescaleButton = std::make_unique<UtilityButton>("Rescale",FontOptions("Default", 15, Font::plain));
autoRescaleButton ->addListener(this);
addAndMakeVisible(autoRescaleButton.get());

Expand Down Expand Up @@ -231,7 +231,7 @@ Axis::Axis()
colour(Colours::white)
{

font = Font("Default", 15, Font::plain);
font = FontOptions("Default", 15, Font::plain);

}

Expand Down
9 changes: 4 additions & 5 deletions Source/UI/ControlPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ void RecordButton::updateImages()

CPUMeter::CPUMeter() : Label ("CPU Meter", "0.0"), cpu (0.0f)
{
font = Font ("Silkscreen", "Regular", 12);
font = FontOptions ("Silkscreen", "Regular", 12);

setTooltip ("CPU usage");
}
Expand Down Expand Up @@ -169,7 +169,7 @@ void CPUMeter::paint (Graphics& g)
DiskSpaceMeter::DiskSpaceMeter()

{
font = Font ("Silkscreen", "Regular", 12);
font = FontOptions ("Silkscreen", "Regular", 12);

setTooltip ("Disk space available");
}
Expand Down Expand Up @@ -398,13 +398,13 @@ ControlPanel::ControlPanel (ProcessorGraph* graph_, AudioComponent* audio_, bool
recordSelector->addListener (this);
addChildComponent (recordSelector.get());

recordOptionsButton = std::make_unique<UtilityButton> ("R", Font ("Silkscreen", "Regular", 15));
recordOptionsButton = std::make_unique<UtilityButton> ("R", FontOptions ("Silkscreen", "Regular", 15));
recordOptionsButton->setEnabledState (true);
recordOptionsButton->addListener (this);
recordOptionsButton->setTooltip ("Configure options for selected record engine");
addChildComponent (recordOptionsButton.get());

newDirectoryButton = std::make_unique<UtilityButton> ("+", Font ("Silkscreen", "Regular", 15));
newDirectoryButton = std::make_unique<UtilityButton> ("+", FontOptions ("Silkscreen", "Regular", 15));
newDirectoryButton->setEnabledState (false);
newDirectoryButton->addListener (this);
newDirectoryButton->setTooltip ("Start a new data directory");
Expand All @@ -420,7 +420,6 @@ ControlPanel::ControlPanel (ProcessorGraph* graph_, AudioComponent* audio_, bool

if (! isConsoleApp)
{
font = Font ("Miso", "Regular", 13);

audioEditor = (AudioEditor*) graph->getAudioNode()->createEditor();
addAndMakeVisible (audioEditor);
Expand Down
6 changes: 2 additions & 4 deletions Source/UI/ControlPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CPUMeter : public Label
void paint (Graphics& g);

private:
Font font;
FontOptions font;
float cpu;
};

Expand Down Expand Up @@ -179,7 +179,7 @@ class DiskSpaceMeter : public Component,
void paint (Graphics& g);

private:
Font font;
FontOptions font;

float diskFree;
};
Expand Down Expand Up @@ -468,8 +468,6 @@ class TESTABLE ControlPanel : public Component,

bool keyPressed (const KeyPress& key);

Font font;

bool open;

Path p1, p2;
Expand Down
2 changes: 1 addition & 1 deletion Source/UI/EditorViewport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1125,7 +1125,7 @@ SignalChainTabButton::SignalChainTabButton (int index) : Button ("Signal Chain T
setRadioGroupId (99);
setClickingTogglesState (true);

buttonFont = Font ("Silkscreen", 10, Font::plain);
buttonFont = FontOptions ("Silkscreen", 10, Font::plain);
buttonFont.setHeight (14);

offset = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/UI/GraphViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void GraphViewport::paint (Graphics& g)
g.setOpacity (1.0f);
g.setColour (findColour (ThemeColors::componentBackground).brighter (0.3f));

g.setFont (Font ("Silkscreen", "Regular", 15));
g.setFont (FontOptions ("Silkscreen", "Regular", 15));
g.drawFittedText (currentVersionText, 40, 40, getWidth() - 72, getHeight() - 60, Justification::bottomRight, 100);
}

Expand Down
2 changes: 1 addition & 1 deletion Source/UI/LookAndFeel/CustomLookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ void CustomLookAndFeel::drawComboBox (Graphics& g, int width, int height, const

Font CustomLookAndFeel::getComboBoxFont (ComboBox& box)
{
return Font ("Inter", "Regular", box.getHeight() * 0.75);
return FontOptions ("Inter", "Regular", box.getHeight() * 0.75);
}

void CustomLookAndFeel::positionComboBoxText (juce::ComboBox& box, juce::Label& label)
Expand Down

0 comments on commit 59089de

Please sign in to comment.