Example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFlickScroll

List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFlickScroll

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d.ui ScrollPane setFlickScroll.

Prototype

public void setFlickScroll(boolean flickScroll) 

Source Link

Usage

From source file:de.longri.cachebox3.develop.tools.skin_editor.ColorPickerDialog.java

License:Apache License

/**
 *
 *//*from w  w w.  ja va  2s  .  c  o  m*/
public ColorPickerDialog(final SkinEditorGame game, final Field field) {

    super("Color Picker", game.skin);

    this.game = game;
    this.field = field;

    tableColors = new Table(game.skin);
    tableColors.left().top().pad(5);
    tableColors.defaults().pad(5);
    colors = game.skinProject.getAll(SkinColor.class);

    updateTable();

    TextButton buttonNewColor = new TextButton("New Color", game.skin);
    buttonNewColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            // Need to steal focus first with this hack (Thanks to Z-Man)
            Frame frame = new Frame();
            frame.setUndecorated(true);
            frame.setOpacity(0);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
            frame.setVisible(false);
            frame.dispose();

            // Call swing color picker
            java.awt.Color color = JColorChooser.showDialog(null, "Pick your color", java.awt.Color.WHITE);
            if (color != null) {

                String colorName = JOptionPane.showInputDialog("Name your color");

                if ((colorName != null) && (colorName.isEmpty() == false)) {
                    // Verify if the color name is already in use
                    if (colors.containsKey(colorName) == true) {
                        game.showMsgDlg("Error", "Color name already in use!", game.screenMain.stage);
                    } else {
                        // Add the color (asuming RGBA)
                        float[] components = color.getComponents(null);
                        SkinColor newColor = new SkinColor(components[0], components[1], components[2],
                                components[3]);
                        newColor.skinName = colorName;
                        colors.put(colorName, newColor);
                        game.screenMain.saveToSkin();

                        // update table
                        updateTable();
                    }
                }
            }

        }

    });

    TextButton buttonNoColor = new TextButton("Empty Color", game.skin);
    buttonNoColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            try {
                field.set(game.screenMain.paneOptions.currentStyle, null);
            } catch (Exception e) {
                e.printStackTrace();
            }

            game.screenMain.saveToSkin();

            hide();
            game.screenMain.panePreview.refresh();
            game.screenMain.paneOptions.updateSelectedTableFields();

        }

    });

    ScrollPane scrollPane = new ScrollPane(tableColors, game.skin);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollbarsOnTop(true);

    getContentTable().add(scrollPane).width(540).height(320).pad(20);
    getButtonTable().add(buttonNewColor);
    if (field != null) {
        getButtonTable().add(buttonNoColor);
    }
    getButtonTable().padBottom(15);
    button("Cancel", false);
    key(com.badlogic.gdx.Input.Keys.ESCAPE, false);

}

From source file:de.longri.cachebox3.develop.tools.skin_editor.FontPickerDialog.java

License:Apache License

/**
 * /*from  ww  w  .  jav a 2s  .  c  o m*/
 */
public FontPickerDialog(final SkinEditorGame game, Field field) {

    super("Bitmap Font Picker", game.skin);

    this.game = game;
    this.field = field;

    tableFonts = new Table(game.skin);
    tableFonts.left().top().pad(5);
    tableFonts.defaults().pad(5);

    fonts = game.skinProject.getAll(BitmapFont.class);

    updateTable();

    TextButton buttonNewFont = new TextButton("New Font", game.skin);
    buttonNewFont.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            showNewFontDialog();

        }

    });

    ScrollPane scrollPane = new ScrollPane(tableFonts, game.skin);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollbarsOnTop(true);

    getContentTable().add(scrollPane).width(720).height(420).pad(20);
    getButtonTable().add(buttonNewFont);
    getButtonTable().padBottom(15);
    button("Cancel", false);
    key(com.badlogic.gdx.Input.Keys.ESCAPE, false);

}

From source file:mobi.shad.s3lib.gui.GuiResource.java

License:Apache License

/**
 * @param widget/*from   ww  w.j av  a 2s . com*/
 * @param name
 * @return
 */
