Search in sources :

Example 1 with CharIcon

use of com.spinyowl.legui.icon.CharIcon 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)

Example 2 with CharIcon

use of com.spinyowl.legui.icon.CharIcon in project legui by SpinyOwl.

the class FlatSelectBoxTheme method apply.

/**
 * Used to apply theme only for component and not apply for child components.
 *
 * @param component component to apply theme.
 */
@Override
public void apply(T component) {
    super.apply(component);
    Button expandButton = component.getExpandButton();
    expandButton.getStyle().setShadow(null);
    expandButton.getStyle().getBackground().setColor(ColorConstants.transparent());
    Button selectionButton = component.getSelectionButton();
    selectionButton.getStyle().setShadow(null);
    selectionButton.getStyle().getBackground().setColor(ColorConstants.transparent());
    Icon collapseIcon = component.getCollapseIcon();
    if (collapseIcon instanceof CharIcon) {
        CharIcon bgIcon = (CharIcon) collapseIcon;
        bgIcon.setColor(ColorUtil.oppositeBlackOrWhite(settings.backgroundColor()));
        bgIcon.setHorizontalAlign(HorizontalAlign.CENTER);
        bgIcon.setVerticalAlign(VerticalAlign.MIDDLE);
    }
    Icon expandIcon = component.getExpandIcon();
    if (expandIcon instanceof CharIcon) {
        CharIcon bgIcon = (CharIcon) expandIcon;
        bgIcon.setColor(ColorUtil.oppositeBlackOrWhite(settings.backgroundColor()));
        bgIcon.setHorizontalAlign(HorizontalAlign.CENTER);
        bgIcon.setVerticalAlign(VerticalAlign.MIDDLE);
    }
}
Also used : Button(com.spinyowl.legui.component.Button) CharIcon(com.spinyowl.legui.icon.CharIcon) Icon(com.spinyowl.legui.icon.Icon) CharIcon(com.spinyowl.legui.icon.CharIcon)

Example 3 with CharIcon

use of com.spinyowl.legui.icon.CharIcon in project legui by SpinyOwl.

the class FlatCheckBoxTheme method apply.

/**
 * Used to apply theme only for component and not apply for child components.
 *
 * @param component component to apply theme.
 */
@Override
public void apply(T component) {
    super.apply(component);
    component.setIconUnchecked(new CharIcon(new Vector2f(14), MATERIAL_ICONS_REGULAR, (char) 0xE835, ColorUtil.oppositeBlackOrWhite(settings.backgroundColor())));
    component.setIconChecked(new CharIcon(new Vector2f(14), MATERIAL_ICONS_REGULAR, (char) 0xE834, ColorUtil.oppositeBlackOrWhite(settings.backgroundColor())));
    component.getIconUnchecked().setHorizontalAlign(HorizontalAlign.LEFT);
    component.getIconChecked().setHorizontalAlign(HorizontalAlign.LEFT);
}
Also used : Vector2f(org.joml.Vector2f) CharIcon(com.spinyowl.legui.icon.CharIcon)

Example 4 with CharIcon

use of com.spinyowl.legui.icon.CharIcon in project legui by SpinyOwl.

the class FlatWidgetTheme method applyAll.

/**
 * Used to apply theme for component and for all children of this component. Should be
 * reimplemented for components that contains other child components.
 *
 * @param component component to apply theme.
 */
