Allow path of repository to be editable when property is on

This commit is contained in:
Sebastian Morr 2020-09-29 17:20:24 +02:00
parent 4b988717e6
commit 6e8a310a7a
4 changed files with 26 additions and 2 deletions

View file

@ -4,12 +4,14 @@ onready var index = $Rows/RepoVis/Index
onready var nodes = $Rows/RepoVis/Nodes onready var nodes = $Rows/RepoVis/Nodes
onready var file_browser = $Rows/FileBrowser onready var file_browser = $Rows/FileBrowser
onready var label_node = $Rows/RepoVis/Label onready var label_node = $Rows/RepoVis/Label
onready var path_node = $Rows/RepoVis/Path
onready var simplify_checkbox = $Rows/RepoVis/SimplifyCheckbox onready var simplify_checkbox = $Rows/RepoVis/SimplifyCheckbox
export var label: String setget set_label export var label: String setget set_label
export var path: String setget set_path, get_path export var path: String setget set_path, get_path
export var file_browser_active = true setget set_file_browser_active export var file_browser_active = true setget set_file_browser_active
export var simplified_view = false setget set_simplified_view export var simplified_view = false setget set_simplified_view
export var editable_path = false setget set_editable_path
var node = preload("res://node.tscn") var node = preload("res://node.tscn")
@ -24,6 +26,7 @@ func _ready():
set_label(label) set_label(label)
set_file_browser_active(file_browser_active) set_file_browser_active(file_browser_active)
set_simplified_view(simplified_view) set_simplified_view(simplified_view)
set_editable_path(editable_path)
func _process(_delta): func _process(_delta):
nodes.rect_pivot_offset = nodes.rect_size / 2 nodes.rect_pivot_offset = nodes.rect_size / 2
@ -52,11 +55,11 @@ func update_everything():
index.text = "" index.text = ""
for o in objects: for o in objects:
objects[o].queue_free() objects[o].queue_free()
objects = {} objects = {}
func set_path(new_path): func set_path(new_path):
path = new_path path = new_path
path_node.text = path
shell.cd(new_path) shell.cd(new_path)
for o in objects.values(): for o in objects.values():
o.queue_free() o.queue_free()
@ -270,6 +273,13 @@ func set_simplified_view(simplify):
if simplify_checkbox: if simplify_checkbox:
simplify_checkbox.pressed = simplify simplify_checkbox.pressed = simplify
func set_editable_path(editable):
editable_path = editable
if label_node:
label_node.visible = not editable
if path_node:
path_node.visible = editable
func remove_gone_stuff(): func remove_gone_stuff():
# FIXME: Cache the result of all_objects. # FIXME: Cache the result of all_objects.
var all = {} var all = {}

View file

@ -98,6 +98,15 @@ __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
[node name="Path" type="LineEdit" parent="Rows/RepoVis"]
margin_left = 23.3361
margin_top = 12.3197
margin_right = 574.336
margin_bottom = 61.3197
__meta__ = {
"_edit_use_anchors_": false
}
[node name="FileBrowser" parent="Rows" instance=ExtResource( 4 )] [node name="FileBrowser" parent="Rows" instance=ExtResource( 4 )]
anchor_right = 0.0 anchor_right = 0.0
anchor_bottom = 0.0 anchor_bottom = 0.0
@ -110,3 +119,4 @@ size_flags_stretch_ratio = 0.08
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"] [connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
[connection signal="pressed" from="Rows/RepoVis/Button" to="." method="update_everything"] [connection signal="pressed" from="Rows/RepoVis/Button" to="." method="update_everything"]
[connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="simplify_view"] [connection signal="toggled" from="Rows/RepoVis/SimplifyCheckbox" to="." method="simplify_view"]
[connection signal="text_entered" from="Rows/RepoVis/Path" to="." method="set_path"]

View file

@ -40,6 +40,7 @@ anchor_bottom = 0.0
margin_right = 949.0 margin_right = 949.0
margin_bottom = 1070.0 margin_bottom = 1070.0
size_flags_horizontal = 3 size_flags_horizontal = 3
editable_path = true
[node name="Terminal" parent="HSplitContainer" instance=ExtResource( 1 )] [node name="Terminal" parent="HSplitContainer" instance=ExtResource( 1 )]
anchor_right = 0.0 anchor_right = 0.0

View file

@ -117,6 +117,9 @@ margin_left = 18.0
margin_top = 39.0 margin_top = 39.0
margin_right = -687.0 margin_right = -687.0
margin_bottom = -48.0 margin_bottom = -48.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Text" type="RichTextLabel" parent="Pager"] [node name="Text" type="RichTextLabel" parent="Pager"]
anchor_right = 1.0 anchor_right = 1.0