Beispiel #1
0
  public static Table setupScrollpane(
      float x,
      float y,
      float paneWidth,
      float paneHeight,
      ScrollPane target,
      Texture scrollButton) {
    ScrollPane.ScrollPaneStyle scrollPaneStyle = new ScrollPane.ScrollPaneStyle();
    scrollPaneStyle.vScrollKnob = new TextureRegionDrawable(new TextureRegion(scrollButton));

    target.setStyle(scrollPaneStyle);
    target.setFadeScrollBars(false);
    target.setOverscroll(false, false);
    target.setFlickScroll(false);

    target.addListener(new GetScrollFocusWhenEntered(target));

    Table scenarioPaneContainer = new Table();
    scenarioPaneContainer.setX(x);
    scenarioPaneContainer.setY(y);
    scenarioPaneContainer.setWidth(paneWidth);
    scenarioPaneContainer.setHeight(paneHeight);
    scenarioPaneContainer.add(target).fill().expand();
    return scenarioPaneContainer;
  }
 private void setSP(ScrollPane sp) {
   ScrollPaneStyle aux_st = sp.getStyle();
   TextureRegion bg = new TextureRegion(Textures.scroll_box_bg, 0, 0, 256, 512);
   TextureRegionDrawable bg_d = new TextureRegionDrawable(bg);
   aux_st.background = bg_d;
   aux_st.vScroll = null;
   sp.setStyle(aux_st);
   sp.setHeight(415);
   sp.setWidth(212);
   sp.setSmoothScrolling(true);
   sp.setFadeScrollBars(true);
   sp.setFlickScroll(false);
   sp.setScrollbarsOnTop(true);
   sp.setupFadeScrollBars(2, 1.5f);
 }
