use of com.spinyowl.legui.component.Button in project legui by SpinyOwl.
the class ExampleGui method createSwitchThemeButton.
private Button createSwitchThemeButton() {
final Theme[] current = { Themes.getDefaultTheme() };
final Theme[] list = { Themes.FLAT_DARK, Themes.FLAT_PETERRIVER, Themes.FLAT_PETERRIVER_DARK, Themes.FLAT_WHITE };
final int[] themeIndex = { 0 };
String text = "Switch theme ";
Button switchTheme = new Button(text, 600, 400, 120, 30);
switchTheme.getListenerMap().addListener(MouseClickEvent.class, switchThemeClickListener(current, list, themeIndex, switchTheme));
return switchTheme;
}
use of com.spinyowl.legui.component.Button in project legui by SpinyOwl.
the class ExampleGui method createButtonWithTooltip.
private Button createButtonWithTooltip() {
Button button = new Button(20, 170, 50, 20);
/*button.getStyle().getBackground().setColor(new Vector4f(1));*/
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) System.out::println);
Tooltip tooltip = new Tooltip("Just button");
button.setTooltip(tooltip);
tooltip.setPosition(0, 25);
tooltip.getSize().set(50, 60);
tooltip.getStyle().setPadding(4f);
tooltip.getListenerMap().addListener(TooltipTextSizeChangeEvent.class, e -> tooltip.setSize(50, e.getHeight()));
int[] idv = { 0 };
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) (MouseClickEvent event) -> {
if (event.getAction().equals(CLICK)) {
idv[0]++;
HorizontalAlign h;
VerticalAlign v;
int hh = idv[0] % 3;
int vv = (idv[0] / 3) % 3;
switch(hh) {
case 0:
h = LEFT;
break;
case 1:
h = CENTER;
break;
case 2:
default:
h = RIGHT;
break;
}
switch(vv) {
case 0:
v = TOP;
break;
case 1:
v = MIDDLE;
break;
case 2:
default:
v = BOTTOM;
break;
}
System.out.println(h + " " + v);
tooltip.getStyle().setHorizontalAlign(h);
tooltip.getStyle().setVerticalAlign(v);
}
});
return button;
}
Aggregations