Allow both drag & drop as well as zooming in repositories

This commit is contained in:
Sebastian Morr 2020-09-21 18:53:36 +02:00
parent 0fdc6cd69c
commit 6cd68f3599
5 changed files with 24 additions and 10 deletions

13
node.gd
View file

@ -8,6 +8,7 @@ var repository: Container
var children = {} setget children_set
var id_always_visible = false
var held = false
var hovered = false
var arrow = preload("res://arrow.tscn")
@ -84,14 +85,24 @@ func children_set(new_children):
children = new_children
func _on_hover():
hovered = true
$Content.visible = true
$ID.visible = true
func _on_unhover():
hovered = false
if not id_always_visible:
$Content.visible = false
$ID.visible = false
func _input(event):
if hovered:
if event.is_action_pressed("click"):
held = true
if event.is_action_released("click"):
held = false
func _input_event(_viewport, event, _shape_idx):
if event is InputEventMouseButton:
if event.button_index == BUTTON_LEFT:

View file

@ -15,7 +15,7 @@ margin_left = -29.0
margin_top = -28.0
margin_right = 29.0
margin_bottom = 30.0
mouse_filter = 2
mouse_filter = 1
color = Color( 0.984314, 0, 0, 1 )
__meta__ = {
"_edit_use_anchors_": false
@ -53,6 +53,8 @@ __meta__ = {
shape = SubResource( 1 )
[node name="Arrows" type="Node2D" parent="."]
[connection signal="mouse_entered" from="Rect" to="." method="_on_hover"]
[connection signal="mouse_exited" from="Rect" to="." method="_on_unhover"]
[connection signal="input_event" from="Area" to="." method="_input_event"]
[connection signal="mouse_entered" from="Area" to="." method="_on_hover"]
[connection signal="mouse_exited" from="Area" to="." method="_on_unhover"]

View file

@ -18,12 +18,12 @@ func _process(_delta):
if path:
apply_forces()
#func _input(event):
# if mouse_inside:
# if event.is_action_pressed("zoom_out") and $Nodes.rect_scale.x > 0.3:
# $Nodes.rect_scale -= Vector2(0.05, 0.05)
# if event.is_action_pressed("zoom_in") and $Nodes.rect_scale.x < 2:
# $Nodes.rect_scale += Vector2(0.05, 0.05)
func _input(event):
if mouse_inside:
if event.is_action_pressed("zoom_out") and $Nodes.rect_scale.x > 0.3:
$Nodes.rect_scale -= Vector2(0.05, 0.05)
if event.is_action_pressed("zoom_in") and $Nodes.rect_scale.x < 2:
$Nodes.rect_scale += Vector2(0.05, 0.05)
func update_everything():
if shell.run("test -d .git && echo yes || echo no") == "yes\n":

View file

@ -11,7 +11,7 @@ margin_left = 2.0
margin_top = 3.0
margin_right = -6.0
margin_bottom = -4.0
mouse_filter = 2
mouse_filter = 1
theme = ExtResource( 2 )
script = ExtResource( 1 )
__meta__ = {

View file

@ -6,7 +6,6 @@
[node name="TextEditor" type="TextEdit"]
anchor_right = 1.0
anchor_bottom = 1.0
custom_fonts/font = ExtResource( 1 )
custom_colors/background_color = Color( 0, 0, 0, 1 )
text = "Text here"
syntax_highlighting = true
@ -24,7 +23,9 @@ margin_left = -117.279
margin_top = -59.399
margin_right = -17.2788
margin_bottom = -14.399
focus_mode = 0
custom_fonts/font = ExtResource( 1 )
enabled_focus_mode = 0
text = "Save"
__meta__ = {
"_edit_use_anchors_": false