Search in sources :

Example 1 with CursorEnterEventListener

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;
}
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) Vector4f(org.joml.Vector4f) CheckBox(com.spinyowl.legui.component.CheckBox)

Example 2 with CursorEnterEventListener

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;
}
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)

Example 3 with CursorEnterEventListener

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);
}
Also used : GLFW.glfwDestroyWindow(org.lwjgl.glfw.GLFW.glfwDestroyWindow) GLFW.glfwSwapBuffers(org.lwjgl.glfw.GLFW.glfwSwapBuffers) GLFW_RELEASE(org.lwjgl.glfw.GLFW.GLFW_RELEASE) Component(com.spinyowl.legui.component.Component) MouseClickEventListener(com.spinyowl.legui.listener.MouseClickEventListener) Button(com.spinyowl.legui.component.Button) GLFW.glfwCreateWindow(org.lwjgl.glfw.GLFW.glfwCreateWindow) GLFW.glfwPollEvents(org.lwjgl.glfw.GLFW.glfwPollEvents) GLFWErrorCallback(org.lwjgl.glfw.GLFWErrorCallback) GLFW.glfwSwapInterval(org.lwjgl.glfw.GLFW.glfwSwapInterval) RadioButton(com.spinyowl.legui.component.RadioButton) GL11.glViewport(org.lwjgl.opengl.GL11.glViewport) NULL(org.lwjgl.system.MemoryUtil.NULL) ArrayList(java.util.ArrayList) GL_COLOR_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT) Renderer(com.spinyowl.legui.system.renderer.Renderer) GLFW.glfwSetErrorCallback(org.lwjgl.glfw.GLFW.glfwSetErrorCallback) GLFWWindowCloseCallbackI(org.lwjgl.glfw.GLFWWindowCloseCallbackI) CallbackKeeper(com.spinyowl.legui.system.context.CallbackKeeper) GL11.glClear(org.lwjgl.opengl.GL11.glClear) GLFW.glfwShowWindow(org.lwjgl.glfw.GLFW.glfwShowWindow) LayoutManager(com.spinyowl.legui.system.layout.LayoutManager) CursorEnterEventListener(com.spinyowl.legui.listener.CursorEnterEventListener) NvgRenderer(com.spinyowl.legui.system.renderer.nvg.NvgRenderer) GL_STENCIL_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_STENCIL_BUFFER_BIT) CursorEnterEvent(com.spinyowl.legui.event.CursorEnterEvent) Context(com.spinyowl.legui.system.context.Context) ColorConstants(com.spinyowl.legui.style.color.ColorConstants) Frame(com.spinyowl.legui.component.Frame) SystemEventProcessorImpl(com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl) RadioButtonGroup(com.spinyowl.legui.component.RadioButtonGroup) GLFW.glfwTerminate(org.lwjgl.glfw.GLFW.glfwTerminate) GLFWKeyCallbackI(org.lwjgl.glfw.GLFWKeyCallbackI) GL11.glClearColor(org.lwjgl.opengl.GL11.glClearColor) DefaultCallbackKeeper(com.spinyowl.legui.system.context.DefaultCallbackKeeper) Label(com.spinyowl.legui.component.Label) GLFW.glfwSetWindowPos(org.lwjgl.glfw.GLFW.glfwSetWindowPos) GLFW(org.lwjgl.glfw.GLFW) GLFW.glfwMakeContextCurrent(org.lwjgl.glfw.GLFW.glfwMakeContextCurrent) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent) SystemEventProcessor(com.spinyowl.legui.system.handler.processor.SystemEventProcessor) EventProcessorProvider(com.spinyowl.legui.listener.processor.EventProcessorProvider) List(java.util.List) Vector2i(org.joml.Vector2i) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) GLFW_KEY_ESCAPE(org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) GL(org.lwjgl.opengl.GL) Button(com.spinyowl.legui.component.Button) RadioButton(com.spinyowl.legui.component.RadioButton) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) Component(com.spinyowl.legui.component.Component)

