Skip to content

Commit

Permalink
Merge pull request #114 from Tracktion/main
Browse files Browse the repository at this point in the history
Added compatibility with juce 8
  • Loading branch information
sudara committed Jun 16, 2024
2 parents 7bcf92e + d069a16 commit e4c86b2
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 1 deletion.
14 changes: 13 additions & 1 deletion melatonin/components/box_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,31 @@ namespace melatonin

addAndMakeVisible (widthLabel);
widthLabel.addListener (this);
#if JUCE_MAJOR_VERSION == 8
widthLabel.setFont (juce::FontOptions (20.0f));
#else
widthLabel.setFont (20.0f);
#endif
widthLabel.setJustificationType (juce::Justification::centredRight);
widthLabel.setColour (juce::Label::textColourId, colors::white);

addAndMakeVisible (byLabel);
byLabel.setText (juce::CharPointer_UTF8("\xc3\x97"), juce::dontSendNotification);
#if JUCE_MAJOR_VERSION == 8
byLabel.setFont (juce::FontOptions (20.f));
#else
byLabel.setFont (20.f);
#endif
byLabel.setJustificationType (juce::Justification::centred);
byLabel.setColour (juce::Label::textColourId, colors::white);

addAndMakeVisible (heightLabel);
heightLabel.addListener (this);
heightLabel.setFont (20.0f);
#if JUCE_MAJOR_VERSION == 8
heightLabel.setFont (juce::FontOptions (20.f));
#else
heightLabel.setFont (20.f);
#endif
heightLabel.setJustificationType (juce::Justification::centredLeft);
heightLabel.setColour (juce::Label::textColourId, colors::white);

Expand Down
4 changes: 4 additions & 0 deletions melatonin/components/collapsable_panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ namespace melatonin

void drawToggleButton (juce::Graphics& g, juce::ToggleButton& button, bool shouldDrawButtonAsHighlighted, bool shouldDrawButtonAsDown) override
{
#if JUCE_MAJOR_VERSION == 8
auto font = juce::FontOptions ("Verdana", 14.5, juce::Font::FontStyleFlags::plain).withKerningFactor (0.1f);
#else
auto font = juce::Font ("Verdana", 14.5, juce::Font::FontStyleFlags::plain).withExtraKerningFactor (0.1f);
#endif
auto tickWidth = font.getHeight();

drawTickBox (g, button, 6.0f, ((float) button.getHeight() - tickWidth) * 0.5f, tickWidth, tickWidth, button.getToggleState(), button.isEnabled(), shouldDrawButtonAsHighlighted, shouldDrawButtonAsDown);
Expand Down
12 changes: 12 additions & 0 deletions melatonin/components/color_picker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ namespace melatonin
g.setColour (colors::customBackground);
g.fillRoundedRectangle (getLocalBounds().withSizeKeepingCentre (38, 16).toFloat(), 3);
g.setColour (colors::label);
#if JUCE_MAJOR_VERSION == 8
g.setFont (juce::FontOptions ("Verdana", 9, juce::Font::FontStyleFlags::bold));
#else
g.setFont (juce::Font ("Verdana", 9, juce::Font::FontStyleFlags::bold));
#endif
g.drawText (rgba ? "RGBA" : "HEX", getLocalBounds(), juce::Justification::centred);
}

Expand Down Expand Up @@ -98,14 +102,22 @@ namespace melatonin
g.fillRoundedRectangle (colorValueBounds.withTrimmedBottom (1).toFloat(), 4);

g.setColour (colors::text);
#if JUCE_MAJOR_VERSION == 8
g.setFont (juce::FontOptions ("Verdana", 14.5, juce::Font::FontStyleFlags::plain));
#else
g.setFont (juce::Font ("Verdana", 14.5, juce::Font::FontStyleFlags::plain));
#endif
g.drawText (stringForColor (selectedColor), colorValueBounds.withTrimmedBottom (2), juce::Justification::centred);
}