public static ScrollPane flickScrollPane(Actor widget, String name) {
    if (S3Constans.INFO) {
        S3Log.log(TAG, "Create FlickScrollPane: " + name);
    }
    ScrollPane scrollPane = new ScrollPane(widget);
    scrollPane.setFlickScroll(true);
    scrollPane.setName(name);
    return scrollPane;
}

From source file:mobi.shad.s3lib.gui.GuiResource.java

License:Apache License

/**
 * @param region/*from   ww w . j av  a2 s . c  o m*/
 * @param name
 * @return
 */
public static ScrollPane flickScrollPane(TextureRegion region, String name) {
    if (S3Constans.INFO) {
        S3Log.log(TAG, "Create FlickScrollPane: " + name);
    }
    ScrollPane scrollPane = new ScrollPane(new Image(region));
    scrollPane.setFlickScroll(true);
    scrollPane.setName(name);
    return scrollPane;
}

From source file:mobi.shad.s3lib.gui.widget.ScrollBoxImageButton.java

License:Apache License

/**
 * @return//  ww  w  .j  a  v a  2s .co m
 */
public Table getTable() {

    Gui gui = new Gui();
    buttonAct = new Vector<Button>();

    gui.row();
    int j = 0;
    boolean newRow = false;
    for (int i = 0; i < items.size(); i++) {
        newRow = false;
        if (j > buttonX) {
            newRow = true;
            j = 0;
        }
        Button addImgButton = gui.addImgButton(items.get(i), this, "buttonIdx", i, newRow, 1, true, buttonSize,
                "btn" + this.toString(), localChangeListener);
        if (i == value) {
            addImgButton.setChecked(true);
        }
        buttonAct.add(i, addImgButton);
        j++;
    }

    Table table = gui.getTable();
    ScrollPane scrollPane = GuiResource.scrollPane(table, "scroll");
    scrollPane.setFadeScrollBars(true);
    scrollPane.setClamp(true);
    scrollPane.setFlickScroll(true);

    scrollPane.setScrollingDisabled(true, false);

    window = GuiResource.table("window");
    window.row();
    window.add(scrollPane).width(width).height(height);
    window.row();

    return window;
}

From source file:mobi.shad.s3lib.gui.widget.ScrollImageButton.java

License:Apache License

/**
 * //from w  w w .  java  2 s  .co  m
 * @return 
 */
public Table getTable() {

    Gui gui = new Gui();
    buttonAct = new Vector<Button>();

    gui.row();
    for (int i = 0; i < items.size(); i++) {
        Button addImgButton = gui.addImgButton(items.get(i), this, "buttonIdx", i, vertical, 1, true,
                buttonSize, "btn" + this.toString(), changeListener);
        if (i == value) {
            addImgButton.setChecked(true);
        }
        buttonAct.add(i, addImgButton);
    }
    if (!vertical) {
        gui.row();
        gui.addLabel("", true, items.size());
    }

    Table table = gui.getTable();
    table.row();
    table.add(" ").colspan(items.size());

    ScrollPane scrollPane = GuiResource.scrollPane(table, "scroll");
    scrollPane.setFadeScrollBars(true);
    scrollPane.setClamp(true);
    scrollPane.setFlickScroll(true);

    if (!vertical) {
        scrollPane.setScrollingDisabled(false, true);
    } else {
        scrollPane.setScrollingDisabled(true, false);
    }

    window = GuiResource.table("window");
    window.row();
    window.add(scrollPane);
    window.row();

    return window;
}

From source file:net.mwplay.cocostudio.ui.parser.group.CCScrollView.java

License:Apache License

