Interface CottonHud.Positioner

Enclosing class:
CottonHud
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public static interface CottonHud.Positioner
Positioners can be used to change the position of a widget based on the window dimensions.
  • Method Summary

    Modifier and Type
    Method
    Description
    Creates a new positioner that centers widgets on the X axis and offsets them on the Y axis.
    of(int x, int y)
    Creates a new positioner that offsets widgets.
    void
    reposition(WWidget widget, int hudWidth, int hudHeight)
    Repositions the widget according to the HUD dimensions.
  • Method Details

    • reposition

      void reposition(WWidget widget, int hudWidth, int hudHeight)
      Repositions the widget according to the HUD dimensions.
      Parameters:
      widget - the widget
      hudWidth - the width of the HUD
      hudHeight - the height of the HUD
    • of

      static CottonHud.Positioner of(int x, int y)
      Creates a new positioner that offsets widgets.

      If an offset is negative, the offset is subtracted from the HUD dimension on that axis.

      Parameters:
      x - the x offset
      y - the y offset
      Returns:
      an offsetting positioner
    • horizontallyCentered

      static CottonHud.Positioner horizontallyCentered(int y)
      Creates a new positioner that centers widgets on the X axis and offsets them on the Y axis.

      If the Y offset is negative, the offset is subtracted from the HUD height.

      Parameters:
      y - the y offset
      Returns:
      a centering positioner