@papercraftgames/estragon 0.1.0-beta.12 → 0.1.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -519,6 +519,7 @@ func candidates(text: String, source: String, lexical: RefCounted, row: int, col
519
519
  if context.mode=="gd" and member_cursor>=0 and left[member_cursor]=="." and item.kind==CodeEdit.KIND_FUNCTION and not callable_attribute and not lexical.lines[row].substr(column).strip_edges().begins_with("("):
520
520
  insert += "()"
521
521
  var display: String = str(name) if item.has("import") else (str(name)+" — "+str(item.origin) if item.has("origin") else str(name))
522
+ if context.mode == "tag" and item.kind == CodeEdit.KIND_MEMBER and not str(item.get("type","")).is_empty(): display += " — "+str(item.type)
522
523
  if context.mode == "tag" and not item.has("import") and ClassDB.class_exists(insert): display += " — Godot "+ClassDB.get_parent_class(insert)
523
524
  result.append({"text":display,"insert":insert,"kind":item.kind,"row":row,"start":cursor if context.mode == "tag" and context.closing else cursor+1,"column":column,"hint":item.get("hint",""),"imports":[item["import"]] if item.has("import") else []})
524
525
  result.sort_custom(func(a,b): return a.text < b.text)
@@ -3,5 +3,5 @@
3
3
  name="Estragon"
4
4
  description="Native Gogo/GGX highlighting, compilation and validation before Play."
5
5
  author="Resist Design"
6
- version="0.1.0-beta.12"
6
+ version="0.1.0-beta.14"
7
7
  script="plugin.gd"
@@ -39,7 +39,7 @@ func update(view: Node) -> void:
39
39
  if layout == null or not layout.active: return
40
40
  _disconnect()
41
41
  layout.managed_root = root
42
- target = layout.participant(view)
42
+ target = layout.participant(view,true)
43
43
  if target != null and target._mode == Coordinator.Mode.ENTRY: target = null
44
44
  if target != null: target.model.invalidated.connect(_configure)
45
45
  layout._sync()
@@ -48,9 +48,11 @@ func _configure() -> void:
48
48
  if layout == null or not layout.active: return
49
49
  var requested := Vector3(-1,-1,0) if layout._dimension==2 else Vector3(-1,-1,-1)
50
50
  var fills := Vector3.ZERO
51
- if target != null:
51
+ var included: bool = target != null and (target._mode != Coordinator.Mode.CONTROL or target.control_adapter.participates())
52
+ if included:
52
53
  requested = target.model.requested
53
54
  fills = target.model.fill
55
+ layout.model.allocation_minimum = target.model.allocation_minimum if included else Vector3.ZERO
54
56
  # One child, at zero local offset. Parent places the native host once;
55
57
  # root constraints determine both proxy allocation and root allocation.
56
58
  layout.model.configure(requested,0,false,0,fills)
@@ -66,8 +66,8 @@ func _layout_options() -> Dictionary:
66
66
  func _is_layout_entry() -> bool:
67
67
  return false
68
68
 
69
- func _layout_viewport_scale() -> float:
70
- return 0.0
69
+ func _layout_viewport_scale() -> Vector2:
70
+ return Vector2.ZERO
71
71
 
72
72
  func _changed() -> void:
73
73
  if layout != null: layout.changed()
@@ -52,8 +52,8 @@ func requested_extent() -> Vector3:
52
52
  func _is_layout_entry() -> bool:
53
53
  return false
54
54
 
55
- func _layout_viewport_scale() -> float:
56
- return 0.0
55
+ func _layout_viewport_scale() -> Vector2:
56
+ return Vector2.ZERO
57
57
 
58
58
  func _changed() -> void:
59
59
  if layout != null: layout.changed()
@@ -8,11 +8,17 @@ extends "component_2d.gd"
8
8
  viewport_width_scale = value
9
9
  if layout != null: layout._invalidated()
10
10
 
11
+ @export var viewport_height_scale: float = 0.0:
12
+ set(value):
13
+ if not is_finite(value) or value < 0 or viewport_height_scale == value: return
14
+ viewport_height_scale = value
15
+ if layout != null: layout._invalidated()
16
+
11
17
  func _is_layout_entry() -> bool:
12
18
  return true
13
19
 
14
- func _layout_viewport_scale() -> float:
15
- return viewport_width_scale
20
+ func _layout_viewport_scale() -> Vector2:
21
+ return Vector2(viewport_width_scale,viewport_height_scale)
16
22
 
17
23
  const Pointer = preload("internal/pointer_2d.gd")
18
24
  var _pointer = Pointer.new(self)
@@ -8,8 +8,14 @@ extends "component_3d.gd"
8
8
  viewport_width_scale = value
9
9
  if layout != null: layout._invalidated()
10
10
 
11
+ @export var viewport_height_scale: float = 0.0:
12
+ set(value):
13
+ if not is_finite(value) or value < 0 or viewport_height_scale == value: return
14
+ viewport_height_scale = value
15
+ if layout != null: layout._invalidated()
16
+
11
17
  func _is_layout_entry() -> bool:
12
18
  return true
13
19
 
14
- func _layout_viewport_scale() -> float:
15
- return viewport_width_scale
20
+ func _layout_viewport_scale() -> Vector2:
21
+ return Vector2(viewport_width_scale,viewport_height_scale)
@@ -2,6 +2,40 @@
2
2
  extends Resource
3
3
  ## External weak lookup only. Never serialized onto authored Nodes/Resources.
4
4
  var hosts: Dictionary = {}
5
+ # Strong bridge records, weak native hosts. Native exit/projection release owns
6
+ # teardown; no adapter lifetime or coordinator is stored on application Nodes.
7
+ var controls: Dictionary = {}
8
+ var exiting_controls: Dictionary = {}
9
+ func block_control(node: Control) -> void:
10
+ var id := node.get_instance_id()
11
+ if exiting_controls.has(id): return
12
+ var reference: WeakRef = weakref(node)
13
+ exiting_controls[id] = reference
14
+ _unblock_control.call_deferred(id,reference)
15
+ func enter_control(node: Control) -> void:
16
+ exiting_controls.erase(node.get_instance_id())
17
+ func control_exiting(node: Control) -> bool:
18
+ var reference = exiting_controls.get(node.get_instance_id())
19
+ return reference != null and reference.get_ref() == node
20
+ func _unblock_control(id: int, reference: WeakRef) -> void:
21
+ if exiting_controls.get(id) != reference: return
22
+ exiting_controls.erase(id)
23
+ var node = reference.get_ref()
24
+ if node != null and node.is_inside_tree():
25
+ var parent = projected_parent(node)
26
+ if parent == null: parent = node.get_parent()
27
+ var layout = _coordinator(parent)
28
+ if layout != null: layout._sync()
29
+ func add_control(node: Control, coordinator: RefCounted) -> void:
30
+ controls[node.get_instance_id()] = coordinator
31
+ add(node,coordinator)
32
+ func release_control(node: Control) -> void:
33
+ var id := node.get_instance_id()
34
+ var coordinator = controls.get(id)
35
+ if coordinator == null: return
36
+ coordinator.stop()
37
+ remove(node,coordinator)
38
+ controls.erase(id)
5
39
  func find(node: Node):
6
40
  if node == null: return null
7
41
  var reference = hosts.get(node.get_instance_id())
@@ -85,6 +119,7 @@ func replace_projection(owner: RefCounted, next: Dictionary, next_orders: Dictio
85
119
  if not next.has(id):
86
120
  projections.erase(id)
87
121
  if node != null:
122
+ if node is Control: release_control(node)
88
123
  if node.get_parent() == item.native_parent.get_ref() and item.position != null: node.position = item.position
89
124
  refresh.append(node)
90
125
  for id in next:
@@ -98,7 +133,7 @@ func replace_projection(owner: RefCounted, next: Dictionary, next_orders: Dictio
98
133
  if _placement(node,parent) == null and item.position != null:
99
134
  if node.get_parent() == item.native_parent.get_ref(): node.position = item.position
100
135
  item.position = null
101
- elif _placement(node,parent) != null and item.position == null: item.position = node.position
136
+ elif _placement(node,parent) != null and item.position == null and (node is Node2D or node is Node3D): item.position = node.position
102
137
  item.parent = weakref(parent)
103
138
  refresh.append(node)
104
139
  for id in order_owners.keys():
@@ -0,0 +1,164 @@
1
+ @tool
2
+ extends RefCounted
3
+ ## Native Control minimum/outer-rect bridge. Container internals remain opaque.
4
+ const Hosts = preload("composition_hosts.tres")
5
+ var host: WeakRef
6
+ var coordinator: WeakRef
7
+ var original: Rect2
8
+ var native_parent: WeakRef
9
+ var assigned: Rect2
10
+ var allocated := false
11
+ var active := false
12
+ var queued := false
13
+ var writing := false
14
+ var reason := ""
15
+ var minimum_reads := 0
16
+ var refreshes := 0
17
+ var native_writes := 0
18
+ var subscribed := false
19
+ var included := false
20
+
21
+ func _init(node: Control, layout: RefCounted) -> void:
22
+ host = weakref(node)
23
+ coordinator = weakref(layout)
24
+ original = Rect2(node.position,node.size)
25
+ assigned = original
26
+
27
+ func start() -> void:
28
+ active = true
29
+ var node = host.get_ref()
30
+ for event in ["minimum_size_changed","theme_changed","size_flags_changed","visibility_changed"]:
31
+ node.connect(event,changed)
32
+ node.resized.connect(rect_changed)
33
+ node.item_rect_changed.connect(rect_changed)
34
+ node.tree_exiting.connect(exiting)
35
+ subscribed = true
36
+ refresh()
37
+
38
+ func stop() -> void:
39
+ if not active: return
40
+ active = false
41
+ var node = host.get_ref()
42
+ if node == null: return
43
+ for event in ["minimum_size_changed","theme_changed","size_flags_changed","visibility_changed"]:
44
+ if node.is_connected(event,changed): node.disconnect(event,changed)
45
+ for event in ["resized","item_rect_changed"]:
46
+ if node.is_connected(event,rect_changed): node.disconnect(event,rect_changed)
47
+ if node.tree_exiting.is_connected(exiting): node.tree_exiting.disconnect(exiting)
48
+ subscribed = false
49
+ restore()
50
+
51
+ func exiting() -> void:
52
+ var node = host.get_ref()
53
+ var layout = coordinator.get_ref()
54
+ var parent = layout.parent_coordinator() if layout != null else null
55
+ if node != null:
56
+ Hosts.block_control(node)
57
+ Hosts.release_control(node)
58
+ # Native child_exiting_tree can precede actual removal. Reconcile the core
59
+ # after that removal, never reacquire an exiting Control in its callback.
60
+ if parent != null: parent._sync.call_deferred()
61
+
62
+ func changed() -> void:
63
+ if not active or queued: return
64
+ queued = true
65
+ refresh.call_deferred()
66
+
67
+ func rect_changed() -> void:
68
+ if writing or not active: return
69
+ var node = host.get_ref()
70
+ if node == null: return
71
+ if not allocated or limitation() != reason or not node.position.is_equal_approx(assigned.position) or not node.size.is_equal_approx(assigned.size): changed()
72
+
73
+ func logical_parent() -> Node:
74
+ var node = host.get_ref()
75
+ if node == null: return null
76
+ var projected = Hosts.projected_parent(node)
77
+ return projected if projected != null else node.get_parent()
78
+
79
+ func limitation() -> String:
80
+ var node = host.get_ref()
81
+ var parent = logical_parent()
82
+ if node == null or not node.is_inside_tree(): return "outside the native tree"
83
+ if node.get_parent() is Container: return "native Container owns its direct children's rectangles"
84
+ if node.is_set_as_top_level(): return "top_level Control uses independent native coordinates"
85
+ if node.anchor_left != 0 or node.anchor_top != 0 or node.anchor_right != 0 or node.anchor_bottom != 0: return "nonzero anchors compete with Box allocation"
86
+ if not is_zero_approx(node.rotation) or not node.scale.is_equal_approx(Vector2.ONE) or not node.pivot_offset.is_zero_approx(): return "local rotation/scale/pivot requires explicit positioning"
87
+ if not parent is CanvasItem: return "no compatible CanvasItem layout parent"
88
+ if parent.get_viewport() != node.get_viewport() or parent.get_canvas() != node.get_canvas(): return "different native viewport/CanvasLayer"
89
+ # CanvasItem's native parent-item getter is not a public Script API.
90
+ # The local/global matrices expose the same parent basis without traversal.
91
+ var basis: Transform2D = node.get_global_transform()*node.get_transform().affine_inverse()
92
+ if is_zero_approx(basis.x.cross(basis.y)): return "singular native parent transform"
93
+ var relative: Transform2D = basis.affine_inverse()*parent.get_global_transform()
94
+ if not relative.x.is_equal_approx(Vector2.RIGHT) or not relative.y.is_equal_approx(Vector2.DOWN): return "borrowed logical/native parent bases differ"
95
+ return ""
96
+
97
+ func participates() -> bool:
98
+ var node = host.get_ref()
99
+ return active and node != null and node.is_visible_in_tree() and limitation().is_empty()
100
+
101
+ func refresh() -> void:
102
+ queued = false
103
+ if not active: return
104
+ var node = host.get_ref()
105
+ var layout = coordinator.get_ref()
106
+ if node == null or layout == null: return
107
+ refreshes += 1
108
+ var next := limitation()
109
+ if next != reason and not next.is_empty(): push_warning("Estragon native Control layout skipped: "+str(node.get_path())+": "+next)
110
+ reason = next
111
+ var next_included := participates()
112
+ var inclusion_changed := included != next_included
113
+ included = next_included
114
+ minimum_reads += 1
115
+ var minimum: Vector2 = node.get_combined_minimum_size()
116
+ var fills := Vector3(1 if node.size_flags_horizontal == Control.SIZE_EXPAND_FILL else 0,1 if node.size_flags_vertical == Control.SIZE_EXPAND_FILL else 0,0)
117
+ layout.model.allocation_minimum = Vector3(minimum.x,minimum.y,0)
118
+ layout.model.configure(Vector3(-1,-1,0),0,false,0,fills,Vector3(minimum.x,minimum.y,0))
119
+ if inclusion_changed: layout.model.invalidate()
120
+ if not participates(): restore()
121
+ elif allocated and (not node.position.is_equal_approx(assigned.position) or not node.size.is_equal_approx(assigned.size)): layout.model.invalidate()
122
+ var parent = layout.parent_coordinator()
123
+ if parent != null: parent._sync()
124
+
125
+ func restore() -> void:
126
+ if not allocated: return
127
+ var node = host.get_ref()
128
+ if node != null and native_parent != null and node.get_parent() == native_parent.get_ref():
129
+ writing = true
130
+ node.position = original.position
131
+ node.size = original.size
132
+ writing = false
133
+ allocated = false
134
+
135
+ func place(offset: Vector3) -> void:
136
+ if not participates(): return
137
+ var node = host.get_ref()
138
+ if not allocated:
139
+ # Capture after native add/reparent/theme initialization completes, not
140
+ # inside child_entered_tree halfway through that native transaction.
141
+ original = Rect2(node.position,node.size)
142
+ native_parent = weakref(node.get_parent())
143
+ var parent: CanvasItem = logical_parent()
144
+ var point: Vector2 = parent.get_global_transform()*Vector2(offset.x,offset.y)
145
+ writing = true
146
+ if not node.global_position.is_equal_approx(point):
147
+ node.global_position = point
148
+ native_writes += 1
149
+ assigned.position = node.position
150
+ writing = false
151
+ allocated = true
152
+
153
+ func arrange(size: Vector3) -> void:
154
+ if not participates(): return
155
+ var layout = coordinator.get_ref()
156
+ place(layout.model.offset)
157
+ var node = host.get_ref()
158
+ var wanted := Vector2(size.x,size.y)
159
+ writing = true
160
+ if not node.size.is_equal_approx(wanted):
161
+ node.size = wanted
162
+ native_writes += 1
163
+ assigned.size = node.size
164
+ writing = false
@@ -0,0 +1 @@
1
+ uid://d10lmffp0yjv1
@@ -5,7 +5,8 @@ const Profile = preload("../../composition/profile.tres")
5
5
  const Core = preload("layout_core.gd")
6
6
  const CompositionHosts = preload("composition_hosts.tres")
7
7
  const META := "_estragon_b2_coordinator"
8
- enum Mode { PROOF, PARTICIPANT, ENTRY, COMPOSITION }
8
+ enum Mode { PROOF, PARTICIPANT, ENTRY, COMPOSITION, CONTROL }
9
+ var control_adapter
9
10
  var managed_root: WeakRef
10
11
  var _mode: int
11
12
  var model := Core.new()
@@ -31,8 +32,9 @@ func parent_coordinator():
31
32
  var projected = CompositionHosts.projected_parent(host)
32
33
  return participant(projected if projected != null else host.get_parent())
33
34
 
34
- func participant(node: Node):
35
+ func participant(node: Node, acquire_control := false):
35
36
  if node == null: return null
37
+ if node is Control and CompositionHosts.control_exiting(node): return null
36
38
  var found
37
39
  if _mode == Mode.PROOF:
38
40
  if not node.has_meta(META): return null
@@ -40,6 +42,10 @@ func participant(node: Node):
40
42
  else:
41
43
  # Runtime references must never be serialized as Node metadata.
42
44
  found = node._get_layout_coordinator() if node.has_method("_get_layout_coordinator") else CompositionHosts.find(node)
45
+ if found == null and acquire_control and _dimension == 2 and node is Control and node.is_inside_tree():
46
+ found = get_script().new(node,2,Mode.CONTROL)
47
+ CompositionHosts.add_control(node,found)
48
+ found.start()
43
49
  return found if found != null and found.active and found._dimension == _dimension else null
44
50
 
45
51
  func scope_root():
@@ -56,17 +62,21 @@ func root_host() -> Node:
56
62
  var found = scope_root()
57
63
  return found._host.get_ref() if found != null else null
58
64
 
59
- func _viewport_scale(host: Node) -> float:
60
- return host.viewport_width_scale if _mode == Mode.PROOF else host._layout_viewport_scale()
65
+ func _viewport_scale(host: Node) -> Vector2:
66
+ return Vector2(host.viewport_width_scale,0) if _mode == Mode.PROOF else host._layout_viewport_scale()
61
67
 
62
68
  func start() -> void:
63
69
  active = true
64
70
  var host: Node = _host.get_ref()
71
+ if _mode == Mode.CONTROL:
72
+ control_adapter = preload("control_participant.gd").new(host,self)
73
+ control_adapter.start()
74
+ return
65
75
  # PackedScene restores metadata after construction. Refresh the proof-only
66
76
  # weak registry at entry; C1 resolves the live script field instead.
67
77
  if _mode == Mode.PROOF: host.set_meta(META, weakref(self))
68
- host.child_entered_tree.connect(_child_changed)
69
- host.child_exiting_tree.connect(_child_changed)
78
+ host.child_entered_tree.connect(_child_entered)
79
+ host.child_exiting_tree.connect(_child_exiting)
70
80
  if host.has_signal("child_order_changed"): host.connect("child_order_changed", _sync)
71
81
  if _mode in [Mode.PROOF,Mode.ENTRY]:
72
82
  _viewport = host.get_viewport()
@@ -79,8 +89,12 @@ func start() -> void:
79
89
  func stop() -> void:
80
90
  active = false
81
91
  var host: Node = _host.get_ref()
82
- if host.child_entered_tree.is_connected(_child_changed): host.child_entered_tree.disconnect(_child_changed)
83
- if host.child_exiting_tree.is_connected(_child_changed): host.child_exiting_tree.disconnect(_child_changed)
92
+ if _mode == Mode.CONTROL:
93
+ if control_adapter != null: control_adapter.stop()
94
+ model.set_children([])
95
+ return
96
+ if host.child_entered_tree.is_connected(_child_entered): host.child_entered_tree.disconnect(_child_entered)
97
+ if host.child_exiting_tree.is_connected(_child_exiting): host.child_exiting_tree.disconnect(_child_exiting)
84
98
  if host.has_signal("child_order_changed") and host.is_connected("child_order_changed", _sync): host.disconnect("child_order_changed", _sync)
85
99
  if _viewport != null and _viewport.size_changed.is_connected(_viewport_changed): _viewport.size_changed.disconnect(_viewport_changed)
86
100
  _viewport = null
@@ -88,7 +102,12 @@ func stop() -> void:
88
102
  var parent = parent_coordinator()
89
103
  if parent != null: parent._sync()
90
104
 
91
- func _child_changed(_child: Node) -> void:
105
+ func _child_entered(child: Node) -> void:
106
+ if child is Control: CompositionHosts.enter_control(child)
107
+ _sync()
108
+
109
+ func _child_exiting(child: Node) -> void:
110
+ if child is Control: CompositionHosts.block_control(child)
92
111
  _sync()
93
112
 
94
113
  func order_moved() -> void:
@@ -96,15 +115,17 @@ func order_moved() -> void:
96
115
  if parent != null: parent._sync()
97
116
 
98
117
  func _sync() -> void:
99
- if not active: return
118
+ if not active or _mode == Mode.CONTROL: return
100
119
  var values: Array = []
101
120
  var host: Node = _host.get_ref()
102
121
  var children: Array = host.get_children() if _mode != Mode.COMPOSITION else []
103
122
  if _mode == Mode.COMPOSITION and managed_root != null and managed_root.get_ref() != null: children.append(managed_root.get_ref())
104
123
  children = CompositionHosts.children(host,children)
105
124
  for child in children:
106
- var found = participant(child)
107
- if found != null and found._mode != Mode.ENTRY: values.append(found.model)
125
+ var found = participant(child,true)
126
+ if found != null and found._mode != Mode.ENTRY:
127
+ if found._mode == Mode.CONTROL and not found.control_adapter.participates(): continue
128
+ values.append(found.model)
108
129
  var error := model.set_children(values)
109
130
  if error != OK: push_error("Estragon layout model ownership: " + error_string(error))
110
131
 
@@ -118,28 +139,36 @@ func changed() -> void:
118
139
 
119
140
  func _viewport_changed() -> void:
120
141
  var host = _host.get_ref()
121
- if host != null and parent_coordinator() == null and _viewport_scale(host) > 0: _invalidated()
142
+ if host == null or parent_coordinator() != null: return
143
+ var scale := _viewport_scale(host)
144
+ if scale.x > 0 or scale.y > 0: _invalidated()
122
145
 
123
146
  func _invalidated() -> void:
124
147
  if Profile.is_enabled(): Profile.add("layout_invalidations")
125
- if not active or _queued or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION]: return
148
+ if not active or _queued or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION,Mode.CONTROL]: return
126
149
  _queued = true
127
150
  call_deferred("_flush")
128
151
 
129
152
  func _flush() -> void:
130
153
  _queued = false
131
- if not active or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION]: return
154
+ if not active or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION,Mode.CONTROL]: return
132
155
  var host = _host.get_ref()
