Search in sources :

Example 1 with HorizontalFlowGroup

use of com.kotcrab.vis.ui.layout.HorizontalFlowGroup in project Eidolons by IDemiurge.

the class EmitterPalette method init.

public void init() {
    clear();
    setSize(GdxMaster.getWidth() - 300, 256);
    // int columns = (int) (getWidth() / 64);
    defaults().padLeft(200).top().right().width(GdxMaster.getWidth() - 300);
    Map<String, List<File>> presets = new LinkedHashMap<>();
    List<File> subfolders = FileManager.getFilesFromDirectory(PathFinder.getSfxPath(), true);
    subfolders.forEach(file -> {
        if (!file.isDirectory()) {
            MapMaster.addToListMap(presets, "main", file);
        } else
            presets.put(file.getName(), FileManager.getFilesFromDirectory(file.getPath(), false));
    });
    LabelStyle style = StyleHolder.getSizedLabelStyle(FONT.MAIN, 15);
    for (String sub : presets.keySet()) {
        HorizontalFlowGroup table = new HorizontalFlowGroup(0);
        table.setWidth(getWidth() - 100);
        boolean bg = presets.get(sub).size() < 55;
        for (File preset : presets.get(sub)) {
            // textButton?
            ValueContainer label = new ValueContainer(new Label(preset.getName(), style));
            NinePatch patch = NinePatchFactory.getTooltip();
            patch.scale(0.7f, 0.7f);
            if (bg)
                label.setBackground(new NinePatchDrawable(patch));
            label.addListener(new ClickListener() {

                @Override
                public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
                    if (Gdx.input.isKeyPressed(Keys.SHIFT_LEFT)) {
                    // EmitterMaster.
                    }
                    EditorManager.setMode(MAP_EDITOR_MOUSE_MODE.EMITTER);
                    if (selectedLabel != null)
                        selectedLabel.setColor(1, 1, 1, 1);
                    if (sub.equals("main"))
                        selected = preset.getName();
                    else
                        selected = StrPathBuilder.build(sub, preset.getName());
                    selectedLabel = label;
                    label.setColor(1, 0.3f, 0.8f, 1);
                    return super.touchDown(event, x, y, pointer, button);
                }
            });
            table.addActor(label);
        }
        addTab(table, sub);
    }
}
Also used : NinePatch(com.badlogic.gdx.graphics.g2d.NinePatch) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) LabelStyle(com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle) HorizontalFlowGroup(com.kotcrab.vis.ui.layout.HorizontalFlowGroup) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) ValueContainer(eidolons.libgdx.gui.generic.ValueContainer) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) File(java.io.File) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) NinePatchDrawable(com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)

Example 2 with HorizontalFlowGroup

use of com.kotcrab.vis.ui.layout.HorizontalFlowGroup in project Eidolons by IDemiurge.

the class MapResourcesPanel method addResGroup.

private void addResGroup(MAP_RESOURCE[] resourceGroup) {
    HorizontalFlowGroup group = new HorizontalFlowGroup(5);
    group.setWidth(GdxMaster.adjustSize(WIDTH));
    for (MAP_RESOURCE sub : resourceGroup) {
        MapResourcePanel res = new MapResourcePanel(sub);
        group.addActor(res);
        elements.add(res);
    }
    add(group).center();
}
Also used : HorizontalFlowGroup(com.kotcrab.vis.ui.layout.HorizontalFlowGroup)

Aggregations

HorizontalFlowGroup (com.kotcrab.vis.ui.layout.HorizontalFlowGroup)2 NinePatch (com.badlogic.gdx.graphics.g2d.NinePatch)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)1 LabelStyle (com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 NinePatchDrawable (com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable)1 ValueContainer (eidolons.libgdx.gui.generic.ValueContainer)1 File (java.io.File)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1