From 32db2d8c9965e672869a9a9af8689595e94ff1a1 Mon Sep 17 00:00:00 2001 From: EvilDragon Date: Sat, 5 Mar 2022 20:50:53 +0100 Subject: [PATCH] Start plumbing for changing modbutton font (#5942) Addresses #5843 Also minor formatting tweaks, and slight renaming of waveshaper analysis font connectors (I bet nobody used them so far anyways). --- src/common/SkinFonts.cpp | 13 +++-- src/common/SkinFonts.h | 6 +- src/surge-xt/gui/SurgeGUIEditor.cpp | 56 +++++++++++++------ .../gui/overlays/WaveShaperAnalysis.cpp | 6 +- .../gui/widgets/ModulationSourceButton.cpp | 6 +- .../gui/widgets/ModulationSourceButton.h | 8 +++ 6 files changed, 64 insertions(+), 31 deletions(-) diff --git a/src/common/SkinFonts.cpp b/src/common/SkinFonts.cpp index 036102fdcae..aab08d1f77e 100644 --- a/src/common/SkinFonts.cpp +++ b/src/common/SkinFonts.cpp @@ -29,6 +29,7 @@ namespace Widgets const FontDesc NumberField("fonts.widgets.numberfield", System::Display), EffectLabel("fonts.widgets.effectlabel", System::Display); const FontDesc TabButtonFont("fonts.widgets.tabbutton", System::Display); +const FontDesc ModButtonFont("fonts.widgets.modbutton", 8, FontDesc::FontStyleFlags::bold); } // namespace Widgets namespace PatchStore @@ -40,13 +41,15 @@ namespace LuaEditor const FontDesc Code("fonts.luaeditor.code", FontDesc::MONO, 9); } -namespace WaveshaperAnalysis +namespace Waveshaper { -const FontDesc Title("fonts.waveshaper.analysis.title", 9, FontDesc::FontStyleFlags::bold), - DriveAmount("fonts.waveshaper.analysis.drive_amount", 9), - DriveLabel("fonts.waveshaper.analysis.drive_label", 7); +namespace Preview +{ +const FontDesc Title("fonts.waveshaper.preview.title", 9, FontDesc::FontStyleFlags::bold), + DriveAmount("fonts.waveshaper.preview.driveamount", 9), + DriveLabel("fonts.waveshaper.preview.drivelabel", 7); } - +} // namespace Waveshaper } // namespace Fonts /* diff --git a/src/common/SkinFonts.h b/src/common/SkinFonts.h index f9998d1c702..47f250df42a 100644 --- a/src/common/SkinFonts.h +++ b/src/common/SkinFonts.h @@ -86,6 +86,7 @@ namespace Widgets { extern const Surge::Skin::FontDesc NumberField, EffectLabel; extern const Surge::Skin::FontDesc TabButtonFont; +extern const Surge::Skin::FontDesc ModButtonFont; } // namespace Widgets namespace PatchStore { @@ -95,10 +96,13 @@ namespace LuaEditor { extern const Surge::Skin::FontDesc Code; } -namespace WaveshaperAnalysis +namespace Waveshaper +{ +namespace Preview { extern const Surge::Skin::FontDesc Title, DriveAmount, DriveLabel; } +} // namespace Waveshaper } // namespace Fonts #endif // SURGE_XT_SKINFONTS_H diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index ff44dbdceb7..a0db25c9466 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -1288,25 +1288,33 @@ void SurgeGUIEditor::openOrRecreateEditor() if (e.isPrimary) { - auto r = positionForModulationGrid(ms); - int state = 0; + auto r = positionForModulationGrid(ms); if (ms == modsource) + { state = mod_editor ? 2 : 1; + } + if (ms == modsource_editor[current_scene]) + { state |= 4; + } if (!gui_modsrc[ms]) { gui_modsrc[ms] = std::make_unique(); } + + // would be nice if this had worked, alas... + // auto ff = currentSkin->getFont(Fonts::Widgets::ModButtonFont); + // gui_modsrc[ms]->setFont(ff); + gui_modsrc[ms]->setBounds(r); gui_modsrc[ms]->setTag(tag_mod_source0 + ms); gui_modsrc[ms]->addListener(this); gui_modsrc[ms]->setSkin(currentSkin, bitmapStore); gui_modsrc[ms]->setStorage(&(synth->storage)); - gui_modsrc[ms]->update_rt_vals(false, 0, synth->isModsourceUsed(ms)); setupAlternates(ms); @@ -1326,16 +1334,22 @@ void SurgeGUIEditor::openOrRecreateEditor() } addAndMakeVisibleWithTracking(frame->getModButtonLayer(), *gui_modsrc[ms]); + if (ms >= ms_ctrl1 && ms <= ms_ctrl8 && synth->learn_custom == ms - ms_ctrl1) { showMidiLearnOverlay(r); } } } + auto moRect = positionForModOverview(); + if (!modOverviewLauncher) + { modOverviewLauncher = std::make_unique(this); + } + modOverviewLauncher->setBounds(moRect); modOverviewLauncher->setSkin(currentSkin); addAndMakeVisibleWithTracking(frame->getModButtonLayer(), *modOverviewLauncher); @@ -4910,33 +4924,39 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrsetFont(Surge::GUI::getFontManager()->displayFont); - hs->setFontSize(std::atoi( - currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::FONT_SIZE, "9").c_str())); - - hs->setTextHOffset(std::atoi( - currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::TEXT_HOFFSET, "0") - .c_str())); - - hs->setTextVOffset(std::atoi( - currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::TEXT_VOFFSET, "0") - .c_str())); - - hs->setDeactivated(false); - hs->setDeactivatedFn([p]() { return p->appears_deactivated(); }); - auto ff = currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::FONT_FAMILY, ""); auto fs = std::atoi( currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::FONT_SIZE, "9").c_str()); + + if (fs < 1) + { + fs = 9; + } + if (ff.size() > 0) { if (currentSkin->typeFaces.find(ff) != currentSkin->typeFaces.end()) + { hs->setFont(juce::Font(currentSkin->typeFaces[ff]).withPointHeight(fs)); + hs->setFontSize(fs); + } } - else if (fs > 0) + else { hs->setFont(Surge::GUI::getFontManager()->getLatoAtSize(fs)); } + hs->setTextHOffset(std::atoi( + currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::TEXT_HOFFSET, "0") + .c_str())); + + hs->setTextVOffset(std::atoi( + currentSkin->propertyValue(skinCtrl, Surge::Skin::Component::TEXT_VOFFSET, "0") + .c_str())); + + hs->setDeactivated(false); + hs->setDeactivatedFn([p]() { return p->appears_deactivated(); }); + if (p->valtype == vt_int || p->valtype == vt_bool) { hs->setIsStepped(true); diff --git a/src/surge-xt/gui/overlays/WaveShaperAnalysis.cpp b/src/surge-xt/gui/overlays/WaveShaperAnalysis.cpp index 74920789dca..1ab2c63961c 100644 --- a/src/surge-xt/gui/overlays/WaveShaperAnalysis.cpp +++ b/src/surge-xt/gui/overlays/WaveShaperAnalysis.cpp @@ -116,13 +116,13 @@ void WaveShaperAnalysis::paint(juce::Graphics &g) std::ostringstream oss; oss << std::fixed << std::setprecision(2) << sliderDb; - g.setFont(skin->getFont(Fonts::WaveshaperAnalysis::DriveAmount)); + g.setFont(skin->getFont(Fonts::Waveshaper::Preview::DriveAmount)); g.setColour(skin->getColor(Colors::Waveshaper::Preview::Text)); g.drawText(oss.str(), tx, juce::Justification::centred); tx = tx.translated(0, 12); - g.setFont(skin->getFont(Fonts::WaveshaperAnalysis::DriveLabel)); + g.setFont(skin->getFont(Fonts::Waveshaper::Preview::DriveLabel)); g.setColour(skin->getColor(Colors::Waveshaper::Preview::Text)); g.drawText("Drive (dB)", tx, juce::Justification::centred); } @@ -132,7 +132,7 @@ void WaveShaperAnalysis::paint(juce::Graphics &g) title << "Current: " << wst_names[wstype]; g.setColour(skin->getColor(Colors::Waveshaper::Preview::Text)); - g.setFont(skin->getFont(Fonts::WaveshaperAnalysis::Title)); + g.setFont(skin->getFont(Fonts::Waveshaper::Preview::Title)); g.drawText(title.str(), txtr, juce::Justification::centred); } diff --git a/src/surge-xt/gui/widgets/ModulationSourceButton.cpp b/src/surge-xt/gui/widgets/ModulationSourceButton.cpp index 4df810d16b1..974019fdbbc 100644 --- a/src/surge-xt/gui/widgets/ModulationSourceButton.cpp +++ b/src/surge-xt/gui/widgets/ModulationSourceButton.cpp @@ -166,13 +166,11 @@ void ModulationSourceButton::paint(juce::Graphics &g) g.setColour(FillCol); g.fillRect(fillRect); - auto btnFont = Surge::GUI::getFontManager()->getLatoAtSize(8, juce::Font::bold); - if (!isMeta) { // modbutton name settings g.setColour(FontCol); - g.setFont(btnFont); + g.setFont(font); // modbutton name g.drawText(getCurrentModLabel(), getLocalBounds(), juce::Justification::centred); @@ -187,7 +185,7 @@ void ModulationSourceButton::paint(juce::Graphics &g) auto topRect = getLocalBounds().withHeight(splitHeight); g.setColour(FontCol); - g.setFont(btnFont); + g.setFont(font); g.drawText(getCurrentModLabel(), topRect, juce::Justification::centred); // macro slider area diff --git a/src/surge-xt/gui/widgets/ModulationSourceButton.h b/src/surge-xt/gui/widgets/ModulationSourceButton.h index 1949b006ffc..b3430c2ce41 100644 --- a/src/surge-xt/gui/widgets/ModulationSourceButton.h +++ b/src/surge-xt/gui/widgets/ModulationSourceButton.h @@ -141,6 +141,14 @@ struct ModulationSourceButton : public juce::Component, repaint(); } + juce::Font font; + + void setFont(const juce::Font &f) + { + font = f; + repaint(); + } + bool isHovered{false}; void mouseEnter(const juce::MouseEvent &event) override;