@papercraftgames/estragon 0.1.0-beta.2 → 0.1.0-beta.21

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.
Files changed (95) hide show
  1. package/CHANGELOG.md +7 -3
  2. package/README.md +11 -8
  3. package/addons/estragon/compiler/bindable.gd +3 -3
  4. package/addons/estragon/compiler/compiler.gd +8 -8
  5. package/addons/estragon/compiler/composition.gd +5 -4
  6. package/addons/estragon/compiler/emitter.gd +34 -8
  7. package/addons/estragon/compiler/frontend.gd +8 -8
  8. package/addons/estragon/compiler/lexer.gd +2 -2
  9. package/addons/estragon/compiler/model.gd +2 -0
  10. package/addons/estragon/compiler/native/resolver.gd +125 -29
  11. package/addons/estragon/compiler/parser.gd +3 -3
  12. package/addons/estragon/compiler/project_sources.gd +91 -0
  13. package/addons/estragon/compiler/project_sources.gd.uid +1 -0
  14. package/addons/estragon/compiler/script_validation.gd +3 -3
  15. package/addons/estragon/compiler/source.gd +19 -2
  16. package/addons/estragon/compiler/source_map.gd +3 -3
  17. package/addons/estragon/compiler/validator.gd +74 -10
  18. package/addons/estragon/editor/build_service.gd +91 -72
  19. package/addons/estragon/editor/color_property.gd +37 -0
  20. package/addons/estragon/editor/color_property.gd.uid +1 -0
  21. package/addons/estragon/editor/completion.gd +531 -0
  22. package/addons/estragon/editor/completion.gd.uid +1 -0
  23. package/addons/estragon/editor/completion_edit.gd +7 -0
  24. package/addons/estragon/editor/completion_edit.gd.uid +1 -0
  25. package/addons/estragon/editor/components.gd +20 -0
  26. package/addons/estragon/editor/components.gd.uid +1 -0
  27. package/addons/estragon/editor/creation_menu.gd.txt +14 -0
  28. package/addons/estragon/editor/generated_editors.gd +256 -0
  29. package/addons/estragon/editor/generated_editors.gd.uid +1 -0
  30. package/addons/estragon/editor/highlighter.gd +62 -103
  31. package/addons/estragon/editor/highlighter_association.gd +11 -2
  32. package/addons/estragon/editor/imports.gd +47 -0
  33. package/addons/estragon/editor/imports.gd.uid +1 -0
  34. package/addons/estragon/editor/language_services.gd +288 -0
  35. package/addons/estragon/editor/language_services.gd.uid +1 -0
  36. package/addons/estragon/editor/length_property.gd +22 -0
  37. package/addons/estragon/editor/length_property.gd.uid +1 -0
  38. package/addons/estragon/editor/lexical_context.gd +159 -0
  39. package/addons/estragon/editor/lexical_context.gd.uid +1 -0
  40. package/addons/estragon/editor/navigation.gd +30 -0
  41. package/addons/estragon/editor/navigation.gd.uid +1 -0
  42. package/addons/estragon/editor/new_script.gd +77 -0
  43. package/addons/estragon/editor/new_script.gd.uid +1 -0
  44. package/addons/estragon/editor/plugin.cfg +1 -1
  45. package/addons/estragon/editor/plugin.gd +113 -40
  46. package/addons/estragon/editor/scene_components.gd +267 -0
  47. package/addons/estragon/editor/scene_components.gd.uid +1 -0
  48. package/addons/estragon/editor/scene_inspector.gd +42 -0
  49. package/addons/estragon/editor/scene_inspector.gd.uid +1 -0
  50. package/addons/estragon/editor/script_dependencies.gd +5 -3
  51. package/addons/estragon/runtime/composition/binding.gd +1 -1
  52. package/addons/estragon/runtime/composition/computation.gd +141 -9
  53. package/addons/estragon/runtime/composition/element.gd +3 -1
  54. package/addons/estragon/runtime/composition/layout_host.gd +58 -0
  55. package/addons/estragon/runtime/composition/layout_host.gd.uid +1 -0
  56. package/addons/estragon/runtime/composition/profile.tres +1 -1
  57. package/addons/estragon/runtime/composition/projection.gd +32 -0
  58. package/addons/estragon/runtime/composition/projection.gd.uid +1 -0
  59. package/addons/estragon/runtime/composition/state.gd +13 -2
  60. package/addons/estragon/runtime/composition/state.tres +1 -1
  61. package/addons/estragon/runtime/node/box.gd +57 -0
  62. package/addons/estragon/runtime/node/box.gd.uid +1 -0
  63. package/addons/estragon/runtime/node/button.gd +44 -15
  64. package/addons/estragon/runtime/node/component_2d.gd +167 -24
  65. package/addons/estragon/runtime/node/component_3d.gd +54 -18
  66. package/addons/estragon/runtime/node/estragon_2d.gd +2 -11
  67. package/addons/estragon/runtime/node/estragon_3d.gd +1 -10
  68. package/addons/estragon/runtime/node/hbox.gd +4 -1
  69. package/addons/estragon/runtime/node/internal/component_2d_icon.tres +4 -0
  70. package/addons/estragon/runtime/node/internal/composition_hosts.gd +159 -0
  71. package/addons/estragon/runtime/node/internal/composition_hosts.gd.uid +1 -0
  72. package/addons/estragon/runtime/node/internal/composition_hosts.tres +6 -0
  73. package/addons/estragon/runtime/node/internal/control_participant.gd +164 -0
  74. package/addons/estragon/runtime/node/internal/control_participant.gd.uid +1 -0
  75. package/addons/estragon/runtime/node/internal/coordinator.gd +79 -27
  76. package/addons/estragon/runtime/node/internal/grid_definition.gd +75 -0
  77. package/addons/estragon/runtime/node/internal/grid_definition.gd.uid +1 -0
  78. package/addons/estragon/runtime/node/internal/layout_core.gd +205 -22
  79. package/addons/estragon/runtime/node/internal/length.gd +94 -0
  80. package/addons/estragon/runtime/node/internal/length.gd.uid +1 -0
  81. package/addons/estragon/runtime/node/internal/stack_contract.gd +21 -0
  82. package/addons/estragon/runtime/node/internal/stack_contract.gd.uid +1 -0
  83. package/addons/estragon/runtime/node/internal/stack_policy.gd +59 -0
  84. package/addons/estragon/runtime/node/internal/stack_policy.gd.uid +1 -0
  85. package/addons/estragon/runtime/node/internal/visual_style_2d.gd +75 -0
  86. package/addons/estragon/runtime/node/internal/visual_style_2d.gd.uid +1 -0
  87. package/addons/estragon/runtime/node/native_2d.gd +5 -5
  88. package/addons/estragon/runtime/node/native_3d.gd +5 -5
  89. package/addons/estragon/runtime/node/rect.gd +13 -13
  90. package/addons/estragon/runtime/node/spacer.gd +4 -0
  91. package/addons/estragon/runtime/node/spacer.gd.uid +1 -0
  92. package/addons/estragon/runtime/node/text.gd +5 -3
  93. package/addons/estragon/runtime/node/toggle.gd +18 -5
  94. package/addons/estragon/runtime/node/vbox.gd +4 -1
  95. package/package.json +1 -1
