Skip to content

Commit

Permalink
Add a Variant tab/body RMB which doesn't do anything yet
Browse files Browse the repository at this point in the history
but this way we can get to work on issues like #1238 and
  • Loading branch information
baconpaul committed Sep 17, 2024
1 parent eb9a079 commit bbdd01f
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libs/sst/sst-jucegui
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,11 @@ void SampleWaveform::rebuildEnvelopePaths()

void SampleWaveform::mouseDown(const juce::MouseEvent &e)
{
if (e.mods.isPopupMenu() && onPopupMenu)
{
onPopupMenu();
return;
}
auto posi = e.position.roundToInt();
if (startSampleHZ.contains(posi))
mouseState = MouseState::HZ_DRAG_SAMPSTART;
Expand Down Expand Up @@ -353,6 +358,10 @@ void SampleWaveform::mouseDrag(const juce::MouseEvent &e)

void SampleWaveform::mouseUp(const juce::MouseEvent &e)
{
if (e.mods.isPopupMenu() && onPopupMenu)
{
return;
}
if (mouseState != MouseState::NONE)
display->onSamplePointChangedFromGUI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ struct SampleWaveform : juce::Component, HasEditor, sst::jucegui::components::Zo
repaint();
}

std::function<void()> onPopupMenu{nullptr};

float vStart{0.f}, vZoom{1.f};
void setVerticalZoom(float ps, float zf) override
{
Expand Down
43 changes: 41 additions & 2 deletions src-ui/app/edit-screen/components/mapping-pane/VariantDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,19 @@ VariantDisplay::VariantDisplay(scxt::ui::app::edit_screen::MacroMappingVariantPa
: HasEditor(p->editor), variantView(p->sampleView), parentPane(p)
{
waveformsTabbedGroup = std::make_unique<MyTabbedComponent>(this);
waveformsTabbedGroup->onTabPopupMenu = [w = juce::Component::SafePointer(this)](auto id) {
if (w)
w->showVariantTabMenu(id);
};
addAndMakeVisible(*waveformsTabbedGroup);
for (auto i = 0; i < maxVariantsPerZone; ++i)
{
waveforms[i].waveformViewport =
std::make_unique<jcmp::ZoomContainer>(std::make_unique<SampleWaveform>(this));
auto wf = std::make_unique<SampleWaveform>(this);
wf->onPopupMenu = [i, w = juce::Component::SafePointer(this)]() {
if (w)
w->showVariantTabMenu(i);
};
waveforms[i].waveformViewport = std::make_unique<jcmp::ZoomContainer>(std::move(wf));
waveforms[i].waveformViewport->setVZoomFloor(1.0 / 16.0);

waveforms[i].waveform = static_cast<SampleWaveform *>(
Expand Down Expand Up @@ -936,4 +944,35 @@ void VariantDisplay::FileInfos::paint(juce::Graphics &g)
g.drawText(msg, bx.reduced(margin, 0), juce::Justification::centred);
}

void VariantDisplay::showVariantTabMenu(int variantIdx)
{
auto numVariants{0};
for (auto i = 0; i < maxVariantsPerZone; ++i)
{
if (variantView.variants[i].active)
{
numVariants++;
}
}
bool isPlus = variantIdx >= numVariants;

juce::PopupMenu p;
if (isPlus)
{
p.addSectionHeader("Add Variant");
p.addSeparator();
;
p.addItem("Copy From", editor->makeComingSoon("Copy From"));
p.addItem("Sample", editor->makeComingSoon("Sample"));
}
else
{
p.addSectionHeader("Variant " + std::to_string(variantIdx + 1));
p.addSeparator();
;
p.addItem("Copy", editor->makeComingSoon("Copy Variant"));
p.addItem("Delete", editor->makeComingSoon("Delete Variant"));
}
p.showMenuAsync(editor->defaultPopupMenuOptions());
}
} // namespace scxt::ui::app::edit_screen
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ struct VariantDisplay : juce::Component, HasEditor
void showVariantPlaymodeMenu();
void showSRCMenu();

void showVariantTabMenu(int variantIdx);

// Header section
using boolToggle_t = sst::jucegui::component_adapters::DiscreteToValueReference<
sst::jucegui::components::ToggleButton, bool>;
Expand Down

0 comments on commit bbdd01f

Please sign in to comment.