diff --git a/src/gui/SurgeGUIEditor.cpp b/src/gui/SurgeGUIEditor.cpp index 6bac778765b..571fc7ea6f5 100644 --- a/src/gui/SurgeGUIEditor.cpp +++ b/src/gui/SurgeGUIEditor.cpp @@ -814,12 +814,12 @@ juce::Rectangle SurgeGUIEditor::positionForModulationGrid(modsources entry) int gridX = Surge::GUI::ModulationGrid::getModulationGrid()->get(entry).x; int gridY = Surge::GUI::ModulationGrid::getModulationGrid()->get(entry).y; - int width = isMacro ? 93 : 74; + int width = isMacro ? 90 : 72; // to ensure the same gap between the modbuttons, // make the first and last non-macro button wider 2px - if ((!isMacro) && ((gridX == 0) || (gridX == 9))) - width += 2; + // if ((!isMacro) && ((gridX == 0) || (gridX == 9))) + // width += 2; auto skinCtrl = currentSkin->controlForUIID("controls.modulation.panel"); @@ -839,17 +839,17 @@ juce::Rectangle SurgeGUIEditor::positionForModulationGrid(modsources entry) if (isMacro) r = r.withTrimmedBottom(-8); - int offsetX = 1; + int offsetX = 23; for (int i = 0; i < gridX; i++) { - if ((!isMacro) && (i == 0)) - offsetX += 2; + // if ((!isMacro) && (i == 0)) + // offsetX += 2; // gross hack for accumulated 2 px horizontal offsets from the previous if clause // needed to align the last column nicely - if ((!isMacro) && (i == 8)) - offsetX -= 18; + // if ((!isMacro) && (i == 8)) + // offsetX -= 18; offsetX += width; } @@ -859,6 +859,25 @@ juce::Rectangle SurgeGUIEditor::positionForModulationGrid(modsources entry) return r; } +juce::Rectangle SurgeGUIEditor::positionForModOverview() +{ + auto skinCtrl = currentSkin->controlForUIID("controls.modulation.panel"); + + if (!skinCtrl) + { + skinCtrl = currentSkin->getOrCreateControlForConnector( + Surge::Skin::Connector::connectorByID("controls.modulation.panel")); + } + + if (skinCtrl->classname == Surge::GUI::NoneClassName && currentSkin->getVersion() >= 2) + { + return juce::Rectangle(); + } + + auto r = juce::Rectangle(skinCtrl->x, skinCtrl->y - 1, 22, 16 * 4 + 8).reduced(1); + return r; +} + void SurgeGUIEditor::setDisabledForParameter(Parameter *p, Surge::Widgets::ModulatableControlInterface *s) { @@ -954,6 +973,12 @@ void SurgeGUIEditor::openOrRecreateEditor() } } } + auto moRect = positionForModOverview(); + auto mol = std::make_unique(this); + mol->setBounds(moRect); + mol->setSkin(currentSkin); + modOverviewLauncher = std::move(mol); + frame->getModButtonLayer()->addAndMakeVisible(*modOverviewLauncher); // fx vu-meters & labels. This is all a bit hacky still { @@ -4753,6 +4778,18 @@ void SurgeGUIEditor::closeModulationEditorDialog() } } +void SurgeGUIEditor::toggleModulationEditorDialog() +{ + if (isAnyOverlayPresent(MODULATION_EDITOR)) + { + dismissEditorOfType(MODULATION_EDITOR); + } + else + { + showModulationEditorDialog(); + } +} + void SurgeGUIEditor::showFormulaEditorDialog() { // For now, follow the MSEG Sizing diff --git a/src/gui/SurgeGUIEditor.h b/src/gui/SurgeGUIEditor.h index a4db5032e49..3c0f917f9cb 100644 --- a/src/gui/SurgeGUIEditor.h +++ b/src/gui/SurgeGUIEditor.h @@ -390,6 +390,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, void closeModulationEditorDialog(); void showModulationEditorDialog(); + void toggleModulationEditorDialog(); void closeFormulaEditorDialog(); void showFormulaEditorDialog(); @@ -423,6 +424,8 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, private: juce::Rectangle positionForModulationGrid(modsources entry); + juce::Rectangle positionForModOverview(); + std::unique_ptr modOverviewLauncher; int wsx = BASE_WINDOW_SIZE_X; int wsy = BASE_WINDOW_SIZE_Y; diff --git a/src/gui/widgets/ModulationSourceButton.cpp b/src/gui/widgets/ModulationSourceButton.cpp index 3b99071489e..86d49704ef0 100644 --- a/src/gui/widgets/ModulationSourceButton.cpp +++ b/src/gui/widgets/ModulationSourceButton.cpp @@ -469,5 +469,47 @@ void ModulationSourceButton::resized() { hamburgerHome = getLocalBounds().withWidth(11).reduced(2, 2); } + +void ModulationOverviewLaunchButton::buttonClicked(Button *button) +{ + editor->toggleModulationEditorDialog(); + repaint(); +} + +void ModulationOverviewLaunchButton::paintButton(juce::Graphics &g, + bool shouldDrawButtonAsHighlighted, + bool shouldDrawButtonAsDown) +{ + auto FillCol = skin->getColor(Colors::ModSource::Unused::Background); + auto FrameCol = skin->getColor(Colors::ModSource::Unused::Border); + auto FontCol = skin->getColor(Colors::ModSource::Unused::Text); + if (shouldDrawButtonAsHighlighted || shouldDrawButtonAsDown) + { + FrameCol = skin->getColor(Colors::ModSource::Unused::BorderHover); + FontCol = skin->getColor(Colors::ModSource::Unused::TextHover); + } + g.fillAll(FillCol); + g.setColour(FrameCol); + g.drawRect(getLocalBounds(), 1); + + std::string msg = "Show"; + if (editor->isAnyOverlayPresent(SurgeGUIEditor::MODULATION_EDITOR)) + { + msg = "Hide"; + } + auto f = Surge::GUI::getFontManager()->displayFont; + auto h = f.getHeight() * 0.9f; + auto sh = h * msg.length(); + auto y0 = (getHeight() - sh) / 2.f; + g.setFont(f); + g.setColour(FontCol); + for (auto c : msg) + { + auto s = std::string("") + c; + g.drawText(s, juce::Rectangle(0, y0, getWidth(), h), juce::Justification::centred); + y0 += h; + } +} + } // namespace Widgets } // namespace Surge \ No newline at end of file diff --git a/src/gui/widgets/ModulationSourceButton.h b/src/gui/widgets/ModulationSourceButton.h index 8fed2547d10..5f211fb537c 100644 --- a/src/gui/widgets/ModulationSourceButton.h +++ b/src/gui/widgets/ModulationSourceButton.h @@ -168,6 +168,24 @@ struct ModulationSourceButton : public juce::Component, JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationSourceButton); }; + +struct ModulationOverviewLaunchButton : public juce::Button, + juce::Button::Listener, + Surge::GUI::SkinConsumingComponent +{ + ModulationOverviewLaunchButton(SurgeGUIEditor *ed) : juce::Button("modov"), editor(ed) + { + addListener(this); + } + + void paintButton(juce::Graphics &g, bool shouldDrawButtonAsHighlighted, + bool shouldDrawButtonAsDown) override; + + void buttonClicked(Button *button) override; + + SurgeGUIEditor *editor; + JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ModulationOverviewLaunchButton); +}; } // namespace Widgets } // namespace Surge #endif // SURGE_XT_MODULATIONSOURCEBUTTON_H