todo list styles and test data
authorEduardo <[email protected]>
Thu, 28 Sep 2023 16:35:08 +0000 (18:35 +0200)
committerEduardo <[email protected]>
Thu, 28 Sep 2023 16:35:08 +0000 (18:35 +0200)
custom_elements/todo_list_elements/todo_element.gd [new file with mode: 0644]
custom_elements/todo_list_elements/todo_element.tscn
scenes/todo_list/ToDoList.gd
scenes/todo_list/ToDoList.tscn
themes/default/resources/star_icon.png [new file with mode: 0644]
themes/default/resources/star_icon.png.import [new file with mode: 0644]

diff --git a/custom_elements/todo_list_elements/todo_element.gd b/custom_elements/todo_list_elements/todo_element.gd
new file mode 100644 (file)
index 0000000..3e99e5f
--- /dev/null
@@ -0,0 +1,38 @@
+extends Control
+
+@onready var check_box = $MarginContainer/CheckBox
+
+@onready var one_star = $"1Star"
+@onready var two_star = $"2Star"
+@onready var three_star = $"3Star"
+
+func set_task(tasik_id: int, task: String, done: bool, position: int, priority: int, created_at: String, updated_at: String):
+               set_meta("task_id", tasik_id)
+               set_meta("position", position)
+               set_meta("created_at", created_at)
+               set_meta("updated_at", updated_at)
+               set_text(task)
+               check_box.button_pressed = done
+               set_priority(priority)
+
+func set_stars(how_many: int):
+       one_star.set_visible(false)
+       two_star.set_visible(false)
+       three_star.set_visible(false)
+
+       match how_many:
+               1:
+                       one_star.set_visible(true)
+               2:
+                       two_star.set_visible(true)
+               3:
+                       three_star.set_visible(true)
+
+func set_priority(priority: int):
+       set_stars(priority)
+
+func set_text(text: String):
+       check_box.text = text
+
+func destroy_self():
+       queue_free()
index 1d6e88a4d6ad93db8bdbd4bc7f3b8e703faa6eca..3e57a79977fe78003bfc4fbeb1352f18bfe57562 100644 (file)
-[gd_scene format=3 uid="uid://cilxydvrxa3oj"]
+[gd_scene load_steps=3 format=3 uid="uid://cilxydvrxa3oj"]
 
-[node name="todo_element" type="MarginContainer"]
+[ext_resource type="Script" path="res://custom_elements/todo_list_elements/todo_element.gd" id="1_4t3br"]
+[ext_resource type="Texture2D" uid="uid://crhn8w3ljpuv7" path="res://themes/default/resources/star_icon.png" id="1_xkf81"]
+
+[node name="todo_element" type="Control"]
+layout_mode = 3
+anchors_preset = 10
+anchor_right = 1.0
+grow_horizontal = 2
+size_flags_horizontal = 3
+size_flags_vertical = 3
+script = ExtResource("1_4t3br")
+metadata/position = 0
+metadata/task_id = 0
+metadata/created_at = ""
+metadata/updated_at = ""
+
+[node name="MarginContainer" type="MarginContainer" parent="."]
 clip_contents = true
+layout_mode = 1
 anchors_preset = 10
 anchor_right = 1.0
 offset_bottom = 119.0
 grow_horizontal = 2
+theme_override_constants/margin_right = 200
 
-[node name="CheckBox" type="CheckBox" parent="."]
+[node name="CheckBox" type="CheckBox" parent="MarginContainer"]
 layout_mode = 2
 text = "Pick the laundry and something else very long that canot enter the line"
 text_overrun_behavior = 3
+
+[node name="1Star" type="Control" parent="."]
+visible = false
+layout_mode = 1
+anchors_preset = 1
+anchor_left = 1.0
+anchor_right = 1.0
+offset_left = -40.0
+offset_bottom = 40.0
+grow_horizontal = 0
+
+[node name="StarTextureRect" type="TextureRect" parent="1Star"]
+layout_mode = 0
+offset_left = -54.0
+offset_top = 26.0
+offset_right = -6.0
+offset_bottom = 74.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
+
+[node name="2Star" type="Control" parent="."]
+layout_mode = 1
+anchors_preset = 6
+anchor_left = 1.0
+anchor_top = 0.5
+anchor_right = 1.0
+anchor_bottom = 0.5
+offset_left = -40.0
+offset_top = -20.0
+offset_bottom = 20.0
+grow_horizontal = 0
+grow_vertical = 2
+
+[node name="StarTextureRect" type="TextureRect" parent="2Star"]
+layout_mode = 0
+offset_left = -26.0
+offset_top = 52.0
+offset_right = 22.0
+offset_bottom = 100.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
+
+[node name="StarTextureRect2" type="TextureRect" parent="2Star"]
+layout_mode = 0
+offset_left = -91.0
+offset_top = 40.0
+offset_right = -43.0
+offset_bottom = 88.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
+
+[node name="3Star" type="Control" parent="."]
+visible = false
+layout_mode = 1
+anchors_preset = 6
+anchor_left = 1.0
+anchor_top = 0.5
+anchor_right = 1.0
+anchor_bottom = 0.5
+offset_left = -40.0
+offset_top = -20.0
+offset_bottom = 20.0
+grow_horizontal = 0
+grow_vertical = 2
+
+[node name="StarTextureRect" type="TextureRect" parent="3Star"]
+layout_mode = 0
+offset_left = -14.0
+offset_top = 33.0
+offset_right = 34.0
+offset_bottom = 81.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
+
+[node name="StarTextureRect2" type="TextureRect" parent="3Star"]
+layout_mode = 0
+offset_left = -99.0
+offset_top = 25.0
+offset_right = -51.0
+offset_bottom = 73.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
+
+[node name="StarTextureRect3" type="TextureRect" parent="3Star"]
+layout_mode = 0
+offset_left = -62.0
+offset_top = 65.0
+offset_right = -14.0
+offset_bottom = 113.0
+texture = ExtResource("1_xkf81")
+expand_mode = 1
+stretch_mode = 4
index 6518edd8c5728fa2814bc76d8c9f7fa6ed81a369..ee6caa04ac19df48c524f67659fea3d090daaf7b 100644 (file)
@@ -5,6 +5,10 @@ signal scene_changed(scene_name)
 @onready var background = $Background
 @onready var scroll_container = $ScrollContainer
 
