manager
FreeBodyEngine.ui.manager
#
KEY_CHAR_MAP = {Key.A: ('a', 'A'), Key.B: ('b', 'B'), Key.C: ('c', 'C'), Key.D: ('d', 'D'), Key.E: ('e', 'E'), Key.F: ('f', 'F'), Key.G: ('g', 'G'), Key.H: ('h', 'H'), Key.I: ('i', 'I'), Key.J: ('j', 'J'), Key.K: ('k', 'K'), Key.L: ('l', 'L'), Key.M: ('m', 'M'), Key.N: ('n', 'N'), Key.O: ('o', 'O'), Key.P: ('p', 'P'), Key.Q: ('q', 'Q'), Key.R: ('r', 'R'), Key.S: ('s', 'S'), Key.T: ('t', 'T'), Key.U: ('u', 'U'), Key.V: ('v', 'V'), Key.W: ('w', 'W'), Key.X: ('x', 'X'), Key.Y: ('y', 'Y'), Key.Z: ('z', 'Z'), Key.ONE: ('1', '!'), Key.TWO: ('2', '@'), Key.THREE: ('3', '#'), Key.FOUR: ('4', '$'), Key.FIVE: ('5', '%'), Key.SIX: ('6', '^'), Key.SEVEN: ('7', '&'), Key.EIGHT: ('8', '*'), Key.NINE: ('9', '('), Key.ZERO: ('0', ')'), Key.SPACE: (' ', ' '), Key.MINUS: ('-', '_'), Key.EQUAL: ('=', '+'), Key.LEFT_BRACKET: ('[', '{'), Key.RIGHT_BRACKET: (']', '}'), Key.BACKSLASH: ('\\', '|'), Key.SEMICOLON: (';', ':'), Key.APOSTROPHE: ("'", '"'), Key.TILDE: ('`', '~'), Key.COMMA: (',', '<'), Key.PERIOD: ('.', '>'), Key.SLASH: ('/', '?')}
module-attribute
#
LEFT_MOUSE_BUTTON = 0
module-attribute
#
UIManager(styles={})
#
Bases: Service
Engine service owning the UI tree's root element - the entry point for adding/removing top-level UI elements, and for driving their layout/ animation update plus mouse hit-testing, keyboard text-input routing, and wheel scrolling (see the INTERACTION style docs in ui/element.py).
Args: styles: Root-level styles, sized to the current framebuffer.
SCROLL_SPEED = 40.0
class-attribute
instance-attribute
#
root = RootElement(win_size[0], win_size[1], styles)
instance-attribute
#
add(element)
#
Adds element as a top-level child of the UI root.
draw()
#
Draws the UI tree.
on_destroy()
#
Unregisters the callbacks registered in on_initialize.
on_initialize()
#
Registers the resize/draw/update callbacks this service needs while active.
paste_text(pasted)
#
Inserts pasted into the focused field at the cursor, or does
nothing if there's no focused field or pasted is empty/None.
Factored out of _on_key's own Ctrl+V handling so a backend that
can't answer Window.get_clipboard_text() synchronously (see
WebWindow's own docstring on exactly this - the browser Clipboard
API is async, this engine's clipboard contract isn't) can still
support pasting by calling this directly once it does have the
text in hand, from wherever it actually got it (WebWindow does
this from the browser's native paste DOM event instead, which -
unlike navigator.clipboard.readText() - hands over clipboard
contents synchronously as part of the event itself).
remove(element)
#
Removes element from the UI root's children.
resize(size)
#
Resizes the root layout area to match the new framebuffer size.
update()
#
Advances any running style animations, recalculates the whole tree's layout from the (possibly now-changed) styles, then runs mouse hit-testing/hover/click/scroll for this frame.