133
156
  if host == null or host.is_queued_for_deletion(): return
134
157
  flush_count += 1
135
158
  if Profile.is_enabled(): Profile.add("layout_flushes")
136
159
  var available: Vector3 = model.measure()
137
- if _viewport_scale(host) > 0 and _viewport != null:
138
- available.x = _viewport.get_visible_rect().size.x * _viewport_scale(host)
160
+ if _viewport != null:
161
+ var scale := _viewport_scale(host)
162
+ var visible := _viewport.get_visible_rect().size
163
+ if scale.x > 0: available.x = visible.x * scale.x
164
+ if scale.y > 0: available.y = visible.y * scale.y
139
165
  model.arrange(available)
140
166
  CompositionHosts.refresh_positions(self)
141
167
 
142
168
  func _place(offset: Vector3) -> void:
169
+ if _mode == Mode.CONTROL:
170
+ control_adapter.place(offset)
171
+ return
143
172
  var host = _host.get_ref()
144
173
  if host == null: return
145
174
  if host.has_method("apply_layout_position"): host.apply_layout_position(offset)
@@ -153,5 +182,8 @@ func _place(offset: Vector3) -> void:
153
182
  elif host is Node3D and projected is Node3D: host.global_position = projected.to_global(host.position)
154
183
 
155
184
  func _arranged(size: Vector3) -> void:
185
+ if _mode == Mode.CONTROL:
186
+ control_adapter.arrange(size)
187
+ return
156
188
  var host = _host.get_ref()
157
189
  if host != null and _mode != Mode.COMPOSITION: host.apply_layout_size(size)
@@ -11,6 +11,8 @@ var center: bool = false
11
11
  var axis: int = 0
12
12
  var fill := Vector3.ZERO
13
13
  var intrinsic := Vector3.ZERO
14
+ # Native Control minimums constrain assigned slots, never read back from size.
15
+ var allocation_minimum := Vector3.ZERO
14
16
  var children: Array = []
15
17
  var measured := Vector3.ZERO
16
18
  var size := Vector3.ZERO
@@ -93,18 +95,35 @@ func arrange(available: Vector3) -> void:
93
95
  # follow-up instead of being overwritten when this pass finishes.
94
96
  _arrange_dirty = false
95
97
  var fixed: float = gap * maxi(0, children.size() - 1)
96
- var flexible: int = 0
98
+ var flexible: Array = []
97
99
  for child in children:
98
- if child.fill[axis] > 0 and child.requested[axis] < 0: flexible += 1
100
+ if child.fill[axis] > 0 and child.requested[axis] < 0: flexible.append(child)
99
101
  else: fixed += child.measured[axis]
