private AbstractComponent createButton(final Animation animation) {
    PlainContainer container = new PlainContainer();
    container.setLayout(new VerticalLayout());
    container.setXAlignment(0.5);

    PlainContainer center = new PlainContainer();
    center.setXAlignment(0.5);
    center.setYAlignment(0.5);
    center.setMinimumWidth(64);
    center.setMaximumWidth(64);
    center.setMinimumHeight(64);
    center.setMaximumHeight(64);

    ImagePose icon =
        Editor.instance.getStylesheet().resources.getPose("animation-" + animation.getTagName());
    ImageComponent img = new ImageComponent((icon == null) ? null : icon.getSurface());
    center.addChild(img);
    Button button = new Button(center);
    container.addChild(button);

    container.addChild(new Label(animation.getName()));

    button.addActionListener(
        new ActionListener() {
          @Override
          public void action() {
            AnimationTypePicker.this.hide();
            AnimationTypePicker.this.pick(animation);
          }
        });

    return container;
  }
Esempio n. 2
0
  private AbstractComponent createNinePatchButton(final NinePatch ninePatch) {
    PlainContainer container = new PlainContainer();

    container.setLayout(new VerticalLayout());
    container.setXAlignment(0.5f);

    ImageComponent img = new ImageComponent();
    if (ninePatch != null) {
      img.setImage(ninePatch.getThumbnail());
    }
    Button button = new Button(img);
    button.addActionListener(
        new ActionListener() {
          @Override
          public void action() {
            NinePatchPicker.this.hide();
            NinePatchPicker.this.pick(ninePatch);
          }
        });

    Label label = new Label(ninePatch == null ? "<none>" : ninePatch.getName());

    container.addChild(button);
    container.addChild(label);

    return container;
  }
Esempio n. 3
0
  public NinePatchPicker(Resources resources, NinePatch defaultNinePatch) {
    super("Pick a Nine Patch");
    this.resources = resources;
    this.defaultNinePatch = defaultNinePatch;

    this.clientArea.setLayout(new VerticalLayout());
    this.clientArea.setFill(true, false);

    PlainContainer container = new PlainContainer();
    container.setLayout(new VerticalLayout());
    VerticalScroll vs = new VerticalScroll(container);

    Component focus = this.createChoices(container);
    this.clientArea.addChild(vs);
    this.clientArea.addStyle("vScrolled");

    PlainContainer buttons = new PlainContainer();
    buttons.addStyle("buttonBar");
    buttons.setLayout(new HorizontalLayout());
    buttons.setXAlignment(0.5f);

    Button cancel = new Button("Cancel");
    cancel.addActionListener(
        new ActionListener() {

          @Override
          public void action() {
            NinePatchPicker.this.hide();
          }
        });
    buttons.addChild(cancel);
    this.clientArea.addChild(buttons);

    if (focus != null) {
      focus.focus();
    }
  }
Esempio n. 4
0
  protected Component createChoices(Container parent) {
    PlainContainer container = new PlainContainer();
    parent.addChild(container);

    Component focus = null;

    GridLayout gridLayout = new GridLayout(container, 5);
    container.setLayout(gridLayout);
    container.addStyle("pickGrid");

    for (String name : this.resources.ninePatchNames()) {
      NinePatch ninePatch = this.resources.getNinePatch(name);

      AbstractComponent component = this.createNinePatchButton(ninePatch);
      if (ninePatch == this.defaultNinePatch) {
        focus = component;
      }

      gridLayout.addChild(component);
    }
    gridLayout.endRow();

    return focus;
  }