Search in sources :

Example 16 with Button

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;
}
Also used : Button(com.spinyowl.legui.component.Button) RadioButton(com.spinyowl.legui.component.RadioButton) ToggleButton(com.spinyowl.legui.component.ToggleButton) Theme(com.spinyowl.legui.theme.Theme)

Example 17 with Button

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;
}
Also used : VerticalAlign(com.spinyowl.legui.component.optional.align.VerticalAlign) Button(com.spinyowl.legui.component.Button) RadioButton(com.spinyowl.legui.component.RadioButton) ToggleButton(com.spinyowl.legui.component.ToggleButton) Tooltip(com.spinyowl.legui.component.Tooltip) HorizontalAlign(com.spinyowl.legui.component.optional.align.HorizontalAlign) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent)

Aggregations

Button (com.spinyowl.legui.component.Button)17 Component (com.spinyowl.legui.component.Component)9 SimpleLineBorder (com.spinyowl.legui.style.border.SimpleLineBorder)9 Label (com.spinyowl.legui.component.Label)8 RadioButton (com.spinyowl.legui.component.RadioButton)8 MouseClickEvent (com.spinyowl.legui.event.MouseClickEvent)7 Panel (com.spinyowl.legui.component.Panel)6 RadioButtonGroup (com.spinyowl.legui.component.RadioButtonGroup)6 Widget (com.spinyowl.legui.component.Widget)6 CursorEnterEvent (com.spinyowl.legui.event.CursorEnterEvent)6 CursorEnterEventListener (com.spinyowl.legui.listener.CursorEnterEventListener)6 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)6 ColorConstants (com.spinyowl.legui.style.color.ColorConstants)6 List (java.util.List)6 GLFW (org.lwjgl.glfw.GLFW)6 ToggleButton (com.spinyowl.legui.component.ToggleButton)5 Frame (com.spinyowl.legui.component.Frame)4 EventProcessorProvider (com.spinyowl.legui.listener.processor.EventProcessorProvider)4 CallbackKeeper (com.spinyowl.legui.system.context.CallbackKeeper)4 Context (com.spinyowl.legui.system.context.Context)4