100
- var share: float = maxf(0,available[axis] - fixed) / maxi(1,flexible)
101
- var row_extent: float = fixed + share * flexible
102
+ var remaining: float = maxf(0,available[axis] - fixed)
103
+ var shares: Dictionary = {}
104
+ # Reserve constrained native minimums, then share the remaining space.
105
+ # Zero floors preserve the existing equal-share Box behavior.
106
+ while not flexible.is_empty():
107
+ var share: float = remaining / flexible.size()
108
+ var constrained := false
109
+ for child in flexible.duplicate():
110
+ if child.allocation_minimum[axis] > share:
111
+ shares[child] = child.allocation_minimum[axis]
112
+ remaining = maxf(0,remaining-child.allocation_minimum[axis])
113
+ flexible.erase(child)
114
+ constrained = true
115
+ if not constrained:
116
+ for child in flexible: shares[child] = share
117
+ break
118
+ var row_extent: float = fixed
119
+ for share in shares.values(): row_extent += share
102
120
  var cursor: float = (available[axis] - row_extent) * 0.5 if center else 0.0
103
121
  for child in children:
104
122
  var allocation: Vector3 = child.measured
105
123
  for index in range(3):
106
124
  if child.fill[index] > 0 and child.requested[index] < 0:
107
- allocation[index] = share if index == axis else available[index]
125
+ allocation[index] = shares[child] if index == axis else available[index]
126
+ allocation[index] = maxf(allocation[index],child.allocation_minimum[index])
108
127
  var next := Vector3.ZERO
109
128
  next[axis] = cursor
110
129
  if child.offset != next or child.arrange_count == 0:
package/package.json CHANGED
@@ -29,5 +29,5 @@
29
29
  "tag": "beta",
30
30
  "registry": "https://registry.npmjs.org/"
31
31
  },
32
- "version": "0.1.0-beta.12"
32
+ "version": "0.1.0-beta.14"
33
33
  }