Search in sources :

Example 1 with UIGraphConfiguration

use of com.gempukku.libgdx.graph.ui.UIGraphConfiguration in project gdx-graph by MarcinSc.

the class GraphDesignTab method createPropertyPopupMenu.

private PopupMenu createPropertyPopupMenu(float x, float y) {
    PopupMenu menu = new PopupMenu();
    for (UIGraphConfiguration uiGraphConfiguration : uiGraphConfigurations) {
        for (Map.Entry<String, PropertyBoxProducer> propertyEntry : uiGraphConfiguration.getPropertyBoxProducers().entrySet()) {
            final String name = propertyEntry.getKey();
            final PropertyBoxProducer value = propertyEntry.getValue();
            MenuItem valueMenuItem = new MenuItem(name);
            valueMenuItem.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    PropertyBox defaultPropertyBox = value.createDefaultPropertyBox(skin, type.getPropertyLocations());
                    addPropertyBox(name, defaultPropertyBox);
                }
            });
            menu.addItem(valueMenuItem);
        }
    }
    return menu;
}
Also used : UIGraphConfiguration(com.gempukku.libgdx.graph.ui.UIGraphConfiguration) PropertyBox(com.gempukku.libgdx.graph.ui.graph.property.PropertyBox) Actor(com.badlogic.gdx.scenes.scene2d.Actor) PropertyBoxProducer(com.gempukku.libgdx.graph.ui.graph.property.PropertyBoxProducer) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 2 with UIGraphConfiguration

use of com.gempukku.libgdx.graph.ui.UIGraphConfiguration in project gdx-graph by MarcinSc.

the class GraphDesignTab method createGraphPopupMenu.

private PopupMenu createGraphPopupMenu(final float popupX, final float popupY) {
    PopupMenu popupMenu = new PopupMenu();
    for (UIGraphConfiguration uiGraphConfiguration : uiGraphConfigurations) {
        boolean hasChild = false;
        for (final GraphBoxProducer producer : uiGraphConfiguration.getGraphBoxProducers()) {
            String menuLocation = producer.getMenuLocation();
            if (menuLocation != null) {
                String[] menuSplit = menuLocation.split("/");
                PopupMenu targetMenu = findOrCreatePopupMenu(popupMenu, menuSplit, 0);
                final String title = producer.getName();
                MenuItem valueMenuItem = new MenuItem(title);
                valueMenuItem.addListener(new ChangeListener() {

                    @Override
                    public void changed(ChangeEvent event, Actor actor) {
                        String id = UUID.randomUUID().toString().replace("-", "");
                        GraphBox graphBox = producer.createDefault(skin, id);
                        graphContainer.addGraphBox(graphBox, title, true, popupX, popupY);
                    }
                });
                targetMenu.addItem(valueMenuItem);
                hasChild = true;
            }
        }
        if (hasChild)
            popupMenu.addSeparator();
    }
    MenuItem propertyMenuItem = new MenuItem("Property");
    propertyMenuItem.setDisabled(true);
    popupMenu.addItem(propertyMenuItem);
    if (!propertyBoxes.isEmpty()) {
        PopupMenu propertyMenu = new PopupMenu();
        for (final PropertyBox propertyProducer : propertyBoxes) {
            final String name = propertyProducer.getName();
            MenuItem valueMenuItem = new MenuItem(name);
            valueMenuItem.addListener(new ChangeListener() {

                @Override
                public void changed(ChangeEvent event, Actor actor) {
                    String id = UUID.randomUUID().toString().replace("-", "");
                    GraphBox graphBox = propertyProducer.createPropertyBox(skin, id, popupX, popupY);
                    graphContainer.addGraphBox(graphBox, "Property", true, popupX, popupY);
                }
            });
            propertyMenu.addItem(valueMenuItem);
        }
        propertyMenuItem.setSubMenu(propertyMenu);
        propertyMenuItem.setDisabled(false);
    }
    return popupMenu;
}
Also used : UIGraphConfiguration(com.gempukku.libgdx.graph.ui.UIGraphConfiguration) PropertyBox(com.gempukku.libgdx.graph.ui.graph.property.PropertyBox) GraphBoxProducer(com.gempukku.libgdx.graph.ui.producer.GraphBoxProducer) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 UIGraphConfiguration (com.gempukku.libgdx.graph.ui.UIGraphConfiguration)2 PropertyBox (com.gempukku.libgdx.graph.ui.graph.property.PropertyBox)2 PropertyBoxProducer (com.gempukku.libgdx.graph.ui.graph.property.PropertyBoxProducer)1 GraphBoxProducer (com.gempukku.libgdx.graph.ui.producer.GraphBoxProducer)1