From 03b75f729fdc74f5301478475bb86c5b125e935a Mon Sep 17 00:00:00 2001 From: Paul Walker Date: Tue, 20 Apr 2021 21:33:46 -0400 Subject: [PATCH] First example of a juce::PopupMenu in SGE 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 --- src/common/gui/SurgeGUIEditor.cpp | 40 +++++++++++-------------------- 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/src/common/gui/SurgeGUIEditor.cpp b/src/common/gui/SurgeGUIEditor.cpp index e1aa87dda49..131d2f63630 100644 --- a/src/common/gui/SurgeGUIEditor.cpp +++ b/src/common/gui/SurgeGUIEditor.cpp @@ -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; }