PieMenu - circular widgets with selection callback

Any community contributions to libgdx go here! Some may get included in the core API when permission is granted.

PieMenu - circular widgets with selection callback

Postby payne » Tue Nov 19, 2019 4:28 am

PieMenu

This library is mostly to be used for obtaining a circular context menu, but can also be used to just layout Actors in a circular fashion.

In terms of User Interface, circular context menu "are faster and more reliable to select from than linear menus, because selection depends on direction instead of distance." (Wikipedia source). That is the whole motivation behind this library.

Here's a demo-gif:
Image

I've also set up an online demo, for those of you that would rather try it out before trying to integrate it:
https://payne911.github.io/PieMenu/

----------------------------------------------------------------------

The library:
* is very well documented
* offers many out-of-the-box examples with their associated code
* is thoroughly tested
* is OpenSource (MIT)
* and is ready to receive some Pull Requests from the community.

Try it out, and let me know if you have any issues with it. (For the most part, I would recommend adding `Label`, `Stack`, or `Image` as children inside the Menu, but you are not restricted to those.)

Enjoy! :)

----------------------------------------------------------------------

For the more curious of you guys, here is what the code might look like:

Code: Select all
/* Setting up and creating the widget. */
PieMenu.PieMenuStyle style = new PieMenu.PieMenuStyle();
style.sliceColor = new Color(.33f,.33f,.33f,1); // "style" variables affect the way the widget looks
PieMenu menu = new PieMenu(skin.getRegion("white"), style, 80); // "white" would be a 1x1 white pixel

/* Adding a listener. */
menu.addListener(new ChangeListener() {
    @Override
    public void changed(ChangeEvent event, Actor actor) {
        System.out.println("The selected index is: " + menu.getSelectedIndex());
    }
});

/* Populating the widget. */
for (int i = 0; i < 8; i++) {
    Label label = new Label(Integer.toString(i), skin);
    menu.addActor(label);
}

/* Including the Widget in the Stage. */
stage.addActor(menu);
payne
 
Posts: 1
Joined: Tue Nov 19, 2019 4:22 am

Re: PieMenu - circular widgets with selection callback

Postby raeleus » Thu Dec 05, 2019 2:13 pm

That's a pretty awesome web demo. Thanks for sharing! It works very well all around.
Join us on Discord for faster and friendlier service.
Create skins visually with Skin Composer.
JOIN THE libGDX Jam of October 2019!
raeleus
 
Posts: 480
Joined: Wed Aug 07, 2013 10:57 pm

Re: PieMenu - circular widgets with selection callback

Postby slebed » Sat Dec 07, 2019 8:06 pm

Very cool, thanks!
slebed
 
Posts: 227
Joined: Fri Dec 28, 2012 3:29 am


Return to Libgdx Contributions

Who is online

Users browsing this forum: No registered users and 1 guest