Class BaseWidget

    • Field Detail

      • emptyZones

        protected final Set<be.yildizgames.common.geometry.Rectangle> emptyZones
        List of zones to ignore to check if a point is inside the container.
    • Constructor Detail

      • BaseWidget

        protected BaseWidget​(String name,
                             be.yildizgames.module.coordinate.BaseCoordinate coordinates)
        Full constructor.
        Parameters:
        name - Widget unique name.
        coordinates - Widget initial size and position.
      • BaseWidget

        protected BaseWidget​(String name,
                             be.yildizgames.module.coordinate.BaseCoordinate coordinates,
                             Container parent)
        Full constructor.
        Parameters:
        name - Widget unique name.
        coordinates - Widget initial size and position.
        parent - Optional parent container.
    • Method Detail

      • addMouseLeftClickListener

        public final void addMouseLeftClickListener​(be.yildizgames.module.window.input.MouseLeftClickListener listener)
        Description copied from interface: Widget
        Add a new MouseClickListener on this widget.
        Specified by:
        addMouseLeftClickListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addMouseRightClickListener

        public final void addMouseRightClickListener​(be.yildizgames.module.window.input.MouseRightClickListener listener)
        Specified by:
        addMouseRightClickListener in interface Widget
      • addMouseDoubleLeftClickListener

        public final void addMouseDoubleLeftClickListener​(be.yildizgames.module.window.input.MouseDoubleLeftClickListener listener)
        Description copied from interface: Widget
        Add a new MouseDoubleClickListener on this widget.
        Specified by:
        addMouseDoubleLeftClickListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addMouseReleaseListener

        public final void addMouseReleaseListener​(be.yildizgames.module.window.input.MouseReleaseListener listener)
        Description copied from interface: Widget
        Add a new MouseReleaseClickListener on this widget.
        Specified by:
        addMouseReleaseListener in interface Widget
        Parameters:
        listener - Listener to add.
      • removeAllClickListeners

        public final void removeAllClickListeners()
        Description copied from interface: Widget
        Clear the list of all click listeners.
        Specified by:
        removeAllClickListeners in interface Widget
      • addKeyboardListener

        public final void addKeyboardListener​(be.yildizgames.module.window.input.KeyboardListener listener)
        Description copied from interface: Widget
        Add a new KeyboardListener on this widget and set the widget focusable.
        Specified by:
        addKeyboardListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addMouseMoveListener

        public final void addMouseMoveListener​(be.yildizgames.module.window.input.MouseMoveListener listener)
        Description copied from interface: Widget
        Add a new MouseMoveListener on this widget.
        Specified by:
        addMouseMoveListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addMouseWheelListener

        public final void addMouseWheelListener​(be.yildizgames.module.window.input.MouseWheelListener listener)
        Description copied from interface: Widget
        Add a new MouseWheelListener on this widget.
        Specified by:
        addMouseWheelListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addMouseDragListener

        public final void addMouseDragListener​(be.yildizgames.module.window.input.MouseDragListener listener)
        Description copied from interface: Widget
        Add a new MouseDragListener on this widget.
        Specified by:
        addMouseDragListener in interface Widget
        Parameters:
        listener - Listener to add.
      • addOnMouseOverListener

        public final void addOnMouseOverListener​(OnMouseOverListener listener)
        Description copied from interface: Widget
        Add a new OnMouseOverListener on this widget.
        Specified by:
        addOnMouseOverListener in interface Widget
        Parameters:
        listener - Listener to add.
      • highlightImpl

        protected abstract void highlightImpl​(boolean highlightState)
        Implementation to set the widget highlight.
        Parameters:
        highlightState - Highlight state.
      • contains

        public final boolean contains​(be.yildizgames.module.window.input.MousePosition position)
        Description copied from interface: Widget
        Check if a point in contained in this container.
        Specified by:
        contains in interface Widget
        Parameters:
        position - Point coordinates.
        Returns:
        true if the point is contained in this container, false otherwise.
      • contains

        public final boolean contains​(int x,
                                      int y)
        Specified by:
        contains in interface Widget
      • addEmptyZone

        public final void addEmptyZone​(be.yildizgames.common.geometry.Rectangle zone)
        Description copied from interface: Widget
        Add a zone to ignore when checking if the container contains the mouse, if the mouse position is inside this zone, it will be considered as outside of the container.
        Specified by:
        addEmptyZone in interface Widget
        Parameters:
        zone - Empty zone.
      • addEmptyZoneImpl

        protected abstract void addEmptyZoneImpl​(be.yildizgames.common.geometry.Rectangle zone)
      • mouseLeftClick

        public final void mouseLeftClick​(be.yildizgames.module.window.input.MousePosition position)
        Called when the mouse left button is pressed. Only to be used from the EventDispatcher.
        Parameters:
        position - Mouse position.
      • getAbsolutePosition

        public final be.yildizgames.common.geometry.Point2D getAbsolutePosition()
      • keyPressed

        public final void keyPressed​(char key)
        Called when a key is pressed on the keyboard. Only to be used from the EventDispatcher.
        Parameters:
        key - Character pressed.
      • specialKeyPressed

        public final void specialKeyPressed​(be.yildizgames.module.window.input.Key keyCode)
        Called when a special key is pressed on the keyboard. Only to be used from the EventDispatcher.
        Parameters:
        keyCode - Key pressed value.
      • highlight

        public final void highlight​(boolean over)
        Called when the highlight status must be updated.
        Specified by:
        highlight in interface Widget
        Parameters:
        over - New highlight status.
      • focus

        public final void focus​(boolean over)
        Called when the focus status must be updated.
        Specified by:
        focus in interface Widget
        Parameters:
        over - New focus status.
      • align

        public final void align​(Element.Alignment alignment)
        Description copied from interface: Widget
        Align the widget
        Specified by:
        align in interface Widget
        Parameters:
        alignment - New alignment value.
      • setMouseClickActive

        protected final void setMouseClickActive​(boolean active)
        Activate or disable the mouse button action on this widget.
        Parameters:
        active - true will set the mouse button active, false will deactivate them.
      • isFocusable

        public final boolean isFocusable()
        Specified by:
        isFocusable in interface Widget
        Returns:
        true if the widget can be focused, false otherwise.
      • setFocusable

        public final void setFocusable​(boolean focusable)
        Set the widget to be considered as focusable or not.
        Parameters:
        focusable - true to set the widget focusable.
      • setHighlightable

        protected final void setHighlightable​(boolean value)
        Set the widget to be considered as hightligthable or not.
        Parameters:
        value - true to make the widget highlitable.
      • setMouseOver

        public final Element setMouseOver​(boolean over,
                                          be.yildizgames.module.window.input.MousePosition position)
        Called when the mouse enter or get out of a widget.
        Parameters:
        over - New mouse over status.
        position - Current mouse position.
        Returns:
        This object for chaining.
      • isMouseOver

        protected final boolean isMouseOver()
        Returns:
        true if the mouse is over this widget.
      • forceContainsFalse

        public final void forceContainsFalse()
        Force the contains method to always return false, in order to ignore inputs.
      • toString

        public String toString()
        Overrides:
        toString in class be.yildizgames.common.util.BaseRegisterable
        Returns:
        The class name.
      • getAbsoluteLeft

        public final int getAbsoluteLeft()
        Description copied from interface: Widget
        Give the absolute left position instead of relative from parent.
        Specified by:
        getAbsoluteLeft in interface Widget
        Returns:
        The parent left position + the widget left position.
      • getAbsoluteTop

        public final int getAbsoluteTop()
        Description copied from interface: Widget
        Give the absolute top position instead of relative from parent.
        Specified by:
        getAbsoluteTop in interface Widget
        Returns:
        The parent top position + the widget top position.
      • isContainer

        public boolean isContainer()
      • disableEmptyZone

        public final void disableEmptyZone()
      • enableEmptyZone

        public final void enableEmptyZone()