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