@papercraftgames/estragon 0.1.0-beta.12 → 0.1.0-beta.13
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.
- package/addons/estragon/editor/plugin.cfg +1 -1
- package/addons/estragon/runtime/composition/layout_host.gd +4 -2
- package/addons/estragon/runtime/node/internal/composition_hosts.gd +36 -1
- package/addons/estragon/runtime/node/internal/control_participant.gd +164 -0
- package/addons/estragon/runtime/node/internal/control_participant.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/coordinator.gd +39 -12
- package/addons/estragon/runtime/node/internal/layout_core.gd +24 -5
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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)
|
|
@@ -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():
|
|
@@ -62,11 +68,15 @@ func _viewport_scale(host: Node) -> float:
|
|
|
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(
|
|
69
|
-
host.child_exiting_tree.connect(
|
|
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
|
|
83
|
-
|
|
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
|
|
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:
|
|
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
|
|
|
@@ -122,13 +143,13 @@ func _viewport_changed() -> void:
|
|
|
122
143
|
|
|
123
144
|
func _invalidated() -> void:
|
|
124
145
|
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
|
|
146
|
+
if not active or _queued or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION,Mode.CONTROL]: return
|
|
126
147
|
_queued = true
|
|
127
148
|
call_deferred("_flush")
|
|
128
149
|
|
|
129
150
|
func _flush() -> void:
|
|
130
151
|
_queued = false
|
|
131
|
-
if not active or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION]: return
|
|
152
|
+
if not active or parent_coordinator() != null or _mode in [Mode.PARTICIPANT,Mode.COMPOSITION,Mode.CONTROL]: return
|
|
132
153
|
var host = _host.get_ref()
|
|
133
154
|
if host == null or host.is_queued_for_deletion(): return
|
|
134
155
|
flush_count += 1
|
|
@@ -140,6 +161,9 @@ func _flush() -> void:
|
|
|
140
161
|
CompositionHosts.refresh_positions(self)
|
|
141
162
|
|
|
142
163
|
func _place(offset: Vector3) -> void:
|
|
164
|
+
if _mode == Mode.CONTROL:
|
|
165
|
+
control_adapter.place(offset)
|
|
166
|
+
return
|
|
143
167
|
var host = _host.get_ref()
|
|
144
168
|
if host == null: return
|
|
145
169
|
if host.has_method("apply_layout_position"): host.apply_layout_position(offset)
|
|
@@ -153,5 +177,8 @@ func _place(offset: Vector3) -> void:
|
|
|
153
177
|
elif host is Node3D and projected is Node3D: host.global_position = projected.to_global(host.position)
|
|
154
178
|
|
|
155
179
|
func _arranged(size: Vector3) -> void:
|
|
180
|
+
if _mode == Mode.CONTROL:
|
|
181
|
+
control_adapter.arrange(size)
|
|
182
|
+
return
|
|
156
183
|
var host = _host.get_ref()
|
|
157
184
|
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:
|
|
98
|
+
var flexible: Array = []
|
|
97
99
|
for child in children:
|
|
98
|
-
if child.fill[axis] > 0 and child.requested[axis] < 0: flexible
|
|
100
|
+
if child.fill[axis] > 0 and child.requested[axis] < 0: flexible.append(child)
|
|
99
101
|
else: fixed += child.measured[axis]
|
|
100
|
-
var
|
|
101
|
-
var
|
|
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] =
|
|
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