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;
  }
Example #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;
  }
Example #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();
    }
  }