Search in sources :

Example 6 with Panel

use of com.spinyowl.legui.component.Panel in project legui by SpinyOwl.

the class SingleClassExample2 method createRightPanel.

private static Panel createRightPanel() {
    int minWidth = WIDTH - 260;
    int minHeight = HEIGHT - 40;
    Panel contentPanel = new Panel();
    contentPanel.getStyle().setMinWidth(minWidth);
    contentPanel.getStyle().setMinWidth(minWidth);
    contentPanel.getStyle().setMinHeight(minHeight);
    contentPanel.getStyle().getFlexStyle().setFlexGrow(1);
    contentPanel.getStyle().getFlexStyle().setFlexShrink(1);
    contentPanel.getStyle().setMargin(20F, 20F, 20F, 0F);
    contentPanel.getStyle().setPosition(RELATIVE);
    // content panel has manual display type - so we have to manually set size and position for
    // components via constructor or #setSize & #setPosition
    int gap = 30;
    int wid = (minWidth - gap * 3) / 2;
    int hei = (minHeight - gap * 3) / 2;
    Widget widget1 = new Widget("", gap, gap, wid, hei);
    setWidgetStyles(widget1);
    contentPanel.add(widget1);
    Widget widget2 = new Widget("", wid + gap * 2, gap, wid, hei);
    setWidgetStyles(widget2);
    contentPanel.add(widget2);
    Widget widget3 = new Widget("", gap, hei + gap * 2, wid, hei);
    setWidgetStyles(widget3);
    contentPanel.add(widget3);
    Widget widget4 = new Widget("", wid + gap * 2, hei + gap * 2, wid, hei);
    setWidgetStyles(widget4);
    contentPanel.add(widget4);
    return contentPanel;
}
Also used : Panel(com.spinyowl.legui.component.Panel) Widget(com.spinyowl.legui.component.Widget)

Example 7 with Panel

use of com.spinyowl.legui.component.Panel in project legui by SpinyOwl.

the class SingleClassExample2 method createLeftPanel.

private static Panel createLeftPanel() {
    Panel leftPanel = new Panel();
    leftPanel.getStyle().setMargin(20F);
    leftPanel.getStyle().setMinWidth(200F);
    leftPanel.getStyle().setWidth(200F);
    leftPanel.getStyle().setMinHeight(HEIGHT - 40F);
    leftPanel.getStyle().setPosition(RELATIVE);
    leftPanel.getStyle().getFlexStyle().setFlexDirection(COLUMN);
    leftPanel.getStyle().getFlexStyle().setJustifyContent(JustifyContent.FLEX_START);
    leftPanel.getStyle().getFlexStyle().setAlignContent(AlignContent.STRETCH);
    leftPanel.getStyle().getFlexStyle().setAlignItems(AlignItems.STRETCH);
    leftPanel.getStyle().setDisplay(FLEX);
    Panel personPanel = createPersonPanel();
    leftPanel.add(personPanel);
    SimpleLineBorder border = new SimpleLineBorder(ColorConstants.lightGray(), 0.8f);
    leftPanel.add(createMenuButton("Protect", border));
    leftPanel.add(createMenuButton("Some", border));
    leftPanel.add(createMenuButton("Cool", border));
    leftPanel.add(createMenuButton("Aliens", border));
    Button apply = new Button("\uF12C");
    setBottomButtonStyles(apply, border);
    apply.getStyle().getBackground().setColor(ColorUtil.rgba(0xa5, 0xd6, 0xa7, 1));
    apply.getStyle().setLeft(0);
    apply.getStyle().setBottom(0);
    leftPanel.add(apply);
    Button decline = new Button("\uF156");
    setBottomButtonStyles(decline, border);
    decline.getStyle().getBackground().setColor(ColorUtil.rgba(0xef, 0x9a, 0x9a, 1));
    decline.getStyle().setRight(0);
    decline.getStyle().setBottom(0);
    leftPanel.add(decline);
    return leftPanel;
}
Also used : Panel(com.spinyowl.legui.component.Panel) Button(com.spinyowl.legui.component.Button) SimpleLineBorder(com.spinyowl.legui.style.border.SimpleLineBorder)

Example 8 with Panel

use of com.spinyowl.legui.component.Panel in project legui by SpinyOwl.

the class SingleClassExample2 method createUI.

private static void createUI(Frame frame) {
    frame.getContainer().clearChildComponents();
    frame.getContainer().getStyle().setDisplay(FLEX);
    frame.getContainer().getStyle().getFlexStyle().setFlexDirection(ROW);
    frame.getContainer().getStyle().getBackground().setColor(ColorUtil.rgba(0xe1, 0xf5, 0xfe, 1));
    Panel leftPanel = createLeftPanel();
    frame.getContainer().add(leftPanel);
    Panel rightPanel = createRightPanel();
    frame.getContainer().add(rightPanel);
}
Also used : Panel(com.spinyowl.legui.component.Panel)

Example 9 with Panel

use of com.spinyowl.legui.component.Panel 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

Panel (com.spinyowl.legui.component.Panel)9 SimpleLineBorder (com.spinyowl.legui.style.border.SimpleLineBorder)5 Button (com.spinyowl.legui.component.Button)4 Component (com.spinyowl.legui.component.Component)4 Label (com.spinyowl.legui.component.Label)4 Widget (com.spinyowl.legui.component.Widget)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 ScrollablePanel (com.spinyowl.legui.component.ScrollablePanel)2 SplitPanel (com.spinyowl.legui.component.SplitPanel)2 TabbedPanel (com.spinyowl.legui.component.TabbedPanel)2 Tab (com.spinyowl.legui.component.TabbedPanel.Tab)2 TabStripPosition (com.spinyowl.legui.component.TabbedPanel.TabStripPosition)2 CursorEnterEvent (com.spinyowl.legui.event.CursorEnterEvent)2 KeyEvent (com.spinyowl.legui.event.KeyEvent)2 MouseClickEvent (com.spinyowl.legui.event.MouseClickEvent)2 CursorEnterEventListener (com.spinyowl.legui.listener.CursorEnterEventListener)2 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)2 PositionType (com.spinyowl.legui.style.Style.PositionType)2 ColorConstants (com.spinyowl.legui.style.color.ColorConstants)2 List (java.util.List)2