From d44dec06527d5d0329b613457eb47bceda35d138 Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Thu, 1 Aug 2024 16:17:12 -0400 Subject: [PATCH] Start work on header region None of it does anything yet, but work some on the layout and so forth, and also upgrade jucegui with the correct icons for most things. --- libs/sst/sst-jucegui | 2 +- src-ui/components/HeaderRegion.cpp | 115 ++++++++++++------ src-ui/components/HeaderRegion.h | 14 ++- src-ui/components/SCXTEditor.h | 2 +- src-ui/components/mixer/PartEffectsPane.cpp | 2 +- src-ui/components/multi/ModPane.cpp | 26 ++-- src-ui/components/multi/ProcessorPane.cpp | 6 +- src-ui/components/multi/ProcessorPane.h | 2 +- .../multi/detail/GroupZoneTreeControl.h | 2 +- src-ui/theme/ThemeApplier.cpp | 43 +++++++ src-ui/theme/ThemeApplier.h | 1 + 11 files changed, 155 insertions(+), 60 deletions(-) diff --git a/libs/sst/sst-jucegui b/libs/sst/sst-jucegui index 3e5c20ff..fd58c831 160000 --- a/libs/sst/sst-jucegui +++ b/libs/sst/sst-jucegui @@ -1 +1 @@ -Subproject commit 3e5c20ff8f77613a9971169c9d4c1be1e8b516e6 +Subproject commit fd58c8315918a6b36f21657b94dc907cb9e5dfe1 diff --git a/src-ui/components/HeaderRegion.cpp b/src-ui/components/HeaderRegion.cpp index c1cd984c..250b46f1 100644 --- a/src-ui/components/HeaderRegion.cpp +++ b/src-ui/components/HeaderRegion.cpp @@ -36,6 +36,7 @@ namespace scxt::ui { namespace cmsg = scxt::messaging::client; +namespace jcmp = sst::jucegui::components; struct spData : sst::jucegui::data::Discrete { @@ -67,9 +68,9 @@ struct spData : sst::jucegui::data::Discrete switch ((SCXTEditor::ActiveScreen)i) { case SCXTEditor::MULTI: - return "MULTI"; + return "EDIT"; case SCXTEditor::MIXER: - return "MIXER"; + return "MIX"; case SCXTEditor::PLAY: return "PLAY"; } @@ -93,12 +94,60 @@ HeaderRegion::HeaderRegion(SCXTEditor *e) : HasEditor(e) vuMeter->direction = sst::jucegui::components::VUMeter::HORIZONTAL; addAndMakeVisible(*vuMeter); - scMenu = std::make_unique(); + scMenu = std::make_unique(jcmp::GlyphPainter::SHORTCIRCUIT_LOGO); scMenu->setOnCallback([w = juce::Component::SafePointer(this)]() { if (w) w->editor->showMainMenu(); }); addAndMakeVisible(*scMenu); + + undoButton = std::make_unique(); + undoButton->setLabel("Undo"); + addAndMakeVisible(*undoButton); + + redoButton = std::make_unique(); + redoButton->setLabel("Redo"); + addAndMakeVisible(*redoButton); + + tuningButton = std::make_unique(); + tuningButton->setLabel("Tune"); + addAndMakeVisible(*tuningButton); + + zoomButton = std::make_unique(); + zoomButton->setLabel("Zoom"); + addAndMakeVisible(*zoomButton); + + chipButton = std::make_unique(jcmp::GlyphPainter::MEMORY); + addAndMakeVisible(*chipButton); + + saveAsButton = std::make_unique(jcmp::GlyphPainter::SAVE); + addAndMakeVisible(*saveAsButton); + + multiMenuButton = std::make_unique(); + multiMenuButton->setLabel("This is my Super Awesome Multi"); + addAndMakeVisible(*multiMenuButton); + + cpuLabel = std::make_unique(); + cpuLabel->setText("CPU"); + cpuLabel->setJustification(juce::Justification::centredLeft); + addAndMakeVisible(*cpuLabel); + + cpuLevel = std::make_unique(); + cpuLevel->setText("x%"); + cpuLevel->setJustification(juce::Justification::centredRight); + addAndMakeVisible(*cpuLevel); + + ramLabel = std::make_unique(); + ramLabel->setText("RAM"); + ramLabel->setJustification(juce::Justification::centredLeft); + addAndMakeVisible(*ramLabel); + + ramLevel = std::make_unique(); + ramLevel->setText("xMB"); + ramLevel->setJustification(juce::Justification::centredRight); + addAndMakeVisible(*ramLevel); + + editor->themeApplier.applyHeaderTheme(this); } HeaderRegion::~HeaderRegion() @@ -109,9 +158,29 @@ HeaderRegion::~HeaderRegion() void HeaderRegion::resized() { - selectedPage->setBounds(4, 4, 170, getHeight() - 8); - scMenu->setBounds(getWidth() - getHeight() - 8, 4, getHeight() - 8, getHeight() - 8); - vuMeter->setBounds(getWidth() - getHeight() - 8 - 140, 4, 135, getHeight() - 8); + auto b = getBounds().reduced(6); + selectedPage->setBounds(b.withWidth(196)); + + undoButton->setBounds(b.withTrimmedLeft(246).withWidth(48)); + redoButton->setBounds(b.withTrimmedLeft(246 + 50).withWidth(48)); + + tuningButton->setBounds(b.withTrimmedLeft(823).withWidth(48)); + zoomButton->setBounds(b.withTrimmedLeft(823 + 50).withWidth(48)); + + chipButton->setBounds(b.withTrimmedLeft(393).withWidth(24)); + saveAsButton->setBounds(b.withTrimmedLeft(755).withWidth(24)); + + multiMenuButton->setBounds(b.withTrimmedLeft(421).withWidth(330)); + + scMenu->setBounds(b.withTrimmedLeft(1148).withWidth(24)); + + cpuLabel->setBounds(b.withTrimmedLeft(979).withWidth(20).withHeight(12)); + ramLabel->setBounds(b.withTrimmedLeft(979).withWidth(20).withHeight(12).translated(0, 12)); + + cpuLevel->setBounds(b.withTrimmedLeft(1002).withWidth(35).withHeight(12)); + ramLevel->setBounds(b.withTrimmedLeft(1002).withWidth(35).withHeight(12).translated(0, 12)); + + vuMeter->setBounds(b.withTrimmedLeft(1048).withWidth(96)); } void HeaderRegion::setVULevel(float L, float R) @@ -133,38 +202,4 @@ void HeaderRegion::setVULevel(float L, float R) } } -void HeaderRegion::paint(juce::Graphics &g) - -{ -#if DEBUG_VOICE_COUNT - auto vc = fmt::format("Voices: {}", voiceCount); - g.setColour(juce::Colours::white); - g.drawText(vc, getLocalBounds().reduced(3, 1), juce::Justification::centred); -#endif - -#if MAC - g.setFont(juce::Font("Comic Sans MS", 18, juce::Font::plain)); - - auto vc = fmt::format("Dbg: {:.2f} Mb, Pos {:.2f} @ {} in {}/{}", memUsageInMegabytes, - (double)editor->sharedUiMemoryState.transportDisplay.hostpos, - (double)editor->sharedUiMemoryState.transportDisplay.tempo, - (int)editor->sharedUiMemoryState.transportDisplay.tsnum, - (int)editor->sharedUiMemoryState.transportDisplay.tsden); - g.setColour(juce::Colours::white); - g.drawText(vc, getLocalBounds().reduced(3, 1), juce::Justification::centred); -#endif - - return; -#if BUILD_IS_DEBUG - g.fillAll(juce::Colours::red); - g.setColour(juce::Colours::pink.contrasting()); - g.setFont(juce::Font("Comic Sans MS", 14, juce::Font::plain)); - g.drawText("DEBUG DEBUG DEBUG", getLocalBounds(), juce::Justification::centred); -#else - g.fillAll(juce::Colours::pink); - g.setColour(juce::Colours::pink.contrasting()); - g.setFont(juce::Font("Comic Sans MS", 14, juce::Font::plain)); - g.drawText("header", getLocalBounds(), juce::Justification::centred); -#endif -} } // namespace scxt::ui \ No newline at end of file diff --git a/src-ui/components/HeaderRegion.h b/src-ui/components/HeaderRegion.h index d97697cf..4aceb6d6 100644 --- a/src-ui/components/HeaderRegion.h +++ b/src-ui/components/HeaderRegion.h @@ -30,6 +30,10 @@ #include #include +#include +#include +#include +#include #include #include @@ -46,16 +50,20 @@ struct SCXTEditor; struct HeaderRegion : juce::Component, HasEditor { - std::unique_ptr scMenu; std::unique_ptr selectedPage; std::unique_ptr selectedPageData; std::unique_ptr vuMeter; + std::unique_ptr undoButton, redoButton, tuningButton, + zoomButton; + std::unique_ptr cpuLevel, ramLevel; + std::unique_ptr cpuLabel, ramLabel; + + std::unique_ptr chipButton, saveAsButton, scMenu; + std::unique_ptr multiMenuButton; HeaderRegion(SCXTEditor *); ~HeaderRegion(); - void paint(juce::Graphics &g) override; - void resized() override; uint32_t voiceCount{0}; diff --git a/src-ui/components/SCXTEditor.h b/src-ui/components/SCXTEditor.h index f0c58771..9e71e258 100644 --- a/src-ui/components/SCXTEditor.h +++ b/src-ui/components/SCXTEditor.h @@ -136,9 +136,9 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont enum ActiveScreen { + PLAY, MULTI, MIXER, - PLAY } activeScreen{MULTI}; void setActiveScreen(ActiveScreen s); void showAboutOverlay(); diff --git a/src-ui/components/mixer/PartEffectsPane.cpp b/src-ui/components/mixer/PartEffectsPane.cpp index 96ab3708..11feab46 100644 --- a/src-ui/components/mixer/PartEffectsPane.cpp +++ b/src-ui/components/mixer/PartEffectsPane.cpp @@ -258,7 +258,7 @@ juce::Component *PartEffectsPane::attachToggleToDeactivated(int index) { auto res = std::make_unique(); res->drawMode = sst::jucegui::components::ToggleButton::DrawMode::GLYPH; - res->setGlyph(jcmp::GlyphPainter::GlyphType::POWER_LIGHT); + res->setGlyph(jcmp::GlyphPainter::GlyphType::SMALL_POWER_LIGHT); auto &data = mixer->busEffectsData[busAddress][fxSlot]; auto &pmd = data.first[index]; diff --git a/src-ui/components/multi/ModPane.cpp b/src-ui/components/multi/ModPane.cpp index 77b1d0d1..b7436d75 100644 --- a/src-ui/components/multi/ModPane.cpp +++ b/src-ui/components/multi/ModPane.cpp @@ -150,10 +150,10 @@ template struct ModRow : juce::Component, HasEditor addAndMakeVisible(*r); return r; }; - x1 = mg(jcmp::GlyphPainter::CROSS); - x2 = mg(jcmp::GlyphPainter::CROSS); + x1 = mg(jcmp::GlyphPainter::CLOSE); + x2 = mg(jcmp::GlyphPainter::CLOSE); a1 = mg(jcmp::GlyphPainter::ARROW_L_TO_R); - a2 = mg(jcmp::GlyphPainter::ARROW_L_TO_R); + a2 = mg(jcmp::GlyphPainter::MODULATION_ADDITIVE); refreshRow(); } @@ -171,15 +171,23 @@ template struct ModRow : juce::Component, HasEditor b = b.translated(sz + 2, 0); }; + auto sqr = [&b](const auto &wd, auto sz) { + auto bx = b.withWidth(sz); + if (bx.getHeight() > sz) + bx = bx.reduced(0, (b.getHeight() - sz) * 0.5f); + wd->setBounds(bx); + b = b.translated(sz + 2, 0); + }; + map(power, b.getHeight()); map(source, 90); - map(x1, 6); + sqr(x1, 12); map(sourceVia, 90); - map(x2, 6); + sqr(x2, 12); map(depth, 120, 2); - map(a1, 10); + sqr(a1, 12); map(curve, 60); - map(a2, 10); + sqr(a2, 12); map(target, getWidth() - b.getX()); } void refreshRow() @@ -279,11 +287,11 @@ template struct ModRow : juce::Component, HasEditor { if (GZTrait::isMultiplicative(*(row.target))) { - a2->glyph = sst::jucegui::components::GlyphPainter::ARROW_L_TO_R_WITH_MUL; + a2->glyph = sst::jucegui::components::GlyphPainter::MODULATION_MULTIPLICATIVE; } else { - a2->glyph = sst::jucegui::components::GlyphPainter::ARROW_L_TO_R; + a2->glyph = sst::jucegui::components::GlyphPainter::MODULATION_ADDITIVE; } } diff --git a/src-ui/components/multi/ProcessorPane.cpp b/src-ui/components/multi/ProcessorPane.cpp index 7697f682..18251512 100644 --- a/src-ui/components/multi/ProcessorPane.cpp +++ b/src-ui/components/multi/ProcessorPane.cpp @@ -575,7 +575,7 @@ bool ProcessorPane::layoutControlsFromJSON(const std::string &jsonpath, auto hpLight = createWidgetAttachedTo(deactivateAttachments[c.index]); hpLight->setDrawMode(jcmp::ToggleButton::DrawMode::GLYPH); - hpLight->setGlyph(jcmp::GlyphPainter::POWER_LIGHT); + hpLight->setGlyph(jcmp::GlyphPainter::SMALL_POWER_LIGHT); hpLight->setBounds(elo.powerButtonPositionFor(nm)); floatDeactivateEditors[c.index] = std::make_unique(std::move(hpLight)); attachRebuildToDeactivateAttachment(c.index); @@ -712,7 +712,7 @@ void ProcessorPane::layoutControlsStringResonator() auto bounds = getContentAreaComponent()->getLocalBounds(); auto dual = createWidgetAttachedTo(intAttachments[1]); dual->setDrawMode(jcmp::ToggleButton::DrawMode::GLYPH); - dual->setGlyph(jcmp::GlyphPainter::POWER_LIGHT); + dual->setGlyph(jcmp::GlyphPainter::SMALL_POWER_LIGHT); auto dualBounds = bounds.withLeft(1).withRight(11).withTop(63).withBottom(74); dual->setBounds(dualBounds); intEditors[1] = std::make_unique(std::move(dual)); @@ -815,7 +815,7 @@ void ProcessorPane::LayoutControlsTremolo() auto harmonic = createWidgetAttachedTo(intAttachments[0]); harmonic->setDrawMode(jcmp::ToggleButton::DrawMode::GLYPH); - harmonic->setGlyph(jcmp::GlyphPainter::POWER_LIGHT); + harmonic->setGlyph(jcmp::GlyphPainter::SMALL_POWER_LIGHT); auto plusBounds = bounds.withLeft(148).withRight(160).withTop(0).withBottom(12); harmonic->setBounds(plusBounds); intEditors[0] = std::make_unique(std::move(harmonic)); diff --git a/src-ui/components/multi/ProcessorPane.h b/src-ui/components/multi/ProcessorPane.h index 32482975..b5e861bb 100644 --- a/src-ui/components/multi/ProcessorPane.h +++ b/src-ui/components/multi/ProcessorPane.h @@ -244,7 +244,7 @@ struct ProcessorPane : sst::jucegui::components::NamedPanel, HasEditor, juce::Dr namespace jcmp = sst::jucegui::components; auto res = createWidgetAttachedTo(at); res->setDrawMode(jcmp::ToggleButton::DrawMode::GLYPH); - res->setGlyph(jcmp::GlyphPainter::POWER_LIGHT); + res->setGlyph(jcmp::GlyphPainter::SMALL_POWER_LIGHT); res->setBounds(elo.powerButtonPositionFor(lotag)); return std::make_unique(std::move(res)); } diff --git a/src-ui/components/multi/detail/GroupZoneTreeControl.h b/src-ui/components/multi/detail/GroupZoneTreeControl.h index c444f8a5..1ec4380b 100644 --- a/src-ui/components/multi/detail/GroupZoneTreeControl.h +++ b/src-ui/components/multi/detail/GroupZoneTreeControl.h @@ -321,7 +321,7 @@ template struct GroupZoneListBoxModel : juce::ListBoxMo std::unique_ptr gBut; rowAddComponent() { - gBut = std::make_unique(jcmp::GlyphPainter::GlyphType::BIG_PLUS); + gBut = std::make_unique(jcmp::GlyphPainter::GlyphType::PLUS); addAndMakeVisible(*gBut); gBut->glyphButtonPad = 3; gBut->setOnCallback([this]() { gsb->addGroup(); }); diff --git a/src-ui/theme/ThemeApplier.cpp b/src-ui/theme/ThemeApplier.cpp index 5d27ccbd..b483528a 100644 --- a/src-ui/theme/ThemeApplier.cpp +++ b/src-ui/theme/ThemeApplier.cpp @@ -37,6 +37,8 @@ #include "sst/jucegui/components/ToolTip.h" #include "sst/jucegui/components/ToggleButton.h" #include "sst/jucegui/components/JogUpDownButton.h" +#include "sst/jucegui/components/TextPushButton.h" +#include "sst/jucegui/components/GlyphButton.h" #include "sst/jucegui/components/MenuButton.h" #include "sst/jucegui/components/VUMeter.h" #include "sst/jucegui/components/ScrollBar.h" @@ -122,6 +124,21 @@ void init() } // namespace group } // namespace multi +namespace header +{ +static constexpr sheet_t::Class TextPushButton{"header.textbutton"}; +static constexpr sheet_t::Class ToggleButton{"header.togglebutton"}; +static constexpr sheet_t::Class MenuButton{"header.menubutton"}; +static constexpr sheet_t::Class GlyphButton{"header.menubutton"}; +void applyColors(const sheet_t::ptr_t &, const ColorMap &); +void init() +{ + sheet_t::addClass(TextPushButton).withBaseClass(jcmp::TextPushButton::Styles::styleClass); + sheet_t::addClass(ToggleButton).withBaseClass(jcmp::ToggleButton::Styles::styleClass); + sheet_t::addClass(MenuButton).withBaseClass(jcmp::MenuButton::Styles::styleClass); + sheet_t::addClass(GlyphButton).withBaseClass(jcmp::GlyphButton::Styles::styleClass); +} +} // namespace header } // namespace detail ThemeApplier::ThemeApplier() @@ -133,6 +150,7 @@ ThemeApplier::ThemeApplier() detail::multi::init(); detail::multi::zone::init(); detail::multi::group::init(); + detail::header::init(); detailInitialized = true; } colors = ColorMap::createColorMap(ColorMap::WIREFRAME); @@ -144,6 +162,7 @@ void ThemeApplier::recolorStylesheet(const sst::jucegui::style::StyleSheet::ptr_ detail::multi::applyColors(s, *colors); detail::multi::zone::applyColors(s, *colors); detail::multi::group::applyColors(s, *colors); + detail::header::applyColors(s, *colors); } void ThemeApplier::recolorStylesheetWith(std::unique_ptr &&c, const sheet_t::ptr_t &s) @@ -190,6 +209,16 @@ void ThemeApplier::applyGroupMultiScreenTheme(juce::Component *toThis) map.applyMapTo(toThis); } +void ThemeApplier::applyHeaderTheme(juce::Component *toThis) +{ + jstl::CustomTypeMap map; + map.addCustomClass(detail::header::TextPushButton); + map.addCustomClass(detail::header::ToggleButton); + map.addCustomClass(detail::header::MenuButton); + map.addCustomClass(detail::header::GlyphButton); + map.applyMapTo(toThis); +} + juce::Font ThemeApplier::interMediumFor(int ht) { static auto interMed = @@ -411,5 +440,19 @@ void applyColors(const sheet_t::ptr_t &base, const ColorMap &cols) } } // namespace group } // namespace multi +namespace header +{ +void applyColors(const sheet_t::ptr_t &base, const ColorMap &cols) +{ + base->setColour(TextPushButton, jcmp::TextPushButton::Styles::fill, cols.get(ColorMap::bg_2)); + base->setColour(TextPushButton, jcmp::TextPushButton::Styles::fill_hover, + cols.get(ColorMap::bg_3)); + base->setColour(ToggleButton, jcmp::ToggleButton::Styles::fill, cols.get(ColorMap::bg_2)); + base->setColour(ToggleButton, jcmp::ToggleButton::Styles::fill_hover, cols.get(ColorMap::bg_3)); + base->setColour(MenuButton, jcmp::MenuButton::Styles::fill, cols.get(ColorMap::bg_2)); + base->setColour(GlyphButton, jcmp::GlyphButton::Styles::fill, cols.get(ColorMap::bg_2)); + base->setColour(GlyphButton, jcmp::GlyphButton::Styles::fill_hover, cols.get(ColorMap::bg_3)); +} +} // namespace header } // namespace detail } // namespace scxt::ui::theme \ No newline at end of file diff --git a/src-ui/theme/ThemeApplier.h b/src-ui/theme/ThemeApplier.h index e5cdd462..c8f50787 100644 --- a/src-ui/theme/ThemeApplier.h +++ b/src-ui/theme/ThemeApplier.h @@ -52,6 +52,7 @@ struct ThemeApplier void applyGroupMultiScreenModulationTheme(juce::Component *toThis); void applyMixerEffectTheme(juce::Component *toThis); void applyMixerChannelTheme(juce::Component *toThis); + void applyHeaderTheme(juce::Component *toThis); const std::unique_ptr &colorMap() { return colors; }