Example #1
0
  @GuiCallback("scroll_bar")
  public void onProgressChange(Widget w, DraggedEvent event) {
    VerticalDragBar vdb = VerticalDragBar.get(w);

    ElementList list = ElementList.get(pageMain.getWidget("area"));
    list.setProgress((int) (vdb.getProgress() * list.getMaxProgress()));
  }
Example #2
0
  private void addButtons() {
    Widget tmp;

    tmp = setupButton(0, "arrow_left", CGUILang.butDechild());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveLeft();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(1, "arrow_right", CGUILang.butChild());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveRight();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(2, "arrow_up", CGUILang.butMoveUp());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveUp();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(3, "arrow_down", CGUILang.butMoveDown());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().moveDown();
              buildHierarchy();
            }
          }
        });

    //		tmp = setupButton(4, "rename", CGUILang.butRename());
    //		tmp.regEventHandler(new MouseDownHandler() {
    //			@Override
    //			public void handleEvent(Widget w, MouseDownEvent event) {
    //				if(getAccessTarget() != null) {
    //					TextBox box = handlers.get(getAccessTarget()).box;
    //					box.allowEdit = true;
    //					handlers.get(getAccessTarget()).transform.doesListenKey = true;
    //					System.out.println("Rename callback");
    //				}
    //			}
    //		});

    tmp = setupButton(4, "remove", CGUILang.butRemove());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().dispose();
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(5, "duplicate", CGUILang.butDuplicate());
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (getAccessTarget() != null) {
              getAccessTarget().getAbstractParent().addWidget(getAccessTarget().copy());
              buildHierarchy();
            }
          }
        });

    tmp = setupButton(6, "up", "Move Up");
    tmp.transform.setPos(90, 30);
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (hList != null) {
              ElementList list = ElementList.get(hList);
              list.progressLast();
            }
          }
        });

    tmp = setupButton(7, "down", "Move Down");
    tmp.transform.setPos(90, 110);
    tmp.regEventHandler(
        new MouseDownHandler() {
          @Override
          public void handleEvent(Widget w, MouseDownEvent event) {
            if (hList != null) {
              ElementList list = ElementList.get(hList);
              list.progressNext();
            }
          }
        });

    {
      tmp = new Widget();
      tmp.transform.setSize(10, 10);
      tmp.transform.setPos(90, 40);

      final VerticalDragBar bar = new VerticalDragBar();
      bar.setArea(40, 100);
      tmp.addComponent(bar);

      DrawTexture dt = new DrawTexture().setTex(null).setColor4i(200, 200, 255, 200);
      tmp.addComponent(dt);

      tmp.regEventHandler(
          new DraggedHandler() {
            @Override
            public void handleEvent(Widget w, DraggedEvent event) {
              double p = bar.getProgress();
              if (hList != null) {
                ElementList list = ElementList.get(hList);
                list.setProgress((int) Math.round(p * list.getMaxProgress()));
              }
            }
          });

      addWidget(tmp);
      dragbar = tmp;
    }
  }