if (model.colors.empty())
{
g.setColour (colors::propertyName);
#if JUCE_MAJOR_VERSION == 8
g.setFont (juce::FontOptions ("Verdana", 15, juce::Font::FontStyleFlags::plain));
#else
g.setFont (juce::Font ("Verdana", 15, juce::Font::FontStyleFlags::plain));
#endif
g.drawText ("No Color Properties", panelBounds.withTrimmedLeft (3).withTrimmedTop (2), juce::Justification::topLeft);
}
}
Expand Down
4 changes: 4 additions & 0 deletions melatonin/components/component_tree_view_item.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,11 @@ namespace melatonin
g.setColour (colors::treeItemTextDisabled);

auto name = componentString (component);
#if JUCE_MAJOR_VERSION == 8
auto font = juce::FontOptions ("Verdana", 15, juce::Font::FontStyleFlags::plain);
#else
auto font = juce::Font ("Verdana", 15, juce::Font::FontStyleFlags::plain);
#endif

g.setFont (font);

Expand Down
4 changes: 4 additions & 0 deletions melatonin/components/fps_meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,11 @@ namespace melatonin
private:
juce::Component* overlay = nullptr;
juce::Rectangle<int> bounds;
#if JUCE_MAJOR_VERSION == 8
juce::Font font = juce::FontOptions (juce::Font::getDefaultMonospacedFontName(), 16.0f, juce::Font::plain);
#else
juce::Font font = juce::Font (juce::Font::getDefaultMonospacedFontName(), 16.0f, juce::Font::plain);
#endif
double lastTime = juce::Time::getMillisecondCounterHiRes();
double frameTime = 0;
int fps = 0;
Expand Down
8 changes: 8 additions & 0 deletions melatonin/components/overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ namespace melatonin

for (auto* l : labels)
{
#if JUCE_MAJOR_VERSION == 8
l->setFont (juce::FontOptions (13.f));
#else
l->setFont (13.f);
#endif
l->setJustificationType (juce::Justification::centred);
l->setColour (juce::Label::textColourId, colors::white);

addAndMakeVisible (l);
}

#if JUCE_MAJOR_VERSION == 8
dimensions.setFont (juce::FontOptions (13.f));
#else
dimensions.setFont (13.f);
#endif
dimensions.setJustificationType (juce::Justification::centred);
dimensions.setColour (juce::Label::textColourId, colors::white);
}
Expand Down
4 changes: 4 additions & 0 deletions melatonin/components/preview.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ namespace melatonin
addAndMakeVisible (timingToggle);
maxLabel.setColour (juce::Label::textColourId, colors::iconOff);
maxLabel.setJustificationType (juce::Justification::centredTop);
#if JUCE_MAJOR_VERSION == 8
maxLabel.setFont (juce::FontOptions ("Verdana", 18, juce::Font::FontStyleFlags::bold));
#else
maxLabel.setFont (juce::Font ("Verdana", 18, juce::Font::FontStyleFlags::bold));
#endif

// by default timings aren't on
timingToggle.on = settings->props->getBoolValue ("showPerformanceTimings", false);
Expand Down
4 changes: 4 additions & 0 deletions melatonin/inspector_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ namespace melatonin
tree.getViewport()->setScrollBarThickness (20);

searchBox.setHelpText ("search");
#if JUCE_MAJOR_VERSION == 8
searchBox.setFont (juce::FontOptions ("Verdana", 17, juce::Font::FontStyleFlags::plain));
#else
searchBox.setFont (juce::Font ("Verdana", 17, juce::Font::FontStyleFlags::plain));
#endif
searchBox.setColour (juce::Label::backgroundColourId, juce::Colours::transparentBlack);
searchBox.setColour (juce::Label::textColourId, colors::treeItemTextSelected);
searchBox.setColour (juce::TextEditor::outlineColourId, juce::Colours::transparentBlack);
Expand Down
4 changes: 4 additions & 0 deletions melatonin/lookandfeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ namespace melatonin
// don't use the target app's font
juce::Font getLabelFont (juce::Label& label) override
{
#if JUCE_MAJOR_VERSION == 8
return juce::FontOptions { "Verdana", label.getFont().getHeight(), label.getFont().getStyleFlags() };
#else
return { "Verdana", label.getFont().getHeight(), label.getFont().getStyleFlags() };
#endif
}

// oh i dream of css resets...
Expand Down

0 comments on commit e4c86b2

Please sign in to comment.