Beispiel #3
0
  @Override
  public void create() {
    skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    texture1 = new Texture(Gdx.files.internal("data/badlogicsmall.jpg"));
    texture2 = new Texture(Gdx.files.internal("data/badlogic.jpg"));
    TextureRegion image = new TextureRegion(texture1);
    TextureRegion imageFlipped = new TextureRegion(image);
    imageFlipped.flip(true, true);
    TextureRegion image2 = new TextureRegion(texture2);
    // stage = new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false, new
    // PolygonSpriteBatch());
    stage = new Stage();
    // stage.setViewport(new ExtendViewport(800, 480));
    Gdx.input.setInputProcessor(stage);

    // Group.debug = true;

    ImageButtonStyle style = new ImageButtonStyle(skin.get(ButtonStyle.class));
    style.imageUp = new TextureRegionDrawable(image);
    style.imageDown = new TextureRegionDrawable(imageFlipped);
    ImageButton iconButton = new ImageButton(style);

    Button buttonMulti = new TextButton("Multi\nLine\nToggle", skin, "toggle");
    Button imgButton = new Button(new Image(image), skin);
    Button imgToggleButton = new Button(new Image(image), skin, "toggle");

    Label myLabel = new Label("this is some text.", skin);
    myLabel.setWrap(true);

    Table t = new Table();
    t.row();
    t.add(myLabel);

    t.layout();

    CheckBox checkBox = new CheckBox("Check me", skin);
    final Slider slider = new Slider(0, 10, 1, false, skin);
    TextField textfield = new TextField("", skin);
    textfield.setMessageText("Click here!");
    SelectBox dropdown = new SelectBox(skin);
    dropdown.setItems(
        "Android1",
        "Windows1",
        "Linux1",
        "OSX1",
        "Android2",
        "Windows2",
        "Linux2",
        "OSX2",
        "Android3",
        "Windows3",
        "Linux3",
        "OSX3",
        "Android4",
        "Windows4",
        "Linux4",
        "OSX4",
        "Android5",
        "Windows5",
        "Linux5",
        "OSX5",
        "Android6",
        "Windows6",
        "Linux6",
        "OSX6",
        "Android7",
        "Windows7",
        "Linux7",
        "OSX7");
    dropdown.setSelected("Linux6");
    Image imageActor = new Image(image2);
    ScrollPane scrollPane = new ScrollPane(imageActor);
    List list = new List(skin);
    list.setItems(listEntries);
    list.getSelection().setMultiple(true);
    list.getSelection().setRequired(false);
    // list.getSelection().setToggle(true);
    ScrollPane scrollPane2 = new ScrollPane(list, skin);
    scrollPane2.setFlickScroll(false);
    SplitPane splitPane = new SplitPane(scrollPane, scrollPane2, false, skin, "default-horizontal");
    fpsLabel = new Label("fps:", skin);

    // configures an example of a TextField in password mode.
    final Label passwordLabel = new Label("Textfield in password mode: ", skin);
    final TextField passwordTextField = new TextField("", skin);
    passwordTextField.setMessageText("password");
    passwordTextField.setPasswordCharacter('*');
    passwordTextField.setPasswordMode(true);

    // window.debug();
    Window window = new Window("Dialog", skin);
    window.getButtonTable().add(new TextButton("X", skin)).height(window.getPadTop());
    window.setPosition(0, 0);
    window.defaults().spaceBottom(10);
    window.row().fill().expandX();
    window.add(iconButton);
    window.add(buttonMulti);
    window.add(imgButton);
    window.add(imgToggleButton);
    window.row();
    window.add(checkBox);
    window.add(slider).minWidth(100).fillX().colspan(3);
    window.row();
    window.add(dropdown);
    window.add(textfield).minWidth(100).expandX().fillX().colspan(3);
    window.row();
    window.add(splitPane).fill().expand().colspan(4).maxHeight(200);
    window.row();
    window.add(passwordLabel).colspan(2);
    window.add(passwordTextField).minWidth(100).expandX().fillX().colspan(2);
    window.row();
    window.add(fpsLabel).colspan(4);
    window.pack();

    // stage.addActor(new Button("Behind Window", skin));
    stage.addActor(window);

    textfield.setTextFieldListener(
        new TextFieldListener() {
          public void keyTyped(TextField textField, char key) {
            if (key == '\n') textField.getOnscreenKeyboard().show(false);
          }
        });

    slider.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            Gdx.app.log("UITest", "slider: " + slider.getValue());
          }
        });

    iconButton.addListener(
        new ChangeListener() {
          public void changed(ChangeEvent event, Actor actor) {
            new Dialog("Some Dialog", skin, "dialog") {
              protected void result(Object object) {
                System.out.println("Chosen: " + object);
              }
            }.text("Are you enjoying this demo?")
                .button("Yes", true)
                .button("No", false)
                .key(Keys.ENTER, true)
                .key(Keys.ESCAPE, false)
                .show(stage);
          }
        });
  }
  public void createWindow() {
    Skin skin = new Skin(Gdx.files.internal("data/uiskin.json"));
    TextButton closeButton = new TextButton("", skin, "close-toggle");

    Random random = new Random();

    dialog = new Window("Terminal", skin);
    dialog.setBounds(10 + random.nextInt(50), 100 + random.nextInt(50), 400, 200);
    dialog.setResizable(true);
    dialog.setKeepWithinStage(true);
    dialog
        .getTitleTable()
        .add(closeButton)
        .size(dialog.getPadTop() * 4 / 5, dialog.getPadTop() * 4 / 5)
        .padRight(dialog.getPadRight());
    dialog.left().top();
    dialog.setResizeBorder(5);
    dialog.padRight(0);
    dialog.padBottom(1);

    SimpleDateFormat simpleDateformat = new SimpleDateFormat("E");
    String day = simpleDateformat.format(new Date());
    String month = new SimpleDateFormat("MMM").format(Calendar.getInstance().getTime());
    int date = Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
    int hour = Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
    int min = Calendar.getInstance().get(Calendar.MINUTE);
    int sec = Calendar.getInstance().get(Calendar.SECOND);
    String textTest =
        "Last login: "******" "
            + month
            + " "
            + String.format("%02d", date)
            + " "
            + String.format("%02d", hour)
            + ":"
            + String.format("%02d", min)
            + ":"
            + String.format("%02d", sec);

    cld.textHistory = textTest;
    consoleDialog = new Label(cld.textHistory, skin);
    consoleDialog.setWrap(true);
    consoleDialog.setAlignment(Align.topLeft, Align.topLeft);

    consoleArrow =
        new Label(cld.parser.getInputPrefix(), new LabelStyle(skin.get(LabelStyle.class)));
    consoleField = new TextField("", skin);
    consoleField.setFocusTraversal(false);
    Color colour = Color.ORANGE;
    colour.a = 0.8f;
    consoleField.getStyle().cursor = skin.newDrawable("white", colour);
    consoleField.getStyle().cursor.setMinWidth(10);
    consoleField.setBlinkTime(0.6f);

    Table scrollTable = new Table();
    scrollTable.top();
    scrollTable.add(consoleDialog).colspan(2).growX().fill().left().top();
    scrollTable.row();
    scrollTable.add(consoleArrow).left().top();
    scrollTable.add(consoleField).expand(true, false).fill().left().top();
    scrollTable.padBottom(1);

    consoleScroll = new ScrollPane(scrollTable, skin);
    consoleScroll.setFadeScrollBars(false);
    consoleScroll.setVariableSizeKnobs(true);
    consoleScroll.setFlickScroll(false);
    dialog.add(consoleScroll).fill().expand();
    this.stage.addActor(dialog);

    closeButton.addListener(new CLICloseButtonListener(this, dialog));

    setKeyboardFocus();
  }