Skip to content

Commit

Permalink
Add a "Show/Hide" button in mod area to show overview (surge-synthesi…
Browse files Browse the repository at this point in the history
…zer#4953)

This will allow us int he future to let the context menus set
filters on the overview and still have the global view available

Addresses surge-synthesizer#2049
  • Loading branch information
baconpaul authored Aug 29, 2021
1 parent ab6a6c0 commit a19eaa0
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 8 deletions.
53 changes: 45 additions & 8 deletions src/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,12 +814,12 @@ juce::Rectangle<int> 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");

Expand All @@ -839,17 +839,17 @@ juce::Rectangle<int> 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;
}
Expand All @@ -859,6 +859,25 @@ juce::Rectangle<int> SurgeGUIEditor::positionForModulationGrid(modsources entry)
return r;
}

juce::Rectangle<int> 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<int>();
}

auto r = juce::Rectangle<int>(skinCtrl->x, skinCtrl->y - 1, 22, 16 * 4 + 8).reduced(1);
return r;
}

void SurgeGUIEditor::setDisabledForParameter(Parameter *p,
Surge::Widgets::ModulatableControlInterface *s)
{
Expand Down Expand Up @@ -954,6 +973,12 @@ void SurgeGUIEditor::openOrRecreateEditor()
}
}
}
auto moRect = positionForModOverview();
auto mol = std::make_unique<Surge::Widgets::ModulationOverviewLaunchButton>(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
{
Expand Down Expand Up @@ -4752,6 +4777,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
Expand Down
3 changes: 3 additions & 0 deletions src/gui/SurgeGUIEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,

void closeModulationEditorDialog();
void showModulationEditorDialog();
void toggleModulationEditorDialog();

void closeFormulaEditorDialog();
void showFormulaEditorDialog();
Expand Down Expand Up @@ -423,6 +424,8 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener,

private:
juce::Rectangle<int> positionForModulationGrid(modsources entry);
juce::Rectangle<int> positionForModOverview();
std::unique_ptr<juce::Component> modOverviewLauncher;

int wsx = BASE_WINDOW_SIZE_X;
int wsy = BASE_WINDOW_SIZE_Y;
Expand Down
42 changes: 42 additions & 0 deletions src/gui/widgets/ModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(0, y0, getWidth(), h), juce::Justification::centred);
y0 += h;
}
}

} // namespace Widgets
} // namespace Surge
18 changes: 18 additions & 0 deletions src/gui/widgets/ModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a19eaa0

Please sign in to comment.