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

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.
@@ -86,7 +86,7 @@ static func _string(value: String) -> String:
86
86
  return output + '"'
87
87
 
88
88
  static func literal(value: Model.Literal) -> String:
89
- return _string(value.value)
89
+ return str(value.value) if value.kind == "pixel-literal" else _string(value.value)
90
90
 
91
91
  func _argument(expression: Model.GdExpression, type_name: String, factory: Factory) -> void:
92
92
  var argument := Argument.new()
@@ -5,6 +5,7 @@ const Element = preload("../runtime/composition/element.gd")
5
5
  const Model = preload("model.gd")
6
6
  const Source = preload("source.gd")
7
7
  const Resolver = preload("native/resolver.gd")
8
+ const Pixels = preload("../runtime/node/internal/pixel_contract.gd")
8
9
  const Lexer = preload("lexer.gd")
9
10
  var file: Source
10
11
  var resolver
@@ -82,7 +83,12 @@ func _component(node: Model.Component) -> void:
82
83
  else:
83
84
  _error("Unknown, read-only or reserved Node property/signal " + name, attribute.name_span)
84
85
  return
86
+ var pixel_kind := Pixels.kind(resolved.script,name)
87
+ if not pixel_kind.is_empty():
88
+ _pixel(attribute,pixel_kind)
89
+ if not file.diagnostics.is_empty(): return
85
90
  if attribute.value is Model.Literal:
91
+ if attribute.value.kind == "pixel-literal": continue
86
92
  if attribute.type_name not in ["String", "StringName"]:
87
93
  _error("Typed Node values require {GDScript expressions}; only strings may be quoted", attribute.value.span)
88
94
  return
@@ -276,3 +282,20 @@ func _binding(attribute, node, properties: Dictionary, signals: Dictionary) -> v
276
282
  attribute.kind = "binding"
277
283
  attribute.type_name = "Variant"
278
284
  attribute.binding_path = names
285
+
286
+ func _pixel(attribute, domain: String) -> void:
287
+ var value = attribute.value
288
+ if value is Model.Literal:
289
+ var text: String = str(value.value)
290
+ if domain == "length" and (text == "auto" or text.is_valid_float() and Pixels.valid(float(text),domain)):
291
+ value.value = -1.0 if text == "auto" else float(text)
292
+ value.kind = "pixel-literal"
293
+ return
294
+ _error("Pixel lengths require finite nonnegative numbers; only width/height allow quoted numbers or auto",value.span)
295
+ return
296
+ var tokens := _expression_tokens(value)
297
+ var text := ""
298
+ if tokens.size()==1: text = tokens[0].text
299
+ elif tokens.size()==2 and tokens[0].text in ["+","-"] and tokens[1].kind=="number": text = tokens[0].text+tokens[1].text
300
+ if text in ["NAN","INF","-INF","+INF"] or text.is_valid_float() and not Pixels.valid(float(text),domain):
301
+ _error("Pixel lengths require finite nonnegative numbers (width/height also allow -1 for auto)",value.span)
@@ -241,7 +241,12 @@ func _chain(tokens: Array, end: int, row: int, depth: int = 0) -> Dictionary:
241
241
  return {"start":receiver.start,"value":members[token.text]}
242
242
  if token.text=="self": return {"start":end,"value":{"self":true,"row":row}}
243
243
  var scope := _scope_members(row)
244
- if scope.has(token.text): return {"start":end,"value":scope[token.text]}
244
+ if scope.has(token.text):
245
+ # A preload alias is also a const declaration. Its empty value type must
246
+ # not hide the Script receiver; local/typed shadows remain authoritative.
247
+ if _aliases.has(token.text) and scope[token.text].kind == CodeEdit.KIND_CONSTANT and scope[token.text].get("owner","").is_empty() and scope[token.text].get("type","").is_empty():
248
+ return {"start":end,"value":{"type":token.text}}
249
+ return {"start":end,"value":scope[token.text]}
245
250
  if ClassDB.class_exists(token.text) or _aliases.has(token.text): return {"start":end,"value":{"type":token.text}}
246
251
  return {}
