2022-02-01 00:56:02 +01:00
|
|
|
tool
|
2022-07-19 11:19:37 +02:00
|
|
|
extends Control
|
2022-02-01 00:56:02 +01:00
|
|
|
|
2022-07-19 11:19:37 +02:00
|
|
|
onready var column_container = $VBoxContainer/ScrollContainer/Columns
|
|
|
|
onready var vbox_container = $VBoxContainer
|
|
|
|
var item_placement_holder: Panel
|
2022-02-01 00:56:02 +01:00
|
|
|
var undo_redo: UndoRedo
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2022-07-19 11:19:37 +02:00
|
|
|
item_placement_holder = create_drag_placement_holder()
|
|
|
|
|
2022-02-01 00:56:02 +01:00
|
|
|
undo_redo = UndoRedo.new()
|
|
|
|
|
2022-07-19 11:19:37 +02:00
|
|
|
func create_drag_placement_holder() -> Panel:
|
|
|
|
var new_holder = preload("res://addons/SimpleTODO/ItemPlacementHolder.tscn").instance()
|
|
|
|
new_holder.visible = false
|
|
|
|
add_child(new_holder)
|
|
|
|
|
|
|
|
return new_holder
|
|
|
|
|
2022-02-01 00:56:02 +01:00
|
|
|
func add_column(from_button := false) -> Control:
|
|
|
|
var column = preload("res://addons/SimpleTODO/TODOColumn.tscn").instance()
|
2022-07-19 11:19:37 +02:00
|
|
|
column.main = self
|
2022-02-01 00:56:02 +01:00
|
|
|
column.undo_redo = undo_redo
|
2022-07-19 11:19:37 +02:00
|
|
|
|
2022-02-01 00:56:02 +01:00
|
|
|
column.connect("delete", self, "delete_column", [column])
|
|
|
|
|
|
|
|
undo_redo.create_action("Add Column")
|
|
|
|
undo_redo.add_do_method(column_container, "add_child", 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.commit_action()
|
|
|
|
|
|
|
|
if from_button:
|
2022-07-19 11:19:37 +02:00
|
|
|
column.name_edit.call_deferred("grab_focus")
|
|
|
|
column.name_edit.call_deferred("select_all")
|
2022-02-01 00:56:02 +01:00
|
|
|
|
|
|
|
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_undo_reference(column)
|
|
|
|
undo_redo.add_undo_method(self, "request_save")
|
|
|
|
undo_redo.commit_action()
|
|
|
|
|
|
|
|
func request_save() -> void:
|
|
|
|
get_tree().get_nodes_in_group("__todo_plugin__").front().save_data()
|