Class: Teek::UI::Realizer
- Inherits:
-
Object
- Object
- Teek::UI::Realizer
- Defined in:
- lib/teek/ui/realizer.rb
Overview
Layout is real for +:column+/+:row+ (flow packing driven by
+gap:+/+align:+/+pad:+ and each child's grow:), :grid (real Tk
grid arrangement driven by +#cell+/+#stretch+), and a ui.canvas
child positioned via #overlay (Tk place, driven by an anchor -
see OverlayAnchors) - everything else is still a placeholder,
its children just packing top-to-bottom with no options.
Walks a Document and realizes it into a live App - two passes (Resolved decision #4 in the architecture doc):
create- creates every widget, allocates a hierarchical/meaningful Tk path per node, fills each node'srealizedslot.link- applies (placeholder, see below) geometry and wires event bindings, resolvingtarget:references by name. Runs aftercreatehas finished the WHOLE tree, so a target declared later in the build already has a live path by the time it's looked up - that ordering is what makes forward references work.
Every widget creation and mutation goes through App#command, so teek's interceptor/leak-cleanup layer applies automatically.
Constant Summary collapse
- RESERVED_OPTIONS =
DSL-reserved opts keys - layout keywords (gap:/align:/pad:/ stretch_columns/stretch_rows) plus other entries the DSL stashes on node.opts for the realizer to pick up later (on_close:, and title:/ geometry:/resizable:/transient:/modal: for :window nodes, applied by WindowRealize; x:/y: for :scrollable and native-scrollable nodes, applied by #create_scrollable/#create_native_scrollable; scroll: for native-scrollable nodes, applied by #auto_scrollable?; tab_label for :tab nodes, applied by TabRealize; pane_weight for :pane nodes, applied by PaneRealize) - none of these are real Tk options, so none are ever passed through to a widget-creation call. +:split+'s own
orient:isn't reserved - it's a realttk::panedwindowoption already, so it passes straight through. %i[ gap align pad stretch_columns stretch_rows on_close title geometry resizable transient modal x y scroll tab_label pane_weight ].freeze
Instance Method Summary collapse
-
#initialize(app, document, default_scroll: nil) ⇒ Realizer
constructor
private
A new instance of Realizer.
- #realize ⇒ void
-
#realize_subtree(node, parent_node) ⇒ void
Realize a single already-built (but not-yet-realized) node - and its descendants - into an already-running app, scoped under a parent that's realized already.
Constructor Details
#initialize(app, document, default_scroll: nil) ⇒ Realizer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Realizer.
52 53 54 55 56 |
# File 'lib/teek/ui/realizer.rb', line 52 def initialize(app, document, default_scroll: nil) @app = app @document = document @default_scroll = default_scroll end |
Instance Method Details
#realize ⇒ void
This method returns an undefined value.
59 60 61 62 |
# File 'lib/teek/ui/realizer.rb', line 59 def realize create(@document.root, '.') link(@document.root) end |
#realize_subtree(node, parent_node) ⇒ void
This method returns an undefined value.
Realize a single already-built (but not-yet-realized) node - and its descendants - into an already-running app, scoped under a parent that's realized already. Reuses the exact same create/link machinery #realize uses for the initial tree, just entered at an arbitrary node instead of the document root - see Session#add.
72 73 74 75 76 77 78 79 |
# File 'lib/teek/ui/realizer.rb', line 72 def realize_subtree(node, parent_node) create(node, parent_node.realized.path) # re-arrange ALL of parent_node's children (old + new), not just the # new one in isolation - gap:/align: positioning depends on a # child's index relative to every sibling, not just itself. arrange_children(parent_node) link(node) end |