Skip to content

Commit

Permalink
Start work on header region (#1059)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
baconpaul authored Aug 1, 2024
1 parent 03a75c5 commit 20ded66
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 60 deletions.
2 changes: 1 addition & 1 deletion libs/sst/sst-jucegui
Submodule sst-jucegui updated 57 files
+41 −3 CMakeLists.txt
+2 −2 examples/component-demo/GlyphDemo.h
+50 −15 include/sst/jucegui/components/GlyphPainter.h
+2 −1 include/sst/jucegui/components/ToggleButton.h
+4 −0 res/glyphs/add-mod.svg
+5 −0 res/glyphs/arrow-ltor.svg
+3 −0 res/glyphs/close.svg
+3 −0 res/glyphs/curve.svg
+3 −0 res/glyphs/down.svg
+4 −0 res/glyphs/edit.svg
+5 −0 res/glyphs/ellipsis-h.svg
+5 −0 res/glyphs/ellipsis-v.svg
+3 −0 res/glyphs/favorite.svg
+4 −0 res/glyphs/forward-backward.svg
+3 −0 res/glyphs/freeze.svg
+4 −0 res/glyphs/left-right.svg
+3 −0 res/glyphs/left.svg
+3 −0 res/glyphs/link.svg
+3 −0 res/glyphs/lock.svg
+3 −0 res/glyphs/memory.svg
+3 −0 res/glyphs/midi.svg
+4 −0 res/glyphs/mul-mod.svg
+0 −12 res/glyphs/mute.svg
+5 −0 res/glyphs/note-priority.svg
+3 −0 res/glyphs/pan.svg
+3 −0 res/glyphs/pin.svg
+3 −0 res/glyphs/plus-minus.svg
+3 −0 res/glyphs/plus.svg
+16 −0 res/glyphs/polyphony.svg
+3 −0 res/glyphs/portamento.svg
+4 −0 res/glyphs/power.svg
+3 −0 res/glyphs/reverse.svg
+3 −0 res/glyphs/right.svg
+3 −0 res/glyphs/save.svg
+3 −0 res/glyphs/search.svg
+3 −0 res/glyphs/settings.svg
+3 −0 res/glyphs/shortcircuit-logo.svg
+6 −0 res/glyphs/speaker.svg
+0 −0 res/glyphs/step-count.svg
+3 −0 res/glyphs/surge-logo.svg
+3 −0 res/glyphs/tuning.svg
+3 −0 res/glyphs/unpin.svg
+4 −0 res/glyphs/up-down.svg
+3 −0 res/glyphs/up.svg
+3 −0 res/glyphs/volume.svg
+3 −0 res/waveform-glyphs/waveform-envelope.svg
+3 −0 res/waveform-glyphs/waveform-formula.svg
+6 −0 res/waveform-glyphs/waveform-mseg.svg
+3 −0 res/waveform-glyphs/waveform-noise.svg
+13 −0 res/waveform-glyphs/waveform-sandh.svg
+3 −0 res/waveform-glyphs/waveform-saw.svg
+3 −0 res/waveform-glyphs/waveform-sine.svg
+3 −0 res/waveform-glyphs/waveform-square.svg
+8 −0 res/waveform-glyphs/waveform-step-seq.svg
+3 −0 res/waveform-glyphs/waveform-triangle.svg
+58 −216 src/sst/jucegui/components/GlyphPainter.cpp
+2 −2 src/sst/jucegui/components/ToggleButton.cpp
115 changes: 75 additions & 40 deletions src-ui/components/HeaderRegion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace scxt::ui
{

namespace cmsg = scxt::messaging::client;
namespace jcmp = sst::jucegui::components;

struct spData : sst::jucegui::data::Discrete
{
Expand Down Expand Up @@ -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";
}
Expand All @@ -93,12 +94,60 @@ HeaderRegion::HeaderRegion(SCXTEditor *e) : HasEditor(e)
vuMeter->direction = sst::jucegui::components::VUMeter::HORIZONTAL;
addAndMakeVisible(*vuMeter);

scMenu = std::make_unique<widgets::ShortCircuitMenuButton>();
scMenu = std::make_unique<jcmp::GlyphButton>(jcmp::GlyphPainter::SHORTCIRCUIT_LOGO);
scMenu->setOnCallback([w = juce::Component::SafePointer(this)]() {
if (w)
w->editor->showMainMenu();
});
addAndMakeVisible(*scMenu);

undoButton = std::make_unique<jcmp::TextPushButton>();
undoButton->setLabel("Undo");
addAndMakeVisible(*undoButton);

redoButton = std::make_unique<jcmp::TextPushButton>();
redoButton->setLabel("Redo");
addAndMakeVisible(*redoButton);

tuningButton = std::make_unique<jcmp::TextPushButton>();
tuningButton->setLabel("Tune");
addAndMakeVisible(*tuningButton);

zoomButton = std::make_unique<jcmp::TextPushButton>();
zoomButton->setLabel("Zoom");
addAndMakeVisible(*zoomButton);

chipButton = std::make_unique<jcmp::GlyphButton>(jcmp::GlyphPainter::MEMORY);
addAndMakeVisible(*chipButton);

saveAsButton = std::make_unique<jcmp::GlyphButton>(jcmp::GlyphPainter::SAVE);
addAndMakeVisible(*saveAsButton);

multiMenuButton = std::make_unique<jcmp::MenuButton>();
multiMenuButton->setLabel("This is my Super Awesome Multi");
addAndMakeVisible(*multiMenuButton);

cpuLabel = std::make_unique<jcmp::Label>();
cpuLabel->setText("CPU");
cpuLabel->setJustification(juce::Justification::centredLeft);
addAndMakeVisible(*cpuLabel);

cpuLevel = std::make_unique<jcmp::Label>();
cpuLevel->setText("x%");
cpuLevel->setJustification(juce::Justification::centredRight);
addAndMakeVisible(*cpuLevel);

ramLabel = std::make_unique<jcmp::Label>();
ramLabel->setText("RAM");
ramLabel->setJustification(juce::Justification::centredLeft);
addAndMakeVisible(*ramLabel);

ramLevel = std::make_unique<jcmp::Label>();
ramLevel->setText("xMB");
ramLevel->setJustification(juce::Justification::centredRight);
addAndMakeVisible(*ramLevel);

editor->themeApplier.applyHeaderTheme(this);
}

HeaderRegion::~HeaderRegion()
Expand All @@ -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)
Expand All @@ -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
14 changes: 11 additions & 3 deletions src-ui/components/HeaderRegion.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@