@Override
public Actor parse(CocoStudioUIEditor editor, ObjectData widget) {
    ScrollPaneStyle style = new ScrollPaneStyle();

    if (widget.getFileData() != null) {

        style.background = editor.findDrawable(widget, widget.getFileData());
    }//from ww w .ja  v a  2s  .  com

    ScrollPane scrollPane = new ScrollPane(null, style);

    if ("Vertical_Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, true);
    } else if ("Horizontal".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(true, false);
    } else if ("Vertical".equals(widget.getScrollDirectionType())) {
        scrollPane.setForceScroll(false, true);
    }

    scrollPane.setClamp(widget.isClipAble());
    scrollPane.setFlickScroll(widget.isIsBounceEnabled());

    Table table = new Table();
    table.setSize(widget.getInnerNodeSize().getWidth(), widget.getInnerNodeSize().getHeight());

    if (widget.getComboBoxIndex() == 0) {// 

    } else if (widget.getComboBoxIndex() == 1) {// ?

        Pixmap pixmap = new Pixmap((int) table.getWidth(), (int) table.getHeight(), Format.RGBA8888);
        Color color = editor.getColor(widget.getSingleColor(), widget.getBackColorAlpha());

        pixmap.setColor(color);

        pixmap.fill();

        Drawable drawable = new TextureRegionDrawable(new TextureRegion(new Texture(pixmap)));

        table.setBackground(drawable);
        pixmap.dispose();

    }
    scrollPane.setWidget(table);
    return scrollPane;
}

From source file:org.gearvrf.widgetViewer.MyGdxWidget.java

License:Apache License

@SuppressWarnings("unchecked")
public void create() {
    mStage = new Stage();
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    Gdx.input.setInputProcessor(mStage);
    mContainer = new Table();
    mStage.addActor(mContainer);/*  www .  j  a v  a  2s .c o  m*/
    mContainer.setFillParent(true);
    Table table = new Table();
    final ScrollPane scroll = new ScrollPane(table, skin);

    InputListener stopTouchDown = new InputListener() {
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            event.stop();
            return false;
        }
    };

    table.pad(0).defaults().expandX().space(10);
    for (int i = 0; i < 4; i++) {
        table.row();
        table.add(new Label("", skin)).expandX().fillX();
        TextButton button = null;
        if (i == 0) {
            button = new TextButton("  Next  ", skin);
            button.getLabel().setFontScale(mFontScale);
            mNextButton = button;
            button.addListener(new ClickListener() {
                public void clicked(InputEvent event, float x, float y) {
                    System.out.println("click " + x + ", " + y);

                    mMain.ThumbnailSelected = (mMain.ThumbnailSelected + 1) % 5;
                    mNextButton.setChecked(false);
                }
            });
        } else if (i == 1) {
            button = new TextButton("Previous", skin);
            button.getLabel().setFontScale(mFontScale);
            mPreviousButton = button;
            button.addListener(new ClickListener() {
                public void clicked(InputEvent event, float x, float y) {
                    System.out.println("click " + x + ", " + y);
                    mMain.ThumbnailSelected = (mMain.ThumbnailSelected + 4) % 5;
                    mPreviousButton.setChecked(false);
                }
            });
        } else if (i == 2) {

            BitmapFont f = skin.getFont("default-font");
            f.getData().setScale(mFontScale - 1.0f);
            SelectBoxStyle style = new SelectBoxStyle(f, Color.WHITE, skin.getDrawable("default-select"),
                    skin.get(ScrollPaneStyle.class), skin.get(ListStyle.class));

            final SelectBox selectBox = new SelectBox(style);
            selectBox.addListener(new ChangeListener() {
                public void changed(ChangeEvent event, Actor actor) {
                    mMain.mTexColor = selectBox.getSelectedIndex() + 1;
                }
            });
            selectBox.setItems("Maroon", "Black", "Blue", "Green", "Silver");

            selectBox.setSelected("Maroon");
            selectBox.setVisible(false);
            selectBox.setName("colorbutton");

            table.add(selectBox).height(120.0f).width(600.0f);

        } else {
            final CheckBox box = new CheckBox("Reset", skin);
            mCheckBox = box;
            box.setChecked(true);
            box.addListener(new ChangeListener() {
                public void changed(ChangeEvent event, Actor actor) {
                    ((Slider) xSlider).setValue(0.0f);
                    mResetSlider = box.isChecked();
                }
            });
            box.getLabel().setFontScale(mFontScale);
            box.getCells().get(0).size(80.0f, 80.0f);
            table.add(box);
        }

        table.add(button).height(120).width(450);

        Slider slider = null;
        if (i < 3) {
            slider = new Slider(0, 100, 1, false, skin);
            if (i == 0) {
                slider.setName("X");
                slider.setVisible(false);
            }
            if (i == 1) {
                slider.setName("Y");
                slider.setVisible(false);
            }
            if (i == 2) {
                slider.setName("Z");
                slider.setVisible(false);
            }
            ;
            slider.addListener(stopTouchDown); // Stops touchDown events
                                               // from propagating to the
                                               // FlickScrollPane.
            if (i == 0) {
                Label l = new Label("Rotate X", skin);
                table.add(l);
                l.setVisible(false);
            }
            if (i == 1) {
                Label l = new Label("Rotate Y", skin);
                l.setVisible(false);
                table.add(l);
            }
            if (i == 2) {
                Label l2 = new Label("Rotate Z", skin);
                table.add(l2);
                l2.setVisible(false);
            }
            table.add(slider).height(120).width(500);
        }

    }

    table.row();
    table.add(new Label("", skin)).expandX().fillX();
    TextButton button = new TextButton("Look Inside", skin);
    button.getLabel().setFontScale(mFontScale);
    mLookInsideButton = button;
    button.addListener(new ClickListener() {
        public void clicked(InputEvent event, float x, float y) {

            mMain.mLookInside = true;
            mLookInsideButton.setChecked(false);
            mLookInsideButton.toggle();
        }
    });
    button.setVisible(false);
    button.setName("lookinsidebutton");
    table.add(button).height(120).width(450);
    table.row();

    Slider slider = null;

    slider = new Slider(0, 100, 1, false, skin);
    slider.setName("Zoom");
    slider.addListener(stopTouchDown);
    Label zoom = new Label("  Zoom  ", skin);
    zoom.setFontScale(mFontScale);
    table.pad(10).add(zoom);
    table.add(slider).height(150.0f).width(800);
    final TextButton flickButton = new TextButton("Flick Scroll", skin.get("toggle", TextButtonStyle.class));
    flickButton.setChecked(true);
    flickButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setFlickScroll(flickButton.isChecked());
        }
    });
    final TextButton fadeButton = new TextButton("Fade Scrollbars", skin.get("toggle", TextButtonStyle.class));
    fadeButton.setChecked(true);
    fadeButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setFadeScrollBars(fadeButton.isChecked());
        }
    });
    final TextButton smoothButton = new TextButton("Smooth Scrolling",
            skin.get("toggle", TextButtonStyle.class));
    smoothButton.setChecked(true);
    smoothButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setSmoothScrolling(smoothButton.isChecked());
        }
    });
    final TextButton onTopButton = new TextButton("Scrollbars On Top",
            skin.get("toggle", TextButtonStyle.class));
    onTopButton.addListener(new ChangeListener() {
        public void changed(ChangeEvent event, Actor actor) {
            scroll.setScrollbarsOnTop(onTopButton.isChecked());
        }
    });
    mContainer.add(scroll).expand().fill().colspan(4);
    mContainer.row().space(10).padBottom(10);

}