+# debug elements
+@onready var reorderable_list = $ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox
+var bg: Thread
+
 func _process(_delta):
        background.material.set_shader_parameter("position", scroll_container.scroll_vertical)
 
@@ -17,12 +21,23 @@ func _on_Back_pressed():
        emit_signal("scene_changed", "res://scenes/main_menu/MainMenu.tscn")
 
 func DEBUG_put_lots_of_tasks(how_many: int):
-       for i in range(how_many):
-
-               var new_entry = $ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element2.duplicate()
-               $ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox.add_child(new_entry)
+       var text_arr := [
+               "text 1",
+               "feed the bunnuy",
+               "do the list",
+               "Pick the laundry",
+               "Feed the bunnuy",
+               "Wash the dishes",
+               "Text 2",
+               "Don't use numbers Edu, they don't look good"
+       ]
 
+       for i in range(how_many):
+               var el = load("res://custom_elements/todo_list_elements/todo_element.tscn").instantiate()
+               reorderable_list.call_deferred("add_child", el)
+               el.call_deferred("set_stars", randi_range(1, 3))
+               el.call_deferred("set_text", text_arr[randi_range(0, text_arr.size() - 1)])
 
 func _on_ready():
-       DEBUG_put_lots_of_tasks(50)
-
+       bg = Thread.new()
+       #bg.start(DEBUG_put_lots_of_tasks.bind(50))
index e0b39481267aeeaea14a1068d4a29c98ed95d0cd..3bc71fc1998aec5ba8599e4b523a8371a563dddc 100644 (file)
@@ -62,7 +62,7 @@ vertical_alignment = 1
 
 [node name="ReorderableVBox" type="Container" parent="ScrollContainer/MarginContainer/VBoxContainer" node_paths=PackedStringArray("scroll_container")]
 process_mode = 1
-custom_minimum_size = Vector2(0, 319)
+custom_minimum_size = Vector2(0, 200)
 layout_mode = 2
 size_flags_vertical = 3
 script = ExtResource("4_6gjj0")
@@ -73,20 +73,25 @@ auto_scroll_range = 0.1
 
 [node name="todo_element" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox" instance=ExtResource("4_grm34")]
 layout_mode = 2
-size_flags_horizontal = 3
+
+[node name="1Star" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element" index="1"]
+visible = true
+
+[node name="2Star" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element" index="2"]
+visible = false
 
 [node name="todo_element2" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox" instance=ExtResource("4_grm34")]
 layout_mode = 2
 
-[node name="CheckBox" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element2" index="0"]
-text = "Feed Bunnuy"
+[node name="2Star" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element2" index="2"]
+visible = false
+
+[node name="3Star" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element2" index="3"]
+visible = true
 
 [node name="todo_element3" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox" instance=ExtResource("4_grm34")]
 layout_mode = 2
 
-[node name="CheckBox" parent="ScrollContainer/MarginContainer/VBoxContainer/ReorderableVBox/todo_element3" index="0"]
-text = "Wash the dishes"
-
 [node name="AnimatedButton" parent="." instance=ExtResource("2_xdr44")]
 anchors_preset = 3
 anchor_left = 1.0
diff --git a/themes/default/resources/star_icon.png b/themes/default/resources/star_icon.png
new file mode 100644 (file)
index 0000000..2316cf7
Binary files /dev/null and b/themes/default/resources/star_icon.png differ
diff --git a/themes/default/resources/star_icon.png.import b/themes/default/resources/star_icon.png.import
new file mode 100644 (file)
index 0000000..86daece
--- /dev/null
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://crhn8w3ljpuv7"
+path="res://.godot/imported/star_icon.png-f40e51edd994a794d9afb049797392c3.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://themes/default/resources/star_icon.png"
+dest_files=["res://.godot/imported/star_icon.png-f40e51edd994a794d9afb049797392c3.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1