Skip to content

Commit

Permalink
hookup group poly checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Oct 24, 2024
1 parent 3603616 commit 1b19165
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src-ui/app/SCXTEditorDataCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <functional>

#include "engine/bus.h"
#include "engine/part.h"
Expand Down Expand Up @@ -64,9 +66,19 @@ struct SCXTEditorDataCache
void fireSubscription(void *el, sst::jucegui::data::Continuous *);
void fireSubscription(void *el, sst::jucegui::data::Discrete *);

void addNotificationCallback(void *el, std::function<void()>);
template <typename P> void fireAllNotificationsFor(const P &p)
{
auto st = &p;
auto end = &p + sizeof(P);
fireAllNotificationsBetween((void *)st, (void *)end);
}

private:
void fireAllNotificationsBetween(void *st, void *end);
std::unordered_map<void *, std::unordered_set<sst::jucegui::data::Continuous *>> csubs;
std::unordered_map<void *, std::unordered_set<sst::jucegui::data::Discrete *>> dsubs;
std::unordered_map<void *, std::vector<std::function<void()>>> fsubs;

struct CListener : sst::jucegui::data::Continuous::DataListener
{
Expand Down
13 changes: 12 additions & 1 deletion src-ui/app/edit-screen/components/GroupSettingsCard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ GroupSettingsCard::GroupSettingsCard(SCXTEditor *e)
: HasEditor(e), info(e->editorDataCache.groupOutputInfo)
{
using fac = connectors::SingleValueFactory<attachment_t, floatMsg_t>;
editor->editorDataCache.addNotificationCallback(&info,
[w = juce::Component::SafePointer(this)]() {
if (w)
w->rebuildFromInfo();
});

auto mkg = [this](auto gl) {
auto res = std::make_unique<jcmp::GlyphPainter>(gl);
Expand All @@ -61,7 +66,11 @@ GroupSettingsCard::GroupSettingsCard(SCXTEditor *e)
outputGlyph = mkg(jcmp::GlyphPainter::GlyphType::SPEAKER);
outputMenu = mkm("PART", "Output");
polyGlygh = mkg(jcmp::GlyphPainter::GlyphType::POLYPHONY);
polyMenu = mkm("PART", "Polyphony");
polyMenu = std::make_unique<jcmp::TextPushButton>();
polyMenu->setLabel("PART");
polyMenu->setOnCallback([w = juce::Component::SafePointer(this)]() { SCLOG("POLY MENU"); });
addAndMakeVisible(*polyMenu);

prioGlyph = mkg(jcmp::GlyphPainter::GlyphType::NOTE_PRIORITY);
prioMenu = mkm("LAST", "Priority");
glideGlpyh = mkg(jcmp::GlyphPainter::GlyphType::CURVE);
Expand Down Expand Up @@ -123,4 +132,6 @@ void GroupSettingsCard::resized()
ospair(tuneGlyph, tuneDrag);
}

void GroupSettingsCard::rebuildFromInfo() { SCLOG("Rebuild from Info"); }

} // namespace scxt::ui::app::edit_screen
7 changes: 5 additions & 2 deletions src-ui/app/edit-screen/components/GroupSettingsCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "sst/jucegui/components/DraggableTextEditableValue.h"
#include "sst/jucegui/components/Label.h"
#include "sst/jucegui/components/GlyphButton.h"
#include "sst/jucegui/components/TextPushButton.h"

#include "messaging/messaging.h"
#include "connectors/PayloadDataAttachment.h"
Expand All @@ -47,12 +48,14 @@ struct GroupSettingsCard : juce::Component, HasEditor
GroupSettingsCard(SCXTEditor *e);
void paint(juce::Graphics &g) override;
void resized() override;
void rebuildFromInfo();

std::unique_ptr<sst::jucegui::components::GlyphPainter> midiGlyph, outputGlyph, polyGlygh,
prioGlyph, glideGlpyh, volGlyph, panGlyph, tuneGlyph;
std::unique_ptr<sst::jucegui::components::Label> pbLabel, SRCLabel;
std::unique_ptr<sst::jucegui::components::MenuButton> midiMenu, outputMenu, polyMenu, prioMenu,
glideMenu, srcMenu;
std::unique_ptr<sst::jucegui::components::TextPushButton> polyMenu;
std::unique_ptr<sst::jucegui::components::MenuButton> midiMenu, outputMenu, prioMenu, glideMenu,
srcMenu;
std::unique_ptr<sst::jucegui::components::DraggableTextEditableValue> pbDnVal, pbUpDrag,
glideDrag, volDrag, panDrag, tuneDrag;

Expand Down
41 changes: 41 additions & 0 deletions src-ui/app/editor-impl/SCXTEditorDataCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,45 @@ void SCXTEditorDataCache::DListener::sourceVanished(sst::jucegui::data::Discrete
}
}

void SCXTEditorDataCache::addNotificationCallback(void *el, std::function<void()> f)
{
fsubs[el].push_back(f);
}

void SCXTEditorDataCache::fireAllNotificationsBetween(void *st, void *end)
{
for (auto &[da, ds] : fsubs)
{
if (da >= st && da <= end)
{
for (auto &d : ds)
{
d();
}
}
}

for (auto &[da, ds] : dsubs)
{
if (da >= st && da <= end)
{
for (auto &d : ds)
{
d->setValueFromModel(*((int *)da));
}
}
}

for (auto &[da, ds] : csubs)
{
if (da >= st && da <= end)
{
for (auto &d : ds)
{
d->setValueFromModel(*((float *)da));
}
}
}
}

} // namespace scxt::ui::app
2 changes: 2 additions & 0 deletions src-ui/app/editor-impl/SCXTEditorResponseHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ void SCXTEditor::onZoneOutputInfoUpdated(const scxt::messaging::client::zoneOutp
{
auto [active, inf] = p;
editorDataCache.zoneOutputInfo = inf;
editorDataCache.fireAllNotificationsFor(editorDataCache.zoneOutputInfo);
editScreen->getZoneElements()->outPane->setActive(active);
if (active)
{
Expand All @@ -215,6 +216,7 @@ void SCXTEditor::onGroupOutputInfoUpdated(const scxt::messaging::client::groupOu
{
auto [active, inf] = p;
editorDataCache.groupOutputInfo = inf;
editorDataCache.fireAllNotificationsFor(editorDataCache.groupOutputInfo);
editScreen->getGroupElements()->outPane->setActive(active);
if (active)
{
Expand Down

0 comments on commit 1b19165

Please sign in to comment.