From source file:org.shadebob.skineditor.actors.OptionsPane.java

License:Apache License

/**
 * //w  w  w.j  a v a  2  s .  co m
 */
public OptionsPane(final SkinEditorGame game) {
    super();

    this.game = game;

    left();
    top();
    setBackground(game.skin.getDrawable("default-pane"));

    add(new Label("Styles", game.skin, "title")).pad(5).row();
    listStyles = new List<String>(game.skin, "dimmed");
    listStyles.setItems(listItems);
    ScrollPane scroll = new ScrollPane(listStyles, game.skin);
    scroll.setFlickScroll(false);
    scroll.setFadeScrollBars(false);
    scroll.setScrollbarsOnTop(true);
    scroll.setScrollBarPositions(false, true);
    scroll.setScrollingDisabled(true, false);
    add(scroll).height(200).expandX().fillX().pad(5).row();

    // Add buttons
    Table tableStylesButtons = new Table();
    TextButton buttonNewStyle = new TextButton("New Style", game.skin);
    TextButton buttonDeleteStyle = new TextButton("Delete Style", game.skin);
    tableStylesButtons.add(buttonNewStyle).pad(5);
    tableStylesButtons.add(buttonDeleteStyle).pad(5);
    add(tableStylesButtons).row();

    // Callbacks

    listStyles.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            String key = (String) listStyles.getSelected();
            if (key != null) {
                Gdx.app.log("OptionsPane", "Selected style: " + key);
                currentStyle = styles.get(key);
                updateTableFields(key);
            }
        }

    });

    buttonNewStyle.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            createNewStyle();
        }

    });

    buttonDeleteStyle.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            showDeleteDialog();
        }

    });

    // Initialize table

    add(new Label("Fields", game.skin, "title")).pad(5).padTop(10).row();

    tableFields = new Table(game.skin);
    tableFields.setBackground(game.skin.getDrawable("dialogDim"));
    tableFields.left().top();

    ScrollPane scroll2 = new ScrollPane(tableFields, game.skin);
    scroll2.setFlickScroll(false);
    scroll2.setFadeScrollBars(false);
    scroll2.setScrollbarsOnTop(true);
    scroll2.setScrollBarPositions(false, true);
    scroll2.setScrollingDisabled(true, false);
    add(scroll2).pad(5).expand().fill();

}