Example 4 with CursorEnterEventListener

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);
}
Also used : TOP(com.spinyowl.legui.component.TabbedPanel.TabStripPosition.TOP) GLFW.glfwDestroyWindow(org.lwjgl.glfw.GLFW.glfwDestroyWindow) GLFW_RELEASE(org.lwjgl.glfw.GLFW.GLFW_RELEASE) Button(com.spinyowl.legui.component.Button) RIGHT(com.spinyowl.legui.component.TabbedPanel.TabStripPosition.RIGHT) GLFW.glfwCreateWindow(org.lwjgl.glfw.GLFW.glfwCreateWindow) GLFW.glfwPollEvents(org.lwjgl.glfw.GLFW.glfwPollEvents) GLFW.glfwSwapInterval(org.lwjgl.glfw.GLFW.glfwSwapInterval) GL11.glViewport(org.lwjgl.opengl.GL11.glViewport) NULL(org.lwjgl.system.MemoryUtil.NULL) KeyEvent(com.spinyowl.legui.event.KeyEvent) Renderer(com.spinyowl.legui.system.renderer.Renderer) FlexDirection(com.spinyowl.legui.style.flex.FlexStyle.FlexDirection) MouseClickAction(com.spinyowl.legui.event.MouseClickEvent.MouseClickAction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) CallbackKeeper(com.spinyowl.legui.system.context.CallbackKeeper) GLFW.glfwShowWindow(org.lwjgl.glfw.GLFW.glfwShowWindow) LayoutManager(com.spinyowl.legui.system.layout.LayoutManager) CursorEnterEventListener(com.spinyowl.legui.listener.CursorEnterEventListener) GL_STENCIL_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_STENCIL_BUFFER_BIT) CursorEnterEvent(com.spinyowl.legui.event.CursorEnterEvent) PositionType(com.spinyowl.legui.style.Style.PositionType) ColorUtil(com.spinyowl.legui.style.color.ColorUtil) LEFT(com.spinyowl.legui.component.TabbedPanel.TabStripPosition.LEFT) FLEX(com.spinyowl.legui.style.Style.DisplayType.FLEX) ColorConstants(com.spinyowl.legui.style.color.ColorConstants) Frame(com.spinyowl.legui.component.Frame) GLFW.glfwTerminate(org.lwjgl.glfw.GLFW.glfwTerminate) GLFW_KEY_5(org.lwjgl.glfw.GLFW.GLFW_KEY_5) GLFWKeyCallbackI(org.lwjgl.glfw.GLFWKeyCallbackI) GLFW_KEY_6(org.lwjgl.glfw.GLFW.GLFW_KEY_6) DefaultCallbackKeeper(com.spinyowl.legui.system.context.DefaultCallbackKeeper) Label(com.spinyowl.legui.component.Label) GLFW(org.lwjgl.glfw.GLFW) GLFW.glfwMakeContextCurrent(org.lwjgl.glfw.GLFW.glfwMakeContextCurrent) EventProcessorProvider(com.spinyowl.legui.listener.processor.EventProcessorProvider) List(java.util.List) Vector2i(org.joml.Vector2i) TabStripPosition(com.spinyowl.legui.component.TabbedPanel.TabStripPosition) NotNull(org.jetbrains.annotations.NotNull) GLFW.glfwSwapBuffers(org.lwjgl.glfw.GLFW.glfwSwapBuffers) Component(com.spinyowl.legui.component.Component) TabbedPanel(com.spinyowl.legui.component.TabbedPanel) MouseClickEventListener(com.spinyowl.legui.listener.MouseClickEventListener) BOTTOM(com.spinyowl.legui.component.TabbedPanel.TabStripPosition.BOTTOM) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ArrayList(java.util.ArrayList) GL_COLOR_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT) GLFWWindowCloseCallbackI(org.lwjgl.glfw.GLFWWindowCloseCallbackI) GLFW_KEY_3(org.lwjgl.glfw.GLFW.GLFW_KEY_3) GL11.glClear(org.lwjgl.opengl.GL11.glClear) GLFW_KEY_4(org.lwjgl.glfw.GLFW.GLFW_KEY_4) GLFW_KEY_1(org.lwjgl.glfw.GLFW.GLFW_KEY_1) GLFW_KEY_2(org.lwjgl.glfw.GLFW.GLFW_KEY_2) NvgRenderer(com.spinyowl.legui.system.renderer.nvg.NvgRenderer) Context(com.spinyowl.legui.system.context.Context) SystemEventProcessorImpl(com.spinyowl.legui.system.handler.processor.SystemEventProcessorImpl) GL11.glClearColor(org.lwjgl.opengl.GL11.glClearColor) IOException(java.io.IOException) AnimatorProvider(com.spinyowl.legui.animation.AnimatorProvider) Panel(com.spinyowl.legui.component.Panel) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent) SystemEventProcessor(com.spinyowl.legui.system.handler.processor.SystemEventProcessor) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) Widget(com.spinyowl.legui.component.Widget) GLFW_KEY_ESCAPE(org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) Tab(com.spinyowl.legui.component.TabbedPanel.Tab) Vector4f(org.joml.Vector4f) GL(org.lwjgl.opengl.GL) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) Button(com.spinyowl.legui.component.Button) Label(com.spinyowl.legui.component.Label) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) Component(com.spinyowl.legui.component.Component)

