Skip to content

UIBridge

abstract class UIBridge
Implements: IUIBridge
Known subtypes: StackUIBridge
Package: dev.joid.lib.bridge.ui · Module: core · Source: UIBridge.java

The base class of every UI bridge, which dispatches the input to its UIs, updates them and draws them by layer.

A subclass decides what opening and closing a UI mean; StackUIBridge already does it with a screen stack, and is the usual base. UIBridgeRegistry calls the input methods and the steps of the frame; each input method returns true when the bridge consumed the event. Draw JOID over your own scene overrides drawBackground() to keep the scene of the host under the UIs.

ReturnsSignatureSummary
UIBridge() protectedCreates a bridge with no UI.

ReturnsSignatureSummary
voidload()Lays every UI of the bridge out at the current size of the window; the registry calls it when the size changes.
voidupdate()Updates every UI of the bridge; the registry calls it once per frame, before drawing.
ReturnsSignatureSummary
booleanmouseMoved()Sends a drag to the UIs from the top down while a button is held, and returns true when a UI consumed it; without a held button it does nothing, since the hover is read from the pointer position each frame.
booleanmousePressed(MouseButton button)Sends the press to the UIs from the top down, until one consumes it or a popup stops it, and remembers the UIs that received it for the release.
booleanmouseReleased(MouseButton button)Sends the release to the UIs from the top down and to every UI that received the press; returns true when the press was consumed, so that the host receives the release of every press it received.
booleanmouseScroll(double notchesX, double notchesY)Sends a scroll of that many notches to the UIs from the top down; a scroll of zero notches does nothing.
booleancharTyped(int codepoint)Sends a typed character, as a Unicode code point, to the UIs from the top down; control characters are ignored.
booleankeyPressed(Key physicalKey, Key key)Sends a key press to the UIs from the top down.
booleankeyReleased(Key physicalKey, Key key)Sends the release to the UIs from the top down and to every UI that received the press; returns true when the press was consumed.
booleanisKeyConsumed(Key key)If true, the last press of that key was consumed by this bridge.
ReturnsSignatureSummary
voiddraw()Draws every UI of the bridge; the same as draw(filter) with a filter that accepts every UI.
voiddraw(Predicate filter)Draws the shown UIs that the filter accepts: the overlays below the screens, then the screens and popups, then the overlays above the screens, each group in zindex order, then sets the cursor.
ReturnsSignatureSummary
booleanisOpen(UI ui)If true, the bridge holds the UI.
booleanisOnTop(UI ui)If true, the UI is the first of its kind to receive the input.
List<UI>getUiList()Returns the UIs of the bridge sorted by zindex, then by opening order.
booleanisScreenOpen()If true, the bridge holds a UI that is not an overlay.
booleanisOverlayHidden()If true, the overlays that do not ask to stay drawn are neither drawn nor given the input; false by default.
ReturnsSignatureSummary
voidadd(UI ui)Adds the UI to the list of the bridge.
voidremove(UI ui)Removes the UI from the list of the bridge.
voiddrawHover(UI ui, Object content, double mouseX, double mouseY)Draws nothing; with the dev jar, prints a warning once per bridge.
ReturnsSignatureSummary
voiddrawBackground() hook protectedJOID calls it once per frame on the bridge of the lowest priority only, before any UI is drawn; it does nothing by default.
booleanhasScreen() protectedIf true, the bridge holds a UI that is not an overlay.
Inherited from IUIBridge (5)

canHandle · getInterfaceScale · forceOpen · replace · closeAll

UIBridge() protected

Creates a bridge with no UI.

void load()

Lays every UI of the bridge out at the current size of the window; the registry calls it when the size changes.

void update()

Updates every UI of the bridge; the registry calls it once per frame, before drawing.

boolean mouseMoved()

Sends a drag to the UIs from the top down while a button is held, and returns true when a UI consumed it; without a held button it does nothing, since the hover is read from the pointer position each frame.

boolean mousePressed(MouseButton button)

Sends the press to the UIs from the top down, until one consumes it or a popup stops it, and remembers the UIs that received it for the release.

boolean mouseReleased(MouseButton button)

Sends the release to the UIs from the top down and to every UI that received the press; returns true when the press was consumed, so that the host receives the release of every press it received.

boolean mouseScroll(double notchesX, double notchesY)

Sends a scroll of that many notches to the UIs from the top down; a scroll of zero notches does nothing.

boolean charTyped(int codepoint)

Sends a typed character, as a Unicode code point, to the UIs from the top down; control characters are ignored.

boolean keyPressed(Key physicalKey, Key key)

Sends a key press to the UIs from the top down. Escape closes the top closeable UI that is not an overlay when no node consumed it (Know who receives the keyboard).

boolean keyReleased(Key physicalKey, Key key)

Sends the release to the UIs from the top down and to every UI that received the press; returns true when the press was consumed.

boolean isKeyConsumed(Key key)

If true, the last press of that key was consumed by this bridge.

void draw()

Draws every UI of the bridge; the same as draw(filter) with a filter that accepts every UI.

void draw(Predicate<UI> filter)

Throws:

  • IllegalStateException: ….draw() needs an open frame and the render bridge has none: call render.beginFrame() before and render.endFrame() after, or use BridgeHandler.UI.frame()

Draws the shown UIs that the filter accepts: the overlays below the screens, then the screens and popups, then the overlays above the screens, each group in zindex order, then sets the cursor. It first releases the GPU resources that nothing uses any more. Throws an IllegalStateException outside a frame of the render bridge; a draw that throws skips the rest of the frame of the bridge, puts the matrix and state stacks back and prints one warning.

boolean isOpen(UI ui)

If true, the bridge holds the UI.

boolean isOnTop(UI ui)

If true, the UI is the first of its kind to receive the input.

List<UI> getUiList()

Returns the UIs of the bridge sorted by zindex, then by opening order.

boolean isScreenOpen()

If true, the bridge holds a UI that is not an overlay. JOID never calls it: a host overrides it to answer for its own screens too.

boolean isOverlayHidden()

If true, the overlays that do not ask to stay drawn are neither drawn nor given the input; false by default. Override it to follow a host that hides its own interface.

void add(UI ui)

Adds the UI to the list of the bridge.

void remove(UI ui)

Removes the UI from the list of the bridge.

void drawHover(UI ui, Object content, double mouseX, double mouseY)

Draws nothing; with the dev jar, prints a warning once per bridge. Override it to draw tooltips, or extend WindowUIBridge.

void drawBackground() hook protected

JOID calls it once per frame on the bridge of the lowest priority only, before any UI is drawn; it does nothing by default. Override it to clear or paint the window.

boolean hasScreen() protected

If true, the bridge holds a UI that is not an overlay.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page