Search in sources :

Example 1 with Interpol

use of com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.Interpol in project skin-composer by raeleus.

the class GeneralListeners method interpolationListener.

public static PopTableClickListener interpolationListener(final DialogSceneComposer dialogSceneComposer, InterpolationSelected interpolationSelected) {
    var graphDrawerDrawables = new Array<GraphDrawerDrawable>();
    var table = new Table();
    var scrollPane = new ScrollPane(table, skin, "scene");
    var listener = new PopTableClickListener(skin) {

        {
            getPopTable().key(Keys.ESCAPE, popTable::hide);
        }

        @Override
        public void tableShown(Event event) {
            dialogSceneComposer.getStage().setScrollFocus(scrollPane);
            for (var graphDrawerDrawable : graphDrawerDrawables) {
                graphDrawerDrawable.setColor(Color.BLACK);
            }
        }

        @Override
        public void tableHidden(Event event) {
            for (var graphDrawerDrawable : graphDrawerDrawables) {
                graphDrawerDrawable.setColor(Color.CLEAR);
            }
        }
    };
    var popTable = listener.getPopTable();
    scrollPane.setFadeScrollBars(false);
    popTable.add(scrollPane);
    table.defaults().space(5);
    for (Interpol interpol : Interpol.values()) {
        var button = new Button(skin, "scene-med");
        table.add(button).growX();
        var stack = new Stack();
        button.add(stack).size(50);
        var image = new Image(skin.getDrawable("white"));
        stack.add(image);
        var graphDrawerDrawable = new GraphDrawerDrawable(graphDrawer);
        graphDrawerDrawable.setColor(Color.BLACK);
        graphDrawerDrawable.setInterpolation(interpol.interpolation);
        graphDrawerDrawable.setSamples(10);
        graphDrawerDrawables.add(graphDrawerDrawable);
        image = new Image(graphDrawerDrawable);
        var container = new Container(image);
        container.pad(5).fill();
        stack.add(container);
        var label = new Label(interpol.toString(), skin, "scene-label");
        button.add(label).expandX().left().space(5);
        button.addListener(handListener);
        button.addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                popTable.hide();
                interpolationSelected.selected(interpol);
            }
        });
        table.row();
    }
    dialogSceneComposer.getStage().setScrollFocus(scrollPane);
    return listener;
}
Also used : PopTable(com.ray3k.stripe.PopTable) GraphDrawerDrawable(space.earlygrey.shapedrawer.scene2d.GraphDrawerDrawable) Interpol(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.Interpol) Array(com.badlogic.gdx.utils.Array) PopTableClickListener(com.ray3k.stripe.PopTableClickListener) SimActor(com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Aggregations

ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 Array (com.badlogic.gdx.utils.Array)1 Interpol (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.Interpol)1 SimActor (com.ray3k.skincomposer.dialog.scenecomposer.DialogSceneComposerModel.SimActor)1 PopTable (com.ray3k.stripe.PopTable)1 PopTableClickListener (com.ray3k.stripe.PopTableClickListener)1 GraphDrawerDrawable (space.earlygrey.shapedrawer.scene2d.GraphDrawerDrawable)1