@@ -1,34 +1,141 @@
1
+ @icon("internal/component_2d_icon.tres")
1
2
  @tool
2
3
  class_name EstragonComponent2D
3
4
  extends Node2D
4
5
  ## Native C1 participant. Needs a contiguous same-dimensional chain to an entry.
5
6
  signal layout_applied(size: Vector2)
6
- const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordinator.gd")
7
- @export var width: float = -1.0:
7
+ const Coordinator = preload("internal/coordinator.gd")
8
+ const ESTRAGON_LENGTHS := true
9
+ const VisualStyle = preload("internal/visual_style_2d.gd")
10
+ var _visual_style = VisualStyle.new()
11
+ const Length = preload("internal/length.gd")
12
+ var lengths = Length.new()
13
+ const ESTRAGON_VISUAL_STYLE := true
14
+ var background_color: Variant = "transparent":
8
15
  set(value):
9
- if not valid_length(value) or width == value: return
16
+ if is_same(background_color,value) or not _style_supported() or not _visual_style.assign("background_color",value): return
17
+ background_color = value
18
+ _queue_style_redraw()
19
+ var border_color: Variant = "transparent":
20
+ set(value):
21
+ if is_same(border_color,value) or not _style_supported() or not _visual_style.assign("border_color",value): return
22
+ border_color = value
23
+ _queue_style_redraw()
24
+ var border_width: Variant = 0.0:
25
+ set(value):
26
+ if is_same(border_width,value) or not _style_supported() or not lengths.assign("border_width",value): return
27
+ border_width = value
28
+ _changed()
29
+ _queue_style_redraw()
30
+ var border_top_width: Variant = "auto":
31
+ set(value):
32
+ if is_same(border_top_width,value) or not _style_supported() or not lengths.assign("border_top_width",value): return
33
+ border_top_width = value
34
+ _changed()
35
+ _queue_style_redraw()
36
+ var border_right_width: Variant = "auto":
37
+ set(value):
38
+ if is_same(border_right_width,value) or not _style_supported() or not lengths.assign("border_right_width",value): return
39
+ border_right_width = value
40
+ _changed()
41
+ _queue_style_redraw()
42
+ var border_bottom_width: Variant = "auto":
43
+ set(value):
44
+ if is_same(border_bottom_width,value) or not _style_supported() or not lengths.assign("border_bottom_width",value): return
45
+ border_bottom_width = value
46
+ _changed()
47
+ _queue_style_redraw()
48
+ var border_left_width: Variant = "auto":
49
+ set(value):
50
+ if is_same(border_left_width,value) or not _style_supported() or not lengths.assign("border_left_width",value): return
51
+ border_left_width = value
52
+ _changed()
53
+ _queue_style_redraw()
54
+ var padding: Variant = 0.0:
55
+ set(value):
56
+ if is_same(padding,value) or not lengths.assign("padding",value,Length.domain("padding",get_script())): return
57
+ padding = value
58
+ _changed()
59
+ var padding_top: Variant = "auto":
60
+ set(value):
61
+ if is_same(padding_top,value) or not lengths.assign("padding_top",value): return
62
+ padding_top = value
63
+ _changed()
64
+ var padding_right: Variant = "auto":
65
+ set(value):
66
+ if is_same(padding_right,value) or not lengths.assign("padding_right",value): return
67
+ padding_right = value
68
+ _changed()
69
+ var padding_bottom: Variant = "auto":
70
+ set(value):
71
+ if is_same(padding_bottom,value) or not lengths.assign("padding_bottom",value): return
72
+ padding_bottom = value
73
+ _changed()
74
+ var padding_left: Variant = "auto":
75
+ set(value):
76
+ if is_same(padding_left,value) or not lengths.assign("padding_left",value): return
77
+ padding_left = value
78
+ _changed()
79
+ var width: Variant = "auto":
80
+ set(value):
81
+ if is_same(width,value) or not lengths.assign("width",value): return
10
82
  width = value
