Search in sources :

Example 1 with FLEX

use of com.spinyowl.legui.style.Style.DisplayType.FLEX 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)

Aggregations

AnimatorProvider (com.spinyowl.legui.animation.AnimatorProvider)1 Button (com.spinyowl.legui.component.Button)1 Component (com.spinyowl.legui.component.Component)1 Frame (com.spinyowl.legui.component.Frame)1 Label (com.spinyowl.legui.component.Label)1 Panel (com.spinyowl.legui.component.Panel)1 TabbedPanel (com.spinyowl.legui.component.TabbedPanel)1 Tab (com.spinyowl.legui.component.TabbedPanel.Tab)1 TabStripPosition (com.spinyowl.legui.component.TabbedPanel.TabStripPosition)1 BOTTOM (com.spinyowl.legui.component.TabbedPanel.TabStripPosition.BOTTOM)1 LEFT (com.spinyowl.legui.component.TabbedPanel.TabStripPosition.LEFT)1 RIGHT (com.spinyowl.legui.component.TabbedPanel.TabStripPosition.RIGHT)1 TOP (com.spinyowl.legui.component.TabbedPanel.TabStripPosition.TOP)1 Widget (com.spinyowl.legui.component.Widget)1 CursorEnterEvent (com.spinyowl.legui.event.CursorEnterEvent)1 KeyEvent (com.spinyowl.legui.event.KeyEvent)1 MouseClickEvent (com.spinyowl.legui.event.MouseClickEvent)1 MouseClickAction (com.spinyowl.legui.event.MouseClickEvent.MouseClickAction)1 CursorEnterEventListener (com.spinyowl.legui.listener.CursorEnterEventListener)1 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)1