Search in sources :

Example 1 with MouseClickEvent

use of com.spinyowl.legui.event.MouseClickEvent in project legui by SpinyOwl.

the class SplitPanelSeparatorListenerDelegate method process.

/**
 * Used to handle specific event.
 *
 * @param event event to handle.
 */
@Override
public void process(Event event) {
    if (!event.getTargetComponent().equals(splitPanel.getSeparator())) {
        return;
    }
    if (event instanceof MouseClickEvent) {
        MouseClickEvent e = (MouseClickEvent) event;
        if (e.getAction() == PRESS) {
            dragging = true;
        }
        if (e.getAction() == RELEASE) {
            dragging = false;
            CursorServiceProvider.getInstance().setCursor(Cursor.ARROW, e.getContext());
        }
    }
    if (event instanceof CursorEnterEvent) {
        CursorEnterEvent e = (CursorEnterEvent) event;
        Orientation orientation = splitPanel.getOrientation();
        if (e.isEntered() && orientation == HORIZONTAL) {
            CursorServiceProvider.getInstance().setCursor(Cursor.H_RESIZE, e.getContext());
        } else if (e.isEntered() && orientation != HORIZONTAL) {
            CursorServiceProvider.getInstance().setCursor(Cursor.V_RESIZE, e.getContext());
        } else if (!dragging) {
            CursorServiceProvider.getInstance().setCursor(Cursor.ARROW, e.getContext());
        }
    }
}
Also used : CursorEnterEvent(com.spinyowl.legui.event.CursorEnterEvent) Orientation(com.spinyowl.legui.component.optional.Orientation) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent)

Example 2 with MouseClickEvent

use of com.spinyowl.legui.event.MouseClickEvent in project legui by SpinyOwl.

the class ExampleGui method createButtonWithTooltip.

private Button createButtonWithTooltip() {
    Button button = new Button(20, 170, 50, 20);
    /*button.getStyle().getBackground().setColor(new Vector4f(1));*/
    button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) System.out::println);
    Tooltip tooltip = new Tooltip("Just button");
    button.setTooltip(tooltip);
    tooltip.setPosition(0, 25);
    tooltip.getSize().set(50, 60);
    tooltip.getStyle().setPadding(4f);
    tooltip.getListenerMap().addListener(TooltipTextSizeChangeEvent.class, e -> tooltip.setSize(50, e.getHeight()));
    int[] idv = { 0 };
    button.getListenerMap().addListener(MouseClickEvent.class, (MouseClickEventListener) (MouseClickEvent event) -> {
        if (event.getAction().equals(CLICK)) {
            idv[0]++;
            HorizontalAlign h;
            VerticalAlign v;
            int hh = idv[0] % 3;
            int vv = (idv[0] / 3) % 3;
            switch(hh) {
                case 0:
                    h = LEFT;
                    break;
                case 1:
                    h = CENTER;
                    break;
                case 2:
                default:
                    h = RIGHT;
                    break;
            }
            switch(vv) {
                case 0:
                    v = TOP;
                    break;
                case 1:
                    v = MIDDLE;
                    break;
                case 2:
                default:
                    v = BOTTOM;
                    break;
            }
            System.out.println(h + " " + v);
            tooltip.getStyle().setHorizontalAlign(h);
            tooltip.getStyle().setVerticalAlign(v);
        }
    });
    return button;
}
Also used : VerticalAlign(com.spinyowl.legui.component.optional.align.VerticalAlign) Button(com.spinyowl.legui.component.Button) RadioButton(com.spinyowl.legui.component.RadioButton) ToggleButton(com.spinyowl.legui.component.ToggleButton) Tooltip(com.spinyowl.legui.component.Tooltip) HorizontalAlign(com.spinyowl.legui.component.optional.align.HorizontalAlign) MouseClickEvent(com.spinyowl.legui.event.MouseClickEvent)

Aggregations

MouseClickEvent (com.spinyowl.legui.event.MouseClickEvent)2 Button (com.spinyowl.legui.component.Button)1 RadioButton (com.spinyowl.legui.component.RadioButton)1 ToggleButton (com.spinyowl.legui.component.ToggleButton)1 Tooltip (com.spinyowl.legui.component.Tooltip)1 Orientation (com.spinyowl.legui.component.optional.Orientation)1 HorizontalAlign (com.spinyowl.legui.component.optional.align.HorizontalAlign)1 VerticalAlign (com.spinyowl.legui.component.optional.align.VerticalAlign)1 CursorEnterEvent (com.spinyowl.legui.event.CursorEnterEvent)1