11
83
  _changed()
12
- @export var height: float = -1.0:
84
+ var height: Variant = "auto":
13
85
  set(value):
14
- if not valid_length(value) or height == value: return
86
+ if is_same(height,value) or not lengths.assign("height",value): return
15
87
  height = value
16
88
  _changed()
17
- @export var fill_width: bool = false:
89
+ var x: Variant = 0.0:
18
90
  set(value):
19
- if fill_width == value: return
20
- fill_width = value
91
+ if is_same(x,value) or not lengths.assign("x",value): return
92
+ x = value
21
93
  _changed()
22
- @export var fill_height: bool = false:
94
+ var y: Variant = 0.0:
23
95
  set(value):
24
- if fill_height == value: return
25
- fill_height = value
96
+ if is_same(y,value) or not lengths.assign("y",value): return
97
+ y = value
26
98
  _changed()
27
- @export var gap: float = 0.0:
99
+ var gap: Variant = 0.0:
28
100
  set(value):
29
- if not is_finite(value) or value < 0 or value == gap: return
101
+ if is_same(gap,value) or not lengths.assign("gap",value): return
30
102
  gap = value
31
103
  _changed()
104
+ var margin: Variant = 0.0:
105
+ set(value):
106
+ if is_same(margin,value) or not lengths.assign("margin",value): return
107
+ margin = value
108
+ _changed()
109
+ var margin_top: Variant = "auto":
110
+ set(value):
111
+ if is_same(margin_top,value) or not lengths.assign("margin_top",value): return
112
+ margin_top = value
113
+ _changed()
114
+ var margin_right: Variant = "auto":
115
+ set(value):
116
+ if is_same(margin_right,value) or not lengths.assign("margin_right",value): return
117
+ margin_right = value
118
+ _changed()
119
+ var margin_bottom: Variant = "auto":
120
+ set(value):
121
+ if is_same(margin_bottom,value) or not lengths.assign("margin_bottom",value): return
122
+ margin_bottom = value
123
+ _changed()
124
+ var margin_left: Variant = "auto":
125
+ set(value):
126
+ if is_same(margin_left,value) or not lengths.assign("margin_left",value): return
127
+ margin_left = value
128
+ _changed()
129
+ @export var grow: float = 0.0:
130
+ set(value):
131
+ if not is_finite(value) or value<0 or value==grow: return
132
+ grow = value
133
+ _changed()
134
+ @export_enum("Natural", "Stretch") var stretch: int = 0:
135
+ set(value):
136
+ if value not in [0,1] or value==stretch: return
137
+ stretch = value
138
+ _changed()
32
139
  @export var center: bool = false:
33
140
  set(value):
34
141
  if center == value: return
@@ -37,11 +144,13 @@ const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordin
37
144
  var layout_size: Vector2:
38
145
  get: return _layout_size
39
146
  var _layout_size := Vector2.ZERO
40
- # Internal bridge, deliberately not the public authoring API.
41
147
  var layout = Coordinator.new(self, 2, Coordinator.Mode.ENTRY if _is_layout_entry() else Coordinator.Mode.PARTICIPANT)
42
-
43
- static func valid_length(value: float) -> bool:
44
- return is_finite(value) and (value >= 0 or value == -1)
148
+ func _get_property_list() -> Array[Dictionary]:
149
+ var properties := Length.properties(["width","height","x","y","gap","padding","padding_top","padding_right","padding_bottom","padding_left","margin","margin_top","margin_right","margin_bottom","margin_left"])
150
+ if VisualStyle.supported(get_script()): properties.append_array(Length.properties(["border_width","border_top_width","border_right_width","border_bottom_width","border_left_width","background_color","border_color"]))
151
+ return properties
152
+ static func valid_length(value) -> bool:
153
+ return Length.valid(value,"extent")
45
154
 
46
155
  func set_extent(value: Vector2) -> Error:
47
156
  for axis in range(2):
@@ -51,7 +160,7 @@ func set_extent(value: Vector2) -> Error:
51
160
  return OK
52
161
 
53
162
  func requested_extent() -> Vector3:
54
- return Vector3(width, height, 0.0)
163
+ return layout.model.requested
55
164
 
56
165
  func _layout_axis() -> int:
57
166
  return 0
@@ -59,16 +168,24 @@ func _layout_axis() -> int:
59
168
  func _measure_native() -> Vector2:
60
169
  return Vector2.ZERO
61
170
 
171
+ func _default_padding() -> Vector4:
172
+ return Vector4.ZERO
173
+
174
+ func _padding_insets() -> Vector4:
175
+ layout.model.prepare(layout.model.parent_reference,layout.model.viewport_size)
176
+ return layout.model.padding
177
+
178
+ func get_content_rect() -> Rect2:
179
+ var insets: Vector4 = layout.model.padding+layout.model.border
180
+ return Rect2(Vector2(insets.x,insets.y),Vector2(maxf(0,layout_size.x-insets.x-insets.z),maxf(0,layout_size.y-insets.y-insets.w)))
181
+
62
182
  func _layout_options() -> Dictionary:
63
183
  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)}
184
+ return {"axis":_layout_axis(),"fill":Vector3.ZERO,"intrinsic":Vector3(natural.x,natural.y,0)}
65
185
 
66
186
  func _is_layout_entry() -> bool:
67
187
  return false
68
188
 
69
- func _layout_viewport_scale() -> float:
70
- return 0.0
71
-
72
189
  func _changed() -> void:
73
190
  if layout != null: layout.changed()
74
191
 
@@ -77,10 +194,15 @@ func _notification(what: int) -> void:
77
194
  if what == 12 and layout != null: layout.order_moved()
78
195
 
79
196
  func _enter_tree() -> void:
