Skip to content

Commit

Permalink
Move to our diffs + JUCE 8.0.2 (#7802)
Browse files Browse the repository at this point in the history
* Move to our diffs + JUCE 8.0.2

Lets see if this builds!

* Move to ubuntu 20 docker mage

* More juce font nonsense

* more font nonsense

* Turn off melatonin inspector for a bit

* more font nonsense

* String width nonsense

* sigh
  • Loading branch information
baconpaul authored Sep 27, 2024
1 parent 3cea5c8 commit a1d0805
Show file tree
Hide file tree
Showing 32 changed files with 177 additions and 77 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
ctest -j 4 || ctest --rerun-failed --output-on-failure
build_plugin_lindoc:
name: PR - U18 Docker
name: PR - U20 Docker
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand All @@ -98,6 +98,7 @@ jobs:
- name: Build in Docker
uses: surge-synthesizer/sst-githubactions/cmake-in-docker@main
with:
image: ghcr.io/surge-synthesizer/sst-dockerimages/ubuntu20_gcc11:main
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
cmakeArgs: -DCMAKE_BUILD_TYPE=Debug -GNinja
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ jobs:
- name: Build in Docker
uses: surge-synthesizer/sst-githubactions/cmake-in-docker@main
with:
image: ghcr.io/surge-synthesizer/sst-dockerimages/ubuntu20_gcc11:main
username: ${{ github.actor }}
token: ${{ secrets.GITHUB_TOKEN }}
cmakeArgs: -DAZURE_PIPELINE=1 -DSURGE_BUILD_LV2=TRUE -DSURGE_VERSION="${{ needs.surge_version.outputs.surge_version }}" -DCMAKE_BUILD_TYPE=Release -GNinja
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE STRING "Minimum macOS version")
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS version")
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

Expand Down
40 changes: 40 additions & 0 deletions fix_string_width.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/perl


use File::Find;
use File::Basename;

find(
{
wanted => \&findfiles,
},
'src'
);