Example 5 with CursorEnterEventListener

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;
}
Also used : GLFW.glfwDestroyWindow(org.lwjgl.glfw.GLFW.glfwDestroyWindow) GL15.glBufferData(org.lwjgl.opengl.GL15.glBufferData) GLFW_RELEASE(org.lwjgl.glfw.GLFW.GLFW_RELEASE) GL_COMPILE_STATUS(org.lwjgl.opengl.GL20.GL_COMPILE_STATUS) GL30.glDeleteVertexArrays(org.lwjgl.opengl.GL30.glDeleteVertexArrays) GL20.glCompileShader(org.lwjgl.opengl.GL20.glCompileShader) Button(com.spinyowl.legui.component.Button) FloatBuffer(java.nio.FloatBuffer) GLFW.glfwCreateWindow(org.lwjgl.glfw.GLFW.glfwCreateWindow) GLFW.glfwPollEvents(org.lwjgl.glfw.GLFW.glfwPollEvents) GL_INFO_LOG_LENGTH(org.lwjgl.opengl.GL20.GL_INFO_LOG_LENGTH) GLFW.glfwSwapInterval(org.lwjgl.glfw.GLFW.glfwSwapInterval) GL20.glCreateShader(org.lwjgl.opengl.GL20.glCreateShader) GL11.glDisable(org.lwjgl.opengl.GL11.glDisable) GL11.glViewport(org.lwjgl.opengl.GL11.glViewport) GL20.glAttachShader(org.lwjgl.opengl.GL20.glAttachShader) NULL(org.lwjgl.system.MemoryUtil.NULL) Renderer(com.spinyowl.legui.system.renderer.Renderer) GL20.glGetShaderInfoLog(org.lwjgl.opengl.GL20.glGetShaderInfoLog) CallbackKeeper(com.spinyowl.legui.system.context.CallbackKeeper) GLFW.glfwShowWindow(org.lwjgl.glfw.GLFW.glfwShowWindow) GL30.glGenVertexArrays(org.lwjgl.opengl.GL30.glGenVertexArrays) LayoutManager(com.spinyowl.legui.system.layout.LayoutManager) GL15.glDeleteBuffers(org.lwjgl.opengl.GL15.glDeleteBuffers) CursorEnterEventListener(com.spinyowl.legui.listener.CursorEnterEventListener) GL_STENCIL_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_STENCIL_BUFFER_BIT) CursorEnterEvent(com.spinyowl.legui.event.CursorEnterEvent) GL_TRIANGLES(org.lwjgl.opengl.GL11.GL_TRIANGLES) ColorConstants(com.spinyowl.legui.style.color.ColorConstants) Frame(com.spinyowl.legui.component.Frame) RadioButtonGroup(com.spinyowl.legui.component.RadioButtonGroup) GLFW.glfwTerminate(org.lwjgl.glfw.GLFW.glfwTerminate) GL_DEPTH_TEST(org.lwjgl.opengl.GL11.GL_DEPTH_TEST) GLFWKeyCallbackI(org.lwjgl.glfw.GLFWKeyCallbackI) Label(com.spinyowl.legui.component.Label) GL20.glShaderSource(org.lwjgl.opengl.GL20.glShaderSource) GL20.glLinkProgram(org.lwjgl.opengl.GL20.glLinkProgram) GL_VERTEX_SHADER(org.lwjgl.opengl.GL20.GL_VERTEX_SHADER) GLFW(org.lwjgl.glfw.GLFW) GLFW.glfwMakeContextCurrent(org.lwjgl.glfw.GLFW.glfwMakeContextCurrent) BufferUtils(org.lwjgl.BufferUtils) GL_STATIC_DRAW(org.lwjgl.opengl.GL15.GL_STATIC_DRAW) EventProcessorProvider(com.spinyowl.legui.listener.processor.EventProcessorProvider) List(java.util.List) Vector2i(org.joml.Vector2i) GLFW_KEY_H(org.lwjgl.glfw.GLFW.GLFW_KEY_H) GL_FLOAT(org.lwjgl.opengl.GL11.GL_FLOAT) GL20.glDeleteProgram(org.lwjgl.opengl.GL20.glDeleteProgram) GL11.glDrawArrays(org.lwjgl.opengl.GL11.glDrawArrays) GL20.glGetProgrami(org.lwjgl.opengl.GL20.glGetProgrami) GLFW.glfwSwapBuffers(org.lwjgl.glfw.GLFW.glfwSwapBuffers) GL20.glUseProgram(org.lwjgl.opengl.GL20.glUseProgram) DefaultInitializer(com.spinyowl.legui.DefaultInitializer) GL20.glDeleteShader(org.lwjgl.opengl.GL20.glDeleteShader) Component(com.spinyowl.legui.component.Component) MouseClickEventListener(com.spinyowl.legui.listener.MouseClickEventListener) GL20.glEnableVertexAttribArray(org.lwjgl.opengl.GL20.glEnableVertexAttribArray) GL_LINK_STATUS(org.lwjgl.opengl.GL20.GL_LINK_STATUS) RadioButton(com.spinyowl.legui.component.RadioButton) GL15.glBindBuffer(org.lwjgl.opengl.GL15.glBindBuffer) GL15.glGenBuffers(org.lwjgl.opengl.GL15.glGenBuffers) ArrayList(java.util.ArrayList) GL_COLOR_BUFFER_BIT(org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT) GLFWWindowCloseCallbackI(org.lwjgl.glfw.GLFWWindowCloseCallbackI) GL11.glClear(org.lwjgl.opengl.GL11.glClear) Context(com.spinyowl.legui.system.context.Context) GL11.glEnable(org.lwjgl.opengl.GL11.glEnable) GL30.glBindVertexArray(org.lwjgl.opengl.GL30.glBindVertexArray) GL20.glVertexAttribPointer(org.lwjgl.opengl.GL20.glVertexAttribPointer) GL11.glClearColor(org.lwjgl.opengl.GL11.glClearColor) GL_FRAGMENT_SHADER(org.lwjgl.opengl.GL20.GL_FRAGMENT_SHADER) GL20.glCreateProgram(org.lwjgl.opengl.GL20.glCreateProgram) IOException(java.io.IOException) AnimatorProvider(com.spinyowl.legui.animation.AnimatorProvider) GL_ARRAY_BUFFER(org.lwjgl.opengl.GL15.GL_ARRAY_BUFFER) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent) GL_FALSE(org.lwjgl.opengl.GL11.GL_FALSE) GL20.glDetachShader(org.lwjgl.opengl.GL20.glDetachShader) GL_BLEND(org.lwjgl.opengl.GL11.GL_BLEND) GL20.glDisableVertexAttribArray(org.lwjgl.opengl.GL20.glDisableVertexAttribArray) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) GLFW_KEY_ESCAPE(org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE) GL20.glGetShaderi(org.lwjgl.opengl.GL20.glGetShaderi) GL(org.lwjgl.opengl.GL) Frame(com.spinyowl.legui.component.Frame) Button(com.spinyowl.legui.component.Button) RadioButton(com.spinyowl.legui.component.RadioButton) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder) Component(com.spinyowl.legui.component.Component)

Aggregations

Button (com.spinyowl.legui.component.Button)6 Component (com.spinyowl.legui.component.Component)6 Label (com.spinyowl.legui.component.Label)6 CursorEnterEvent (com.spinyowl.legui.event.CursorEnterEvent)6 RadioButton (com.spinyowl.legui.component.RadioButton)5 RadioButtonGroup (com.spinyowl.legui.component.RadioButtonGroup)5 MouseClickEvent (com.spinyowl.legui.event.MouseClickEvent)5 CursorEnterEventListener (com.spinyowl.legui.listener.CursorEnterEventListener)5 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)5 SimpleLineBorder (com.spinyowl.legui.style.border.SimpleLineBorder)5 ColorConstants (com.spinyowl.legui.style.color.ColorConstants)5 List (java.util.List)5 GLFW (org.lwjgl.glfw.GLFW)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 LayoutManager (com.spinyowl.legui.system.layout.LayoutManager)4 Renderer (com.spinyowl.legui.system.renderer.Renderer)4 ArrayList (java.util.ArrayList)4