@Override
public void applyAll(T component) {
    super.apply(component);
    component.getStyle().getBackground().setColor(settings.backgroundColor());
    Button minimizeButton = component.getMinimizeButton();
    minimizeButton.getStyle().getBackground().setColor(settings.borderColor());
    minimizeButton.getStyle().setShadow(null);
    Button closeButton = component.getCloseButton();
    closeButton.getStyle().getBackground().setColor(settings.borderColor());
    closeButton.getStyle().setShadow(null);
    Component titleContainer = component.getTitleContainer();
    titleContainer.getStyle().getBackground().setColor(settings.borderColor());
    Button resizeButton = component.getResizeButton();
    resizeButton.getStyle().setBorder(null);
    resizeButton.getStyle().getBackground().setColor(ColorConstants.transparent());
    resizeButton.getHoveredStyle().getBackground().setColor(ColorConstants.transparent());
    resizeButton.getPressedStyle().getBackground().setColor(ColorConstants.transparent());
    CharIcon icon = new CharIcon(FontRegistry.MATERIAL_DESIGN_ICONS, '\uF45D');
    icon.setHorizontalAlign(HorizontalAlign.RIGHT);
    icon.setVerticalAlign(VerticalAlign.BOTTOM);
    icon.setColor(settings.textColor());
    resizeButton.getStyle().getBackground().setIcon(icon);
    resizeButton.getStyle().setShadow(null);
    component.getTitle().getStyle().setPadding(3f, 5f);
    Icon closeIcon = component.getCloseIcon();
    if (closeIcon instanceof CharIcon) {
        CharIcon bgIcon = (CharIcon) closeIcon;
        bgIcon.setColor(settings.textColor());
        bgIcon.setHorizontalAlign(HorizontalAlign.CENTER);
        bgIcon.setVerticalAlign(VerticalAlign.MIDDLE);
    }
    Icon minimizeIcon = component.getMinimizeIcon();
    if (minimizeIcon instanceof CharIcon) {
        CharIcon bgIcon = (CharIcon) minimizeIcon;
        bgIcon.setColor(settings.textColor());
        bgIcon.setHorizontalAlign(HorizontalAlign.CENTER);
        bgIcon.setVerticalAlign(VerticalAlign.MIDDLE);
    }
    Icon maximizeIcon = component.getMaximizeIcon();
    if (maximizeIcon instanceof CharIcon) {
        CharIcon bgIcon = (CharIcon) maximizeIcon;
        bgIcon.setColor(settings.textColor());
        bgIcon.setHorizontalAlign(HorizontalAlign.CENTER);
        bgIcon.setVerticalAlign(VerticalAlign.MIDDLE);
    }
    Themes.getDefaultTheme().applyAll(component.getContainer());
    component.getContainer().getStyle().setShadow(null);
}
Also used : Button(com.spinyowl.legui.component.Button) CharIcon(com.spinyowl.legui.icon.CharIcon) Icon(com.spinyowl.legui.icon.Icon) CharIcon(com.spinyowl.legui.icon.CharIcon) Component(com.spinyowl.legui.component.Component)

Example 5 with CharIcon

use of com.spinyowl.legui.icon.CharIcon in project legui by SpinyOwl.

the class FlatRadioButtonTheme method apply.

/**
 * Used to apply theme only for component and not apply for child components.
 *
 * @param component component to apply theme.
 */
@Override
public void apply(T component) {
    super.apply(component);
    component.setIconUnchecked(new CharIcon(new Vector2f(14), MATERIAL_ICONS_REGULAR, (char) 0xE836, ColorUtil.oppositeBlackOrWhite(settings.backgroundColor())));
    component.setIconChecked(new CharIcon(new Vector2f(14), MATERIAL_ICONS_REGULAR, (char) 0xE837, ColorUtil.oppositeBlackOrWhite(settings.backgroundColor())));
    component.getIconUnchecked().setHorizontalAlign(HorizontalAlign.LEFT);
    component.getIconChecked().setHorizontalAlign(HorizontalAlign.LEFT);
}
Also used : Vector2f(org.joml.Vector2f) CharIcon(com.spinyowl.legui.icon.CharIcon)

Aggregations

CharIcon (com.spinyowl.legui.icon.CharIcon)6 Vector2f (org.joml.Vector2f)4 Button (com.spinyowl.legui.component.Button)2 Icon (com.spinyowl.legui.icon.Icon)2 Component (com.spinyowl.legui.component.Component)1 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 WidgetCloseButMouseClickEventListener (com.spinyowl.legui.component.misc.listener.widget.WidgetCloseButMouseClickEventListener)1 WidgetDragListener (com.spinyowl.legui.component.misc.listener.widget.WidgetDragListener)1 WidgetMinimizeButMouseClickEventListener (com.spinyowl.legui.component.misc.listener.widget.WidgetMinimizeButMouseClickEventListener)1 WidgetResizeButtonDragListener (com.spinyowl.legui.component.misc.listener.widget.WidgetResizeButtonDragListener)1 FocusEvent (com.spinyowl.legui.event.FocusEvent)1 FocusEventListener (com.spinyowl.legui.listener.FocusEventListener)1 MouseClickEventListener (com.spinyowl.legui.listener.MouseClickEventListener)1