#include <juce_gui_basics/juce_gui_basics.h>
#include <sst/jucegui/components/ToggleButton.h>
#include <sst/jucegui/components/TextPushButton.h>
#include <sst/jucegui/components/MenuButton.h>
#include <sst/jucegui/components/GlyphButton.h>
#include <sst/jucegui/components/Label.h>
#include <sst/jucegui/components/VUMeter.h>
#include <fmt/core.h>

Expand All @@ -46,16 +50,20 @@ struct SCXTEditor;

struct HeaderRegion : juce::Component, HasEditor
{
std::unique_ptr<widgets::ShortCircuitMenuButton> scMenu;
std::unique_ptr<sst::jucegui::components::ToggleButtonRadioGroup> selectedPage;
std::unique_ptr<sst::jucegui::data::Discrete> selectedPageData;
std::unique_ptr<sst::jucegui::components::VUMeter> vuMeter;
std::unique_ptr<sst::jucegui::components::TextPushButton> undoButton, redoButton, tuningButton,
zoomButton;
std::unique_ptr<sst::jucegui::components::Label> cpuLevel, ramLevel;
std::unique_ptr<sst::jucegui::components::Label> cpuLabel, ramLabel;

std::unique_ptr<sst::jucegui::components::GlyphButton> chipButton, saveAsButton, scMenu;
std::unique_ptr<sst::jucegui::components::MenuButton> multiMenuButton;

HeaderRegion(SCXTEditor *);
~HeaderRegion();

void paint(juce::Graphics &g) override;

void resized() override;

uint32_t voiceCount{0};
Expand Down
2 changes: 1 addition & 1 deletion src-ui/components/SCXTEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src-ui/components/mixer/PartEffectsPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ juce::Component *PartEffectsPane::attachToggleToDeactivated(int index)
{
auto res = std::make_unique<jcmp::ToggleButton>();
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];
Expand Down
26 changes: 17 additions & 9 deletions src-ui/components/multi/ModPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@ template <typename GZTrait> 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();
}
Expand All @@ -171,15 +171,23 @@ template <typename GZTrait> 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()
Expand Down Expand Up @@ -279,11 +287,11 @@ template <typename GZTrait> 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;
}
}