197
+ # Native draw signal precedes script _draw, so derived Box foreground hooks
198
+ # cannot accidentally bypass the shared style. Legacy widget painters
199
+ # explicitly opt out of S01 styles and remain untouched until S02.
200
+ if VisualStyle.supported(get_script()) and not draw.is_connected(_paint_visual_style): draw.connect(_paint_visual_style)
80
201
  layout.changed()
81
202
  layout.start()
82
203
 
83
204
  func _exit_tree() -> void:
205
+ if draw.is_connected(_paint_visual_style): draw.disconnect(_paint_visual_style)
84
206
  layout.stop()
85
207
 
86
208
  func invalidate_layout() -> void:
@@ -99,7 +221,28 @@ func apply_layout_position(offset: Vector3) -> void:
99
221
  position = Vector2(offset.x, offset.y)
100
222
 
101
223
  func apply_layout_size(size: Vector3) -> void:
102
- _layout_size = Vector2(size.x, size.y)
224
+ var next := Vector2(size.x,size.y)
225
+ if next!=_layout_size: _queue_style_redraw()
226
+ _layout_size = next
103
227
  # Explicit invalidation also restores a native position edited externally.
104
- if layout.parent_coordinator() != null: apply_layout_position(layout.model.offset)
228
+ if layout.parent_coordinator() != null: layout._place(layout.model.offset)
105
229
  layout_applied.emit(_layout_size)
230
+
231
+ func _margin_insets() -> Vector4:
232
+ layout.model.prepare(layout.model.parent_reference,layout.model.viewport_size)
233
+ return layout.model.margin
234
+
235
+ func _queue_style_redraw() -> void:
236
+ _visual_style.redraw_count += 1
237
+ queue_redraw()
238
+ func _paint_visual_style() -> void:
239
+ _visual_style.paint(self,layout_size,layout.model.border,get_background_color())
240
+ func get_background_color() -> Color:
241
+ return _visual_style.colors.background_color
242
+ func get_visual_style_stats() -> Dictionary:
243
+ return {"parse":_visual_style.parse_count,"draw":_visual_style.draw_count,"commands":_visual_style.command_count,"redraw":_visual_style.redraw_count}
244
+
245
+ func _style_supported() -> bool:
246
+ if VisualStyle.supported(get_script()): return true
247
+ push_error("Estragon style: shared visual styling is unsupported on this participant")
248
+ return false
@@ -3,27 +3,60 @@ class_name EstragonComponent3D
3
3
  extends Node3D
4
4
  ## Native C1 participant. Needs a contiguous same-dimensional chain to an entry.
5
5
  signal layout_applied(size: Vector3)
6
- const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordinator.gd")
7
- @export var width: float = -1.0:
6
+ const Coordinator = preload("internal/coordinator.gd")
7
+ const ESTRAGON_LENGTHS := true
8
+ const Length = preload("internal/length.gd")
9
+ var lengths = Length.new()
10
+ var width: Variant = "auto":
8
11
  set(value):
9
- if not valid_length(value) or width == value: return
12
+ if is_same(width,value) or not lengths.assign("width",value): return
10
13
  width = value
11
14
  _changed()
12
- @export var height: float = -1.0:
15
+ var height: Variant = "auto":
13
16
  set(value):
14
- if not valid_length(value) or height == value: return
17
+ if is_same(height,value) or not lengths.assign("height",value): return
15
18
  height = value
16
19
  _changed()
17
- @export var depth: float = -1.0:
20
+ var depth: Variant = "auto":
18
21
  set(value):
19
- if not valid_length(value) or depth == value: return
22
+ if is_same(depth,value) or not lengths.assign("depth",value): return
20
23
  depth = value
21
24
  _changed()
22
- @export var gap: float = 0.0:
25
+ var x: Variant = 0.0:
23
26
  set(value):
24
- if not is_finite(value) or value < 0 or value == gap: return
27
+ if is_same(x,value) or not lengths.assign("x",value): return
28
+ x = value
29
+ _changed()
30
+ var y: Variant = 0.0:
31
+ set(value):
32
+ if is_same(y,value) or not lengths.assign("y",value): return
33
+ y = value
34
+ _changed()
35
+ var z: Variant = 0.0:
36
+ set(value):
37
+ if is_same(z,value) or not lengths.assign("z",value): return
38
+ z = value
39
+ _changed()
40
+ var gap: Variant = 0.0:
41
+ set(value):
42
+ if is_same(gap,value) or not lengths.assign("gap",value): return
25
43
  gap = value