From source file:org.shadebob.skineditor.ColorPickerDialog.java

License:Apache License

/**
 * //from  w w w  .  java2s.co m
 */
public ColorPickerDialog(final SkinEditorGame game, final Field field) {

    super("Color Picker", game.skin);

    this.game = game;
    this.field = field;

    tableColors = new Table(game.skin);
    tableColors.left().top().pad(5);
    tableColors.defaults().pad(5);
    colors = game.skinProject.getAll(Color.class);

    updateTable();

    TextButton buttonNewColor = new TextButton("New Color", game.skin);
    buttonNewColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            // Need to steal focus first with this hack (Thanks to Z-Man)
            Frame frame = new Frame();
            frame.setUndecorated(true);
            // TODO fix falls frame.setOpacity(0);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
            frame.toFront();
            frame.setVisible(false);
            frame.dispose();

            // Call swing color picker
            java.awt.Color color = JColorChooser.showDialog(null, "Pick your color", java.awt.Color.WHITE);
            if (color != null) {

                String colorName = JOptionPane.showInputDialog("Name your color");

                if ((colorName != null) && (colorName.isEmpty() == false)) {
                    // Verify if the color name is already in use
                    if (colors.containsKey(colorName) == true) {
                        game.showNotice("Error", "Color name already in use!", game.screenMain.stage);
                    } else {
                        // Add the color (asuming RGBA)
                        float[] components = color.getComponents(null);
                        Color newColor = new Color(components[0], components[1], components[2], components[3]);
                        if (isColorInUse(newColor)) {
                            game.showNotice("Error",
                                    "Same color value (" + newColor.toString()
                                            + ") is already defined with a different name!",
                                    game.screenMain.stage);
                            return;
                        }

                        colors.put(colorName, newColor);
                        game.screenMain.saveToSkin();

                        // update table
                        updateTable();
                    }
                }
            }

        }

    });

    TextButton buttonNoColor = new TextButton("Empty Color", game.skin);
    buttonNoColor.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {

            try {
                field.set(game.screenMain.paneOptions.currentStyle, null);
            } catch (Exception e) {
                e.printStackTrace();
            }

            game.screenMain.saveToSkin();

            hide();
            game.screenMain.panePreview.refresh();
            game.screenMain.paneOptions.updateSelectedTableFields();

        }

    });

    ScrollPane scrollPane = new ScrollPane(tableColors, game.skin);
    scrollPane.setFlickScroll(false);
    scrollPane.setFadeScrollBars(false);
    scrollPane.setScrollbarsOnTop(true);

    getContentTable().add(scrollPane).width(540).height(320).pad(20);
    getButtonTable().add(buttonNewColor);
    if (field != null) {
        getButtonTable().add(buttonNoColor);
    }
    getButtonTable().padBottom(15);
    button("Cancel", false);
    key(com.badlogic.gdx.Input.Keys.ESCAPE, false);

}