Class BoxLayoutWidget

java.lang.Object
com.avrix.ui.widgets.Widget
com.avrix.ui.widgets.BoxLayoutWidget
Direct Known Subclasses:
HorizontalBoxWidget, VerticalBoxWidget

public class BoxLayoutWidget extends Widget
A Widget that serves as a base class for layout containers like VerticalBoxWidget and HorizontalBoxWidget. It provides common functionality for arranging child widgets with a specified margin between them.
  • Constructor Details

    • BoxLayoutWidget

      public BoxLayoutWidget(int x, int y, int width, int height, boolean autoresize)
      Constructs a new Widget with the specified position and size.
      Parameters:
      x - the x-coordinate of the Widget
      y - the y-coordinate of the Widget
      width - the width of the Widget
      height - the height of the Widget
      autoresize - whether the Widget should automatically resize to fit its children
  • Method Details

    • addChild

      public void addChild(Widget widget)
      Adds a child widget to this widget's list of children.
      Overrides:
      addChild in class Widget
      Parameters:
      widget - the widget to add as a child
    • removeChild

      public void removeChild(Widget widget)
      Removes a child widget from this widget's list of children.
      Overrides:
      removeChild in class Widget
      Parameters:
      widget - the widget to remove from the list of children
    • updateLayout

      public void updateLayout()
      Updates the layout of the Widget, positioning its children with the specified margin between them. Adjusts the size of the widget if autoresize is enabled.
    • isUpdatingLayout

      public boolean isUpdatingLayout()
      Checks if the layout is currently being updated.
      Returns:
      true if the layout is being updated, false otherwise
    • setUpdatingLayout

      public void setUpdatingLayout(boolean updatingLayout)
      Sets the updating layout status.
      Parameters:
      updatingLayout - true if the layout is being updated, false otherwise
    • getMargin

      public final int getMargin()
      Returns the margin between child Widgets.
      Returns:
      the margin between child Widgets
    • setMargin

      public final void setMargin(int margin)
      Sets the margin between child Widgets.
      Parameters:
      margin - the margin between child Widgets
    • isAutoresize

      public final boolean isAutoresize()
      Returns whether the Widget automatically resizes to fit its children.
      Returns:
      true if the Widget automatically resizes to fit its children, false otherwise
    • setAutoresize

      public final void setAutoresize(boolean autoresize)
      Sets whether the Widget should automatically resize to fit its children.
      Parameters:
      autoresize - true if the Widget should automatically resize to fit its children, false otherwise
    • render

      public void render()
      Renders the Widget
      Specified by:
      render in class Widget