mirror of
https://github.com/Relintai/Godot-Simple-TODO.git
synced 2025-02-05 16:25:56 +01:00
Update to Godot 4.0
This commit is contained in:
parent
34c8b74346
commit
4e9560bcdf
7
addons/SimpleTODO/ColumnHeader.gd
Normal file
7
addons/SimpleTODO/ColumnHeader.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends HBoxContainer
|
||||
@tool
|
||||
|
||||
@onready var drag_panel: Panel = $DragPanel
|
||||
@onready var name_edit: LineEdit = $Name
|
||||
@onready var counter: Label = $Counter
|
||||
@onready var minimize_button: Button = $Minimize
|
@ -1,32 +1,37 @@
|
||||
[gd_scene format=2]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cwcwdmxxpf65e"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleTODO/ColumnHeader.gd" id="1_kya6i"]
|
||||
|
||||
[node name="Header" type="HBoxContainer"]
|
||||
margin_right = 392.0
|
||||
margin_bottom = 24.0
|
||||
script = ExtResource("1_kya6i")
|
||||
|
||||
[node name="DragPanel" type="Panel" parent="."]
|
||||
margin_right = 20.0
|
||||
margin_bottom = 24.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
custom_minimum_size = Vector2i(20, 0)
|
||||
layout_mode = 2
|
||||
offset_right = 20.0
|
||||
offset_bottom = 31.0
|
||||
mouse_default_cursor_shape = 13
|
||||
|
||||
[node name="Name" type="LineEdit" parent="."]
|
||||
margin_left = 24.0
|
||||
margin_right = 344.0
|
||||
margin_bottom = 24.0
|
||||
layout_mode = 2
|
||||
offset_left = 24.0
|
||||
offset_right = 91.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
text = "Column name"
|
||||
|
||||
[node name="Counter" type="Label" parent="."]
|
||||
margin_left = 348.0
|
||||
margin_top = 5.0
|
||||
margin_right = 376.0
|
||||
margin_bottom = 19.0
|
||||
rect_min_size = Vector2( 28, 0 )
|
||||
layout_mode = 2
|
||||
offset_left = 95.0
|
||||
offset_top = 2.0
|
||||
offset_right = 105.0
|
||||
offset_bottom = 28.0
|
||||
text = "0"
|
||||
align = 1
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Minimize" type="Button" parent="."]
|
||||
margin_left = 380.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 24.0
|
||||
layout_mode = 2
|
||||
offset_left = 109.0
|
||||
offset_right = 117.0
|
||||
offset_bottom = 31.0
|
||||
tooltip_text = "Fold/Unfold"
|
||||
|
@ -1,18 +1,21 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dayvgw4nwet74"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.529412, 0.529412, 0.529412, 0.529412 )
|
||||
[sub_resource type="StyleBoxFlat" id="1"]
|
||||
bg_color = Color(0.529412, 0.529412, 0.529412, 0.529412)
|
||||
border_width_left = 4
|
||||
border_width_top = 4
|
||||
border_width_right = 4
|
||||
border_width_bottom = 4
|
||||
border_color = Color( 0, 0.741176, 1, 1 )
|
||||
border_color = Color(0, 0.741176, 1, 1)
|
||||
corner_radius_top_left = 16
|
||||
corner_radius_top_right = 16
|
||||
corner_radius_bottom_right = 16
|
||||
corner_radius_bottom_left = 16
|
||||
|
||||
[node name="ItemPlacementHolder" type="Panel"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme_override_styles/panel = SubResource("1")
|
||||
|
@ -1,4 +1,4 @@
|
||||
tool
|
||||
@tool
|
||||
extends EditorPlugin
|
||||
|
||||
const DATA_FILE = "res://TODO.cfg"
|
||||
@ -6,28 +6,28 @@ const DATA_FILE = "res://TODO.cfg"
|
||||
var todo_screen: Control
|
||||
var is_loading: bool
|
||||
|
||||
func get_plugin_name():
|
||||
func _get_plugin_name():
|
||||
return "TODO"
|
||||
|
||||
func get_plugin_icon():
|
||||
return get_editor_interface().get_base_control().get_icon("Node", "EditorIcons")
|
||||
func _get_plugin_icon():
|
||||
return get_editor_interface().get_base_control().get_theme_icon(&"CheckBox", &"EditorIcons")
|
||||
|
||||
func has_main_screen() -> bool:
|
||||
func _has_main_screen() -> bool:
|
||||
return true
|
||||
|
||||
func _enter_tree():
|
||||
todo_screen = preload("res://addons/SimpleTODO/TODO.tscn").instance()
|
||||
todo_screen = preload("res://addons/SimpleTODO/TODO.tscn").instantiate()
|
||||
todo_screen.plugin = self
|
||||
todo_screen.hide()
|
||||
add_to_group("__todo_plugin__")
|
||||
|
||||
get_editor_interface().get_editor_viewport().add_child(todo_screen)
|
||||
get_editor_interface().get_editor_main_screen().add_child(todo_screen)
|
||||
load_data()
|
||||
print("TODO loaded")
|
||||
|
||||
func _ready() -> void:
|
||||
set_process_input(false)
|
||||
|
||||
func set_window_layout(configuration: ConfigFile):
|
||||
func _set_window_layout(configuration: ConfigFile):
|
||||
if configuration.has_section("SimpleTODO"):
|
||||
var minimized_tabs = configuration.get_value("SimpleTODO", "minimized_tabs")
|
||||
|
||||
@ -35,13 +35,16 @@ func set_window_layout(configuration: ConfigFile):
|
||||
return
|
||||
|
||||
for i in todo_screen.column_container.get_child_count():
|
||||
var column = todo_screen.column_container.get_children()[i]
|
||||
column.minimized = minimized_tabs[i]
|
||||
var column: PanelContainer = todo_screen.column_container.get_child(i)
|
||||
column.set_minimized.call_deferred(minimized_tabs[i])
|
||||
|
||||
func get_window_layout(configuration: ConfigFile):
|
||||
func _get_window_layout(configuration: ConfigFile):
|
||||
var new_minimized_tabs = []
|
||||
|
||||
|
||||
for column in todo_screen.column_container.get_children():
|
||||
if not column is PanelContainer:
|
||||
continue
|
||||
|
||||
new_minimized_tabs.append(column.minimized)
|
||||
|
||||
configuration.set_value("SimpleTODO", "minimized_tabs", new_minimized_tabs)
|
||||
@ -49,18 +52,18 @@ func get_window_layout(configuration: ConfigFile):
|
||||
func _exit_tree():
|
||||
todo_screen.queue_free()
|
||||
|
||||
func make_visible(visible: bool) -> void:
|
||||
func _make_visible(visible: bool) -> void:
|
||||
todo_screen.visible = visible
|
||||
set_process_input(visible)
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventKey:
|
||||
if event.pressed:
|
||||
if event.control:
|
||||
if event.scancode == KEY_Z:
|
||||
if event.is_command_or_control_pressed():
|
||||
if event.keycode == KEY_Z:
|
||||
todo_screen.undo_redo.undo()
|
||||
get_viewport().set_input_as_handled()
|
||||
elif event.scancode == KEY_Y:
|
||||
elif event.keycode == KEY_Y:
|
||||
todo_screen.undo_redo.redo()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
@ -68,10 +71,9 @@ func save_data():
|
||||
if is_loading:
|
||||
return
|
||||
|
||||
var data = ConfigFile.new()
|
||||
|
||||
var data := ConfigFile.new()
|
||||
for column in todo_screen.column_container.get_children():
|
||||
var section = column.name_edit.text
|
||||
var section = column.header.name_edit.text
|
||||
|
||||
if column.item_container.get_child_count() > 0:
|
||||
for item in column.item_container.get_children():
|
||||
@ -82,7 +84,7 @@ func save_data():
|
||||
data.save(DATA_FILE)
|
||||
|
||||
func load_data():
|
||||
var data = ConfigFile.new()
|
||||
var data := ConfigFile.new()
|
||||
data.load(DATA_FILE)
|
||||
|
||||
is_loading = true
|
||||
@ -90,7 +92,7 @@ func load_data():
|
||||
for section in data.get_sections():
|
||||
var column = todo_screen.add_column()
|
||||
column.set_name(section)
|
||||
|
||||
|
||||
for item in data.get_section_keys(section):
|
||||
if item == "__none__":
|
||||
continue
|
||||
@ -99,5 +101,4 @@ func load_data():
|
||||
column_item.text_field.text = data.get_value(section, item)
|
||||
|
||||
todo_screen.undo_redo.clear_history()
|
||||
|
||||
is_loading = false
|
||||
|
@ -1,68 +1,69 @@
|
||||
tool
|
||||
@tool
|
||||
extends Control
|
||||
|
||||
onready var column_container = $"%Columns"
|
||||
onready var vbox_container = $VBoxContainer
|
||||
onready var column_mirror = $"%ColumnMirror"
|
||||
onready var scroll_container = $"%ScrollContainer"
|
||||
@onready var column_container: Control = %Columns
|
||||
@onready var column_mirror: Control = %ColumnMirror
|
||||
@onready var scroll_container: ScrollContainer = %ScrollContainer
|
||||
|
||||
var plugin: EditorPlugin
|
||||
|
||||
var item_placement_holder: Panel
|
||||
var undo_redo: UndoRedo
|
||||
var item_placement_holder: Panel
|
||||
|
||||
func _ready() -> void:
|
||||
item_placement_holder = create_drag_placement_holder()
|
||||
|
||||
undo_redo = UndoRedo.new()
|
||||
|
||||
scroll_container.get_v_scrollbar().connect("value_changed", self, "update_mirror")
|
||||
item_placement_holder = create_drag_placement_holder()
|
||||
scroll_container.get_v_scroll_bar().value_changed.connect(update_mirror)
|
||||
|
||||
func update_mirror(v: float):
|
||||
column_mirror.visible = v > column_mirror.get_child(0).rect_size.y
|
||||
column_mirror.visible = v > column_mirror.get_child(0).size.y
|
||||
|
||||
func connect_scrollbar(to_object, to_method):
|
||||
scroll_container.get_h_scrollbar().connect("value_changed", to_object, to_method)
|
||||
scroll_container.get_v_scrollbar().connect("value_changed", to_object, to_method)
|
||||
func connect_scrollbar(to_method: Callable):
|
||||
scroll_container.get_h_scroll_bar().value_changed.connect(to_method)
|
||||
scroll_container.get_v_scroll_bar().value_changed.connect(to_method)
|
||||
|
||||
func create_drag_placement_holder() -> Panel:
|
||||
var new_holder = preload("res://addons/SimpleTODO/ItemPlacementHolder.tscn").instance()
|
||||
var new_holder: Panel = preload("res://addons/SimpleTODO/ItemPlacementHolder.tscn").instantiate()
|
||||
new_holder.visible = false
|
||||
add_child(new_holder)
|
||||
|
||||
return new_holder
|
||||
|
||||
func add_column(from_button := false) -> Control:
|
||||
var column = preload("res://addons/SimpleTODO/TODOColumn.tscn").instance()
|
||||
var column = preload("res://addons/SimpleTODO/TODOColumn.tscn").instantiate()
|
||||
column.main = self
|
||||
column.plugin = plugin
|
||||
column.undo_redo = undo_redo
|
||||
|
||||
column.connect("delete", self, "delete_column", [column])
|
||||
column.delete.connect(delete_column.bind(column))
|
||||
|
||||
undo_redo.create_action("Add Column")
|
||||
undo_redo.add_do_method(column_container, "add_child", column)
|
||||
undo_redo.add_do_method(column_container.add_child.bind(column))
|
||||
undo_redo.add_do_reference(column)
|
||||
undo_redo.add_do_method(self, "request_save")
|
||||
undo_redo.add_undo_method(column_container, "remove_child", column)
|
||||
undo_redo.add_undo_method(self, "request_save")
|
||||
undo_redo.add_do_method(request_save)
|
||||
undo_redo.add_undo_method(column_container.remove_child.bind(column))
|
||||
undo_redo.add_undo_method(request_save)
|
||||
undo_redo.commit_action()
|
||||
|
||||
if from_button:
|
||||
column.name_edit.call_deferred("grab_focus")
|
||||
column.name_edit.call_deferred("select_all")
|
||||
column.header.name_edit.grab_focus.call_deferred()
|
||||
column.header.name_edit.select_all.call_deferred()
|
||||
get_tree().create_timer(0.1).timeout.connect(scroll_container.ensure_control_visible.bind(column))
|
||||
|
||||
return column
|
||||
|
||||
func delete_column(column):
|
||||
undo_redo.create_action("Delete Column")
|
||||
undo_redo.add_do_method(column_container, "remove_child", column)
|
||||
undo_redo.add_do_method(self, "request_save")
|
||||
undo_redo.add_undo_method(column_container, "add_child", column)
|
||||
undo_redo.add_do_method(column_container.remove_child.bind(column))
|
||||
undo_redo.add_do_method(request_save)
|
||||
undo_redo.add_undo_method(column_container.add_child.bind(column))
|
||||
undo_redo.add_undo_reference(column)
|
||||
undo_redo.add_undo_method(self, "request_save")
|
||||
undo_redo.add_undo_method(request_save)
|
||||
undo_redo.commit_action()
|
||||
|
||||
func request_save() -> void:
|
||||
get_tree().get_nodes_in_group("__todo_plugin__").front().save_data()
|
||||
plugin.save_data()
|
||||
|
||||
func refresh_mirrors():
|
||||
for column in column_container.get_children():
|
||||
column.call_deferred("update_mirror", 0)
|
||||
column.update_mirror.call_deferred(0)
|
||||
|
@ -1,61 +1,71 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=2 format=3 uid="uid://yf8y5e74vv4o"]
|
||||
|
||||
[ext_resource path="res://addons/SimpleTODO/TODO.gd" type="Script" id=1]
|
||||
[ext_resource type="Script" path="res://addons/SimpleTODO/TODO.gd" id="1"]
|
||||
|
||||
[node name="TODO" type="Control"]
|
||||
clip_contents = true
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_clip_content = true
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_editor_description_": ""
|
||||
}
|
||||
|
||||
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 34.0
|
||||
layout_mode = 2
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer"]
|
||||
margin_left = 7.0
|
||||
margin_top = 7.0
|
||||
margin_right = 1017.0
|
||||
margin_bottom = 27.0
|
||||
layout_mode = 2
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Button" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_left = 460.0
|
||||
margin_right = 549.0
|
||||
margin_bottom = 20.0
|
||||
layout_mode = 2
|
||||
offset_left = 525.0
|
||||
offset_right = 626.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 4
|
||||
text = "Add column"
|
||||
|
||||
[node name="ColumnMirror" type="Control" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
margin_top = 24.0
|
||||
margin_right = 1010.0
|
||||
margin_bottom = 54.0
|
||||
rect_min_size = Vector2( 0, 30 )
|
||||
custom_minimum_size = Vector2i(0, 30)
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
offset_top = 35.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 35.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_top = 38.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
layout_mode = 2
|
||||
offset_top = 35.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 648.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Columns" type="HBoxContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 562.0
|
||||
layout_mode = 2
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 613.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/Button" to="." method="add_column" binds= [ true ]]
|
||||
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/Button" to="." method="add_column" binds= [true]]
|
||||
|
@ -1,71 +1,81 @@
|
||||
tool
|
||||
@tool
|
||||
extends PanelContainer
|
||||
|
||||
onready var header = $VBoxContainer/Header
|
||||
onready var minimize_button = header.get_node("Minimize")
|
||||
onready var name_edit = header.get_node("Name")
|
||||
onready var counter = header.get_node("Counter")
|
||||
onready var top_separator = $VBoxContainer/TopSeparator
|
||||
onready var bottom_separator = $VBoxContainer/BottomSeparator
|
||||
onready var scroll_container = $VBoxContainer/ScrollContainer
|
||||
onready var actions = $VBoxContainer/Actions
|
||||
onready var item_container = $VBoxContainer/ScrollContainer/Items
|
||||
onready var delete_button = $VBoxContainer/Actions/DeleteColumn
|
||||
onready var timer = $Timer
|
||||
@onready var header: Control = %Header
|
||||
@onready var item_container = %Items
|
||||
@onready var foldable = [item_container, %TopSeparator, %BottomSeparator, %Actions]
|
||||
@onready var delete_button = %DeleteColumn
|
||||
@onready var timer = $Timer
|
||||
|
||||
var undo_redo: UndoRedo
|
||||
var minimized = false setget set_minimized
|
||||
var main: Control
|
||||
var plugin: EditorPlugin
|
||||
var undo_redo: UndoRedo
|
||||
|
||||
var item_placement_holder: Panel
|
||||
var is_dragging = false
|
||||
var initial_item_index = 0
|
||||
var current_drag_item_index = 0
|
||||
var item_margin = 20
|
||||
var mirror_header
|
||||
var mirror_counter
|
||||
var mirror_header_panel: PanelContainer
|
||||
var mirror_header: Control
|
||||
|
||||
func set_minimized(val):
|
||||
minimized = val
|
||||
var minimized = false: set = set_minimized
|
||||
|
||||
minimize_button.icon = get_icon("ArrowDown" if minimized else "ArrowUp", "EditorIcons")
|
||||
if mirror_header:
|
||||
mirror_header.get_node("Minimize").icon = get_icon("ArrowDown" if minimized else "ArrowUp", "EditorIcons")
|
||||
|
||||
top_separator.visible = !val
|
||||
scroll_container.visible = !val
|
||||
bottom_separator.visible = !val
|
||||
actions.visible = !val
|
||||
var is_dragging := false
|
||||
var initial_item_index := 0
|
||||
var current_drag_item_index := 0
|
||||
var item_margin := 20
|
||||
|
||||
signal delete
|
||||
|
||||
func set_minimized(val: bool):
|
||||
minimized = val
|
||||
|
||||
header.minimize_button.icon = get_theme_icon(&"ArrowDown" if minimized else &"ArrowUp", &"EditorIcons")
|
||||
mirror_header.minimize_button.icon = get_theme_icon(&"ArrowDown" if minimized else &"ArrowUp", &"EditorIcons")
|
||||
|
||||
for node in foldable:
|
||||
node.visible = not minimized
|
||||
|
||||
func _ready() -> void:
|
||||
set_process(false)
|
||||
item_placement_holder = main.item_placement_holder
|
||||
delete_button.icon = get_icon("Remove", "EditorIcons")
|
||||
counter.rect_min_size.x = delete_button.get_minimum_size().x
|
||||
delete_button.icon = get_theme_icon(&"Remove", &"EditorIcons")
|
||||
|
||||
mirror_header_panel = PanelContainer.new()
|
||||
main.column_mirror.add_child(mirror_header_panel)
|
||||
mirror_header_panel.add_theme_stylebox_override(&"panel", get_theme_stylebox(&"panel"))
|
||||
|
||||
mirror_header = preload("res://addons/SimpleTODO/ColumnHeader.tscn").instantiate()
|
||||
mirror_header_panel.add_child(mirror_header)
|
||||
|
||||
var toggle_minimized := func(): set_minimized(not minimized)
|
||||
|
||||
header.minimize_button.pressed.connect(toggle_minimized)
|
||||
mirror_header.minimize_button.pressed.connect(toggle_minimized)
|
||||
mirror_header.name_edit.editable = false
|
||||
|
||||
header.drag_panel.gui_input.connect(drag_panel_input)
|
||||
mirror_header.drag_panel.gui_input.connect(drag_panel_input)
|
||||
header.counter.custom_minimum_size.x = delete_button.get_minimum_size().x
|
||||
mirror_header.counter.custom_minimum_size.x = delete_button.get_minimum_size().x
|
||||
|
||||
set_process(false)
|
||||
set_process_input(false)
|
||||
set_minimized(false)
|
||||
|
||||
mirror_header = PanelContainer.new()
|
||||
main.column_mirror.add_child(mirror_header)
|
||||
mirror_header.add_stylebox_override("panel", get_stylebox("panel"))
|
||||
mirror_header.add_child(preload("res://addons/SimpleTODO/ColumnHeader.tscn").instance())
|
||||
mirror_header.get_child(0).get_node("Minimize").icon = get_icon("ArrowDown" if minimized else "ArrowUp", "EditorIcons")
|
||||
mirror_header.get_child(0).get_node("Name").editable = false
|
||||
mirror_counter = mirror_header.get_child(0).get_node("Counter")
|
||||
main.connect_scrollbar(self, "update_mirror")
|
||||
|
||||
header.get_node("DragPanel").connect("gui_input", self, "_on_DragPanel_gui_input")
|
||||
mirror_header.get_child(0).get_node("DragPanel").connect("gui_input", self, "_on_DragPanel_gui_input")
|
||||
|
||||
update_mirror(0)
|
||||
|
||||
main.connect_scrollbar(update_mirror)
|
||||
item_container.child_entered_tree.connect(update_counter.unbind(1), CONNECT_DEFERRED)
|
||||
item_container.child_exiting_tree.connect(update_counter.unbind(1), CONNECT_DEFERRED)
|
||||
|
||||
func set_name(column_name):
|
||||
name_edit.text = column_name
|
||||
mirror_header.get_child(0).get_node("Name").text = column_name
|
||||
header.name_edit.text = column_name
|
||||
mirror_header.name_edit.text = column_name
|
||||
|
||||
func update_mirror(v):
|
||||
mirror_header.rect_min_size = Vector2(rect_size.x, header.rect_size.y)
|
||||
mirror_header.rect_global_position.x = rect_global_position.x
|
||||
if not is_inside_tree():
|
||||
return
|
||||
|
||||
mirror_header_panel.custom_minimum_size = Vector2(size.x, header.size.y)
|
||||
await get_tree().process_frame
|
||||
await get_tree().process_frame
|
||||
mirror_header_panel.global_position.x = global_position.x
|
||||
|
||||
func _process(delta):
|
||||
if is_dragging:
|
||||
@ -74,106 +84,95 @@ func _process(delta):
|
||||
var item_under_mouse = get_column_from_mouse_position()
|
||||
if item_under_mouse:
|
||||
if item_under_mouse:
|
||||
var item_index = item_under_mouse.get_index()
|
||||
var item_index := item_under_mouse.get_index()
|
||||
|
||||
if main.column_container != item_placement_holder.get_parent():
|
||||
item_placement_holder.get_parent().remove_child(item_placement_holder)
|
||||
main.column_container.add_child(item_placement_holder)
|
||||
|
||||
|
||||
item_placement_holder.get_parent().move_child(item_placement_holder, item_index)
|
||||
|
||||
current_drag_item_index = item_index
|
||||
|
||||
rect_position = mouse_position
|
||||
position = mouse_position
|
||||
|
||||
func add_item(from_button := false) -> Control:
|
||||
var item = preload("res://addons/SimpleTODO/TODOItem.tscn").instance()
|
||||
var item = preload("res://addons/SimpleTODO/TODOItem.tscn").instantiate()
|
||||
item.parent_column = self
|
||||
item.plugin = plugin
|
||||
item.main = main
|
||||
|
||||
undo_redo.create_action("Add Item")
|
||||
undo_redo.add_do_method(item_container, "add_child", item)
|
||||
undo_redo.add_do_method(item_container.add_child.bind(item))
|
||||
undo_redo.add_do_reference(item)
|
||||
undo_redo.add_do_method(self, "request_save")
|
||||
undo_redo.add_undo_method(item_container, "remove_child", item)
|
||||
undo_redo.add_undo_method(self, "request_save")
|
||||
undo_redo.add_do_method(request_save)
|
||||
undo_redo.add_undo_method(remove_child.bind(item))
|
||||
undo_redo.add_undo_method(request_save)
|
||||
undo_redo.commit_action()
|
||||
|
||||
if from_button:
|
||||
item.get_node("Text").call_deferred("grab_focus")
|
||||
item.get_node("Text").call_deferred("select_all")
|
||||
item.text_field.grab_focus.call_deferred()
|
||||
item.text_field.select_all.call_deferred()
|
||||
|
||||
return item
|
||||
|
||||
func delete_column() -> void:
|
||||
emit_signal("delete")
|
||||
delete.emit()
|
||||
|
||||
func update_counter() -> void:
|
||||
counter.text = str(item_container.get_child_count())
|
||||
mirror_counter.text = str(item_container.get_child_count())
|
||||
header.counter.text = str(item_container.get_child_count())
|
||||
mirror_header.counter.text = str(item_container.get_child_count())
|
||||
|
||||
func request_save() -> void:
|
||||
get_tree().get_nodes_in_group("__todo_plugin__").front().save_data()
|
||||
plugin.save_data()
|
||||
|
||||
func name_changed(_new_text: String) -> void:
|
||||
mirror_header.get_child(0).get_node("Name").text = _new_text
|
||||
mirror_header.name_edit.text = _new_text
|
||||
timer.start()
|
||||
|
||||
func _on_Minimize_pressed():
|
||||
set_minimized(!minimized)
|
||||
|
||||
# Handles left click being pressed on the drag panel
|
||||
func _on_DragPanel_gui_input(event):
|
||||
# Handles left click being pressed on the drag panel.
|
||||
func drag_panel_input(event: InputEvent):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and event.pressed and !is_dragging:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed and !is_dragging:
|
||||
initial_item_index = get_index()
|
||||
|
||||
get_parent().remove_child(self)
|
||||
|
||||
# Set the size vertical flags to none so that it doesn't stretch
|
||||
# when being dragged
|
||||
size_flags_vertical = SIZE_FILL
|
||||
|
||||
main.add_child(self)
|
||||
|
||||
# Set the size vertical flags to none so that it doesn't stretch when being dragged.
|
||||
size_flags_vertical = SIZE_FILL
|
||||
|
||||
set_process(true)
|
||||
|
||||
# Set dragging to true to tell _process to now handle dragging
|
||||
set_process_input(true)
|
||||
is_dragging = true
|
||||
|
||||
item_placement_holder.get_parent().remove_child(item_placement_holder)
|
||||
|
||||
main.column_container.add_child(item_placement_holder)
|
||||
|
||||
item_placement_holder.size_flags_vertical = 0
|
||||
item_placement_holder.visible = true
|
||||
item_placement_holder.rect_min_size = rect_size
|
||||
item_placement_holder.rect_size = rect_size
|
||||
item_placement_holder.custom_minimum_size = size
|
||||
item_placement_holder.size = size
|
||||
|
||||
# Handles left click being released
|
||||
# Handles left click being released.
|
||||
func _input(event):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and !event.pressed and is_dragging:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed and is_dragging:
|
||||
set_process(false)
|
||||
|
||||
set_process_input(false)
|
||||
is_dragging = false
|
||||
|
||||
get_parent().remove_child(self)
|
||||
|
||||
size_flags_vertical = SIZE_EXPAND
|
||||
|
||||
rect_size = Vector2.ZERO
|
||||
reset_size()
|
||||
|
||||
if item_placement_holder:
|
||||
item_placement_holder.size_flags_vertical = SIZE_FILL
|
||||
item_placement_holder.visible = false
|
||||
item_placement_holder.get_parent().remove_child(item_placement_holder)
|
||||
main.add_child(item_placement_holder)
|
||||
|
||||
|
||||
get_parent().remove_child(self)
|
||||
main.column_container.add_child(self)
|
||||
|
||||
move_column(current_drag_item_index)
|
||||
|
||||
|
||||
current_drag_item_index = 0
|
||||
initial_item_index = 0
|
||||
main.refresh_mirrors()
|
||||
@ -181,28 +180,20 @@ func _input(event):
|
||||
func move_column(index):
|
||||
undo_redo.create_action("Move Column")
|
||||
|
||||
var current_index = initial_item_index
|
||||
|
||||
undo_redo.add_do_method(main.column_container, "move_child", self, index)
|
||||
undo_redo.add_do_method(self, "request_save")
|
||||
undo_redo.add_undo_method(main.column_container, "move_child", self, current_index)
|
||||
undo_redo.add_undo_method(self, "request_save")
|
||||
undo_redo.add_do_method(main.column_container.move_child.bind(self, index))
|
||||
undo_redo.add_do_method(request_save)
|
||||
undo_redo.add_undo_method(main.column_container.move_child.bind(self, initial_item_index))
|
||||
undo_redo.add_undo_method(request_save)
|
||||
|
||||
undo_redo.commit_action()
|
||||
|
||||
func get_column_from_mouse_position() -> PanelContainer:
|
||||
var mouse_position = main.column_container.get_local_mouse_position()
|
||||
|
||||
for i in main.column_container.get_child_count():
|
||||
var child = main.column_container.get_child(i)
|
||||
var rect: Rect2 = child.get_rect()
|
||||
|
||||
if rect.has_point(Vector2(mouse_position.x, 0)):
|
||||
for child in main.column_container.get_children():
|
||||
if not child is PanelContainer:
|
||||
continue
|
||||
|
||||
if child.get_rect().has_point(Vector2(mouse_position.x, 0)):
|
||||
return child
|
||||
return null
|
||||
|
||||
func _on_Items_child_entered_tree(node):
|
||||
update_counter()
|
||||
|
||||
func _on_Items_child_exited_tree(node):
|
||||
update_counter()
|
||||
|
@ -1,99 +1,101 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bga0tfe37uva2"]
|
||||
|
||||
[ext_resource path="res://addons/SimpleTODO/TODOColumn.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/SimpleTODO/ColumnHeader.tscn" type="PackedScene" id=2]
|
||||
[ext_resource type="Script" path="res://addons/SimpleTODO/TODOColumn.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwcwdmxxpf65e" path="res://addons/SimpleTODO/ColumnHeader.tscn" id="2"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id=3]
|
||||
[sub_resource type="StyleBoxFlat" id="3"]
|
||||
content_margin_left = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_top = 4.0
|
||||
content_margin_right = 4.0
|
||||
content_margin_bottom = 4.0
|
||||
bg_color = Color( 0, 0, 0, 0.501961 )
|
||||
bg_color = Color(0, 0, 0, 0.501961)
|
||||
corner_radius_top_left = 4
|
||||
corner_radius_top_right = 4
|
||||
corner_radius_bottom_right = 4
|
||||
corner_radius_bottom_left = 4
|
||||
|
||||
[sub_resource type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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
"format": "LumAlpha8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id=5]
|
||||
flags = 4
|
||||
flags = 4
|
||||
image = SubResource( 6 )
|
||||
size = Vector2( 16, 16 )
|
||||
[sub_resource type="ImageTexture" id="5"]
|
||||
image = SubResource("Image_2oyio")
|
||||
|
||||
[node name="TODOColumn" type="PanelContainer"]
|
||||
margin_right = 400.0
|
||||
margin_bottom = 78.0
|
||||
rect_min_size = Vector2( 400, 0 )
|
||||
custom_minimum_size = Vector2i(400, 0)
|
||||
size_flags_vertical = 2
|
||||
custom_styles/panel = SubResource( 3 )
|
||||
script = ExtResource( 1 )
|
||||
theme_override_styles/panel = SubResource("3")
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_left = 4.0
|
||||
margin_top = 4.0
|
||||
margin_right = 396.0
|
||||
margin_bottom = 74.0
|
||||
rect_min_size = Vector2( 200, 0 )
|
||||
layout_mode = 2
|
||||
offset_left = 4.0
|
||||
offset_top = 4.0
|
||||
offset_right = 396.0
|
||||
offset_bottom = 90.0
|
||||
|
||||
[node name="Header" parent="VBoxContainer" instance=ExtResource( 2 )]
|
||||
[node name="Header" parent="VBoxContainer" instance=ExtResource("2")]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_right = 392.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="TopSeparator" type="HSeparator" parent="VBoxContainer"]
|
||||
margin_top = 28.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 32.0
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_top = 35.0
|
||||
offset_right = 392.0
|
||||
offset_bottom = 39.0
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="VBoxContainer"]
|
||||
margin_top = 36.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 36.0
|
||||
size_flags_vertical = 3
|
||||
scroll_horizontal_enabled = false
|
||||
scroll_vertical_enabled = false
|
||||
|
||||
[node name="Items" type="VBoxContainer" parent="VBoxContainer/ScrollContainer"]
|
||||
margin_right = 392.0
|
||||
[node name="Items" type="VBoxContainer" parent="VBoxContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_top = 43.0
|
||||
offset_right = 392.0
|
||||
offset_bottom = 43.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="BottomSeparator" type="HSeparator" parent="VBoxContainer"]
|
||||
margin_top = 40.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 44.0
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_top = 47.0
|
||||
offset_right = 392.0
|
||||
offset_bottom = 51.0
|
||||
|
||||
[node name="Actions" type="HBoxContainer" parent="VBoxContainer"]
|
||||
margin_top = 48.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 70.0
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_top = 55.0
|
||||
offset_right = 392.0
|
||||
offset_bottom = 86.0
|
||||
|
||||
[node name="AddItem" type="Button" parent="VBoxContainer/Actions"]
|
||||
margin_right = 360.0
|
||||
margin_bottom = 22.0
|
||||
hint_tooltip = "Add item"
|
||||
layout_mode = 2
|
||||
offset_right = 364.0
|
||||
offset_bottom = 31.0
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Add Item"
|
||||
text = "+"
|
||||
|
||||
[node name="DeleteColumn" type="Button" parent="VBoxContainer/Actions"]
|
||||
margin_left = 364.0
|
||||
margin_right = 392.0
|
||||
margin_bottom = 22.0
|
||||
hint_tooltip = "Delete column"
|
||||
icon = SubResource( 5 )
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
offset_left = 368.0
|
||||
offset_right = 392.0
|
||||
offset_bottom = 31.0
|
||||
tooltip_text = "Delete Column"
|
||||
icon = SubResource("5")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[connection signal="child_entered_tree" from="VBoxContainer/ScrollContainer/Items" to="." method="_on_Items_child_entered_tree"]
|
||||
[connection signal="child_exiting_tree" from="VBoxContainer/ScrollContainer/Items" to="." method="_on_Items_child_exited_tree"]
|
||||
[connection signal="pressed" from="VBoxContainer/Actions/AddItem" to="." method="add_item" binds= [ true ]]
|
||||
[connection signal="pressed" from="VBoxContainer/Actions/AddItem" to="." method="add_item" binds= [true]]
|
||||
[connection signal="pressed" from="VBoxContainer/Actions/DeleteColumn" to="." method="delete_column"]
|
||||
[connection signal="timeout" from="Timer" to="." method="request_save"]
|
||||
|
@ -1,44 +1,44 @@
|
||||
tool
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
onready var text_field = $Text
|
||||
onready var label_hack = $Text/HackLabel
|
||||
var item_placement_holder: Panel
|
||||
@onready var text_field = $Text
|
||||
@onready var button: Button = $Button
|
||||
|
||||
var main: Control
|
||||
var plugin: EditorPlugin
|
||||
var undo_redo: UndoRedo
|
||||
var initial_item_index = 0
|
||||
# The main TODO scene column container node
|
||||
|
||||
var item_placement_holder: Panel
|
||||
var main_column_container: HBoxContainer
|
||||
var parent_column: PanelContainer
|
||||
var next_parent_column: PanelContainer
|
||||
var current_drag_item_index = 0
|
||||
var is_dragging = false
|
||||
var item_margin = 20
|
||||
|
||||
var initial_item_index := 0
|
||||
var current_drag_item_index := 0
|
||||
var is_dragging := false
|
||||
var item_margin := 20
|
||||
|
||||
func _ready() -> void:
|
||||
undo_redo = main.undo_redo
|
||||
item_placement_holder = main.item_placement_holder
|
||||
next_parent_column = parent_column
|
||||
|
||||
get_node("Button").icon = get_icon("Remove", "EditorIcons")
|
||||
call_deferred("text_changed")
|
||||
button.icon = get_theme_icon(&"Remove", &"EditorIcons")
|
||||
|
||||
set_process(false)
|
||||
set_process_input(false)
|
||||
|
||||
func delete_pressed() -> void:
|
||||
delete_item()
|
||||
|
||||
func request_save() -> void:
|
||||
get_tree().get_nodes_in_group("__todo_plugin__").front().save_data()
|
||||
|
||||
func text_changed() -> void:
|
||||
label_hack.text = text_field.text
|
||||
text_field.rect_min_size.y = label_hack.get_minimum_size().y + 8
|
||||
plugin.save_data()
|
||||
|
||||
func _process(_delta):
|
||||
if is_dragging:
|
||||
var mouse_position = main.get_local_mouse_position()
|
||||
|
||||
var item_under_mouse = get_column_item_from_mouse_position()
|
||||
if item_under_mouse:
|
||||
if not item_under_mouse.is_empty():
|
||||
var column = item_under_mouse.column
|
||||
var column_items = column.item_container
|
||||
var item = item_under_mouse.item
|
||||
@ -56,7 +56,7 @@ func _process(_delta):
|
||||
item_placement_holder.get_parent().move_child(item_placement_holder, 0)
|
||||
current_drag_item_index = 0
|
||||
|
||||
rect_position = mouse_position
|
||||
position = mouse_position
|
||||
|
||||
func get_column_from_mouse_position() -> PanelContainer:
|
||||
var mouse_position = main.column_container.get_local_mouse_position()
|
||||
@ -64,13 +64,13 @@ func get_column_from_mouse_position() -> PanelContainer:
|
||||
for i in main.column_container.get_child_count():
|
||||
var child = main.column_container.get_child(i)
|
||||
var rect: Rect2 = child.get_rect()
|
||||
|
||||
|
||||
if rect.has_point(Vector2(mouse_position.x, 0)):
|
||||
return child
|
||||
return null
|
||||
|
||||
func get_column_item_from_mouse_position():
|
||||
var column_under_mouse = get_column_from_mouse_position()
|
||||
func get_column_item_from_mouse_position() -> Dictionary:
|
||||
var column_under_mouse := get_column_from_mouse_position()
|
||||
if column_under_mouse:
|
||||
var column_items = column_under_mouse.item_container
|
||||
var mouse_position = column_items.get_local_mouse_position()
|
||||
@ -88,96 +88,86 @@ func get_column_item_from_mouse_position():
|
||||
if bottom_rect.has_point(mouse_position):
|
||||
return {"item": child, "column": column_under_mouse}
|
||||
|
||||
# Likely we are dragging into a column with no items
|
||||
# Likely we are dragging into a column with no items.
|
||||
return {"item": null, "column": column_under_mouse}
|
||||
else:
|
||||
return null
|
||||
return {}
|
||||
|
||||
# Handles left click being pressed on the drag panel
|
||||
func _on_DragPanel_gui_input(event):
|
||||
# Handles left click being pressed on the drag panel.
|
||||
func drag_panel_input(event: InputEvent):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and event.pressed and !is_dragging:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and event.pressed and !is_dragging:
|
||||
initial_item_index = get_index()
|
||||
|
||||
get_parent().remove_child(self)
|
||||
|
||||
parent_column.update_counter()
|
||||
|
||||
rect_min_size = rect_size
|
||||
|
||||
# Set the size vertical flags to none so that it doesn't stretch
|
||||
# when being dragged
|
||||
size_flags_vertical = 0
|
||||
|
||||
main.add_child(self)
|
||||
|
||||
set_process(true)
|
||||
|
||||
# Set dragging to true to tell _process to now handle dragging
|
||||
# Set the size vertical flags to none so that it doesn't stretch when being dragged.
|
||||
size_flags_vertical = 0
|
||||
custom_minimum_size = size
|
||||
is_dragging = true
|
||||
|
||||
|
||||
set_process(true)
|
||||
set_process_input(true)
|
||||
|
||||
item_placement_holder.get_parent().remove_child(item_placement_holder)
|
||||
parent_column.item_container.add_child(item_placement_holder)
|
||||
item_placement_holder.get_parent().move_child(item_placement_holder, initial_item_index)
|
||||
|
||||
item_placement_holder.visible = true
|
||||
item_placement_holder.rect_min_size = rect_min_size
|
||||
item_placement_holder.rect_size = rect_size
|
||||
item_placement_holder.custom_minimum_size = custom_minimum_size
|
||||
item_placement_holder.size = size
|
||||
|
||||
# Handles left click being released
|
||||
func _input(event):
|
||||
# Handles left click being released.
|
||||
func _input(event: InputEvent):
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == BUTTON_LEFT and !event.pressed and is_dragging:
|
||||
if event.button_index == MOUSE_BUTTON_LEFT and not event.pressed and is_dragging:
|
||||
set_process(false)
|
||||
|
||||
is_dragging = false
|
||||
set_process_input(false)
|
||||
|
||||
get_parent().remove_child(self)
|
||||
|
||||
is_dragging = false
|
||||
size_flags_vertical = SIZE_FILL
|
||||
|
||||
rect_min_size = Vector2.ZERO
|
||||
custom_minimum_size = Vector2.ZERO
|
||||
|
||||
if item_placement_holder:
|
||||
item_placement_holder.visible = false
|
||||
item_placement_holder.get_parent().remove_child(item_placement_holder)
|
||||
main.add_child(item_placement_holder)
|
||||
|
||||
|
||||
move_item(current_drag_item_index)
|
||||
|
||||
|
||||
current_drag_item_index = 0
|
||||
initial_item_index = 0
|
||||
|
||||
# Used for undo redo, if we can't remove this item then don't error out
|
||||
# Used for undo redo, if we can't remove this item then don't error out.
|
||||
func remove_self_safe():
|
||||
var parent = get_parent()
|
||||
var parent := get_parent()
|
||||
if parent:
|
||||
parent.remove_child(self)
|
||||
|
||||
func move_item(index):
|
||||
undo_redo.create_action("Move Item")
|
||||
|
||||
var current_index = initial_item_index
|
||||
|
||||
undo_redo.add_do_method(self, "remove_self_safe")
|
||||
undo_redo.add_do_method(next_parent_column.item_container, "add_child", self)
|
||||
undo_redo.add_do_method(next_parent_column.item_container, "move_child", self, index)
|
||||
undo_redo.add_do_method(next_parent_column, "request_save")
|
||||
undo_redo.add_do_property(self, "parent_column", next_parent_column)
|
||||
undo_redo.add_do_property(self, "next_parent_column", parent_column)
|
||||
undo_redo.add_do_method(remove_self_safe)
|
||||
undo_redo.add_do_method(next_parent_column.item_container.add_child.bind(self))
|
||||
undo_redo.add_do_method(next_parent_column.item_container.move_child.bind(self, index))
|
||||
undo_redo.add_do_method(next_parent_column.request_save)
|
||||
undo_redo.add_do_property(self, &"parent_column", next_parent_column)
|
||||
undo_redo.add_do_property(self, &"next_parent_column", parent_column)
|
||||
|
||||
undo_redo.add_undo_method(self, "remove_self_safe")
|
||||
undo_redo.add_undo_method(parent_column.item_container, "add_child", self)
|
||||
undo_redo.add_undo_method(parent_column.item_container, "move_child", self, current_index)
|
||||
undo_redo.add_undo_method(parent_column, "request_save")
|
||||
undo_redo.add_undo_property(self, "parent_column", parent_column)
|
||||
undo_redo.add_undo_method(remove_self_safe)
|
||||
undo_redo.add_undo_method(parent_column.item_container.add_child.bind(self))
|
||||
undo_redo.add_undo_method(parent_column.item_container.move_child.bind(self, initial_item_index))
|
||||
undo_redo.add_undo_method(parent_column.request_save)
|
||||
undo_redo.add_undo_property(self, &"parent_column", parent_column)
|
||||
|
||||
undo_redo.commit_action()
|
||||
|
||||
func delete_item():
|
||||
undo_redo.create_action("Delete Item")
|
||||
undo_redo.add_do_method(parent_column.item_container, "remove_child", self)
|
||||
undo_redo.add_do_method(parent_column, "request_save")
|
||||
undo_redo.add_undo_method(parent_column.item_container, "add_child", self)
|
||||
undo_redo.add_undo_method(parent_column, "request_save")
|
||||
undo_redo.add_do_method(parent_column.item_container.remove_child.bind(self))
|
||||
undo_redo.add_do_method(parent_column.request_save)
|
||||
undo_redo.add_undo_method(parent_column.item_container.add_child.bind(self))
|
||||
undo_redo.add_undo_method(parent_column.request_save)
|
||||
undo_redo.commit_action()
|
||||
|
@ -1,69 +1,54 @@
|
||||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://bdesiystlxdb2"]
|
||||
|
||||
[ext_resource path="res://addons/SimpleTODO/TODOItem.gd" type="Script" id=1]
|
||||
[ext_resource type="Script" path="res://addons/SimpleTODO/TODOItem.gd" id="1"]
|
||||
|
||||
[sub_resource type="Image" id=6]
|
||||
[sub_resource type="Image" id="Image_m3ju7"]
|
||||
data = {
|
||||
"data": PoolByteArray( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
|
||||
"format": "LumAlpha8",
|
||||
"height": 16,
|
||||
"mipmaps": false,
|
||||
"width": 16
|
||||
}
|
||||
|
||||
[sub_resource type="ImageTexture" id=5]
|
||||
flags = 4
|
||||
flags = 4
|
||||
image = SubResource( 6 )
|
||||
size = Vector2( 16, 16 )
|
||||
[sub_resource type="ImageTexture" id="5"]
|
||||
image = SubResource("Image_m3ju7")
|
||||
|
||||
[node name="TODOItem" type="HBoxContainer"]
|
||||
margin_right = 480.0
|
||||
margin_bottom = 36.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 1 )
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="DragPanel" type="Panel" parent="."]
|
||||
margin_right = 20.0
|
||||
margin_bottom = 36.0
|
||||
rect_min_size = Vector2( 20, 0 )
|
||||
custom_minimum_size = Vector2i(20, 0)
|
||||
layout_mode = 2
|
||||
offset_right = 20.0
|
||||
offset_bottom = 35.0
|
||||
mouse_default_cursor_shape = 13
|
||||
|
||||
[node name="Text" type="TextEdit" parent="."]
|
||||
margin_left = 24.0
|
||||
margin_right = 448.0
|
||||
margin_bottom = 36.0
|
||||
rect_min_size = Vector2( 0, 22 )
|
||||
layout_mode = 2
|
||||
offset_left = 24.0
|
||||
offset_right = 32.0
|
||||
offset_bottom = 35.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "TODO"
|
||||
wrap_enabled = true
|
||||
|
||||
[node name="HackLabel" type="Label" parent="Text"]
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
margin_left = -224.0
|
||||
margin_top = 80.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 160.0
|
||||
text = "TODO"
|
||||
autowrap = true
|
||||
wrap_mode = 1
|
||||
scroll_fit_content_height = true
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
margin_left = 452.0
|
||||
margin_right = 480.0
|
||||
margin_bottom = 36.0
|
||||
hint_tooltip = "Delete item"
|
||||
icon = SubResource( 5 )
|
||||
layout_mode = 2
|
||||
offset_left = 36.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 35.0
|
||||
tooltip_text = "Delete Item"
|
||||
icon = SubResource("5")
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
|
||||
[connection signal="gui_input" from="DragPanel" to="." method="_on_DragPanel_gui_input"]
|
||||
[connection signal="text_changed" from="Text" to="." method="text_changed"]
|
||||
[connection signal="gui_input" from="DragPanel" to="." method="drag_panel_input"]
|
||||
[connection signal="text_changed" from="Text" to="Timer" method="start"]
|
||||
[connection signal="pressed" from="Button" to="." method="delete_pressed"]
|
||||
[connection signal="timeout" from="Timer" to="." method="request_save"]
|
||||
|
@ -3,5 +3,5 @@
|
||||
name="Simple TODO"
|
||||
description="Organize random notes in tabs."
|
||||
author="KoBeWi"
|
||||
version="1.2"
|
||||
version="1.3"
|
||||
script="SimpleTODO.gd"
|
Loading…
Reference in New Issue
Block a user