nodes can now be dragged
This commit is contained in:
parent
b3d24b3de1
commit
04311758b6
5 changed files with 13 additions and 14 deletions
|
@ -6,7 +6,7 @@
|
||||||
[node name="Sine" type="Control"]
|
[node name="Sine" type="Control"]
|
||||||
layout_mode = 3
|
layout_mode = 3
|
||||||
anchors_preset = 0
|
anchors_preset = 0
|
||||||
mouse_filter = 2
|
mouse_filter = 1
|
||||||
|
|
||||||
[node name="Node" parent="." instance=ExtResource("1_m6pki")]
|
[node name="Node" parent="." instance=ExtResource("1_m6pki")]
|
||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
|
|
|
@ -14,6 +14,7 @@ isOutput = true
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
mouse_filter = 1
|
||||||
text = "Testtesttesttesttest"
|
text = "Testtesttesttesttest"
|
||||||
clip_text = true
|
clip_text = true
|
||||||
|
|
||||||
|
|
|
@ -4,20 +4,18 @@ var rows : Dictionary
|
||||||
var uuid : int #REMEMBER TO SET THIS ON CREATION
|
var uuid : int #REMEMBER TO SET THIS ON CREATION
|
||||||
var dragging : bool
|
var dragging : bool
|
||||||
var canDrag : bool
|
var canDrag : bool
|
||||||
|
var dragOffset : Vector2
|
||||||
func _ready():
|
|
||||||
_init_visuals()
|
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
if dragging:
|
if dragging:
|
||||||
position = get_viewport().get_mouse_position()
|
position = get_viewport().get_mouse_position() + dragOffset
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
func _input(event):
|
||||||
print(str(event) + "A")
|
|
||||||
if event is InputEventMouseButton:
|
if event is InputEventMouseButton:
|
||||||
if event.button_index == MOUSE_BUTTON_LEFT && event.pressed && canDrag:
|
if event.button_index == MOUSE_BUTTON_LEFT && event.pressed && canDrag:
|
||||||
dragging = true
|
dragging = true
|
||||||
if event.button_index == MOUSE_BUTTON_LEFT && event.canceled && dragging:
|
dragOffset = position - get_viewport().get_mouse_position()
|
||||||
|
if event.button_index == MOUSE_BUTTON_LEFT && !event.pressed && dragging:
|
||||||
dragging = false
|
dragging = false
|
||||||
|
|
||||||
func _create_uuid():
|
func _create_uuid():
|
||||||
|
@ -25,10 +23,6 @@ func _create_uuid():
|
||||||
rand.seed = Time.get_unix_time_from_system()
|
rand.seed = Time.get_unix_time_from_system()
|
||||||
uuid = rand.randi()
|
uuid = rand.randi()
|
||||||
|
|
||||||
func _init_visuals():
|
|
||||||
var nodeVisuals = load("res://Scenes/Nodes/Node.tscn").instantiate()
|
|
||||||
call_deferred("add_child",nodeVisuals)
|
|
||||||
|
|
||||||
func _update_visuals():
|
func _update_visuals():
|
||||||
var holder = get_node("Holder")
|
var holder = get_node("Holder")
|
||||||
for child in holder.get_children():
|
for child in holder.get_children():
|
||||||
|
|
|
@ -9,7 +9,10 @@ var dragging:bool
|
||||||
|
|
||||||
var previewLine:Line2D = null
|
var previewLine:Line2D = null
|
||||||
|
|
||||||
func process(delta):
|
func _ready():
|
||||||
|
set_process(true)
|
||||||
|
|
||||||
|
func _process(delta):
|
||||||
if dragging:
|
if dragging:
|
||||||
if previewLine == null:
|
if previewLine == null:
|
||||||
previewLine = Line2D.new()
|
previewLine = Line2D.new()
|
||||||
|
@ -20,7 +23,7 @@ func process(delta):
|
||||||
previewLine.points[0] = position
|
previewLine.points[0] = position
|
||||||
previewLine.points[1] = get_viewport().get_mouse_position()
|
previewLine.points[1] = get_viewport().get_mouse_position()
|
||||||
|
|
||||||
func _on_input_event(viewport, event, shape_idx):
|
func _input(event):
|
||||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if !event.pressed:
|
if !event.pressed:
|
||||||
_finish_drag()
|
_finish_drag()
|
||||||
|
|
|
@ -7,5 +7,6 @@ func _ready():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
|
super._process(delta)
|
||||||
rows["Output"]["output"] = sin(Time.get_ticks_msec() * rows["Length"].get("input",1))
|
rows["Output"]["output"] = sin(Time.get_ticks_msec() * rows["Length"].get("input",1))
|
||||||
pass
|
pass
|
||||||
|
|
Loading…
Add table
Reference in a new issue