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.
Description
Section titled “Description”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.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
| UIBridge() protected | Creates a bridge with no UI. |
Methods
Section titled “Methods”Lifecycle
Section titled “Lifecycle”| Returns | Signature | Summary |
|---|---|---|
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. |
| Returns | Signature | Summary |
|---|---|---|
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. |
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. |
Drawing
Section titled “Drawing”| Returns | Signature | Summary |
|---|---|---|
void | draw() | Draws every UI of the bridge; the same as draw(filter) with a filter that accepts every UI. |
void | draw(Predicate | 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. |
Queries
Section titled “Queries”| Returns | Signature | Summary |
|---|---|---|
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. |
boolean | isOverlayHidden() | If true, the overlays that do not ask to stay drawn are neither drawn nor given the input; false by default. |
Actions
Section titled “Actions”| Returns | Signature | Summary |
|---|---|---|
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. |
For subclasses
Section titled “For subclasses”| Returns | Signature | Summary |
|---|---|---|
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. |
boolean | hasScreen() protected | If true, the bridge holds a UI that is not an overlay. |
Creation details
Section titled “Creation details”UIBridge
Section titled “UIBridge”UIBridge() protected
Creates a bridge with no UI.
Method details
Section titled “Method details”void load()
Lays every UI of the bridge out at the current size of the window; the registry calls it when the size changes.
update
Section titled “update”void update()
Updates every UI of the bridge; the registry calls it once per frame, before drawing.
mouseMoved
Section titled “mouseMoved”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.
mousePressed
Section titled “mousePressed”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.
mouseReleased
Section titled “mouseReleased”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.
mouseScroll
Section titled “mouseScroll”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.
charTyped
Section titled “charTyped”boolean charTyped(int codepoint)
Sends a typed character, as a Unicode code point, to the UIs from the top down; control characters are ignored.
keyPressed
Section titled “keyPressed”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).
keyReleased
Section titled “keyReleased”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.
isKeyConsumed
Section titled “isKeyConsumed”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.
isOpen
Section titled “isOpen”boolean isOpen(UI ui)
If true, the bridge holds the UI.
isOnTop
Section titled “isOnTop”boolean isOnTop(UI ui)
If true, the UI is the first of its kind to receive the input.
getUiList
Section titled “getUiList”List<UI> getUiList()
Returns the UIs of the bridge sorted by zindex, then by opening order.
isScreenOpen
Section titled “isScreenOpen”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.
isOverlayHidden
Section titled “isOverlayHidden”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.
remove
Section titled “remove”void remove(UI ui)
Removes the UI from the list of the bridge.
drawHover
Section titled “drawHover”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.
drawBackground
Section titled “drawBackground”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.
hasScreen
Section titled “hasScreen”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
