Search in sources :

Example 1 with FocusEventListener

use of com.spinyowl.legui.listener.FocusEventListener in project legui by SpinyOwl.

the class SelectBox method initialize.

/**
 * Used to initialize selectbox.
 */
private void initialize() {
    selectionListPanel.setHorizontalScrollBarVisible(false);
    selectionListPanel.getContainer().getStyle().setDisplay(DisplayType.FLEX);
    selectionListPanel.getContainer().getStyle().getFlexStyle().setFlexDirection(FlexDirection.COLUMN);
    selectionListPanel.getContainer().getStyle().getBackground().setColor(ColorConstants.lightBlue());
    this.getStyle().setDisplay(DisplayType.FLEX);
    expandIcon = new CharIcon(new Vector2f(expandButton.getSize()), DEFAULT_ICON_FONT, (char) EXPAND_ICON_CHAR, ColorConstants.black());
    collapseIcon = new CharIcon(new Vector2f(expandButton.getSize()), DEFAULT_ICON_FONT, (char) COLLAPSE_ICON_CHAR, ColorConstants.black());
    expandButton.getStyle().getBackground().setIcon(expandIcon);
    expandButton.getStyle().setMinimumSize(buttonWidth, 0);
    expandButton.getStyle().setMaximumSize(buttonWidth, Float.MAX_VALUE);
    expandButton.getStyle().setRight(0f);
    expandButton.getStyle().setTop(0f);
    expandButton.getStyle().setBottom(0f);
    selectionButton.getStyle().setTop(0f);
    selectionButton.getStyle().setLeft(0f);
    selectionButton.getStyle().setBottom(0f);
    selectionButton.getStyle().setRight(buttonWidth);
    this.add(expandButton);
    this.add(selectionButton);
    MouseClickEventListener mouseClickEventListener = new SelectBoxClickListener<>(this);
    selectionButton.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
    expandButton.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
    selectBoxLayer.getListenerMap().addListener(MouseClickEvent.class, mouseClickEventListener);
    FocusEventListener focusEventListener = new SelectBoxFocusListener<>(this);
    selectionListPanel.getVerticalScrollBar().getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
    selectionButton.getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
    expandButton.getListenerMap().getListeners(FocusEvent.class).add(focusEventListener);
    selectBoxLayer.add(selectionListPanel);
    SelectBoxAnimation animation = new SelectBoxAnimation(this, selectionListPanel);
    animation.startAnimation();
    Themes.getDefaultTheme().getThemeManager().getComponentTheme(SelectBox.class).applyAll(this);
}
Also used : SelectBoxClickListener(com.spinyowl.legui.component.misc.listener.selectbox.SelectBoxClickListener) SelectBoxFocusListener(com.spinyowl.legui.component.misc.listener.selectbox.SelectBoxFocusListener) MouseClickEventListener(com.spinyowl.legui.listener.MouseClickEventListener) FocusEventListener(com.spinyowl.legui.listener.FocusEventListener) Vector2f(org.joml.Vector2f) CharIcon(com.spinyowl.legui.icon.CharIcon) SelectBoxAnimation(com.spinyowl.legui.component.misc.animation.selectbox.SelectBoxAnimation) FocusEvent(com.spinyowl.legui.event.FocusEvent)

Aggregations

SelectBoxAnimation (com.spinyowl.legui.component.misc.animation.selectbox.SelectBoxAnimation)1 SelectBoxClickListener (com.spinyowl.legui.component.misc.listener.selectbox.SelectBoxClickListener)1 SelectBoxFocusListener (com.spinyowl.legui.component.misc.listener.selectbox.SelectBoxFocusListener)1 FocusEvent (com.spinyowl.legui.event.FocusEvent)1 CharIcon (com.spinyowl.legui.icon.CharIcon)1 FocusEventListener (com.spinyowl.legui.listener.FocusEventListener)1 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)1 Vector2f (org.joml.Vector2f)1