Expand Down
6 changes: 3 additions & 3 deletions src-ui/components/multi/ProcessorPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ bool ProcessorPane::layoutControlsFromJSON(const std::string &jsonpath,
auto hpLight =
createWidgetAttachedTo<jcmp::ToggleButton>(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<intEditor_t>(std::move(hpLight));
attachRebuildToDeactivateAttachment(c.index);
Expand Down Expand Up @@ -712,7 +712,7 @@ void ProcessorPane::layoutControlsStringResonator()
auto bounds = getContentAreaComponent()->getLocalBounds();
auto dual = createWidgetAttachedTo<jcmp::ToggleButton>(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<intEditor_t>(std::move(dual));
Expand Down Expand Up @@ -815,7 +815,7 @@ void ProcessorPane::LayoutControlsTremolo()

auto harmonic = createWidgetAttachedTo<jcmp::ToggleButton>(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<intEditor_t>(std::move(harmonic));
Expand Down
2 changes: 1 addition & 1 deletion src-ui/components/multi/ProcessorPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ struct ProcessorPane : sst::jucegui::components::NamedPanel, HasEditor, juce::Dr
namespace jcmp = sst::jucegui::components;
auto res = createWidgetAttachedTo<jcmp::ToggleButton>(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<intEditor_t>(std::move(res));
}
Expand Down
2 changes: 1 addition & 1 deletion src-ui/components/multi/detail/GroupZoneTreeControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ template <typename SidebarParent> struct GroupZoneListBoxModel : juce::ListBoxMo
std::unique_ptr<jcmp::GlyphButton> gBut;
rowAddComponent()
{
gBut = std::make_unique<jcmp::GlyphButton>(jcmp::GlyphPainter::GlyphType::BIG_PLUS);
gBut = std::make_unique<jcmp::GlyphButton>(jcmp::GlyphPainter::GlyphType::PLUS);
addAndMakeVisible(*gBut);
gBut->glyphButtonPad = 3;
gBut->setOnCallback([this]() { gsb->addGroup(); });
Expand Down
43 changes: 43 additions & 0 deletions src-ui/theme/ThemeApplier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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()
Expand All @@ -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);
Expand All @@ -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<ColorMap> &&c, const sheet_t::ptr_t &s)
Expand Down Expand Up @@ -190,6 +209,16 @@ void ThemeApplier::applyGroupMultiScreenTheme(juce::Component *toThis)
map.applyMapTo(toThis);
}

void ThemeApplier::applyHeaderTheme(juce::Component *toThis)
{
jstl::CustomTypeMap map;
map.addCustomClass<jcmp::TextPushButton>(detail::header::TextPushButton);
map.addCustomClass<jcmp::ToggleButton>(detail::header::ToggleButton);
map.addCustomClass<jcmp::MenuButton>(detail::header::MenuButton);
map.addCustomClass<jcmp::GlyphButton>(detail::header::GlyphButton);
map.applyMapTo(toThis);
}

juce::Font ThemeApplier::interMediumFor(int ht)
{
static auto interMed =
Expand Down Expand Up @@ -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
Loading

0 comments on commit 20ded66

Please sign in to comment.