diff --git a/is_dragging.gd b/is_dragging.gd new file mode 100644 index 0000000..e2b3afe --- /dev/null +++ b/is_dragging.gd @@ -0,0 +1,3 @@ +extends Node + +var is_dragging = false diff --git a/is_dragging.gd.uid b/is_dragging.gd.uid new file mode 100644 index 0000000..f45d7c7 --- /dev/null +++ b/is_dragging.gd.uid @@ -0,0 +1 @@ +uid://568n56xr8gm6 diff --git a/project.godot b/project.godot index 9c0d4df..0b6b761 100644 --- a/project.godot +++ b/project.godot @@ -12,9 +12,22 @@ config_version=5 config/name="tween-scroll-test" config/tags=PackedStringArray("experiment", "project_elysium") -config/features=PackedStringArray("4.4", "Forward Plus") +run/main_scene="uid://xvl65qci5w1b" +config/features=PackedStringArray("4.5", "Forward Plus") config/icon="res://icon.svg" +[autoload] + +is_dragging="*res://is_dragging.gd" + [dotnet] project/assembly_name="tween-scroll-test" + +[input] + +click={ +"deadzone": 0.2, +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) +] +} diff --git a/src/empty space thing.tscn b/src/empty space thing.tscn new file mode 100644 index 0000000..3447061 --- /dev/null +++ b/src/empty space thing.tscn @@ -0,0 +1,22 @@ +[gd_scene format=3 uid="uid://dtsyn6bqpojn"] + +[node name="EmptySpaceThing" type="Control"] +layout_mode = 3 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 + +[node name="Button" type="Button" parent="."] +layout_mode = 0 +offset_right = 8.0 +offset_bottom = 8.0 +text = "YEehaw" + +[node name="Button" type="Button" parent="Button"] +layout_mode = 0 +offset_left = 101.0 +offset_right = 176.0 +offset_bottom = 31.0 +text = "Button 2" diff --git a/src/empty_space_thing.gd b/src/empty_space_thing.gd new file mode 100644 index 0000000..616a707 --- /dev/null +++ b/src/empty_space_thing.gd @@ -0,0 +1,31 @@ +extends Control +class_name SpaceNode + +var initial_pos: Vector2 +var offset: Vector2 +var draggable: bool = false + +func _ready() -> void: + draggable = true + return + +func _process(delta: float) -> void: + if draggable: + + if Input.is_action_pressed("click", true): + self.global_position = Vector2(get_global_mouse_position().x, self.global_position.y) + + elif Input.is_action_just_released("click"): + + is_dragging.is_dragging = false + var tween = get_tree().create_tween() + + tween.tween_property(self, "global_position", Vector2(get_global_mouse_position().x, self.global_position.y), 0.5).set_ease(Tween.EASE_IN_OUT) + + else: + return + +func reset_draggable(): + if not is_dragging.is_dragging: + is_dragging.is_dragging = false + draggable = false diff --git a/src/empty_space_thing.gd.uid b/src/empty_space_thing.gd.uid new file mode 100644 index 0000000..a7c02fd --- /dev/null +++ b/src/empty_space_thing.gd.uid @@ -0,0 +1 @@ +uid://vabpak15285q diff --git a/src/scroll_root.tscn b/src/scroll_root.tscn index c8e19a5..c9a6d64 100644 --- a/src/scroll_root.tscn +++ b/src/scroll_root.tscn @@ -1,4 +1,7 @@ -[gd_scene format=3 uid="uid://xvl65qci5w1b"] +[gd_scene load_steps=3 format=3 uid="uid://xvl65qci5w1b"] + +[ext_resource type="PackedScene" uid="uid://dtsyn6bqpojn" path="res://src/empty space thing.tscn" id="1_is8xv"] +[ext_resource type="Script" uid="uid://vabpak15285q" path="res://src/empty_space_thing.gd" id="2_mej84"] [node name="ScrollRoot" type="Node2D"] @@ -6,3 +9,17 @@ offset_right = 1152.0 offset_bottom = 648.0 color = Color(0.133196, 0.133196, 0.133196, 1) + +[node name="Sliding Box" type="Control" parent="."] +layout_mode = 3 +anchors_preset = 0 +offset_right = 40.0 +offset_bottom = 40.0 + +[node name="EmptySpaceThing" parent="Sliding Box" instance=ExtResource("1_is8xv")] +layout_mode = 1 +offset_left = 455.0 +offset_top = 299.0 +offset_right = 455.0 +offset_bottom = 299.0 +script = ExtResource("2_mej84")