@papercraftgames/estragon 0.1.0-beta.31 → 0.1.0-beta.32
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/compiler/emitter.gd +6 -3
- package/addons/estragon/compiler/model.gd +1 -0
- package/addons/estragon/compiler/validator.gd +5 -3
- package/addons/estragon/editor/components.gd +1 -0
- package/addons/estragon/editor/plugin.cfg +1 -1
- package/addons/estragon/runtime/composition/binding.gd +14 -8
- package/addons/estragon/runtime/composition/computation.gd +4 -4
- package/addons/estragon/runtime/node/input.gd +161 -0
- package/addons/estragon/runtime/node/input.gd.uid +1 -0
- package/addons/estragon/runtime/node/internal/input_control.gd +25 -0
- package/addons/estragon/runtime/node/internal/input_control.gd.uid +1 -0
- package/package.json +1 -1
|
@@ -15,6 +15,7 @@ class Argument extends RefCounted:
|
|
|
15
15
|
var type_name: String
|
|
16
16
|
var name: String
|
|
17
17
|
var binding_path: Array = []
|
|
18
|
+
var binding_type := "bool"
|
|
18
19
|
|
|
19
20
|
class Factory extends RefCounted:
|
|
20
21
|
var name: String
|
|
@@ -135,7 +136,9 @@ func _collect(node: Model.Component, factory: Factory) -> void:
|
|
|
135
136
|
if attribute.value is Model.GdExpression:
|
|
136
137
|
_argument(attribute.value, attribute.type_name, factory)
|
|
137
138
|
factory.arguments.back().spread = attribute.kind=="spread"
|
|
138
|
-
if attribute.kind=="binding":
|
|
139
|
+
if attribute.kind=="binding":
|
|
140
|
+
factory.arguments.back().binding_path = attribute.binding_path
|
|
141
|
+
factory.arguments.back().binding_type = attribute.binding_type
|
|
139
142
|
for part in node.text_body:
|
|
140
143
|
if part is Model.GdExpression: _argument(part,"Variant",factory)
|
|
141
144
|
for child in node.children:
|
|
@@ -346,7 +349,7 @@ func _binding_argument(argument: Argument) -> void:
|
|
|
346
349
|
for name in path:
|
|
347
350
|
endpoint += "."+str(name)
|
|
348
351
|
checks.append(endpoint+" != null")
|
|
349
|
-
_writer.append("preload("+_resource(Binding)+").new("+root+", func("+owner+"): return "+endpoint+" if "+" and ".join(checks)+" else null, "+_string(field)+", func("+source+", "+edit+":
|
|
352
|
+
_writer.append("preload("+_resource(Binding)+").new("+root+", func("+owner+"): return "+endpoint+" if "+" and ".join(checks)+" else null, "+_string(field)+", func("+source+", "+edit+": "+argument.binding_type+"): "+source+"."+field+" = "+edit+", "+_string(".".join(argument.binding_path))+", (",argument.expression.span)
|
|
350
353
|
# Keep the original property read in authored scope: native semantic
|
|
351
354
|
# validation still rejects unknown members, and the getter runs once.
|
|
352
355
|
_parts(argument.expression.parts)
|
|
@@ -356,7 +359,7 @@ func _binding_argument(argument: Argument) -> void:
|
|
|
356
359
|
for name in path:
|
|
357
360
|
original += "."+str(name)
|
|
358
361
|
original_checks.append(original+" != null")
|
|
359
|
-
_writer.append(") if "+" and ".join(original_checks)+" else null)",argument.expression.span)
|
|
362
|
+
_writer.append(") if "+" and ".join(original_checks)+" else null"+(", TYPE_STRING" if argument.binding_type=="String" else "")+")",argument.expression.span)
|
|
360
363
|
|
|
361
364
|
func _render_call(node: Model.RenderCall) -> void:
|
|
362
365
|
var cast: String = node.result_type
|
|
@@ -369,10 +369,11 @@ func _native_type(property: Dictionary) -> String:
|
|
|
369
369
|
|
|
370
370
|
func _implicit_binding(attribute, properties: Dictionary, signals: Dictionary, script) -> void:
|
|
371
371
|
if attribute.name!="value" or not attribute.value is Model.GdExpression: return
|
|
372
|
-
if not properties.has("value") or properties.value.type
|
|
373
|
-
|
|
372
|
+
if not properties.has("value") or properties.value.type not in [TYPE_BOOL,TYPE_STRING] or int(properties.value.usage)&PROPERTY_USAGE_READ_ONLY: return
|
|
373
|
+
var kind: int = properties.value.type
|
|
374
|
+
if not properties.value.get("source_bindable",false) and not Binding.declared(script,"value",kind): return
|
|
374
375
|
var args: Array = signals.get("value_changed",{}).get("args",[])
|
|
375
|
-
if args.size()!=2 or args.any(func(arg): return arg.type!=
|
|
376
|
+
if args.size()!=2 or args.any(func(arg): return arg.type!=kind): return
|
|
376
377
|
var tokens := _expression_tokens(attribute.value)
|
|
377
378
|
if tokens.size()<3 or tokens.size()%2!=1: return
|
|
378
379
|
var names: Array = []
|
|
@@ -382,6 +383,7 @@ func _implicit_binding(attribute, properties: Dictionary, signals: Dictionary, s
|
|
|
382
383
|
attribute.kind = "binding"
|
|
383
384
|
attribute.type_name = "Variant"
|
|
384
385
|
attribute.binding_path = names
|
|
386
|
+
attribute.binding_type = "String" if kind==TYPE_STRING else "bool"
|
|
385
387
|
|
|
386
388
|
func _length(attribute, domain: String) -> void:
|
|
387
389
|
var value = attribute.value
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
extends RefCounted
|
|
3
3
|
## Trusted installed resources, not guessed global classes or installation roots.
|
|
4
4
|
const ITEMS := [
|
|
5
|
+
{"alias":"Input","canonical":"EstragonInput","script":preload("../runtime/node/input.gd"),"dimension":2,"origin":"Estragon native; explicit import"},
|
|
5
6
|
{"alias":"Checkbox","canonical":"EstragonCheckbox","script":preload("../runtime/node/checkbox.gd"),"dimension":2,"origin":"Estragon native; explicit import"},
|
|
6
7
|
{"alias":"Grid","canonical":"EstragonGrid","script":preload("../runtime/node/grid.gd"),"dimension":2,"origin":"native layout"},
|
|
7
8
|
{"alias":"Spacer","canonical":"EstragonSpacer","script":preload("../runtime/node/spacer.gd"),"dimension":2,"origin":"native layout"},
|
|
@@ -11,13 +11,15 @@ var write: Callable
|
|
|
11
11
|
var value: Variant
|
|
12
12
|
var valid := false
|
|
13
13
|
var observable := false
|
|
14
|
+
var kind := TYPE_BOOL
|
|
14
15
|
var node: WeakRef
|
|
15
16
|
var computation: WeakRef
|
|
16
17
|
var connected := false
|
|
17
18
|
var writing := false
|
|
18
|
-
func _init(owner: Variant, reader: Callable, property: StringName, writer: Callable, identity: String, snapshot_value: Variant) -> void:
|
|
19
|
+
func _init(owner: Variant, reader: Callable, property: StringName, writer: Callable, identity: String, snapshot_value: Variant, value_type: int = TYPE_BOOL) -> void:
|
|
20
|
+
kind = value_type
|
|
19
21
|
value = snapshot_value
|
|
20
|
-
valid = typeof(value)==
|
|
22
|
+
valid = kind in [TYPE_BOOL,TYPE_STRING] and typeof(value)==kind
|
|
21
23
|
if not owner is Object or not is_instance_valid(owner): return
|
|
22
24
|
route = identity
|
|
23
25
|
root = weakref(owner)
|
|
@@ -28,14 +30,16 @@ func _init(owner: Variant, reader: Callable, property: StringName, writer: Calla
|
|
|
28
30
|
if endpoint == null: return
|
|
29
31
|
source = weakref(endpoint)
|
|
30
32
|
if not valid: return
|
|
31
|
-
observable = declared(endpoint.get_script(),str(field))
|
|
33
|
+
observable = declared(endpoint.get_script(),str(field),kind)
|
|
32
34
|
if observable:
|
|
33
35
|
valid = endpoint.has_signal(str(field)+"_changed")
|
|
34
|
-
static func declared(script, property: String) -> bool:
|
|
36
|
+
static func declared(script, property: String, value_type: int = TYPE_BOOL) -> bool:
|
|
37
|
+
var type_name: String = {TYPE_BOOL:"bool",TYPE_STRING:"String"}.get(value_type,"")
|
|
38
|
+
if type_name.is_empty(): return false
|
|
35
39
|
while script is Script:
|
|
36
40
|
for name in script.get_script_constant_map():
|
|
37
41
|
var contract = script.get_script_constant_map()[name]
|
|
38
|
-
if str(name).begins_with("_GOGO_BINDABLE_PROPERTIES_") and contract is Dictionary and contract.get(property,"")==
|
|
42
|
+
if str(name).begins_with("_GOGO_BINDABLE_PROPERTIES_") and contract is Dictionary and contract.get(property,"")==type_name: return true
|
|
39
43
|
script = script.get_base_script()
|
|
40
44
|
return false
|
|
41
45
|
func current():
|
|
@@ -43,7 +47,7 @@ func current():
|
|
|
43
47
|
var endpoint = read.call(owner) if is_instance_valid(owner) else null
|
|
44
48
|
return endpoint if endpoint is Object and is_instance_valid(endpoint) else null
|
|
45
49
|
func same(other) -> bool:
|
|
46
|
-
return other!=null and valid and other.valid and source.get_ref()==other.source.get_ref() and root.get_ref()==other.root.get_ref() and field==other.field and route==other.route
|
|
50
|
+
return other!=null and valid and other.valid and kind==other.kind and source.get_ref()==other.source.get_ref() and root.get_ref()==other.root.get_ref() and field==other.field and route==other.route
|
|
47
51
|
func attach(target: Node, scope) -> void:
|
|
48
52
|
node = weakref(target)
|
|
49
53
|
computation = weakref(scope)
|
|
@@ -61,7 +65,8 @@ func _target_exit() -> void:
|
|
|
61
65
|
disconnect_edit()
|
|
62
66
|
var scope = computation.get_ref() if computation!=null else null
|
|
63
67
|
if scope!=null and scope.active and not scope.disposed: scope.schedule()
|
|
64
|
-
func edit(_previous:
|
|
68
|
+
func edit(_previous: Variant, next: Variant) -> void:
|
|
69
|
+
if typeof(next)!=kind: return
|
|
65
70
|
var scope = computation.get_ref() if computation!=null else null
|
|
66
71
|
var target = node.get_ref() if node!=null else null
|
|
67
72
|
var endpoint = source.get_ref() if source!=null else null
|
|
@@ -73,7 +78,7 @@ func edit(_previous: bool, next: bool) -> void:
|
|
|
73
78
|
# Reentrant model callbacks can restore the old value; commit must still
|
|
74
79
|
# restore a control whose local user value diverged from its snapshot.
|
|
75
80
|
scope.schedule()
|
|
76
|
-
func project(target: Node, next:
|
|
81
|
+
func project(target: Node, next: Variant) -> void:
|
|
77
82
|
writing = true
|
|
78
83
|
target.set("value",next)
|
|
79
84
|
writing = false
|
|
@@ -91,4 +96,5 @@ func snapshot():
|
|
|
91
96
|
result.value = value
|
|
92
97
|
result.valid = valid
|
|
93
98
|
result.observable = observable
|
|
99
|
+
result.kind = kind
|
|
94
100
|
return result
|
|
@@ -251,7 +251,7 @@ func _valid(desired: Element, previous: Mounted) -> bool:
|
|
|
251
251
|
for key in desired.bindings:
|
|
252
252
|
var binding = desired.bindings[key]
|
|
253
253
|
if not binding is Binding or not binding.valid:
|
|
254
|
-
validation_error = desired.location(str(key))+": invalid observable Bool binding endpoint; previous tree retained"
|
|
254
|
+
validation_error = desired.location(str(key))+": invalid observable "+("String" if binding is Binding and binding.kind==TYPE_STRING else "Bool")+" binding endpoint; previous tree retained"
|
|
255
255
|
return false
|
|
256
256
|
for event in desired.handlers:
|
|
257
257
|
var handler = desired.handlers[event]
|
|
@@ -405,7 +405,7 @@ func _apply(desired: Element, record: Mounted) -> void:
|
|
|
405
405
|
if Profile.is_enabled(): Profile.add("property_writes")
|
|
406
406
|
for key in desired.properties:
|
|
407
407
|
if scroll and key=="scroll_offset": continue
|
|
408
|
-
if not record.properties.has(key) or not is_same(record.properties[key],desired.properties[key]) or key=="value" and Binding.declared(node.get_script(),"value") and not is_same(node.get(key),desired.properties[key]):
|
|
408
|
+
if not record.properties.has(key) or not is_same(record.properties[key],desired.properties[key]) or key=="value" and Binding.declared(node.get_script(),"value",typeof(desired.properties[key])) and not is_same(node.get(key),desired.properties[key]):
|
|
409
409
|
if not stack or key not in ["direction","horizontal_align","vertical_align"]: node.set(key,desired.properties[key])
|
|
410
410
|
writes += 1
|
|
411
411
|
if Profile.is_enabled(): Profile.add("property_writes")
|
|
@@ -702,13 +702,13 @@ func _preflight(desired, previous, parent: Node, contracts: Variant = null) -> b
|
|
|
702
702
|
var expected: String = str(properties[key].get("class_name",""))
|
|
703
703
|
if ClassDB.class_exists(expected) and not value.is_class(expected): return _invalid_attribute(desired,str(key),"incompatible native Object class "+expected)
|
|
704
704
|
for key in desired.bindings:
|
|
705
|
-
if key!="value" or desired.properties.has(key) or not properties.has(key) or properties[key].type
|
|
705
|
+
if key!="value" or desired.properties.has(key) or not properties.has(key) or properties[key].type not in [TYPE_BOOL,TYPE_STRING] or desired.bindings[key].kind!=properties[key].type or int(properties[key].usage)&PROPERTY_USAGE_READ_ONLY: return _invalid_attribute(desired,str(key),"invalid or conflicting controlled binding")
|
|
706
706
|
var args: Array = signals.get("value_changed",{}).get("args",[])
|
|
707
707
|
|
|
708
708
|
# 4.0 lacks signal argument type metadata. Compiler source proof and
|
|
709
709
|
# native typed callback still apply; optional introspection cannot
|
|
710
710
|
# reject a valid input on that engine.
|
|
711
|
-
if args.size()!=2 or args.any(func(arg): return arg.type
|
|
711
|
+
if args.size()!=2 or args.any(func(arg): return arg.type!=TYPE_NIL and arg.type!=properties[key].type): return false
|
|
712
712
|
for key in desired.handlers:
|
|
713
713
|
if not signals.has(key): return _invalid_attribute(desired,str(key),"unknown native signal")
|
|
714
714
|
var message := _handler_error(desired.handlers[key],signals[key].get("args",[]).size())
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
class_name EstragonInput
|
|
3
|
+
extends "component_2d.gd"
|
|
4
|
+
## Node2D layout/skin with one private native single-line editing endpoint.
|
|
5
|
+
signal value_changed(previous: String, value: String)
|
|
6
|
+
signal submitted(value: String)
|
|
7
|
+
signal cancelled
|
|
8
|
+
signal focus_entered
|
|
9
|
+
signal focus_exited
|
|
10
|
+
const Editor = preload("internal/input_control.gd")
|
|
11
|
+
const Focus = preload("internal/focus.tres")
|
|
12
|
+
const State = preload("../composition/state.tres")
|
|
13
|
+
const _GOGO_BINDABLE_PROPERTIES_NATIVE := {"value":"String"}
|
|
14
|
+
@export var value: String = "":
|
|
15
|
+
set(next):
|
|
16
|
+
if value==next: return
|
|
17
|
+
var previous := value
|
|
18
|
+
value = next
|
|
19
|
+
_project_value()
|
|
20
|
+
value_changed.emit(previous,next)
|
|
21
|
+
get:
|
|
22
|
+
State.observe(self,&"value_changed")
|
|
23
|
+
return value
|
|
24
|
+
@export var placeholder: String = "":
|
|
25
|
+
set(next):
|
|
26
|
+
if placeholder==next: return
|
|
27
|
+
placeholder = next
|
|
28
|
+
_sync_editor()
|
|
29
|
+
@export var disabled := false:
|
|
30
|
+
set(next):
|
|
31
|
+
if disabled==next: return
|
|
32
|
+
disabled = next
|
|
33
|
+
_sync_editor()
|
|
34
|
+
queue_redraw()
|
|
35
|
+
@export var read_only := false:
|
|
36
|
+
set(next):
|
|
37
|
+
if read_only==next: return
|
|
38
|
+
read_only = next
|
|
39
|
+
_sync_editor()
|
|
40
|
+
@export var invalid := false:
|
|
41
|
+
set(next):
|
|
42
|
+
if invalid==next: return
|
|
43
|
+
invalid = next
|
|
44
|
+
queue_redraw()
|
|
45
|
+
@export_enum("None", "Click", "All") var focus_mode: int = Control.FOCUS_ALL:
|
|
46
|
+
set(next):
|
|
47
|
+
if next<Control.FOCUS_NONE or next>Control.FOCUS_ALL: return
|
|
48
|
+
focus_mode = next
|
|
49
|
+
_sync_editor()
|
|
50
|
+
@export var font: Font = ThemeDB.fallback_font:
|
|
51
|
+
set(next):
|
|
52
|
+
if next==null or next==font: return
|
|
53
|
+
_disconnect_font()
|
|
54
|
+
font = next
|
|
55
|
+
_connect_font()
|
|
56
|
+
_style_changed()
|
|
57
|
+
@export var font_size: int = 20:
|
|
58
|
+
set(next):
|
|
59
|
+
if next<=0 or font_size==next: return
|
|
60
|
+
font_size = next
|
|
61
|
+
_style_changed()
|
|
62
|
+
@export var color := Color.WHITE:
|
|
63
|
+
set(next):
|
|
64
|
+
if color==next: return
|
|
65
|
+
color = next
|
|
66
|
+
_sync_theme()
|
|
67
|
+
@export var focus_color := Color("#9cdcff"):
|
|
68
|
+
set(next):
|
|
69
|
+
focus_color = next
|
|
70
|
+
queue_redraw()
|
|
71
|
+
@export var invalid_color := Color("#f17b83"):
|
|
72
|
+
set(next):
|
|
73
|
+
invalid_color = next
|
|
74
|
+
queue_redraw()
|
|
75
|
+
var _editor: LineEdit
|
|
76
|
+
var _editor_skin := StyleBoxEmpty.new()
|
|
77
|
+
func _init() -> void:
|
|
78
|
+
background_color = Color("#252d38")
|
|
79
|
+
padding = 8.0
|
|
80
|
+
func _measure_native() -> Vector2:
|
|
81
|
+
# A stable single-line viewport, not a text-dependent expanding field.
|
|
82
|
+
return Vector2(200,font.get_height(font_size))
|
|
83
|
+
func _enter_tree() -> void:
|
|
84
|
+
_connect_font()
|
|
85
|
+
super._enter_tree()
|
|
86
|
+
if Engine.is_editor_hint(): return
|
|
87
|
+
_editor = Editor.new()
|
|
88
|
+
_editor.name = "_EstragonInput"
|
|
89
|
+
_editor.text = value
|
|
90
|
+
add_child(_editor,false,Node.INTERNAL_MODE_BACK)
|
|
91
|
+
_editor.text_changed.connect(_edited)
|
|
92
|
+
_editor.text_submitted.connect(_submitted)
|
|
93
|
+
layout_applied.connect(_sync_editor)
|
|
94
|
+
_sync_theme()
|
|
95
|
+
_sync_editor()
|
|
96
|
+
func _exit_tree() -> void:
|
|
97
|
+
if is_instance_valid(_editor):
|
|
98
|
+
layout_applied.disconnect(_sync_editor)
|
|
99
|
+
remove_child(_editor)
|
|
100
|
+
_editor.free()
|
|
101
|
+
_editor = null
|
|
102
|
+
_disconnect_font()
|
|
103
|
+
super._exit_tree()
|
|
104
|
+
func _composition_is_private(child: Node) -> bool:
|
|
105
|
+
return child==_editor or super._composition_is_private(child)
|
|
106
|
+
func _connect_font() -> void:
|
|
107
|
+
if is_inside_tree() and not font.changed.is_connected(_style_changed): font.changed.connect(_style_changed)
|
|
108
|
+
func _disconnect_font() -> void:
|
|
109
|
+
if font!=null and font.changed.is_connected(_style_changed): font.changed.disconnect(_style_changed)
|
|
110
|
+
func _style_changed() -> void:
|
|
111
|
+
_changed()
|
|
112
|
+
_sync_theme()
|
|
113
|
+
func _sync_theme() -> void:
|
|
114
|
+
if not is_instance_valid(_editor): return
|
|
115
|
+
# Native text/caret/selection draw in the real content rect; the host
|
|
116
|
+
# supplies the local surface, border and focus/invalid outline.
|
|
117
|
+
for state in ["normal","read_only","focus"]: _editor.add_theme_stylebox_override(state,_editor_skin)
|
|
118
|
+
_editor.add_theme_constant_override("minimum_character_width",0)
|
|
119
|
+
_editor.add_theme_font_override("font",font)
|
|
120
|
+
_editor.add_theme_font_size_override("font_size",font_size)
|
|
121
|
+
for key in ["font_color","font_uneditable_color","caret_color"]: _editor.add_theme_color_override(key,color)
|
|
122
|
+
_editor.add_theme_color_override("font_placeholder_color",Color(color,0.5))
|
|
123
|
+
_sync_editor()
|
|
124
|
+
func _sync_editor(_size: Vector2 = Vector2.ZERO) -> void:
|
|
125
|
+
if not is_instance_valid(_editor): return
|
|
126
|
+
var content := get_content_rect()
|
|
127
|
+
_editor.visible = content.size.x>0 and content.size.y>=font.get_height(font_size)
|
|
128
|
+
_editor_skin.content_margin_left = content.position.x
|
|
129
|
+
_editor_skin.content_margin_top = content.position.y
|
|
130
|
+
_editor_skin.content_margin_right = maxf(0,layout_size.x-content.end.x)
|
|
131
|
+
_editor_skin.content_margin_bottom = maxf(0,layout_size.y-content.end.y)
|
|
132
|
+
_editor.position = Vector2.ZERO
|
|
133
|
+
_editor.size = layout_size
|
|
134
|
+
_editor.placeholder_text = placeholder
|
|
135
|
+
_editor.editable = not disabled and not read_only
|
|
136
|
+
_editor.selecting_enabled = not disabled
|
|
137
|
+
_editor.shortcut_keys_enabled = not disabled
|
|
138
|
+
_editor.context_menu_enabled = not disabled
|
|
139
|
+
_editor.focus_mode = Control.FOCUS_NONE if disabled else focus_mode
|
|
140
|
+
_editor.modulate = Color(1,1,1,0.5) if disabled else Color.WHITE
|
|
141
|
+
if not Focus.eligible(_editor): _editor.release_focus()
|
|
142
|
+
func _project_value() -> void:
|
|
143
|
+
if not is_instance_valid(_editor) or _editor.text==value: return
|
|
144
|
+
var caret := _editor.caret_column
|
|
145
|
+
var selected := _editor.has_selection()
|
|
146
|
+
var start := _editor.get_selection_from_column() if selected else 0
|
|
147
|
+
var end := _editor.get_selection_to_column() if selected else 0
|
|
148
|
+
_editor.text = value
|
|
149
|
+
_editor.caret_column = mini(caret,value.length())
|
|
150
|
+
if selected: _editor.select(mini(start,value.length()),mini(end,value.length()))
|
|
151
|
+
func _edited(next: String) -> void: value = next
|
|
152
|
+
func _submitted(next: String) -> void: submitted.emit(next)
|
|
153
|
+
func grab_focus() -> void:
|
|
154
|
+
if is_instance_valid(_editor) and Focus.eligible(_editor): _editor.grab_focus()
|
|
155
|
+
func release_focus() -> void:
|
|
156
|
+
if is_instance_valid(_editor): _editor.release_focus()
|
|
157
|
+
func has_focus() -> bool: return is_instance_valid(_editor) and _editor.has_focus()
|
|
158
|
+
func get_focus_control() -> Control: return _editor
|
|
159
|
+
func _draw() -> void:
|
|
160
|
+
if (has_focus() or invalid) and layout_size.x>4 and layout_size.y>4:
|
|
161
|
+
draw_rect(Rect2(Vector2(2,2),layout_size-Vector2(4,4)),invalid_color if invalid else focus_color,false,2)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://dmgpinqaglofu
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
@tool
|
|
2
|
+
extends LineEdit
|
|
3
|
+
## Native editing, selection and platform text input in the host's actual rect.
|
|
4
|
+
const Focus = preload("focus.tres")
|
|
5
|
+
func _estragon_focus_host(): return get_parent()
|
|
6
|
+
func _ready() -> void:
|
|
7
|
+
clip_contents = true
|
|
8
|
+
expand_to_text_length = false
|
|
9
|
+
focus_entered.connect(_entered)
|
|
10
|
+
focus_exited.connect(_exited)
|
|
11
|
+
func _entered() -> void:
|
|
12
|
+
var host = _estragon_focus_host()
|
|
13
|
+
if not Focus.eligible(self): release_focus(); return
|
|
14
|
+
host.queue_redraw()
|
|
15
|
+
host.focus_entered.emit()
|
|
16
|
+
func _exited() -> void:
|
|
17
|
+
var host = _estragon_focus_host()
|
|
18
|
+
host.queue_redraw()
|
|
19
|
+
host.focus_exited.emit()
|
|
20
|
+
func _gui_input(event: InputEvent) -> void:
|
|
21
|
+
if event is InputEventKey and event.is_action("ui_cancel") and event.pressed and not event.echo:
|
|
22
|
+
accept_event()
|
|
23
|
+
var host = _estragon_focus_host()
|
|
24
|
+
host.release_focus()
|
|
25
|
+
host.cancelled.emit()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
uid://dfb5e8colfuh7
|
package/package.json
CHANGED