Class PageNavigationWidget

java.lang.Object
johnsmith.enchantingoverhauled.client.gui.widget.enchant.PageNavigationWidget

public class PageNavigationWidget extends Object
Handles the rendering and interaction for the pagination controls (Next/Previous page buttons) located in the Enchantment Screen.

Calculates bounds, manages hover states, and delegates scroll/click inputs to modify the active visible offset of the enchantment list.

  • Constructor Summary

    Constructors
    Constructor
    Description
    PageNavigationWidget(EnchantmentMenu menu, MenuLayoutConfig layout, IntSupplier offsetSupplier, IntConsumer offsetUpdater, Runnable onPageChanged)
    Constructs a new PageNavigationWidget.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    mouseClicked(double mouseX, double mouseY, int button)
    Handles left-click interactions for navigating the pages.
    boolean
    mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount)
    Handles mouse wheel scrolling for navigating the pages.
    void
    render(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, float partialTick)
    Renders the previous and next page buttons to the screen, updating their hover and enabled states based on the current context array size and offset.
    void
    updatePosition(int alignX, int alignY)
    Updates the alignment origin for the widget buttons.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PageNavigationWidget

      public PageNavigationWidget(EnchantmentMenu menu, MenuLayoutConfig layout, IntSupplier offsetSupplier, IntConsumer offsetUpdater, Runnable onPageChanged)
      Constructs a new PageNavigationWidget.
      Parameters:
      menu - The active EnchantmentMenu containing context data.
      layout - The layout configuration dictating positioning.
      offsetSupplier - A supplier providing the current list offset.
      offsetUpdater - A consumer accepting the new list offset upon navigation.
      onPageChanged - A callback executed when a navigation event occurs.
  • Method Details

    • updatePosition

      public void updatePosition(int alignX, int alignY)
      Updates the alignment origin for the widget buttons.
      Parameters:
      alignX - The parent screen's left position.
      alignY - The parent screen's top position.
    • render

      public void render(net.minecraft.client.gui.GuiGraphics context, int mouseX, int mouseY, float partialTick)
      Renders the previous and next page buttons to the screen, updating their hover and enabled states based on the current context array size and offset.
      Parameters:
      context - The GUI graphics context.
      mouseX - The current mouse X coordinate.
      mouseY - The current mouse Y coordinate.
      partialTick - The partial tick time.
    • mouseClicked

      public boolean mouseClicked(double mouseX, double mouseY, int button)
      Handles left-click interactions for navigating the pages.
      Parameters:
      mouseX - The mouse X coordinate.
      mouseY - The mouse Y coordinate.
      button - The mouse button pressed (0 for left).
      Returns:
      true if the event was consumed, false otherwise.
    • mouseScrolled

      public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmount, double verticalAmount)
      Handles mouse wheel scrolling for navigating the pages.
      Parameters:
      mouseX - The mouse X coordinate.
      mouseY - The mouse Y coordinate.
      horizontalAmount - The horizontal scroll delta.
      verticalAmount - The vertical scroll delta.
      Returns:
      true if the event was consumed, false otherwise.