sub findfiles
{
$f = $File::Find::name;
print $f . "\n";
if ($f =~ m/\.cpp$/ || $f =~ m/\.h$/)
{
$q = basename($f);

open (IN, "< $q") || die "Cant open $q from $f";
open (OUT, "> $q.bak");
while(<IN>)
{
if (m/getStringWidth/)
{
print;
s/([^\s\{]+).getStringWidthFloat\(/juce::GlyphArrangement::getStringWidth\($1, /;
print;
#die;
}
print OUT;

}
close(IN);
close(OUT);
system("mv ${q}.bak ${q}");
}
}
2 changes: 1 addition & 1 deletion libs/JUCE
Submodule JUCE updated 2786 files
2 changes: 1 addition & 1 deletion libs/melatonin_inspector
Submodule melatonin_inspector updated 40 files
+52 −6 .github/workflows/ci.yml
+ Assets/lock-off.png
+ Assets/lock-on.png
+ Assets/move-off.png
+ Assets/tab-off.png
+ Assets/tab-on.png
+41 −13 CMakeLists.txt
+13 −1 LatestCompiledAssets/BinaryData1.cpp
+9 −368 LatestCompiledAssets/BinaryData11.cpp
+9 −17 LatestCompiledAssets/BinaryData12.cpp
+368 −16 LatestCompiledAssets/BinaryData13.cpp
+18 −15 LatestCompiledAssets/BinaryData14.cpp
+16 −22 LatestCompiledAssets/BinaryData15.cpp
+15 −22 LatestCompiledAssets/BinaryData16.cpp
+22 −14 LatestCompiledAssets/BinaryData17.cpp
+22 −14 LatestCompiledAssets/BinaryData18.cpp
+24 −0 LatestCompiledAssets/BinaryData19.cpp
+23 −0 LatestCompiledAssets/BinaryData20.cpp
+28 −0 LatestCompiledAssets/BinaryData21.cpp
+28 −0 LatestCompiledAssets/BinaryData22.cpp
+14 −2 LatestCompiledAssets/InspectorBinaryData.h
+12 −9 copy_cmake_assets.rb
+109 −5 melatonin/component_model.h
+62 −0 melatonin/components/accesibility.h
+13 −1 melatonin/components/box_model.h
+1 −1 melatonin/components/collapsable_panel.h
+3 −3 melatonin/components/color_picker.h
+3 −3 melatonin/components/colour_property_component.h
+1 −1 melatonin/components/component_tree_view_item.h
+4 −0 melatonin/components/fps_meter.h
+46 −11 melatonin/components/overlay.h
+1 −1 melatonin/components/preview.h
+15 −1 melatonin/components/properties.h
+5 −0 melatonin/helpers/component_helpers.h
+1 −0 melatonin/helpers/misc.h
+24 −1 melatonin/helpers/overlay_mouse_listener.h
+46 −12 melatonin/inspector_component.h
+23 −2 melatonin/lookandfeel.h
+7 −1 melatonin_inspector.cpp
+123 −25 melatonin_inspector.h
13 changes: 10 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ option(SURGE_BUILD_PYTHON_BINDINGS "Build Surge Python bindings with pybind11" O
option(SURGE_COPY_TO_PRODUCTS "Copy built plugins to the products directory" ON)
option(SURGE_COPY_AFTER_BUILD "Copy JUCE plugins to system plugin area after build" OFF)
option(SURGE_EXPOSE_PRESETS "Expose surge presets via the JUCE Program API" OFF)
option(SURGE_INCLUDE_MELATONIN_INSPECTOR "Include melatonin inspector" OFF)

# Currently the JUCE LV2 build crashes in our CI pipeline, so leave it for users to self build
option(SURGE_BUILD_LV2 "Build Surge as an LV2" OFF)
Expand All @@ -20,7 +21,9 @@ include(cmake/lib.cmake)
if (NOT SURGE_SKIP_JUCE_FOR_RACK)
message(STATUS "Using JUCE from ${SURGE_JUCE_PATH}")
add_subdirectory(${SURGE_JUCE_PATH} ${CMAKE_BINARY_DIR}/JUCE EXCLUDE_FROM_ALL)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../libs/melatonin_inspector" ${CMAKE_BINARY_DIR}/melatonin_inspector EXCLUDE_FROM_ALL)
if (SURGE_INCLUDE_MELATONIN_INSPECTOR)
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../libs/melatonin_inspector" ${CMAKE_BINARY_DIR}/melatonin_inspector EXCLUDE_FROM_ALL)
endif()
endif()

if(${CMAKE_VERSION} VERSION_LESS 3.21)
Expand Down Expand Up @@ -57,7 +60,8 @@ target_compile_definitions(surge-juce INTERFACE
JUCE_WEB_BROWSER=0
JUCE_USE_CAMERA=disabled

JUCE_DISPLAY_SPLASH_SCREEN=0
# No longer needed with JUCE 8
# JUCE_DISPLAY_SPLASH_SCREEN=0
JUCE_REPORT_APP_USAGE=0

JUCE_MODAL_LOOPS_PERMITTED=0
Expand All @@ -74,7 +78,10 @@ target_compile_definitions(surge-juce INTERFACE
)

if (NOT SURGE_SKIP_JUCE_FOR_RACK)
target_link_libraries(surge-juce INTERFACE melatonin_inspector)
if (SURGE_INCLUDE_MELATONIN_INSPECTOR)
target_link_libraries(surge-juce INTERFACE melatonin_inspector)
target_compile_definitions(surge-juce INTERFACE SURGE_INCLUDE_MELATONIN_INSPECTOR=1)
endif()
endif()

if(NOT SURGE_SKIP_VST3)
Expand Down
4 changes: 2 additions & 2 deletions src/surge-fx/SurgeFXEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ struct SurgefxAudioProcessorEditor::PromptOverlay : juce::Component, juce::TextE
PromptOverlay()
{
ed = std::make_unique<juce::TextEditor>();
ed->setFont(juce::Font(28));
ed->setFont(juce::FontOptions(28));
ed->setColour(juce::TextEditor::ColourIds::textColourId, juce::Colours::white);
ed->setJustification(juce::Justification::centred);
ed->addListener(this);
Expand All @@ -688,7 +688,7 @@ struct SurgefxAudioProcessorEditor::PromptOverlay : juce::Component, juce::TextE
{
ed->clear();
ed->setText(s, juce::NotificationType::dontSendNotification);
ed->applyFontToAllText(juce::Font(28));
ed->applyFontToAllText(juce::FontOptions(28));
ed->applyColourToAllText(juce::Colours::white);
ed->repaint();
}
Expand Down
10 changes: 5 additions & 5 deletions src/surge-fx/SurgeLookAndFeel.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ class SurgeLookAndFeel : public juce::LookAndFeel_V4
g.drawLine(0, h - orangeHeight, w, h - orangeHeight);

// text
g.setFont(12);
g.setFont(juce::FontOptions(12));
g.drawSingleLineText(Surge::Build::FullVersionStr, w - 3, h - 26.f,
juce::Justification::right);
g.drawSingleLineText(Surge::Build::BuildDate, w - 3, h - 6.f, juce::Justification::right);
Expand Down Expand Up @@ -334,15 +334,15 @@ class SurgeFXParamDisplay : public juce::Component
if (isEnabled())
{
g.setColour(findColour(SurgeLookAndFeel::SurgeColourIds::paramDisplay));
g.setFont(10 * hScale);
g.setFont(juce::FontOptions(10 * hScale));
g.drawSingleLineText(group, bounds.getX() + 5, bounds.getY() + 2 + 10 * hScale);
g.setFont(12 * hScale);
g.setFont(juce::FontOptions(12 * hScale));
g.drawSingleLineText(name, bounds.getX() + 5,
bounds.getY() + 2 + (10 + 3 + 11) * hScale);

if (!overlayEditor->isVisible())
{
g.setFont(20 * hScale);
g.setFont(juce::FontOptions(20 * hScale));
g.drawSingleLineText(display, bounds.getX() + 5,
bounds.getY() + bounds.getHeight() - 5);
}
Expand Down Expand Up @@ -384,7 +384,7 @@ class SurgeFXParamDisplay : public juce::Component
overlayEditor->setColour(juce::TextEditor::ColourIds::highlightColourId,
juce::Colour(0xFF775522));
overlayEditor->setJustification(juce::Justification::bottomLeft);
overlayEditor->setFont(juce::Font(20));
overlayEditor->setFont(juce::FontOptions(20));
overlayEditor->setText(display, juce::dontSendNotification);
overlayEditor->setVisible(true);
overlayEditor->grabKeyboardFocus();
Expand Down
10 changes: 6 additions & 4 deletions src/surge-xt/gui/RuntimeFont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@ juce::Font FontManager::getLatoAtSize(float size, juce::Font::FontStyleFlags sty
{
if (hasLatoOverride)
{
return juce::Font(latoOverride).withPointHeight(size).withStyle(style);
return juce::Font(juce::FontOptions(latoOverride)).withPointHeight(size).withStyle(style);
}
else if (useOSLato)
{
return juce::Font("Lato", 10, 0).withPointHeight(size).withStyle(style);
return juce::Font(juce::FontOptions("Lato", 10, 0)).withPointHeight(size).withStyle(style);
}
else
{
Expand All @@ -98,13 +98,15 @@ juce::Font FontManager::getLatoAtSize(float size, juce::Font::FontStyleFlags sty
{
tf = latoItalicTypeface;
}
return juce::Font(tf).withPointHeight(size).withStyle(style);
return juce::Font(juce::FontOptions(tf)).withPointHeight(size).withStyle(style);
}
}

juce::Font FontManager::getFiraMonoAtSize(float size, juce::Font::FontStyleFlags style) const
{
return juce::Font(firaMonoRegularTypeface).withPointHeight(size).withStyle(style);
return juce::Font(juce::FontOptions(firaMonoRegularTypeface))
.withPointHeight(size)
.withStyle(style);
}

void FontManager::overrideLatoWith(juce::ReferenceCountedObjectPtr<juce::Typeface> itf)
Expand Down
8 changes: 4 additions & 4 deletions src/surge-xt/gui/RuntimeFont.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ struct FontManager

bool useOSLato{false};

juce::Font displayFont;
juce::Font patchNameFont;
juce::Font lfoTypeFont;
juce::Font aboutFont;
juce::Font displayFont{juce::FontOptions()};
juce::Font patchNameFont{juce::FontOptions()};
juce::Font lfoTypeFont{juce::FontOptions()};
juce::Font aboutFont{juce::FontOptions()};
void setupFontMembers();

juce::ReferenceCountedObjectPtr<juce::Typeface> latoRegularTypeface, latoBoldTypeface,
Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/SkinSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,8 @@ juce::Font Skin::getFont(const Surge::Skin::FontDesc &d)
{
auto fo = fontOverrides[d.id];
if (typeFaces.find(fo.family) != typeFaces.end())
return juce::Font(typeFaces[fo.family]).withPointHeight(fo.size);
return juce::Font(fo.family, fo.size, juce::Font::FontStyleFlags::plain);
return juce::Font(juce::FontOptions(typeFaces[fo.family])).withPointHeight(fo.size);
return juce::Font(juce::FontOptions(fo.family, fo.size, juce::Font::FontStyleFlags::plain));
}

if (d.hasParent)
Expand Down
6 changes: 5 additions & 1 deletion src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
* https://github.com/surge-synthesizer/surge
*/

#if SURGE_INCLUDE_MELATONIN_INSPECTOR
#include "melatonin_inspector/melatonin_inspector.h"
#endif

#include "SurgeGUIEditor.h"
#include "resource.h"

Expand Down Expand Up @@ -4210,7 +4213,8 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptr<Surge::GUI::Skin::Control
{
if (currentSkin->typeFaces.find(ff) != currentSkin->typeFaces.end())
{
hs->setFont(juce::Font(currentSkin->typeFaces[ff]).withPointHeight(fs));
hs->setFont(
juce::Font(juce::FontOptions(currentSkin->typeFaces[ff])).withPointHeight(fs));
hs->setFontSize(fs);
}
}
Expand Down
4 changes: 4 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@

class SurgeSynthEditor;

#if SURGE_INCLUDE_MELATONIN_INSPECTOR
namespace melatonin
{
class Inspector;
}
#endif

namespace Surge
{
Expand Down Expand Up @@ -183,7 +185,9 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,

bool debugFocus{false};
void globalFocusChanged(juce::Component *fc) override;
#if SURGE_INCLUDE_MELATONIN_INSPECTOR
std::unique_ptr<melatonin::Inspector> melatoninInspector;
#endif

protected:
virtual void setParameter(long index, float value);
Expand Down
5 changes: 5 additions & 0 deletions src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
* https://github.com/surge-synthesizer/surge
*/

#if SURGE_INCLUDE_MELATONIN_INSPECTOR
#include "melatonin_inspector/melatonin_inspector.h"
#endif

#include "SurgeGUIEditor.h"
#include "SurgeGUIEditorTags.h"
#include "SurgeGUIUtils.h"
Expand Down Expand Up @@ -1821,6 +1824,7 @@ juce::PopupMenu SurgeGUIEditor::makeDevMenu(const juce::Point<int> &where)
devSubMenu.addItem(Surge::GUI::toOSCase("Dump Undo/Redo Stack to stdout"), true, false,
[this]() { undoManager()->dumpStack(); });

#if SURGE_INCLUDE_MELATONIN_INSPECTOR
if (melatoninInspector)
{
devSubMenu.addItem("Close Melatonin Inspector", [this]() {
Expand All @@ -1840,6 +1844,7 @@ juce::PopupMenu SurgeGUIEditor::makeDevMenu(const juce::Point<int> &where)
melatoninInspector->setVisible(true);
});
}
#endif

#ifdef INSTRUMENT_UI
devSubMenu.addItem(Surge::GUI::toOSCase("Show UI Instrumentation..."),
Expand Down
6 changes: 3 additions & 3 deletions src/surge-xt/gui/SurgeJUCELookAndFeel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void SurgeJUCELookAndFeel::drawLabel(Graphics &graphics, Label &label)
int SurgeJUCELookAndFeel::getTabButtonBestWidth(TabBarButton &b, int d)
{
auto f = skin->getFont(Fonts::Widgets::TabButtonFont);
auto r = f.getStringWidth(b.getButtonText()) + 20;
auto r = (int)juce::GlyphArrangement::getStringWidth(f, b.getButtonText()) + 20;
return r;
}

Expand Down Expand Up @@ -238,8 +238,8 @@ void SurgeJUCELookAndFeel::drawDocumentWindowTitleBar(DocumentWindow &window, Gr
fontVersion = fontSurge;
}

auto sw = fontSurge.getStringWidth(surgeLabel);
auto vw = fontVersion.getStringWidth(surgeVersion);
auto sw = (int)juce::GlyphArrangement::getStringWidth(fontSurge, surgeLabel);
auto vw = (int)juce::GlyphArrangement::getStringWidth(fontVersion, surgeVersion);

auto icon = associatedBitmapStore->getImage(IDB_SURGE_ICON);

Expand Down
4 changes: 2 additions & 2 deletions src/surge-xt/gui/overlays/AboutScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void AboutScreen::resized()
lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link));
lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification);

auto strw = font.getStringWidth(std::get<1>(l)) + 8;
auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8;
lb->setBounds(margin + colW, h0, strw, lHeight);

addAndMakeVisible(*lb);
Expand Down Expand Up @@ -344,7 +344,7 @@ void AboutScreen::resized()
lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link));
lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification);

auto strw = font.getStringWidth(std::get<1>(l)) + 8;
auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8;
lb->setBounds(rightSide + colW, h1, strw, lHeight);

addAndMakeVisible(*lb);
Expand Down
16 changes: 10 additions & 6 deletions src/surge-xt/gui/overlays/FilterAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,11 @@ void FilterAnalysis::paint(juce::Graphics &g)
const auto over1000 = freq >= 1000.f;
const auto freqString =
juce::String(over1000 ? freq / 1000.f : freq) + (over1000 ? "k" : "");
const auto labelRect = juce::Rectangle{font.getStringWidth(freqString), labelHeight}
.withBottomY(height - 2)
.withRightX((int)xPos);
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, freqString),
labelHeight}
.withBottomY(height - 2)
.withRightX((int)xPos);

g.setColour(skin->getColor(Colors::MSEGEditor::Axis::Text));
g.drawFittedText(freqString, labelRect, juce::Justification::bottom, 1);
Expand All @@ -245,9 +247,11 @@ void FilterAnalysis::paint(juce::Graphics &g)
g.drawLine(line);

const auto dbString = juce::String(dB) + " dB";
const auto labelRect = juce::Rectangle{font.getStringWidth(dbString), labelHeight}
.withBottomY((int)yPos)
.withRightX(width - 2);
const auto labelRect =
juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, dbString),
labelHeight}
.withBottomY((int)yPos)
.withRightX(width - 2);

g.setColour(skin->getColor(Colors::MSEGEditor::Axis::SecondaryText));
g.drawFittedText(dbString, labelRect, juce::Justification::right, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ struct KeyBindingsListRow : public juce::Component
std::string desc = "";
keyDesc = std::make_unique<juce::Label>("Key Binding", desc);
keyDesc->setAccessible(true);
keyDesc->setFont(juce::Font(10));
keyDesc->setFont(juce::Font(juce::FontOptions(10)));
addAndMakeVisible(*keyDesc);

reset = std::make_unique<Surge::Widgets::SelfDrawButton>("Reset");
Expand Down
Loading

0 comments on commit a1d0805

Please sign in to comment.