Code Monkey home page Code Monkey logo

piemenu's Introduction

Pie Menu logo

PieMenu

JitPack Latest Release Version License GitHub All Releases Downloads Lines of code


A library to obtain a circular WidgetGroup within libGDX, an open-source game development application framework written in Java.

It aims at providing users with the so-called RadialGroup: a simple container that places its children Actors in a circular fashion.

The more interesting feature might be the PieMenu class : it wraps the RadialGroup with a bunch of functionalities that allow assigning callback functions to listeners on the highlight and selection of items within the Group.

In terms of User Interface, circular context menus "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.

Table of Content


Demo

First, let us demonstrate what you might be able to get out of this library (those are just examples and the variety of possiblities is much larger, if not endless).

Basic widgets

An online demo is available.

early_demo

The trickier controls are:

  • RIGHT-CLICK : opens a PieMenu meant for selection through dragging (don't release the right-click until you're done with your selection). It was configured to let you preview the selection's effect.
  • MIDDLE-CLICK : opens a PieMenu meant for "normal" selection. You can release the button and select as you wish with a left-click.

If you want to check out the same demo, but within a desktop setup, check out the Demonstration class.

Custom-animated widgets

You can also create your own animations:

custom_animation

It's surprisingly easy. Check out the Animated Widget wiki page to find out!


Including in your project

To use this in your gradle project, add the version number and jitpack repository information to your root build.gradle file:

allprojects {

    ext {
        ...
        pieMenuVersion = '5.0.0'  // add this line
    }
    
    repositories {
        ...
        maven { url 'https://jitpack.io' }  // add this line if it isn't there
    }
}

And in your core project (still inside the root build.gradle) add the dependency:

project(":core") {
    apply plugin: "java-library"

    dependencies {
        ...
        api "com.github.payne911:PieMenu:$pieMenuVersion"  // add this line
    }
}

See the jitpack website for more info.

If you plan on releasing your project with an html ("HTML5/GWT") or android module, check out the Wiki page on integration.


Usage

The basic idea looks like this:

/* 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. */
final int PIE_SLICES = 8;
for (int i = 0; i < PIE_SLICES; i++) {
    Label label = new Label(Integer.toString(i), skin);
    menu.addActor(label);
}

/* Including the widget in the Stage. */
stage.addActor(menu);

And voilà!

This library offers you many types of behaviors related to pie-menus. Many of those are well-documented in the Wiki (with description, code and gif), so make sure to check it out.

More specifically, you might be interested in:

Configuration infographic


Final word

Very well: you've made it this far in the README! If you ever end up integrating this library into your cool projects, feel free to send a Pull Request of a GIF showcasing this library and with the name of your game; just make sure it's pushed in the media/games folder!

Games showcases

Here are a few GIFs of games that have integrated this library.

Crawl Tactics, by icefill

CT

Hadal Calm, by donpommelo

HC

lurkers.io, by bergice

L

Contributing

If you feel like helping this library grow, make sure to check out the Contributing Wiki page.

Thanks to

For their sustained help through the libGDX Discord channel. Their extensive knowledge was greatly appreciated.

Credits

I used some images from Game-Icons.net, more specifically the 5 icons displayed when clicking the "Toggle Radial" button. To be even more specific, the credits go to Lorc. Those are under the CC BY 3.0 license.

Also, raeleus made the background image for the "middle-click menu" (which is also used in this library's logo), and the test application uses the Plain James UI Skin created by Raymond "Raeleus" Buckley under the CC BY 4.0 license. Check out the others!

The structure and build scripts of this repository were strongly inspired by RafaSKB's typing-label library.

Parts of this README were lazily copied and adapted from EarlyGrey's library (with his agreement). Cheers!

piemenu's People

Contributors

deadlocklogic avatar donpommelo avatar payne911 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

piemenu's Issues

onHighlightChange is not called in GWT

PieMenu version 4.2.0 doesn't fire the onHighlightChange callback in GWT. I tested this on libGDX version 1.9.10, 1.9.11 as well as 1.9.12-SNAPSHOT. It works as expected in Desktop (LWJGL3)

I used the code in the ClickDrag example for testing it out.

I also tested it on PieMenu version 4.1.0 which worked as expected in both GWT as well as LWJGL3

Support multi-selection

The current PieMenu implementation only supports the selection of a single index.

What about when a user would want to use a pie menu for allowing multiple selection at once?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.