Search in sources :

Example 1 with LEFT

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;
}
Also used : TextInput(com.spinyowl.legui.component.TextInput) Button(com.spinyowl.legui.component.Button) ChangeSizeEvent(com.spinyowl.legui.component.event.component.ChangeSizeEvent) PRESS(com.spinyowl.legui.event.MouseClickEvent.MouseClickAction.PRESS) BASELINE(com.spinyowl.legui.component.optional.align.VerticalAlign.BASELINE) SliderChangeValueEventListener(com.spinyowl.legui.component.event.slider.SliderChangeValueEventListener) Shadow(com.spinyowl.legui.style.shadow.Shadow) SliderChangeValueEvent(com.spinyowl.legui.component.event.slider.SliderChangeValueEvent) Themes(com.spinyowl.legui.theme.Themes) KeyEvent(com.spinyowl.legui.event.KeyEvent) Theme(com.spinyowl.legui.theme.Theme) RELEASE(com.spinyowl.legui.event.MouseClickEvent.MouseClickAction.RELEASE) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ImageLoader(com.spinyowl.legui.image.loader.ImageLoader) TOP(com.spinyowl.legui.component.optional.align.VerticalAlign.TOP) SelectBoxChangeSelectionEventListener(com.spinyowl.legui.component.event.selectbox.SelectBoxChangeSelectionEventListener) DropEvent(com.spinyowl.legui.event.DropEvent) UpdateLabelWidthListener(com.spinyowl.legui.component.misc.listener.label.UpdateLabelWidthListener) CursorEnterEventListener(com.spinyowl.legui.listener.CursorEnterEventListener) CursorEnterEvent(com.spinyowl.legui.event.CursorEnterEvent) TextUtil(com.spinyowl.legui.util.TextUtil) HorizontalAlign(com.spinyowl.legui.component.optional.align.HorizontalAlign) PositionType(com.spinyowl.legui.style.Style.PositionType) Animation(com.spinyowl.legui.animation.Animation) ColorConstants(com.spinyowl.legui.style.color.ColorConstants) LEFT(com.spinyowl.legui.component.optional.align.HorizontalAlign.LEFT) Icon(com.spinyowl.legui.icon.Icon) RadioButtonGroup(com.spinyowl.legui.component.RadioButtonGroup) MIDDLE(com.spinyowl.legui.component.optional.align.VerticalAlign.MIDDLE) PasswordInput(com.spinyowl.legui.component.PasswordInput) Label(com.spinyowl.legui.component.Label) Orientation(com.spinyowl.legui.component.optional.Orientation) LabelWidthChangeEvent(com.spinyowl.legui.component.event.label.LabelWidthChangeEvent) GLFW(org.lwjgl.glfw.GLFW) CheckBox(com.spinyowl.legui.component.CheckBox) List(java.util.List) MOUSE_BUTTON_LEFT(com.spinyowl.legui.input.Mouse.MouseButton.MOUSE_BUTTON_LEFT) FocusEvent(com.spinyowl.legui.event.FocusEvent) Vector2f(org.joml.Vector2f) CLICK(com.spinyowl.legui.event.MouseClickEvent.MouseClickAction.CLICK) TooltipTextSizeChangeEvent(com.spinyowl.legui.component.event.tooltip.TooltipTextSizeChangeEvent) Component(com.spinyowl.legui.component.Component) MouseClickEventListener(com.spinyowl.legui.listener.MouseClickEventListener) ImageView(com.spinyowl.legui.component.ImageView) VerticalAlign(com.spinyowl.legui.component.optional.align.VerticalAlign) ScrollablePanel(com.spinyowl.legui.component.ScrollablePanel) SelectBox(com.spinyowl.legui.component.SelectBox) RadioButton(com.spinyowl.legui.component.RadioButton) SplitPanel(com.spinyowl.legui.component.SplitPanel) Style(com.spinyowl.legui.style.Style) CENTER(com.spinyowl.legui.component.optional.align.HorizontalAlign.CENTER) ToggleButton(com.spinyowl.legui.component.ToggleButton) ProgressBar(com.spinyowl.legui.component.ProgressBar) BOTTOM(com.spinyowl.legui.component.optional.align.VerticalAlign.BOTTOM) FontRegistry(com.spinyowl.legui.style.font.FontRegistry) Dialog(com.spinyowl.legui.component.Dialog) ImageIcon(com.spinyowl.legui.icon.ImageIcon) TextDirection(com.spinyowl.legui.style.font.TextDirection) RIGHT(com.spinyowl.legui.component.optional.align.HorizontalAlign.RIGHT) Tooltip(com.spinyowl.legui.component.Tooltip) Panel(com.spinyowl.legui.component.Panel) ScrollBar(com.spinyowl.legui.component.ScrollBar) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent) KeyEventListener(com.spinyowl.legui.listener.KeyEventListener) DisplayType(com.spinyowl.legui.style.Style.DisplayType) FocusEventListener(com.spinyowl.legui.listener.FocusEventListener) Slider(com.spinyowl.legui.component.Slider) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) Widget(com.spinyowl.legui.component.Widget) TextArea(com.spinyowl.legui.component.TextArea) Vector4f(org.joml.Vector4f) ImageIcon(com.spinyowl.legui.icon.ImageIcon) ToggleButton(com.spinyowl.legui.component.ToggleButton) VerticalAlign(com.spinyowl.legui.component.optional.align.VerticalAlign) Vector2f(org.joml.Vector2f) Tooltip(com.spinyowl.legui.component.Tooltip) HorizontalAlign(com.spinyowl.legui.component.optional.align.HorizontalAlign) Icon(com.spinyowl.legui.icon.Icon) ImageIcon(com.spinyowl.legui.icon.ImageIcon)

Aggregations

Animation (com.spinyowl.legui.animation.Animation)1 Button (com.spinyowl.legui.component.Button)1 CheckBox (com.spinyowl.legui.component.CheckBox)1 Component (com.spinyowl.legui.component.Component)1 Dialog (com.spinyowl.legui.component.Dialog)1 ImageView (com.spinyowl.legui.component.ImageView)1 Label (com.spinyowl.legui.component.Label)1 Panel (com.spinyowl.legui.component.Panel)1 PasswordInput (com.spinyowl.legui.component.PasswordInput)1 ProgressBar (com.spinyowl.legui.component.ProgressBar)1 RadioButton (com.spinyowl.legui.component.RadioButton)1 RadioButtonGroup (com.spinyowl.legui.component.RadioButtonGroup)1 ScrollBar (com.spinyowl.legui.component.ScrollBar)1 ScrollablePanel (com.spinyowl.legui.component.ScrollablePanel)1 SelectBox (com.spinyowl.legui.component.SelectBox)1 Slider (com.spinyowl.legui.component.Slider)1 SplitPanel (com.spinyowl.legui.component.SplitPanel)1 TextArea (com.spinyowl.legui.component.TextArea)1 TextInput (com.spinyowl.legui.component.TextInput)1 ToggleButton (com.spinyowl.legui.component.ToggleButton)1