use of com.spinyowl.legui.listener.CursorEnterEventListener in project legui by SpinyOwl.
the class ExampleGui method createCheckboxWithAnimation.
private CheckBox createCheckboxWithAnimation(CheckBox checkBox1) {
CheckBox checkBox2 = new CheckBox(20, 230, 100, 20);
checkBox2.getStyle().getBackground().setColor(new Vector4f(1, 0, 0, 1));
checkBox2.getStyle().setPadding(5f, 10f, 5f, 20f);
checkBox2.setChecked(true);
checkBox2.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) event -> {
boolean entered = event.isEntered();
Vector4f newColor = ColorConstants.green();
if (entered) {
createColorAnimationOnHover(event.getTargetComponent(), newColor, checkBox2).startAnimation();
}
});
checkBox2.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) event -> {
boolean entered = event.isEntered();
Vector4f newColor = ColorConstants.red();
if (entered) {
createColorAnimationOnHover(event.getTargetComponent(), newColor, checkBox1).startAnimation();
}
});
return checkBox2;
}
use of com.spinyowl.legui.listener.CursorEnterEventListener 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;
}
use of com.spinyowl.legui.listener.CursorEnterEventListener in project legui by SpinyOwl.
the class MultipleWindowsExample method createGuiElements.
private static void createGuiElements(Frame frame) {
// Set background color for frame
frame.getContainer().getStyle().getBackground().setColor(ColorConstants.lightBlue());
Button button = new Button("Add components", 20, 20, 160, 30);
SimpleLineBorder border = new SimpleLineBorder(ColorConstants.black(), 1);
button.getStyle().setBorder(border);
boolean[] added = { false };
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) event -> {
if (!added[0]) {
added[0] = true;
for (Component c : generateOnFly()) {
frame.getContainer().add(c);
}
}
});
button.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) System.out::println);
frame.getContainer().add(button);
}
use of com.spinyowl.legui.listener.CursorEnterEventListener in project legui by SpinyOwl.
the class SingleClassExample method createGuiElements.
private static void createGuiElements(Frame frame) {
// Set background color for frame
frame.getContainer().getStyle().getBackground().setColor(ColorConstants.lightBlue());
frame.getContainer().setFocusable(false);
// frame.getContainer().getStyle().setDisplay(FLEX);
// frame.getContainer().getStyle().setPosition(PositionType.ABSOLUTE);
// frame.getContainer().getStyle().getFlexStyle().setFlexDirection(FlexDirection.COLUMN);
//
// Panel menuBar = createPanel(ColorConstants.blue());
// Panel mainPanel = createPanel(ColorConstants.red());
// Panel animationPanel = createPanel(ColorConstants.green());
//
// frame.getContainer().addAll(List.of(menuBar, mainPanel, animationPanel));
Button button = new Button("Add components", 10, 10, 160, 30);
SimpleLineBorder border = new SimpleLineBorder(ColorConstants.black(), 1);
button.getStyle().setBorder(border);
AtomicBoolean added = new AtomicBoolean(false);
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) event -> {
if (!added.getAndSet(true)) {
for (Component c : generateOnFly()) {
frame.getContainer().add(c);
}
}
});
button.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) System.out::println);
mouseTargetLabel = new Label("Hello Label 1", 10, HEIGHT - 30, WIDTH - 20, 20);
frame.getContainer().add(mouseTargetLabel);
frame.getContainer().add(button);
}
use of com.spinyowl.legui.listener.CursorEnterEventListener in project legui by SpinyOwl.
the class ShaderProgram method createFrameWithGUI.
private Frame createFrameWithGUI() {
Frame frame = new Frame(WIDTH, HEIGHT);
// Set background color for frame
frame.getContainer().getStyle().getBackground().setColor(ColorConstants.transparent());
frame.getContainer().setFocusable(false);
Button button = new Button("Add components", 20, 20, 160, 30);
SimpleLineBorder border = new SimpleLineBorder(ColorConstants.black(), 1);
button.getStyle().setBorder(border);
boolean[] added = { false };
button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) event -> {
if (!added[0]) {
added[0] = true;
for (Component c : generateOnFly()) {
frame.getContainer().add(c);
}
}
});
button.getListenerMap().addListener(CursorEnterEvent.class, (CursorEnterEventListener) System.out::println);
frame.getContainer().add(button);
return frame;
}
Aggregations