26
44
  _changed()
45
+ @export var grow: float = 0.0:
46
+ set(value):
47
+ if not is_finite(value) or value<0 or value==grow: return
48
+ grow = value
49
+ _changed()
50
+ @export_enum("Natural", "Stretch") var stretch: int = 0:
51
+ set(value):
52
+ if value not in [0,1] or value==stretch: return
53
+ stretch = value
54
+ _changed()
55
+ @export var pixels_per_unit: float = 100.0:
56
+ set(value):
57
+ if not is_finite(value) or value<=0 or pixels_per_unit==value: return
58
+ pixels_per_unit = value
59
+ _changed()
27
60
  @export var center: bool = false:
28
61
  set(value):
29
62
  if center == value: return
@@ -32,11 +65,11 @@ const Coordinator = preload("res://addons/estragon/runtime/node/internal/coordin
32
65
  var layout_size: Vector3:
33
66
  get: return _layout_size
34
67
  var _layout_size := Vector3.ZERO
35
- # Internal bridge, deliberately not the public authoring API.
36
68
  var layout = Coordinator.new(self, 3, Coordinator.Mode.ENTRY if _is_layout_entry() else Coordinator.Mode.PARTICIPANT)
37
-
38
- static func valid_length(value: float) -> bool:
39
- return is_finite(value) and (value >= 0 or value == -1)
69
+ func _get_property_list() -> Array[Dictionary]:
70
+ return Length.properties(["width","height","depth","x","y","z","gap"])
71
+ static func valid_length(value) -> bool:
72
+ return Length.valid(value,"extent")
40
73
 
41
74
  func set_extent(value: Vector3) -> Error:
42
75
  for axis in range(3):
@@ -47,14 +80,17 @@ func set_extent(value: Vector3) -> Error:
47
80
  return OK
48
81
 
49
82
  func requested_extent() -> Vector3:
50
- return Vector3(width, height, depth)
83
+ return layout.model.requested
84
+
85
+ func _measure_native() -> Vector3:
86
+ return Vector3.ZERO
87
+
88
+ func _layout_options() -> Dictionary:
89
+ return {"axis":0,"fill":Vector3.ZERO,"intrinsic":_measure_native()}
51
90
 
52
91
  func _is_layout_entry() -> bool:
53
92
  return false
54
93
 
55
- func _layout_viewport_scale() -> float:
56
- return 0.0
57
-
58
94
  func _changed() -> void:
59
95
  if layout != null: layout.changed()
60
96
 
@@ -87,5 +123,5 @@ func apply_layout_position(offset: Vector3) -> void:
87
123
  func apply_layout_size(size: Vector3) -> void:
88
124
  _layout_size = size
89
125
  # Explicit invalidation also restores a native position edited externally.
90
- if layout.parent_coordinator() != null: apply_layout_position(layout.model.offset)
126
+ if layout.parent_coordinator() != null: layout._place(layout.model.offset)
91
127
  layout_applied.emit(_layout_size)
@@ -1,20 +1,11 @@
1
1
  @tool
2
2
  class_name Estragon2D
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "box.gd"
4
4
  ## Explicit independent layout scope; does not assign native scene owner.
5
- @export var viewport_width_scale: float = 0.0:
6
- set(value):
7
- if not is_finite(value) or value < 0 or viewport_width_scale == value: return
8
- viewport_width_scale = value
9
- if layout != null: layout._invalidated()
10
-
11
5
  func _is_layout_entry() -> bool:
12
6
  return true
13
7
 
14
- func _layout_viewport_scale() -> float:
15
- return viewport_width_scale
16
-
17
- const Pointer = preload("res://addons/estragon/runtime/node/internal/pointer_2d.gd")
8
+ const Pointer = preload("internal/pointer_2d.gd")
18
9
  var _pointer = Pointer.new(self)
19
10
 
20
11
  func _get_pointer_router():
@@ -1,15 +1,6 @@
1
1
  @tool
2
2
  class_name Estragon3D
3
- extends "res://addons/estragon/runtime/node/component_3d.gd"
3
+ extends "component_3d.gd"
4
4
  ## Explicit independent layout scope; does not assign native scene owner.
5
- @export var viewport_width_scale: float = 0.0:
6
- set(value):
7
- if not is_finite(value) or value < 0 or viewport_width_scale == value: return
8
- viewport_width_scale = value
9
- if layout != null: layout._invalidated()
10
-
11
5
  func _is_layout_entry() -> bool:
12
6
  return true
13
-
14
- func _layout_viewport_scale() -> float:
15
- return viewport_width_scale
@@ -1,6 +1,9 @@
1
1
  @tool
2
2
  class_name EstragonHBox
3
- extends "res://addons/estragon/runtime/node/component_2d.gd"
3
+ extends "box.gd"
4
+ const STACK_DIRECTION := "row"
5
+ func _init() -> void:
6
+ direction = "row"
4
7
  ## Native stack participant using the shared composed layout algorithm.
5
8
  func _layout_axis() -> int:
6
9
  return 0
@@ -0,0 +1,4 @@
1
+ [gd_resource type="PlaceholderTexture2D" format=3]
2
+
3
+ [resource]
4
+ size = Vector2(16, 16)
@@ -0,0 +1,159 @@
1
+ @tool
2
+ extends Resource
3
+ ## External weak lookup only. Never serialized onto authored Nodes/Resources.
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)
39
+ func find(node: Node):
40
+ if node == null: return null
41
+ var reference = hosts.get(node.get_instance_id())
42
+ return reference.get_ref() if reference != null else null
43
+ func add(node: Node, coordinator: RefCounted) -> void:
44
+ hosts[node.get_instance_id()] = weakref(coordinator)
45
+ func remove(node: Node, coordinator: RefCounted) -> void:
46
+ if find(node) == coordinator: hosts.erase(node.get_instance_id())
47
+
48
+ # E08 borrowed scene references. All ownership/order bookkeeping lives here,
49
+ # never on authored objects. Native parents, owners and sibling order stay put.
50
+ var projections: Dictionary = {}
51
+ var orders: Dictionary = {}
52
+ var order_owners: Dictionary = {}
53
+ func projected_parent(node: Node) -> Node:
54
+ var entry = projections.get(node.get_instance_id())
55
+ return entry.parent.get_ref() if entry != null else null
56
+ func children(parent: Node, native_children: Array) -> Array:
57
+ var result: Array = []
58
+ for reference in orders.get(parent.get_instance_id(),[]):
59
+ var node = reference.get_ref()
60
+ if node != null:
61
+ var logical = projected_parent(node)
62
+ if logical == null or logical == parent: result.append(node)
63
+ for node in native_children:
64
+ var logical = projected_parent(node)
65
+ if not result.has(node) and (logical == null or logical == parent): result.append(node)
66
+ return result
67
+ func _coordinator(node: Node):
68
+ if node == null: return null
69
+ return node._get_layout_coordinator() if node.has_method("_get_layout_coordinator") else find(node)
70
+ func _placement(node: Node, parent: Node):
71
+ var coordinator = _coordinator(node)
72
+ if coordinator == null or coordinator._mode == coordinator.Mode.ENTRY or coordinator.participant(parent) == null: return null
73
+ return coordinator
74
+ func _same_projection(owner: RefCounted, next: Dictionary, next_orders: Dictionary) -> bool:
75
+ var count := 0
76
+ for id in projections:
77
+ var item: Dictionary = projections[id]
78
+ if item.claim.get_ref() != owner: continue
79
+ count += 1
80
+ if not next.has(id) or item.node.get_ref() != next[id][0] or item.parent.get_ref() != next[id][1] or item.native_parent.get_ref() != next[id][0].get_parent(): return false
81
+ if count != next.size(): return false
82
+ count = 0
83
+ for id in order_owners:
84
+ if order_owners[id].get_ref() != owner: continue
85
+ count += 1
86
+ if not next_orders.has(id) or orders[id].size() != next_orders[id].size(): return false
87
+ for index in range(orders[id].size()):
88
+ if orders[id][index].get_ref() != next_orders[id][index].get_ref(): return false
89
+ return count == next_orders.size()
90
+ func replace_projection(owner: RefCounted, next: Dictionary, next_orders: Dictionary) -> void:
91
+ if _same_projection(owner,next,next_orders):
92
+ for item in next.values():
93
+ var coordinator = _placement(item[0],item[1])
94
+ if coordinator != null and coordinator.scope_root() != null: coordinator._place(coordinator.model.offset)
95
+ return
96
+ var affected: Array = []
97
+ var refresh: Array = []
98
+ # Detach changed model edges before adopting into another model. Core remains
99
+ # the sole authority for one-parent/cycle validation and layout arithmetic.
100
+ for id in projections:
101
+ var item: Dictionary = projections[id]
102
+ if item.claim.get_ref() != owner: continue
103
+ for reference in [item.parent,item.native_parent]:
104
+ var node = reference.get_ref()
105
+ if node != null and not affected.has(node): affected.append(node)
106
+ for id in next:
107
+ var prior = projections.get(id)
108
+ if prior != null and prior.parent.get_ref() != null and not affected.has(prior.parent.get_ref()): affected.append(prior.parent.get_ref())
109
+ var item: Array = next[id]
110
+ for node in [item[0].get_parent(),item[1]]:
111
+ if node != null and not affected.has(node): affected.append(node)
112
+ for node in affected:
113
+ var coordinator = _coordinator(node)
114
+ if coordinator != null and coordinator.active: coordinator.model.set_children([])
115
+ for id in projections.keys():
116
+ var item: Dictionary = projections[id]
117
+ if item.claim.get_ref() != owner: continue
118
+ var node = item.node.get_ref()
119
+ if not next.has(id):
120
+ projections.erase(id)
121
+ if node != null:
122
+ if node is Control: release_control(node)
123
+ if node.get_parent() == item.native_parent.get_ref() and item.position != null: node.position = item.position
124
+ refresh.append(node)
125
+ for id in next:
126
+ var node: Node = next[id][0]
127
+ var parent: Node = next[id][1]
128
+ if not projections.has(id) or projections[id].claim.get_ref() != owner:
129
+ var coordinator = _placement(node,parent)
130
+ projections[id] = {"node":weakref(node),"native_parent":weakref(node.get_parent()),"position":node.position if coordinator != null and (node is Node2D or node is Node3D) else null,"claim":weakref(owner),"parent":weakref(parent)}
131
+ else:
132
+ var item: Dictionary = projections[id]
133
+ if _placement(node,parent) == null and item.position != null:
134
+ if node.get_parent() == item.native_parent.get_ref(): node.position = item.position
135
+ item.position = null
136
+ elif _placement(node,parent) != null and item.position == null and (node is Node2D or node is Node3D): item.position = node.position
137
+ item.parent = weakref(parent)
138
+ refresh.append(node)
139
+ for id in order_owners.keys():
140
+ if order_owners[id].get_ref() == owner:
141
+ orders.erase(id)
142
+ order_owners.erase(id)
143
+ for id in next_orders:
144
+ orders[id] = next_orders[id]
145
+ order_owners[id] = weakref(owner)
146
+ for node in affected:
147
+ var coordinator = _coordinator(node)
148
+ if coordinator != null: coordinator._sync()
149
+ for node in refresh: _refresh_scope(node)
150
+ func _refresh_scope(node: Node) -> void:
151
+ if node.has_method("_layout_scope_changed"): node._layout_scope_changed()
152
+ for child in node.get_children(): _refresh_scope(child)
153
+ func refresh_positions(root: RefCounted) -> void:
154
+ # Called after event-driven arrange, never per frame. A logical ancestor may
155
+ # move without changing this child's model offset, so refresh its translation.
156
+ for item in projections.values():
157
+ var node = item.node.get_ref()
158
+ var coordinator = _coordinator(node)
159
+ if coordinator != null and coordinator._mode != coordinator.Mode.ENTRY and coordinator.scope_root() == root: coordinator._place(coordinator.model.offset)
@@ -0,0 +1 @@
1
+ uid://6o74mb6n662t
@@ -0,0 +1,6 @@
1
+ [gd_resource type="Resource" load_steps=2 format=3]
2
+
3
+ [ext_resource type="Script" path="composition_hosts.gd" id="1"]
4
+
5
+ [resource]
6
+ script = ExtResource("1")