247
252
  func _receiver_members(tokens: Array, end: int, row: int) -> Dictionary:
@@ -2,6 +2,8 @@
2
2
  extends RefCounted
3
3
  ## Trusted installed resources, not guessed global classes or installation roots.
4
4
  const ITEMS := [
5
+ {"alias":"Pixels","canonical":"EstragonPixels","script":preload("../runtime/composition/pixels.gd"),"dimension":0,"origin":"observed pixel helper"},
6
+ {"alias":"Box","canonical":"EstragonBox","script":preload("../runtime/node/box.gd"),"dimension":2,"origin":"native layout"},
5
7
  {"alias":"Text","canonical":"EstragonText","script":preload("../runtime/node/text.gd"),"dimension":2,"origin":"native widget"},
6
8
  {"alias":"Rect","canonical":"EstragonRect","script":preload("../runtime/node/rect.gd"),"dimension":2,"origin":"native widget"},
7
9
  {"alias":"UiButton","canonical":"EstragonButton","script":preload("../runtime/node/button.gd"),"dimension":2,"origin":"native widget"},
@@ -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.14"
6
+ version="0.1.0-beta.15"
7
7
  script="plugin.gd"
@@ -1,4 +1,5 @@
1
1
  extends RefCounted
2
+ const Pixels = preload("../node/internal/pixel_contract.gd")
2
3
  const Profile = preload("profile.tres")
3
4
  ## F01 computation and retained static-shape records external to native objects.
4
5
  const Binding = preload("binding.gd")
@@ -109,7 +110,7 @@ func _flush() -> void:
109
110
  if Profile.is_enabled(): Profile.add("views")
110
111
  _rendering = true
111
112
  _again = false
112
- manager.begin()
113
+ manager.begin(owner)
113
114
  var desired = owner.call("build_view")
114
115
  var reads: Dictionary = manager.finish()
115
116
  if Profile.is_enabled(): Profile.elapsed("view",started)
@@ -459,6 +460,8 @@ func _preflight(desired, previous, parent: Node, contracts: Variant = null) -> b
459
460
  for key in desired.properties:
460
461
  if not properties.has(key) or key in ["script","owner"] or int(properties[key].usage)&PROPERTY_USAGE_READ_ONLY: return false
461
462
  var value = desired.properties[key]
463
+ var pixel_kind := Pixels.kind(desired.type,key)
464
+ if not pixel_kind.is_empty() and not Pixels.valid(value,pixel_kind): return false
462
465
  var kind: int = properties[key].type
463
466
  if kind!=TYPE_NIL and typeof(value)!=kind and not (kind==TYPE_FLOAT and typeof(value)==TYPE_INT) and not (kind==TYPE_OBJECT and value==null) and not (kind in [TYPE_STRING,TYPE_STRING_NAME] and typeof(value) in [TYPE_STRING,TYPE_STRING_NAME]): return false
464
467
  if kind==TYPE_OBJECT and value!=null:
@@ -55,4 +55,4 @@ func _configure() -> void:
55
55
  layout.model.allocation_minimum = target.model.allocation_minimum if included else Vector3.ZERO
56
56
  # One child, at zero local offset. Parent places the native host once;
57
57
  # root constraints determine both proxy allocation and root allocation.
58
- layout.model.configure(requested,0,false,0,fills)
58
+ layout.model.configure(requested,0,false,0,fills,Vector3.ZERO,Vector4.ZERO,target.model.margin if included else Vector4.ZERO,true)
@@ -0,0 +1,38 @@
1
+ @tool
2
+ class_name EstragonPixels
3
+ extends RefCounted
4
+ ## Opt-in ordinary numeric pixel helpers. Read during the child's build_view;
5
+ ## the existing composition manager observes the parent core's native signal.
6
+ const State = preload("state.tres")
7
+ const Hosts = preload("../node/internal/composition_hosts.tres")
8
+ static func parent_width(context: Node, percent: float) -> float:
9
+ return _parent_pixels(context,percent,0)
10
+ static func parent_height(context: Node, percent: float) -> float:
11
+ return _parent_pixels(context,percent,1)
12
+ static func _parent_pixels(context: Node, percent: float, axis: int) -> float:
13
+ if not is_finite(percent) or percent < 0:
14
+ push_warning("EstragonPixels requires a finite nonnegative percentage; using 0 pixels")
15
+ return 0.0
16
+ if context == null or context != State.current_host():
17
+ push_warning("EstragonPixels context must be self in the current Gogo build_view; using 0 pixels")
18
+ return 0.0
19
+ var layout = context._get_layout_coordinator() if context.has_method("_get_layout_coordinator") else Hosts.find(context)
20
+ if layout == null or layout._dimension != 2: return 0.0
21
+ State.observe(layout.model,&"parent_changed")
22
+ if layout.scope_root() == null or layout._mode == layout.Mode.ENTRY: return 0.0
23
+ var parent = layout.parent_coordinator()
24
+ # Structural Gogo proxies add no content box; use the containing participant.
25
+ while parent != null and parent._mode == parent.Mode.COMPOSITION:
26
+ State.observe(parent.model,&"parent_changed")
27
+ parent = parent.parent_coordinator()
28
+ if parent == null or parent._mode == parent.Mode.CONTROL: return 0.0
29
+ State.observe(parent.model,&"reference_changed")
30
+ # Unarranged references bootstrap at zero. Intrinsic/auto parent axes stay
31
+ # unavailable instead of repeatedly solving a child/parent fixed point.
32
+ var extent: float = parent.model.content_reference[axis]
33
+ if extent < 0: return 0.0
34
+ var pixels: float = extent * (percent / 100.0)
35
+ if not is_finite(pixels) or not is_finite(Vector2(pixels,0).x):
36
+ push_warning("EstragonPixels result exceeds native finite pixel range; using 0 pixels")
37
+ return 0.0
38
+ return pixels
@@ -0,0 +1 @@
1
+ uid://e7b3c54c9f3a
@@ -3,6 +3,7 @@ extends Resource
3
3
  const Profile = preload("profile.tres")
4
4
  ## Framework-owned shared scope stack; never stored on application objects.
5
5
  var scopes: Array = []
6
+ var composing_hosts: Array = []
6
7
  var records: Dictionary = {}
7
8
  var managed: Dictionary = {}
8
9
  var dirty: Array = []
@@ -39,14 +40,19 @@ func drain() -> void:
39
40
  break
40
41
  flushing = false
41
42
  if Profile.is_enabled() and passes>0: Profile.elapsed("drain",started)
42
- func begin() -> void:
43
+ func begin(host: Node = null) -> void:
43
44
  scopes.append({})
45
+ composing_hosts.append(weakref(host) if host != null else null)
46
+ func current_host() -> Node:
47
+ if composing_hosts.is_empty() or composing_hosts.back() == null: return null
48
+ return composing_hosts.back().get_ref()
44
49
  func observe(source: Object, event: StringName) -> void:
45
50
  if scopes.is_empty(): return
46
51
  if Profile.is_enabled(): Profile.add("getter_reads")
47
52
  var key := str(source.get_instance_id())+":"+str(event)
48
53
  scopes.back()[key] = [weakref(source),event]
49
54
  func finish() -> Dictionary:
55
+ composing_hosts.pop_back()
50
56
  return scopes.pop_back()
51
57
  func lifecycle(host: Node, what: int) -> void:
52
58
  if Engine.is_editor_hint(): return
@@ -0,0 +1,38 @@
1
+ @tool
2
+ class_name EstragonBox
3
+ extends "component_2d.gd"
4
+ ## Constructible horizontal Box. VBox selects the vertical axis.
5
+ # -1 means an unset edge; explicit edges always override the shorthand.
6
+ @export var padding: float = 0.0:
7
+ set(value):
8
+ if not is_finite(value) or value < 0 or value == padding: return
9
+ padding = value
10
+ _changed()
11
+ @export var padding_top: float = -1.0:
12
+ set(value):
13
+ if not valid_length(value) or value == padding_top: return
14
+ padding_top = value
15
+ _changed()
16
+ @export var padding_right: float = -1.0:
17
+ set(value):
18
+ if not valid_length(value) or value == padding_right: return
19
+ padding_right = value
20
+ _changed()
21
+ @export var padding_bottom: float = -1.0:
22
+ set(value):
23
+ if not valid_length(value) or value == padding_bottom: return
24
+ padding_bottom = value
25
+ _changed()
26
+ @export var padding_left: float = -1.0:
27
+ set(value):
28
+ if not valid_length(value) or value == padding_left: return
29
+ padding_left = value
30
+ _changed()
31
+
32
+ func _padding_insets() -> Vector4:
33
+ return Vector4(padding_left if padding_left >= 0 else padding,padding_top if padding_top >= 0 else padding,padding_right if padding_right >= 0 else padding,padding_bottom if padding_bottom >= 0 else padding)
34
+
35
+ func _layout_options() -> Dictionary:
36
+ var options := super._layout_options()
37
+ options.padding = _padding_insets()
38
+ return options
@@ -0,0 +1 @@
1
+ uid://beab4bf1a259
@@ -40,6 +40,36 @@ var _layout_size := Vector2.ZERO
40
40
  # Internal bridge, deliberately not the public authoring API.
41
41
  var layout = Coordinator.new(self, 2, Coordinator.Mode.ENTRY if _is_layout_entry() else Coordinator.Mode.PARTICIPANT)
42
42
 
43
+ # -1 means an unset edge; explicit edges always override the shorthand.
44
+ @export var margin: float = 0.0:
45
+ set(value):
46
+ if not is_finite(value) or value < 0 or value == margin: return
47
+ margin = value
48
+ _changed()
49
+ @export var margin_top: float = -1.0:
50
+ set(value):
51
+ if not valid_length(value) or value == margin_top: return
52
+ margin_top = value
53
+ _changed()
54
+ @export var margin_right: float = -1.0:
55
+ set(value):
56
+ if not valid_length(value) or value == margin_right: return
57
+ margin_right = value
58
+ _changed()
59
+ @export var margin_bottom: float = -1.0:
60
+ set(value):
61
+ if not valid_length(value) or value == margin_bottom: return
62
+ margin_bottom = value
63
+ _changed()
64
+ @export var margin_left: float = -1.0:
65
+ set(value):
66
+ if not valid_length(value) or value == margin_left: return
67
+ margin_left = value
68
+ _changed()
69
+
70
+ func _margin_insets() -> Vector4:
71
+ return Vector4(margin_left if margin_left >= 0 else margin,margin_top if margin_top >= 0 else margin,margin_right if margin_right >= 0 else margin,margin_bottom if margin_bottom >= 0 else margin)
72
+
43
73
  static func valid_length(value: float) -> bool:
44
74
  return is_finite(value) and (value >= 0 or value == -1)
45
75
 
@@ -61,7 +91,7 @@ func _measure_native() -> Vector2:
61
91
 
62
92
  func _layout_options() -> Dictionary:
63
93
  var natural := _measure_native()
64
- return {"axis":_layout_axis(),"fill":Vector3(1 if fill_width else 0,1 if fill_height else 0,0),"intrinsic":Vector3(natural.x,natural.y,0)}
94
+ return {"margin":_margin_insets(),"axis":_layout_axis(),"fill":Vector3(1 if fill_width else 0,1 if fill_height else 0,0),"intrinsic":Vector3(natural.x,natural.y,0)}
65
95
 
66
96
  func _is_layout_entry() -> bool:
67
97
  return false
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name Estragon2D
3
- extends "component_2d.gd"
3
+ extends "box.gd"
4
4
  ## Explicit independent layout scope; does not assign native scene owner.
5
5
  @export var viewport_width_scale: float = 0.0:
6
6
  set(value):
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonHBox
3
- extends "component_2d.gd"
3
+ extends "box.gd"
4
4
  ## Native stack participant using the shared composed layout algorithm.
5
5
  func _layout_axis() -> int:
6
6
  return 0
@@ -134,7 +134,7 @@ func changed() -> void:
134
134
  if host == null: return
135
135
  if host.has_method("_layout_options"):
136
136
  var options: Dictionary = host._layout_options()
137
- model.configure(host.requested_extent(),host.gap,host.center,options.axis,options.fill,options.intrinsic)
137
+ model.configure(host.requested_extent(),host.gap,host.center,options.axis,options.fill,options.intrinsic,options.get("padding",Vector4.ZERO),options.get("margin",Vector4.ZERO))
138
138
  else: model.configure(host.requested_extent(), host.gap, host.center)
139
139
 
140
140
  func _viewport_changed() -> void:
@@ -157,12 +157,17 @@ func _flush() -> void:
157
157
  flush_count += 1
158
158
  if Profile.is_enabled(): Profile.add("layout_flushes")
159
159
  var available: Vector3 = model.measure()
160
+ var external_axes := Vector3.ZERO
160
161
  if _viewport != null:
161
162
  var scale := _viewport_scale(host)
162
163
  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
165
- model.arrange(available)
164
+ if scale.x > 0:
165
+ available.x = visible.x * scale.x
166
+ external_axes.x = 1
167
+ if scale.y > 0:
168
+ available.y = visible.y * scale.y
169
+ external_axes.y = 1
170
+ model.arrange(available,external_axes)
166
171
  CompositionHosts.refresh_positions(self)
167
172
 
168
173
  func _place(offset: Vector3) -> void:
@@ -5,6 +5,8 @@ const Profile = preload("../../composition/profile.tres")
5
5
  signal invalidated
6
6
  signal placed(offset)
7
7
  signal arranged(size)
8
+ signal reference_changed
9
+ signal parent_changed
8
10
  var requested := Vector3(-1, -1, -1)
9
11
  var gap: float = 0.0
10
12
  var center: bool = false
@@ -13,8 +15,14 @@ var fill := Vector3.ZERO
13
15
  var intrinsic := Vector3.ZERO
14
16
  # Native Control minimums constrain assigned slots, never read back from size.
15
17
  var allocation_minimum := Vector3.ZERO
18
+ var padding := Vector4.ZERO # left, top, right, bottom; border-box insets
19
+ var margin := Vector4.ZERO # outside own geometry; consumed by the parent
20
+ var transparent: bool = false # composition proxy forwards one root slot
16
21
  var children: Array = []
17
22
  var measured := Vector3.ZERO
23
+ # -1 is an unavailable/cyclic reference axis, distinct from an arranged zero.
24
+ var content_reference := Vector3(-1,-1,-1)
25
+ var _external_axes := Vector3.ZERO
18
26
  var size := Vector3.ZERO
19
27
  var offset := Vector3.ZERO
20
28
  var measure_count: int = 0
@@ -28,11 +36,16 @@ static func valid_extent(value: Vector3) -> bool:
28
36
  if not is_finite(value[axis]) or value[axis] < 0 and value[axis] != -1: return false
29
37
  return true
30
38
 
31
- func configure(extent: Vector3, spacing: float, centered: bool, stack_axis: int = 0, fills: Vector3 = Vector3.ZERO, content: Vector3 = Vector3.ZERO) -> Error:
39
+ func configure(extent: Vector3, spacing: float, centered: bool, stack_axis: int = 0, fills: Vector3 = Vector3.ZERO, content: Vector3 = Vector3.ZERO, inner: Vector4 = Vector4.ZERO, outer: Vector4 = Vector4.ZERO, passthrough: bool = false) -> Error:
32
40
  if not valid_extent(extent) or not is_finite(spacing) or spacing < 0 or stack_axis < 0 or stack_axis > 2: return ERR_INVALID_PARAMETER
33
41
  for index in range(3):
34
42
  if fills[index] not in [0.0,1.0] or not is_finite(content[index]) or content[index] < 0: return ERR_INVALID_PARAMETER
35
- if requested == extent and gap == spacing and center == centered and axis == stack_axis and fill == fills and intrinsic == content: return OK
43
+ for edge in range(4):
44
+ if not is_finite(inner[edge]) or inner[edge] < 0 or not is_finite(outer[edge]) or outer[edge] < 0: return ERR_INVALID_PARAMETER
45
+ if requested == extent and gap == spacing and center == centered and axis == stack_axis and fill == fills and intrinsic == content and padding == inner and margin == outer and transparent == passthrough: return OK
46
+ padding = inner
47
+ margin = outer
48
+ transparent = passthrough
36
49
  axis = stack_axis
37
50
  fill = fills
38
51
  intrinsic = content
@@ -53,11 +66,17 @@ func set_children(values: Array) -> Error:
53
66
  if child._parent != null and child._parent.get_ref() != null and child._parent.get_ref() != self: return ERR_ALREADY_IN_USE
54
67
  seen.append(child)
55
68
  if children == values: return OK
69
+ var moved: Array = []
56
70
  for child in children:
57
- if not values.has(child): child._parent = null
71
+ if not values.has(child):
72
+ child._parent = null
73
+ moved.append(child)
58
74
  children = values.duplicate()
59
- for child in children: child._parent = weakref(self)
75
+ for child in children:
76
+ if child._parent == null or child._parent.get_ref() != self: moved.append(child)
77
+ child._parent = weakref(self)
60
78
  invalidate()
79
+ for child in moved: child.parent_changed.emit()
61
80
  return OK
62
81
 
63
82
  func invalidate() -> void:
@@ -67,6 +86,13 @@ func invalidate() -> void:
67
86
  if parent != null: parent.invalidate()
68
87
  invalidated.emit()
69
88
 
89
+ static func leading(edges: Vector4) -> Vector3:
90
+ return Vector3(edges.x,edges.y,0)
91
+ static func trailing(edges: Vector4) -> Vector3:
92
+ return Vector3(edges.z,edges.w,0)
93
+ func outer_extent() -> Vector3:
94
+ return leading(margin)+trailing(margin)
95
+
70
96
  func measure() -> Vector3:
71
97
  if not _measure_dirty: return measured
72
98
  measure_count += 1
@@ -74,19 +100,37 @@ func measure() -> Vector3:
74
100
  var natural := Vector3.ZERO
75
101
  for child in children:
76
102
  var child_size: Vector3 = child.measure()
103
+ if not transparent: child_size += child.outer_extent()
77
104
  for index in range(3):
78
105
  if index == axis: natural[index] += child_size[index]
79
106
  else: natural[index] = maxf(natural[index],child_size[index])
80
107
  if children.size() > 1: natural[axis] += gap * (children.size() - 1)
81
108
  for index in range(3): natural[index] = maxf(natural[index],intrinsic[index])
109
+ if not transparent: natural += leading(padding)+trailing(padding)
82
110
  measured = natural
83
111
  for axis in range(3):
84
112
  if requested[axis] >= 0: measured[axis] = requested[axis]
85
113
  _measure_dirty = false
86
114
  return measured
87
115
 
88
- func arrange(available: Vector3) -> void:
89
- if not _arrange_dirty and size == available: return
116
+ # An auto axis cannot be a reference to its own descendants. Fill allocations
117
+ # ignore this model's intrinsic extent and can inherit an independent basis.
118
+ func independent_axis(index: int) -> bool:
119
+ if not transparent and (requested[index] >= 0 or _external_axes[index] > 0): return true
120
+ var parent = _parent.get_ref() if _parent != null else null
121
+ if parent == null: return false
122
+ return parent.independent_axis(index) if requested[index] < 0 and fill[index] > 0 else false
123
+
124
+ func arrange(available: Vector3, external_axes: Vector3 = Vector3.ZERO) -> void:
125
+ _external_axes = external_axes
126
+ var content := available-leading(padding)-trailing(padding)
127
+ var reference := Vector3(-1,-1,-1)
128
+ for index in range(3):
129
+ content[index] = maxf(0,content[index])
130
+ if independent_axis(index): reference[index] = content[index]
131
+ var changed: bool = reference != content_reference
132
+ if not _arrange_dirty and size == available and not changed: return
133
+ content_reference = reference
90
134
  measure()
91
135
  arrange_count += 1
92
136
  if Profile.is_enabled(): Profile.add("layout_arranges")
@@ -94,12 +138,22 @@ func arrange(available: Vector3) -> void:
94
138
  # Clear before callbacks so a signal-triggered change queues a genuine
95
139
  # follow-up instead of being overwritten when this pass finishes.
96
140
  _arrange_dirty = false
141
+ if transparent:
142
+ for child in children:
143
+ if child.offset != Vector3.ZERO or child.arrange_count == 0:
144
+ child.offset = Vector3.ZERO
145
+ child.placed.emit(Vector3.ZERO)
146
+ child.arrange(available)
147
+ arranged.emit(size)
148
+ if changed: reference_changed.emit()
149
+ return
97
150
  var fixed: float = gap * maxi(0, children.size() - 1)
98
151
  var flexible: Array = []
99
152
  for child in children:
153
+ fixed += child.outer_extent()[axis]
100
154
  if child.fill[axis] > 0 and child.requested[axis] < 0: flexible.append(child)
101
155
  else: fixed += child.measured[axis]
102
- var remaining: float = maxf(0,available[axis] - fixed)
156
+ var remaining: float = maxf(0,content[axis] - fixed)
103
157
  var shares: Dictionary = {}
104
158
  # Reserve constrained native minimums, then share the remaining space.
105
159
  # Zero floors preserve the existing equal-share Box behavior.
@@ -117,18 +171,19 @@ func arrange(available: Vector3) -> void:
117
171
  break
118
172
  var row_extent: float = fixed
119
173
  for share in shares.values(): row_extent += share
120
- var cursor: float = (available[axis] - row_extent) * 0.5 if center else 0.0
174
+ var cursor: float = (content[axis] - row_extent) * 0.5 if center else 0.0
121
175
  for child in children:
122
176
  var allocation: Vector3 = child.measured
123
177
  for index in range(3):
124
178
  if child.fill[index] > 0 and child.requested[index] < 0:
125
- allocation[index] = shares[child] if index == axis else available[index]
179
+ allocation[index] = shares[child] if index == axis else maxf(0,content[index]-child.outer_extent()[index])
126
180
  allocation[index] = maxf(allocation[index],child.allocation_minimum[index])
127
- var next := Vector3.ZERO
128
- next[axis] = cursor
181
+ var next := leading(padding)+leading(child.margin)
182
+ next[axis] += cursor
129
183
  if child.offset != next or child.arrange_count == 0:
130
184
  child.offset = next
131
185
  child.placed.emit(next)
132
186
  child.arrange(allocation)
133
- cursor += allocation[axis] + gap
187
+ cursor += allocation[axis] + child.outer_extent()[axis] + gap
134
188
  arranged.emit(size)
189
+ if changed: reference_changed.emit()
@@ -0,0 +1,20 @@
1
+ @tool
2
+ extends RefCounted
3
+ ## Shared GGX pixel domain, used before native description commits as well as
4
+ ## by static validation. Ordinary native properties keep their own contracts.
5
+ const Participant = preload("../component_2d.gd")
6
+ const Box = preload("../box.gd")
7
+ static func _derives(type, base: Script) -> bool:
8
+ if not type is Script: return false
9
+ while type != null:
10
+ if type == base: return true
11
+ type = type.get_base_script()
12
+ return false
13
+ static func kind(type, name: String) -> String:
14
+ if not _derives(type,Participant): return ""
15
+ if name in ["width","height"]: return "length"
16
+ if name == "gap" or name in ["margin","margin_top","margin_right","margin_bottom","margin_left"]: return "inset"
17
+ if name in ["padding","padding_top","padding_right","padding_bottom","padding_left"] and _derives(type,Box): return "inset"
18
+ return ""
19
+ static func valid(value, domain: String) -> bool:
20
+ return (value is int or value is float) and is_finite(float(value)) and (value >= 0 or domain == "length" and value == -1)
@@ -0,0 +1 @@
1
+ uid://758ca164d812
@@ -1,6 +1,6 @@
1
1
  @tool
2
2
  class_name EstragonVBox
3
- extends "component_2d.gd"
3
+ extends "box.gd"
4
4
  ## Native stack participant using the shared composed layout algorithm.
5
5
  func _layout_axis() -> int:
6
6
  return 1
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.14"
32
+ "version": "0.1.0-beta.15"
33
33
  }