use of com.spinyowl.legui.component.optional.align.HorizontalAlign.LEFT in project legui by SpinyOwl.
the class ExampleGui method createToggleButtonWithLongTooltip.
private ToggleButton createToggleButtonWithLongTooltip() {
ToggleButton toggleButton = new ToggleButton("", 100, 170, 40, 20);
Icon bgImageNormal = new ImageIcon(ImageLoader.loadImage("com/spinyowl/legui/demo/toggle.png"));
toggleButton.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) System.out::println);
toggleButton.setTooltip(new Tooltip("Just toggle button with long tooltipText text"));
toggleButton.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) event -> {
if (event.isEntered()) {
getColorAnimation(toggleButton, ColorConstants.blue()).startAnimation();
} else {
getColorAnimation(toggleButton, ColorConstants.red()).startAnimation();
}
});
toggleButton.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) event -> getSlideImageOnClick(toggleButton, bgImageNormal).startAnimation());
toggleButton.getTooltip().setPosition(45, 0);
toggleButton.getTooltip().getSize().set(140, 40);
toggleButton.getTooltip().getStyle().getBackground().setColor(ColorConstants.darkGray());
toggleButton.getTooltip().getStyle().setTextColor(ColorConstants.white());
toggleButton.getTooltip().getStyle().setPadding(4f);
int[] id = { 0 };
toggleButton.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) event -> {
if (event.getAction().equals(CLICK)) {
id[0]++;
HorizontalAlign h = LEFT;
VerticalAlign v = TOP;
int hh = id[0] % 3;
int vv = (id[0] / 3) % 3;
switch(hh) {
case 0:
h = LEFT;
break;
case 1:
h = CENTER;
break;
case 2:
h = RIGHT;
break;
}
switch(vv) {
case 0:
v = TOP;
break;
case 1:
v = MIDDLE;
break;
case 2:
v = BOTTOM;
break;
}
System.out.println(h + " " + v);
toggleButton.getTooltip().getStyle().setHorizontalAlign(h);
toggleButton.getTooltip().getStyle().setVerticalAlign(v);
}
});
bgImageNormal.setSize(new Vector2f(100 * 40 / 60, 20));
bgImageNormal.setPosition(new Vector2f(40 - 100 * 40 / 60, 0));
toggleButton.getStyle().getBackground().setIcon(bgImageNormal);
return toggleButton;
}
Aggregations