@papercraftgames/estragon 0.0.0-stage → 0.1.0-beta.2
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/CHANGELOG.md +11 -0
- package/LICENSE +20 -0
- package/README.md +28 -2
- package/addons/estragon/compiler/bindable.gd +213 -0
- package/addons/estragon/compiler/bindable.gd.uid +1 -0
- package/addons/estragon/compiler/compiler.gd +24 -0
- package/addons/estragon/compiler/compiler.gd.uid +1 -0
- package/addons/estragon/compiler/composition.gd +51 -0
- package/addons/estragon/compiler/composition.gd.uid +1 -0
- package/addons/estragon/compiler/diagnostic_capture.gd.txt +18 -0
- package/addons/estragon/compiler/emitter.gd +209 -0
- package/addons/estragon/compiler/emitter.gd.uid +1 -0
- package/addons/estragon/compiler/frontend.gd +22 -0
- package/addons/estragon/compiler/frontend.gd.uid +1 -0
- package/addons/estragon/compiler/lexer.gd +78 -0
- package/addons/estragon/compiler/lexer.gd.uid +1 -0
- package/addons/estragon/compiler/model.gd +87 -0
- package/addons/estragon/compiler/model.gd.uid +1 -0
- package/addons/estragon/compiler/native/resolver.gd +200 -0
- package/addons/estragon/compiler/native/resolver.gd.uid +1 -0
- package/addons/estragon/compiler/parser.gd +252 -0
- package/addons/estragon/compiler/parser.gd.uid +1 -0
- package/addons/estragon/compiler/script_validation.gd +80 -0
- package/addons/estragon/compiler/script_validation.gd.uid +1 -0
- package/addons/estragon/compiler/source.gd +65 -0
- package/addons/estragon/compiler/source.gd.uid +1 -0
- package/addons/estragon/compiler/source_map.gd +59 -0
- package/addons/estragon/compiler/source_map.gd.uid +1 -0
- package/addons/estragon/compiler/validator.gd +277 -0
- package/addons/estragon/compiler/validator.gd.uid +1 -0
- package/addons/estragon/editor/buffer_guard.gd +84 -0
- package/addons/estragon/editor/buffer_guard.gd.uid +1 -0
- package/addons/estragon/editor/build_service.gd +252 -0
- package/addons/estragon/editor/build_service.gd.uid +1 -0
- package/addons/estragon/editor/highlighter.gd +116 -0
- package/addons/estragon/editor/highlighter.gd.uid +1 -0
- package/addons/estragon/editor/highlighter_association.gd +80 -0
- package/addons/estragon/editor/highlighter_association.gd.uid +1 -0
- package/addons/estragon/editor/plugin.cfg +7 -0
- package/addons/estragon/editor/plugin.gd +225 -0
- package/addons/estragon/editor/plugin.gd.uid +1 -0
- package/addons/estragon/editor/script_dependencies.gd +45 -0
- package/addons/estragon/editor/script_dependencies.gd.uid +1 -0
- package/addons/estragon/runtime/composition/binding.gd +62 -0
- package/addons/estragon/runtime/composition/binding.gd.uid +1 -0
- package/addons/estragon/runtime/composition/computation.gd +477 -0
- package/addons/estragon/runtime/composition/computation.gd.uid +1 -0
- package/addons/estragon/runtime/composition/element.gd +23 -0
- package/addons/estragon/runtime/composition/element.gd.uid +1 -0
- package/addons/estragon/runtime/composition/profile.gd +21 -0
- package/addons/estragon/runtime/composition/profile.gd.uid +1 -0
- package/addons/estragon/runtime/composition/profile.tres +6 -0
- package/addons/estragon/runtime/composition/state.gd +65 -0
- package/addons/estragon/runtime/composition/state.gd.uid +1 -0
- package/addons/estragon/runtime/composition/state.tres +6 -0
- package/addons/estragon/runtime/node/button.gd +53 -0
- package/addons/estragon/runtime/node/button.gd.uid +1 -0
- package/addons/estragon/runtime/node/component_2d.gd +105 -0
- package/addons/estragon/runtime/node/component_2d.gd.uid +1 -0
- package/addons/estragon/runtime/node/component_3d.gd +91 -0
- package/addons/estragon/runtime/node/component_3d.gd.uid +1 -0
- package/addons/estragon/runtime/node/estragon_2d.gd +32 -0
- package/addons/estragon/runtime/node/estragon_2d.gd.uid +1 -0
- package/addons/estragon/runtime/node/estragon_3d.gd +15 -0
- package/addons/estragon/runtime/node/estragon_3d.gd.uid +1 -0
- package/addons/estragon/runtime/node/hbox.gd +6 -0
- package/addons/estragon/runtime/node/hbox.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/coordinator.gd +145 -0
- package/addons/estragon/runtime/node/internal/coordinator.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/layout_core.gd +115 -0
- package/addons/estragon/runtime/node/internal/layout_core.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/native_bounds.gd +103 -0
- package/addons/estragon/runtime/node/internal/native_bounds.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/pointer_2d.gd +70 -0
- package/addons/estragon/runtime/node/internal/pointer_2d.gd.uid +1 -0
- package/addons/estragon/runtime/node/native_2d.gd +40 -0
- package/addons/estragon/runtime/node/native_2d.gd.uid +1 -0
- package/addons/estragon/runtime/node/native_3d.gd +40 -0
- package/addons/estragon/runtime/node/native_3d.gd.uid +1 -0
- package/addons/estragon/runtime/node/rect.gd +15 -0
- package/addons/estragon/runtime/node/rect.gd.uid +1 -0
- package/addons/estragon/runtime/node/text.gd +66 -0
- package/addons/estragon/runtime/node/text.gd.uid +1 -0
- package/addons/estragon/runtime/node/toggle.gd +23 -0
- package/addons/estragon/runtime/node/toggle.gd.uid +1 -0
- package/addons/estragon/runtime/node/vbox.gd +6 -0
- package/addons/estragon/runtime/node/vbox.gd.uid +1 -0
- package/package.json +31 -4
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends RefCounted
|
|
3
|
+
## Entry-scoped event routing/capture. Weak participants; no frame polling.
|
|
4
|
+
var _host: WeakRef
|
|
5
|
+
var _buttons: Array[WeakRef] = []
|
|
6
|
+
var _captured: WeakRef
|
|
7
|
+
var _window: Window
|
|
8
|
+
func _init(host: Node) -> void:
|
|
9
|
+
_host = weakref(host)
|
|
10
|
+
func start() -> void:
|
|
11
|
+
var host = _host.get_ref()
|
|
12
|
+
_window = host.get_window()
|
|
13
|
+
_window.focus_exited.connect(cancel)
|
|
14
|
+
func stop() -> void:
|
|
15
|
+
cancel()
|
|
16
|
+
if is_instance_valid(_window) and _window.focus_exited.is_connected(cancel): _window.focus_exited.disconnect(cancel)
|
|
17
|
+
_window = null
|
|
18
|
+
_buttons.clear()
|
|
19
|
+
func register_button(button: Node2D) -> void:
|
|
20
|
+
for ref in _buttons:
|
|
21
|
+
if ref.get_ref() == button: return
|
|
22
|
+
_buttons.append(weakref(button))
|
|
23
|
+
func unregister_button(button: Node2D) -> void:
|
|
24
|
+
if _captured != null and _captured.get_ref() == button: cancel()
|
|
25
|
+
for index in range(_buttons.size()-1,-1,-1):
|
|
26
|
+
if _buttons[index].get_ref() == null or _buttons[index].get_ref() == button: _buttons.remove_at(index)
|
|
27
|
+
func cancel() -> void:
|
|
28
|
+
_captured = null
|
|
29
|
+
for ref in _buttons:
|
|
30
|
+
var button = ref.get_ref()
|
|
31
|
+
if button != null: button._set_pointer_state(false,false)
|
|
32
|
+
func cancel_button(button: Node2D) -> void:
|
|
33
|
+
if _captured != null and _captured.get_ref() == button: cancel()
|
|
34
|
+
button._set_pointer_state(false,false)
|
|
35
|
+
func _z(button: CanvasItem) -> int:
|
|
36
|
+
var result: int = button.z_index
|
|
37
|
+
var parent: CanvasItem = button.get_parent_item()
|
|
38
|
+
while button.z_as_relative and parent != null:
|
|
39
|
+
result += parent.z_index
|
|
40
|
+
button = parent
|
|
41
|
+
parent = button.get_parent_item()
|
|
42
|
+
return result
|
|
43
|
+
func pick(position: Vector2):
|
|
44
|
+
var found
|
|
45
|
+
for ref in _buttons:
|
|
46
|
+
var button = ref.get_ref()
|
|
47
|
+
if button == null or button.is_queued_for_deletion() or not button.is_inside_tree() or not button.is_visible_in_tree() or not button._pointer_contains(position): continue
|
|
48
|
+
if found == null or _z(button) > _z(found) or _z(button) == _z(found) and button.is_greater_than(found): found = button
|
|
49
|
+
return found
|
|
50
|
+
func input(event: InputEvent) -> bool:
|
|
51
|
+
if not event is InputEventMouse: return false
|
|
52
|
+
var hovered = pick(event.position)
|
|
53
|
+
var held = _captured.get_ref() if _captured != null else null
|
|
54
|
+
if event is InputEventMouseMotion:
|
|
55
|
+
for ref in _buttons:
|
|
56
|
+
var button = ref.get_ref()
|
|
57
|
+
if button != null: button._set_pointer_state(button==hovered,button==held)
|
|
58
|
+
return held != null
|
|
59
|
+
if not event is InputEventMouseButton or event.button_index != MOUSE_BUTTON_LEFT: return false
|
|
60
|
+
if event.pressed:
|
|
61
|
+
if held == null and hovered != null and not hovered.disabled:
|
|
62
|
+
_captured = weakref(hovered)
|
|
63
|
+
hovered._set_pointer_state(true,true)
|
|
64
|
+
return hovered != null
|
|
65
|
+
if held == null: return hovered != null
|
|
66
|
+
_captured = null
|
|
67
|
+
var activate: bool = held==hovered and not held.disabled and held.is_visible_in_tree()
|
|
68
|
+
held._set_pointer_state(held==hovered,false)
|
|
69
|
+
if activate: held.pressed.emit()
|
|
70
|
+
return true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://kca0bvfml2ah
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonNative2D
|
|
3
|
+
extends "res://addons/estragon/runtime/node/component_2d.gd"
|
|
4
|
+
## C1 bounded native visual participant; allocation never stretches geometry.
|
|
5
|
+
const Bounds = preload("res://addons/estragon/runtime/node/internal/native_bounds.gd")
|
|
6
|
+
@export var observe_native: bool = false:
|
|
7
|
+
set(value):
|
|
8
|
+
observe_native = value
|
|
9
|
+
if bounds != null: bounds.invalidate()
|
|
10
|
+
var bounds = Bounds.new(self, 2)
|
|
11
|
+
|
|
12
|
+
func _enter_tree() -> void:
|
|
13
|
+
bounds.start()
|
|
14
|
+
super._enter_tree()
|
|
15
|
+
|
|
16
|
+
func _exit_tree() -> void:
|
|
17
|
+
bounds.stop()
|
|
18
|
+
super._exit_tree()
|
|
19
|
+
|
|
20
|
+
func invalidate_native() -> void:
|
|
21
|
+
bounds.invalidate()
|
|
22
|
+
|
|
23
|
+
func requested_extent() -> Vector3:
|
|
24
|
+
var natural: Vector3 = bounds.extent if bounds != null else Vector3.ZERO
|
|
25
|
+
return Vector3(width if width >= 0 else natural.x, height if height >= 0 else natural.y, 0.0)
|
|
26
|
+
|
|
27
|
+
func apply_layout_position(offset: Vector3) -> void:
|
|
28
|
+
var value: Vector3 = offset - bounds.origin
|
|
29
|
+
position = Vector2(value.x, value.y)
|
|
30
|
+
|
|
31
|
+
func apply_layout_size(size: Vector3) -> void:
|
|
32
|
+
_layout_size = Vector2(size.x, size.y)
|
|
33
|
+
if layout.parent_coordinator() != null: apply_layout_position(layout.model.offset)
|
|
34
|
+
layout_applied.emit(_layout_size)
|
|
35
|
+
|
|
36
|
+
func get_native_bounds() -> Rect2:
|
|
37
|
+
return Rect2(Vector2(bounds.origin.x, bounds.origin.y), Vector2(bounds.extent.x, bounds.extent.y))
|
|
38
|
+
|
|
39
|
+
func get_native_bounds_status() -> Error:
|
|
40
|
+
return bounds.status
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://cgeg1e4kjrmls
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonNative3D
|
|
3
|
+
extends "res://addons/estragon/runtime/node/component_3d.gd"
|
|
4
|
+
## C1 bounded native visual participant; allocation never stretches geometry.
|
|
5
|
+
const Bounds = preload("res://addons/estragon/runtime/node/internal/native_bounds.gd")
|
|
6
|
+
@export var observe_native: bool = false:
|
|
7
|
+
set(value):
|
|
8
|
+
observe_native = value
|
|
9
|
+
if bounds != null: bounds.invalidate()
|
|
10
|
+
var bounds = Bounds.new(self, 3)
|
|
11
|
+
|
|
12
|
+
func _enter_tree() -> void:
|
|
13
|
+
bounds.start()
|
|
14
|
+
super._enter_tree()
|
|
15
|
+
|
|
16
|
+
func _exit_tree() -> void:
|
|
17
|
+
bounds.stop()
|
|
18
|
+
super._exit_tree()
|
|
19
|
+
|
|
20
|
+
func invalidate_native() -> void:
|
|
21
|
+
bounds.invalidate()
|
|
22
|
+
|
|
23
|
+
func requested_extent() -> Vector3:
|
|
24
|
+
var natural: Vector3 = bounds.extent if bounds != null else Vector3.ZERO
|
|
25
|
+
return Vector3(width if width >= 0 else natural.x, height if height >= 0 else natural.y, depth if depth >= 0 else natural.z)
|
|
26
|
+
|
|
27
|
+
func apply_layout_position(offset: Vector3) -> void:
|
|
28
|
+
var value: Vector3 = offset - bounds.origin
|
|
29
|
+
position = value
|
|
30
|
+
|
|
31
|
+
func apply_layout_size(size: Vector3) -> void:
|
|
32
|
+
_layout_size = size
|
|
33
|
+
if layout.parent_coordinator() != null: apply_layout_position(layout.model.offset)
|
|
34
|
+
layout_applied.emit(_layout_size)
|
|
35
|
+
|
|
36
|
+
func get_native_bounds() -> AABB:
|
|
37
|
+
return AABB(bounds.origin, bounds.extent)
|
|
38
|
+
|
|
39
|
+
func get_native_bounds_status() -> Error:
|
|
40
|
+
return bounds.status
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://clj7xp0nwlsgy
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonRect
|
|
3
|
+
extends "res://addons/estragon/runtime/node/component_2d.gd"
|
|
4
|
+
## Native rectangle drawing. Width/height are inherited layout inputs.
|
|
5
|
+
@export var fill := Color.WHITE:
|
|
6
|
+
set(value):
|
|
7
|
+
if fill == value: return
|
|
8
|
+
fill = value
|
|
9
|
+
queue_redraw()
|
|
10
|
+
func apply_layout_size(size: Vector3) -> void:
|
|
11
|
+
super.apply_layout_size(size)
|
|
12
|
+
queue_redraw()
|
|
13
|
+
func _draw() -> void:
|
|
14
|
+
if layout_size.x > 0 and layout_size.y > 0:
|
|
15
|
+
draw_rect(Rect2(Vector2.ZERO,layout_size),fill)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://d61h36t65rys
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonText
|
|
3
|
+
extends "res://addons/estragon/runtime/node/component_2d.gd"
|
|
4
|
+
## Native Font measure/draw, explicit lines only. No wrapping or rich text.
|
|
5
|
+
@export var text: String = "":
|
|
6
|
+
set(value):
|
|
7
|
+
if text == value: return
|
|
8
|
+
text = value
|
|
9
|
+
_content_changed()
|
|
10
|
+
@export var font: Font = ThemeDB.fallback_font:
|
|
11
|
+
set(value):
|
|
12
|
+
if value == null or value == font: return
|
|
13
|
+
_disconnect_font()
|
|
14
|
+
font = value
|
|
15
|
+
_connect_font()
|
|
16
|
+
_content_changed()
|
|
17
|
+
@export var font_size: int = 20:
|
|
18
|
+
set(value):
|
|
19
|
+
if value <= 0 or value == font_size: return
|
|
20
|
+
font_size = value
|
|
21
|
+
_content_changed()
|
|
22
|
+
@export var color := Color.WHITE:
|
|
23
|
+
set(value):
|
|
24
|
+
if color == value: return
|
|
25
|
+
color = value
|
|
26
|
+
queue_redraw()
|
|
27
|
+
var _label_cache := Vector2.ZERO
|
|
28
|
+
var _label_dirty: bool = true
|
|
29
|
+
|
|
30
|
+
func _enter_tree() -> void:
|
|
31
|
+
_connect_font()
|
|
32
|
+
super._enter_tree()
|
|
33
|
+
func _exit_tree() -> void:
|
|
34
|
+
_disconnect_font()
|
|
35
|
+
super._exit_tree()
|
|
36
|
+
func _connect_font() -> void:
|
|
37
|
+
if is_inside_tree() and font != null and not font.changed.is_connected(_content_changed): font.changed.connect(_content_changed)
|
|
38
|
+
func _disconnect_font() -> void:
|
|
39
|
+
if font != null and font.changed.is_connected(_content_changed): font.changed.disconnect(_content_changed)
|
|
40
|
+
func _content_changed() -> void:
|
|
41
|
+
_label_dirty = true
|
|
42
|
+
_changed()
|
|
43
|
+
queue_redraw()
|
|
44
|
+
func _measure_label() -> Vector2:
|
|
45
|
+
if not _label_dirty: return _label_cache
|
|
46
|
+
var size := Vector2.ZERO
|
|
47
|
+
if font == null: return size
|
|
48
|
+
for line in text.split("\n"):
|
|
49
|
+
size.x = maxf(size.x,font.get_string_size(line,HORIZONTAL_ALIGNMENT_LEFT,-1,font_size).x)
|
|
50
|
+
size.y += font.get_height(font_size)
|
|
51
|
+
_label_cache = size
|
|
52
|
+
_label_dirty = false
|
|
53
|
+
return size
|
|
54
|
+
func _measure_native() -> Vector2:
|
|
55
|
+
return _measure_label()
|
|
56
|
+
func apply_layout_size(size: Vector3) -> void:
|
|
57
|
+
super.apply_layout_size(size)
|
|
58
|
+
queue_redraw()
|
|
59
|
+
func _draw_label(offset: Vector2 = Vector2.ZERO, tint: Color = Color.WHITE) -> void:
|
|
60
|
+
if font == null: return
|
|
61
|
+
for line in text.split("\n"):
|
|
62
|
+
if not line.is_empty(): draw_string(font,offset+Vector2(0,font.get_ascent(font_size)),line,HORIZONTAL_ALIGNMENT_LEFT,-1,font_size,color*tint)
|
|
63
|
+
offset.y += font.get_height(font_size)
|
|
64
|
+
func _draw() -> void:
|
|
65
|
+
if layout_size.x <= 0 or layout_size.y <= 0: return
|
|
66
|
+
_draw_label()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://c233jntb6276a
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonToggle
|
|
3
|
+
extends "res://addons/estragon/runtime/node/button.gd"
|
|
4
|
+
## Controlled boolean input. Only pointer activation emits a user edit.
|
|
5
|
+
signal value_changed(value: bool)
|
|
6
|
+
@export var value: bool = false:
|
|
7
|
+
set(next):
|
|
8
|
+
if value == next: return
|
|
9
|
+
value = next
|
|
10
|
+
queue_redraw()
|
|
11
|
+
func _init() -> void:
|
|
12
|
+
pressed.connect(_activate)
|
|
13
|
+
func _activate() -> void:
|
|
14
|
+
if disabled: return
|
|
15
|
+
value = not value
|
|
16
|
+
value_changed.emit(value)
|
|
17
|
+
func get_background_color() -> Color:
|
|
18
|
+
if disabled: return super.get_background_color()
|
|
19
|
+
return Color("227a60") if value else super.get_background_color()
|
|
20
|
+
func _draw() -> void:
|
|
21
|
+
super._draw()
|
|
22
|
+
if value and layout_size.x>0 and layout_size.y>0:
|
|
23
|
+
draw_line(Vector2(2,layout_size.y-3),Vector2(layout_size.x-2,layout_size.y-3),Color("65f4b0"),3)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://9qq32x1eqm
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://rgnnyg88yvva
|
package/package.json
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papercraftgames/estragon",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Native Godot addon with Gogo/GGX reactive Node composition and layout-first 2D UI",
|
|
4
|
+
"license": "MIT",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/papercraftgames/Estragon.git"
|
|
8
|
+
},
|
|
9
|
+
"homepage": "https://github.com/papercraftgames/Estragon#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/papercraftgames/Estragon/issues"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"godot",
|
|
15
|
+
"gdscript",
|
|
16
|
+
"gogo",
|
|
17
|
+
"ggx",
|
|
18
|
+
"ui",
|
|
19
|
+
"layout"
|
|
20
|
+
],
|
|
21
|
+
"files": [
|
|
22
|
+
"addons/estragon/**",
|
|
23
|
+
"README.md",
|
|
24
|
+
"CHANGELOG.md",
|
|
25
|
+
"LICENSE"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public",
|
|
29
|
+
"tag": "beta",
|
|
30
|
+
"registry": "https://registry.npmjs.org/"
|
|
31
|
+
},
|
|
32
|
+
"version": "0.1.0-beta.2"
|
|
33
|
+
}
|