add kanban
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
## The visual representation of a kanban board.
|
||||
|
||||
|
||||
const __Singletons := preload("../../plugin_singleton/singletons.gd")
|
||||
const __Shortcuts := preload("../shortcuts.gd")
|
||||
const __EditContext := preload("../edit_context.gd")
|
||||
const __BoardData := preload("../../data/board.gd")
|
||||
const __StageScript := preload("../stage/stage.gd")
|
||||
const __StageScene := preload("../stage/stage.tscn")
|
||||
const __Filter := preload("../filter.gd")
|
||||
const __SettingsScript := preload("../settings/settings.gd")
|
||||
|
||||
signal show_documentation()
|
||||
|
||||
var board_data: __BoardData
|
||||
|
||||
@onready var search_bar: LineEdit = %SearchBar
|
||||
@onready var button_advanced_search: Button = %AdvancedSearch
|
||||
@onready var button_show_categories: Button = %ShowCategories
|
||||
@onready var button_show_descriptions: Button = %ShowDescriptions
|
||||
@onready var button_show_steps: Button = %ShowSteps
|
||||
@onready var button_documentation: Button = %Documentation
|
||||
@onready var button_settings: Button = %Settings
|
||||
@onready var column_holder: HBoxContainer = %ColumnHolder
|
||||
@onready var settings: __SettingsScript = %SettingsView
|
||||
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
board_data.layout.changed.connect(update)
|
||||
|
||||
settings.board_data = board_data
|
||||
|
||||
search_bar.text_changed.connect(__on_filter_changed)
|
||||
search_bar.text_submitted.connect(__on_search_bar_entered)
|
||||
button_advanced_search.toggled.connect(__on_filter_changed)
|
||||
|
||||
button_show_categories.toggled.connect(__on_show_categories_toggled)
|
||||
button_show_descriptions.toggled.connect(__on_show_descriptions_toggled)
|
||||
button_show_steps.toggled.connect(__on_show_steps_toggled)
|
||||
|
||||
notification(NOTIFICATION_THEME_CHANGED)
|
||||
|
||||
await get_tree().create_timer(0.0).timeout
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
|
||||
ctx.settings.changed.connect(update)
|
||||
|
||||
ctx.filter_changed.connect(__on_filter_changed_external)
|
||||
|
||||
button_documentation.pressed.connect(func(): show_documentation.emit())
|
||||
button_documentation.visible = Engine.is_editor_hint()
|
||||
|
||||
button_settings.pressed.connect(settings.popup_centered_ratio_no_fullscreen)
|
||||
|
||||
|
||||
func _shortcut_input(event: InputEvent) -> void:
|
||||
if not __Shortcuts.should_handle_shortcut(self):
|
||||
return
|
||||
var shortcuts: __Shortcuts = __Singletons.instance_of(__Shortcuts, self)
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
if not event.is_echo() and event.is_pressed():
|
||||
if shortcuts.search.matches_event(event):
|
||||
search_bar.grab_focus()
|
||||
get_viewport().set_input_as_handled()
|
||||
elif shortcuts.undo.matches_event(event):
|
||||
ctx.undo_redo.undo()
|
||||
get_viewport().set_input_as_handled()
|
||||
elif shortcuts.redo.matches_event(event):
|
||||
ctx.undo_redo.redo()
|
||||
get_viewport().set_input_as_handled()
|
||||
|
||||
|
||||
func _notification(what):
|
||||
if what == NOTIFICATION_THEME_CHANGED and not is_part_of_edited_scene():
|
||||
if is_instance_valid(search_bar):
|
||||
search_bar.right_icon = get_theme_icon(&"Search", &"EditorIcons")
|
||||
if is_instance_valid(button_settings):
|
||||
button_settings.icon = get_theme_icon(&"Tools", &"EditorIcons")
|
||||
if is_instance_valid(button_documentation):
|
||||
button_documentation.icon = get_theme_icon(&"Help", &"EditorIcons")
|
||||
if is_instance_valid(button_advanced_search):
|
||||
button_advanced_search.icon = get_theme_icon(&"Zoom", &"EditorIcons")
|
||||
if is_instance_valid(button_show_categories):
|
||||
button_show_categories.icon = get_theme_icon(&"Rectangle", &"EditorIcons")
|
||||
if is_instance_valid(button_show_descriptions):
|
||||
button_show_descriptions.icon = get_theme_icon(&"Script", &"EditorIcons")
|
||||
if is_instance_valid(button_show_steps):
|
||||
button_show_steps.icon = get_theme_icon(&"FileList", &"EditorIcons")
|
||||
if is_instance_valid(settings):
|
||||
settings.on_theme_changed()
|
||||
|
||||
|
||||
func update() -> void:
|
||||
for column in column_holder.get_children():
|
||||
column.queue_free()
|
||||
|
||||
for column_data in board_data.layout.columns:
|
||||
var column_scroll = ScrollContainer.new()
|
||||
column_scroll.horizontal_scroll_mode = ScrollContainer.SCROLL_MODE_DISABLED
|
||||
column_scroll.set_v_size_flags(Control.SIZE_EXPAND_FILL)
|
||||
column_scroll.set_h_size_flags(Control.SIZE_EXPAND_FILL)
|
||||
var column = VBoxContainer.new()
|
||||
column.set_v_size_flags(Control.SIZE_EXPAND_FILL)
|
||||
column.set_h_size_flags(Control.SIZE_EXPAND_FILL)
|
||||
|
||||
column_scroll.add_child(column)
|
||||
column_holder.add_child(column_scroll)
|
||||
|
||||
for uuid in column_data:
|
||||
var stage := __StageScene.instantiate()
|
||||
stage.board_data = board_data
|
||||
stage.data_uuid = uuid
|
||||
column.add_child(stage)
|
||||
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
button_show_categories.set_pressed_no_signal(ctx.settings.show_category_on_board)
|
||||
button_show_descriptions.set_pressed_no_signal(ctx.settings.show_description_preview)
|
||||
button_show_steps.set_pressed_no_signal(ctx.settings.show_steps_preview)
|
||||
|
||||
|
||||
# Do not use parameters the method is bound to diffrent signals.
|
||||
func __on_filter_changed(param1: Variant = null):
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
|
||||
if ctx.filter_changed.is_connected(__on_filter_changed_external):
|
||||
ctx.filter_changed.disconnect(__on_filter_changed_external)
|
||||
|
||||
ctx.filter = __Filter.new(search_bar.text, button_advanced_search.button_pressed)
|
||||
|
||||
ctx.filter_changed.connect(__on_filter_changed_external)
|
||||
|
||||
|
||||
func __on_search_bar_entered(filter: String):
|
||||
button_advanced_search.grab_focus()
|
||||
|
||||
|
||||
func __on_filter_changed_external():
|
||||
search_bar.text = ""
|
||||
|
||||
|
||||
func __on_show_categories_toggled(button_pressed: bool):
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
ctx.settings.show_category_on_board = button_pressed
|
||||
|
||||
|
||||
func __on_show_descriptions_toggled(button_pressed: bool):
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
ctx.settings.show_description_preview = button_pressed
|
||||
|
||||
|
||||
func __on_show_steps_toggled(button_pressed: bool):
|
||||
var ctx: __EditContext = __Singletons.instance_of(__EditContext, self)
|
||||
ctx.settings.show_steps_preview = button_pressed
|
||||
@@ -0,0 +1 @@
|
||||
uid://5hks8mhjyp62
|
||||
@@ -0,0 +1,89 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://c5dk4lnyiag3w"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://5hks8mhjyp62" path="res://addons/kanban_tasks/view/board/board.gd" id="1_p7lf4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dh1yunmhipirg" path="res://addons/kanban_tasks/view/settings/settings.tscn" id="2_by8mq"]
|
||||
|
||||
[node name="BoardView" type="VBoxContainer"]
|
||||
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
|
||||
mouse_filter = 0
|
||||
theme_override_constants/separation = 5
|
||||
script = ExtResource("1_p7lf4")
|
||||
|
||||
[node name="Header" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 5
|
||||
|
||||
[node name="SearchBar" type="LineEdit" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Search"
|
||||
clear_button_enabled = true
|
||||
|
||||
[node name="AdvancedSearch" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Search in details."
|
||||
toggle_mode = true
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="Header"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Show categories"
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="ShowCategories" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
toggle_mode = true
|
||||
|
||||
[node name="ShowDescriptions" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Show descriptions."
|
||||
toggle_mode = true
|
||||
|
||||
[node name="ShowSteps" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Show steps."
|
||||
toggle_mode = true
|
||||
|
||||
[node name="VSeparator2" type="VSeparator" parent="Header"]
|
||||
layout_mode = 2
|
||||
theme_override_constants/separation = 0
|
||||
|
||||
[node name="Documentation" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Open documentation."
|
||||
flat = true
|
||||
|
||||
[node name="Settings" type="Button" parent="Header"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
tooltip_text = "Manage board settings."
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 0
|
||||
vertical_scroll_mode = 0
|
||||
|
||||
[node name="ColumnHolder" type="HBoxContainer" parent="ScrollContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
theme_override_constants/separation = 5
|
||||
alignment = 1
|
||||
|
||||
[node name="SettingsView" parent="." instance=ExtResource("2_by8mq")]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
Reference in New Issue
Block a user