Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace COptionMenu with juce::PopupMenu #4341

Closed
3 tasks done
baconpaul opened this issue Apr 21, 2021 · 1 comment · Fixed by #4673
Closed
3 tasks done

Replace COptionMenu with juce::PopupMenu #4341

baconpaul opened this issue Apr 21, 2021 · 1 comment · Fixed by #4673
Labels
Code Refactoring General code refactoring and cleanup issues like names, unused variables, warnings, fixme Rebuild With JUCE Issues pertaining to porting Surge from VSTGUI to JUCE
Milestone

Comments

@baconpaul
Copy link
Collaborator

baconpaul commented Apr 21, 2021

The juce API is more robust. Over the summer go through and replace the escape_from_vstgui COptionMenu with juce::PopupMenu. This issue tracks the menus we have to do as checklists

  • Scene copy paste (so we have a worked example)
  • The param RMB
  • All the rest
@baconpaul baconpaul added the Rebuild With JUCE Issues pertaining to porting Surge from VSTGUI to JUCE label Apr 21, 2021
@baconpaul baconpaul added this to the Surge XT 1.0 milestone Apr 21, 2021
baconpaul added a commit to baconpaul/surge that referenced this issue Apr 21, 2021
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 surge-synthesizer#4341
baconpaul added a commit that referenced this issue Apr 21, 2021
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
@mkruselj mkruselj added the Code Refactoring General code refactoring and cleanup issues like names, unused variables, warnings, fixme label May 6, 2021
@baconpaul
Copy link
Collaborator Author

Alright so here is a short guide for 'how to replace a COptionMenu with a juce::PopupMenu'
This assumes that you aren't doing any funny business (like custom renderers or anything)
Also you mostly have to do an all-or-nothing on a menu so tackling SGE could be work

but basically VSTGUI looks like

auto a = new COptionMenu()
auto b = new CCOmmandMenuItem(); b.setCallback([](){}); a->addItem(b)

that second part we often wrap in a little lambda called 'addCallbackFunction'. Then we have to forget things at the right time, add them to the frame, and force a show.

With juce popup menus we don't actually have to do most of that. A simple juce popup menu example would be

auto contextMenu = juce::PopupMenu();
contextMenu.addItem("Say Hi", []() { std::cout << "Hi" << std::endl; });
contextMenu.addItem("Say Bye", []() { std::cout << "Bye" << std::endl; });
contextMenu.addSeparator();
contextMenu.addItem( "Say Why", []() {std::out << "Why" << std::endl; });

contextMenu.showMenuAsync(juce::PopupMenu::Options());

and that will show the 3 element menu.

The full documentation is https://docs.juce.com/master/classPopupMenu.html but you will see things like multiple instances of addItem. For instance addItem( "Whatzit", false, true, [](){} ); will be not enabled (first bool) and ticked (second).

Adding a submenu is similarly easy. You use addSubMenu( String, PopupMenu ) method. So something like this

auto contextMenu = juce::PopupMenu();

auto hiBye = juce::PopupMenu();
hiBye.addItem("Say Hi", []() { std::cout << "Hi" << std::endl; });
hiBye.addItem("Say Bye", []() { std::cout << "Bye" << std::endl; });
contextMenu.addSubMenu("HiBye", hiBye);
contextMenu.addItem( "Say Why", []() {std::out << "Why" << std::endl; });

contextMenu.showMenuAsync(juce::PopupMenu::Options());

which would give you

HiBye >
    Say Hi
    Say Bye
SayWhy

Right now JUCE menus can't put checkmarks on parent submenus. If you come across a case where you have to do that put a FIXME in the code and I'll fix it once I have that fixed. I know how to fix it and it is easy enough change (basically just a quick subclass).

As a first try I would recommend making the OSC copy and paste menu (around line 1930 of SGE) and convert that. Then try a few of the MSEGs. Once we have it down we can push through and get the rest of them.

mkruselj added a commit that referenced this issue May 19, 2021
mkruselj added a commit to mkruselj/surge that referenced this issue May 20, 2021
mkruselj added a commit that referenced this issue May 20, 2021
mkruselj added a commit to mkruselj/surge that referenced this issue May 20, 2021
Also unbloat the on/off switches in MSEG editor context menu while at it
Addresses surge-synthesizer#4341
mkruselj added a commit that referenced this issue May 20, 2021
Also unbloat the on/off switches in MSEG editor context menu while at it
Addresses #4341
mkruselj added a commit to mkruselj/surge that referenced this issue May 23, 2021
mkruselj added a commit that referenced this issue May 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Refactoring General code refactoring and cleanup issues like names, unused variables, warnings, fixme Rebuild With JUCE Issues pertaining to porting Surge from VSTGUI to JUCE
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants