Class GuiRenderer

java.lang.Object
com.ultikits.ultitools.abstracts.gui.declarative.engine.GuiRenderer

public class GuiRenderer extends Object
Owns the element tree and emits a complete immutable Grid after each successful build. No inventory, click table or backend diff is kept here. A failed build never calls the sink, so the backend retains the previous complete picture.
Since:
6.2.0
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • title

      private final Text title
    • rows

      private final int rows
    • scheduler

      private final GuiScheduler scheduler
    • sink

      private final Consumer<Grid> sink
    • frameTask

      private final Runnable frameTask
    • warnedSlots

      private final Map<GuiRenderer.WarningKind, Set<Integer>> warnedSlots
    • rootElement

      @Nullable private @Nullable Element rootElement
    • widgetSupplier

      @Nullable private @Nullable Supplier<Widget> widgetSupplier
    • rootContext

      @Nullable private @Nullable BuildContext rootContext
    • buildInProgress

      private boolean buildInProgress
    • rebuildRequestedDuringBuild

      private boolean rebuildRequestedDuringBuild
  • Constructor Details

    • GuiRenderer

      public GuiRenderer(Text title, int rows, GuiScheduler scheduler, Consumer<Grid> sink)
      Creates a snapshot renderer; the caller supplies the first frame to UiService and later frames to its session.
      Parameters:
      title - deferred screen title
      rows - the fixed row count, 1..6
      scheduler - the viewer's frame scheduler
      sink - receiver of complete frames
  • Method Details

    • initialize

      public void initialize(@NotNull @NotNull Supplier<Widget> widgetSupplier, @NotNull @NotNull BuildContext context)
      Builds the first frame now on the owning thread, or submits it to that thread. The supplier is evaluated exactly once per frame, including the first.
      Parameters:
      widgetSupplier - the current widget tree
      context - root build context, reused after remounts
    • scheduleBuild

      public void scheduleBuild()
      Requests one later frame; requests during a build are replayed after it exits, never re-entrantly.
    • performBuild

      private void performBuild()
    • mountRoot

      private void mountRoot(Widget widget)
    • rebuildElement

      private void rebuildElement(Element element)
    • collectRenderNodes

      private List<RenderNode> collectRenderNodes(Element element)
    • collectRenderNodesRecursive

      private void collectRenderNodesRecursive(Element element, List<RenderNode> nodes)
    • dispose

      public void dispose()
      Cancels submitted work, detaches build notifications and releases every owned element.
    • getScheduler

      @NotNull public @NotNull GuiScheduler getScheduler()
      Returns:
      the viewer's frame scheduler
    • warnOnce

      private void warnOnce(GuiRenderer.WarningKind kind, int slot, String message)