Skip to content

Commit

Permalink
First example of a juce::PopupMenu in SGE (#4343)
Browse files Browse the repository at this point in the history
Really want to go to the superior juce::PopupMenu API even though
the escape stuff kinda works. Debugging escape vs rewriting the
menus - better to fix th emenus.

So this shows a first example - the scene copy / paste is now entirely
native juce::PopupMenu

Addresses #4341
  • Loading branch information
baconpaul authored Apr 21, 2021
1 parent 2e3703c commit 2f26a3b
Showing 1 changed file with 14 additions and 26 deletions.
40 changes: 14 additions & 26 deletions src/common/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,44 +2374,32 @@ int32_t SurgeGUIEditor::controlModifierClicked(CControl *control, CButtonState b

menuRect.offset(where.x, where.y);

COptionMenu *contextMenu =
new COptionMenu(menuRect, 0, 0, 0, 0, VSTGUI::COptionMenu::kNoDrawStyle);
int eid = 0;
auto contextMenu = juce::PopupMenu();

char txt[256];
auto hu = helpURLForSpecial("scene-select");
char txt[TXT_SIZE];
if (hu != "")
{
snprintf(txt, TXT_SIZE, "[?] Scene %c", 'A' + a);
auto lurl = fullyResolvedHelpURL(hu);
addCallbackMenu(contextMenu, txt,
[lurl]() { Surge::UserInteractions::openURL(lurl); });
eid++;
contextMenu.addItem(txt, [lurl]() { Surge::UserInteractions::openURL(lurl); });
}
else
{
snprintf(txt, TXT_SIZE, "Scene %c", 'A' + a);
contextMenu->addEntry(txt, eid++);
}

contextMenu->addSeparator(eid++);

addCallbackMenu(contextMenu, "Copy",
[this, a]() { synth->storage.clipboard_copy(cp_scene, a, -1); });
eid++;
if (synth->storage.get_clipboard_type() == cp_scene)
{
addCallbackMenu(contextMenu, "Paste", [this, a]() {
synth->storage.clipboard_paste(cp_scene, a, -1);
queue_refresh = true;
});
eid++;
contextMenu.addItem(txt, []() {});
}
contextMenu.addSeparator();
contextMenu.addItem("Copy",
[this, a]() { synth->storage.clipboard_copy(cp_scene, a, -1); });
contextMenu.addItem("Paste",
synth->storage.get_clipboard_type() == cp_scene, // enabled
false, [this, a]() {
synth->storage.clipboard_paste(cp_scene, a, -1);
queue_refresh = true;
});

frame->addView(contextMenu); // add to frame
contextMenu->setDirty();
contextMenu->popup();
frame->removeView(contextMenu, true); // remove from frame and forget
contextMenu.showMenuAsync(juce::PopupMenu::Options());

return 1;
}
Expand Down

0 comments on commit 2f26a3b

Please sign in to comment.