Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macros - Step one of four #1090

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src-ui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ add_library(${PROJECT_NAME} STATIC
components/multi/PartGroupSidebar.cpp
components/multi/ProcessorPane.cpp
components/multi/ProcessorPaneEQsFilters.cpp
components/multi/SingleMacroEditor.cpp

connectors/SCXTResources.cpp
connectors/JSONLayoutConsumer.cpp
Expand Down
4 changes: 4 additions & 0 deletions src-ui/components/SCXTEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,10 @@ struct SCXTEditor : sst::jucegui::components::WindowPanel, juce::DragAndDropCont
allProcessors = v;
}

std::array<std::array<scxt::engine::Macro, scxt::macrosPerPart>, scxt::numParts> macroCache;
void onMacroFullState(const scxt::messaging::client::macroFullState_t &);
void onMacroValue(const scxt::messaging::client::macroValue_t &);

// Originate client to serialization messages
void doSelectionAction(const selection::SelectionManager::ZoneAddress &, bool selecting,
bool distinct, bool asLead);
Expand Down
14 changes: 14 additions & 0 deletions src-ui/components/SCXTEditorResponseHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ void SCXTEditor::onSelectedPart(const int16_t p)
selectedPart = p; // I presume I will shortly get structure messages so don't do anything else
if (multiScreen && multiScreen->parts)
multiScreen->parts->selectedPartChanged();
if (multiScreen && multiScreen->sample)
multiScreen->sample->selectedPartChanged();

repaint();
}
Expand Down Expand Up @@ -330,4 +332,16 @@ void SCXTEditor::onDebugInfoGenerated(const scxt::messaging::client::debugRespon
SCLOG(k << " " << s);
}
}

void SCXTEditor::onMacroFullState(const scxt::messaging::client::macroFullState_t &s)
{
const auto &[part, index, macro] = s;
macroCache[part][index] = macro;
multiScreen->sample->macroDataChanged(part, index);
}

void SCXTEditor::onMacroValue(const scxt::messaging::client::macroValue_t &)
{
SCLOG_WFUNC("Implement");
}
} // namespace scxt::ui
51 changes: 46 additions & 5 deletions src-ui/components/multi/MappingPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include "MappingPane.h"
#include "components/SCXTEditor.h"
#include "components/multi/SingleMacroEditor.h"
#include "datamodel/metadata.h"
#include "selection/selection_manager.h"
#include "sst/jucegui/components/DraggableTextEditableValue.h"
Expand All @@ -38,6 +39,7 @@
#include "sst/jucegui/components/GlyphButton.h"
#include "sst/jucegui/components/TabbedComponent.h"
#include "sst/jucegui/components/Viewport.h"
#include "sst/jucegui/components/Knob.h"
#include "connectors/PayloadDataAttachment.h"
#include "messaging/client/client_serial.h"
#include "messaging/client/client_messages.h"
Expand Down Expand Up @@ -2966,12 +2968,45 @@ void SampleWaveform::updateSamplePlaybackPosition(int64_t samplePos)

struct MacroDisplay : HasEditor, juce::Component
{
MacroDisplay(SCXTEditor *e) : HasEditor(e) {}
void paint(juce::Graphics &g)
std::array<std::unique_ptr<SingleMacroEditor>, scxt::macrosPerPart> macros;
MacroDisplay(SCXTEditor *e) : HasEditor(e)
{
g.setColour(editor->themeColor(theme::ColorMap::warning_1a));
g.setFont(editor->themeApplier.interMediumFor(25));
g.drawText("Macro Region Coming Soon", getLocalBounds(), juce::Justification::centred);
for (int i = 0; i < scxt::macrosPerPart; ++i)
{
macros[i] = std::make_unique<SingleMacroEditor>(editor, editor->selectedPart, i);
addAndMakeVisible(*macros[i]);
// grab whatever data we have
macroDataChanged(editor->selectedPart, i);
}
}
void resized() override
{
auto b = getLocalBounds();
auto dx = b.getWidth() / scxt::macrosPerPart * 2;
auto dy = b.getHeight() / 2;
auto kr = b.withWidth(dx).withHeight(dy).reduced(3);
for (int i = 0; i < scxt::macrosPerPart; ++i)
{
macros[i]->setBounds(kr);
kr = kr.translated(dx, 0);
if (i == scxt::macrosPerPart / 2 - 1)
kr = kr.withX(3).translated(0, dy);
}
}

void selectedPartChanged()
{
for (auto &m : macros)
{
m->changePart(editor->selectedPart);
}
repaint();
}

void macroDataChanged(int part, int index)
{
assert(part == editor->selectedPart);
macros[index]->updateFromEditorData();
}
};

Expand Down Expand Up @@ -3059,4 +3094,10 @@ void MappingPane::updateSamplePlaybackPosition(size_t sampleIndex, int64_t sampl
.waveform->updateSamplePlaybackPosition(samplePos);
}

void MappingPane::selectedPartChanged() { macroDisplay->selectedPartChanged(); }
void MappingPane::macroDataChanged(int part, int index)
{
assert(part == editor->selectedPart);
macroDisplay->macroDataChanged(part, index);
}
} // namespace scxt::ui::multi
2 changes: 2 additions & 0 deletions src-ui/components/multi/MappingPane.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ struct MappingPane : sst::jucegui::components::NamedPanel, HasEditor
void setMappingData(const engine::Zone::ZoneMappingData &);
void setSampleData(const engine::Zone::AssociatedSampleSet &);
void setGroupZoneMappingSummary(const engine::Part::zoneMappingSummary_t &);
void selectedPartChanged();
void macroDataChanged(int part, int index);
void editorSelectionChanged();
void setActive(bool b);

Expand Down
35 changes: 29 additions & 6 deletions src-ui/components/multi/ModPane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,19 +251,32 @@ template <typename GZTrait> struct ModRow : juce::Component, HasEditor
target->setLabel("Target");
curve->setLabel("-");

auto makeSourceName = [](auto &si, auto &sn) {
// This is the second location where we are assuming default macro name
// as mentioned in part.h
auto nm = sn.second;

if (si.gid == 'zmac' || si.gid == 'gmac')
{
auto defname = "Macro " + std::to_string(si.index + 1);
if (nm != defname)
{
nm = "M" + std::to_string(si.index + 1) + ": " + nm;
}
}

return nm;
};

for (const auto &[si, sn] : srcs)
{
if (si == row.source)
{
auto nm = /* sn.first + (sn.first.empty() ? "" : " - ") + */ sn.second;

source->setLabel(nm);
source->setLabel(makeSourceName(si, sn));
}
if (si == row.sourceVia)
{
auto nm = /* sn.first + (sn.first.empty() ? "" : " - ") + */ sn.second;

sourceVia->setLabel(nm);
sourceVia->setLabel(makeSourceName(si, sn));
}
}

Expand Down Expand Up @@ -441,6 +454,16 @@ template <typename GZTrait> struct ModRow : juce::Component, HasEditor
subTicked = true;

auto nm = sn.second;
if (si.gid == 'gmac' || si.gid == 'zmac')
{
// This is where we are assuming default macro name
// from part.h
auto defName = "Macro " + std::to_string(si.index + 1);
if (nm != defName)
{
nm = defName + " (" + nm + ")";
}
}
sub.addItem(nm, true, selected, mkCallback(si));
}

Expand Down
Loading
Loading