2023-08-26 08:08:01 +00:00
|
|
|
/**
|
|
|
|
* task_palette.h
|
|
|
|
* =============================================================================
|
|
|
|
* Copyright 2021-2023 Serhii Snitsaruk
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
2024-01-11 10:22:02 +00:00
|
|
|
|
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
|
2023-08-26 08:08:01 +00:00
|
|
|
#ifndef TASK_PALETTE_H
|
|
|
|
#define TASK_PALETTE_H
|
|
|
|
|
2024-01-07 16:33:05 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
2023-08-26 08:08:01 +00:00
|
|
|
#include "scene/gui/panel_container.h"
|
|
|
|
|
|
|
|
#include "scene/gui/box_container.h"
|
|
|
|
#include "scene/gui/button.h"
|
2023-08-26 13:41:11 +00:00
|
|
|
#include "scene/gui/check_box.h"
|
2023-08-26 08:08:01 +00:00
|
|
|
#include "scene/gui/flow_container.h"
|
|
|
|
#include "scene/gui/line_edit.h"
|
2023-08-26 13:41:11 +00:00
|
|
|
#include "scene/gui/popup.h"
|
2024-01-09 12:34:24 +00:00
|
|
|
#endif // ! LIMBOAI_MODULE
|
2024-01-07 16:33:05 +00:00
|
|
|
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
#include <godot_cpp/classes/button.hpp>
|
|
|
|
#include <godot_cpp/classes/control.hpp>
|
|
|
|
#include <godot_cpp/classes/flow_container.hpp>
|
|
|
|
#include <godot_cpp/classes/line_edit.hpp>
|
|
|
|
#include <godot_cpp/classes/panel_container.hpp>
|
|
|
|
#include <godot_cpp/classes/popup_panel.hpp>
|
|
|
|
#include <godot_cpp/classes/scroll_container.hpp>
|
|
|
|
#include <godot_cpp/classes/texture2d.hpp>
|
|
|
|
#include <godot_cpp/classes/v_box_container.hpp>
|
|
|
|
#include <godot_cpp/templates/hash_set.hpp>
|
|
|
|
|
|
|
|
using namespace godot;
|
2024-01-09 12:34:24 +00:00
|
|
|
#endif // ! LIMBOAI_GDEXTENSION
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
class TaskButton : public Button {
|
|
|
|
GDCLASS(TaskButton, Button);
|
|
|
|
|
2024-01-07 16:33:05 +00:00
|
|
|
private:
|
|
|
|
Control *_do_make_tooltip(const String &p_text) const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2023-08-26 08:08:01 +00:00
|
|
|
public:
|
2024-01-07 16:33:05 +00:00
|
|
|
#ifdef LIMBOAI_MODULE
|
|
|
|
virtual Control *make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); }
|
|
|
|
#endif // LIMBOAI_MODULE
|
|
|
|
#ifdef LIMBOAI_GDEXTENSION
|
|
|
|
virtual Object *_make_custom_tooltip(const String &p_text) const override { return _do_make_tooltip(p_text); }
|
|
|
|
#endif // LIMBOAI_GDEXTENSION
|
2023-12-17 12:58:42 +00:00
|
|
|
|
|
|
|
TaskButton();
|
2023-08-26 08:08:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class TaskPaletteSection : public VBoxContainer {
|
|
|
|
GDCLASS(TaskPaletteSection, VBoxContainer);
|
|
|
|
|
|
|
|
private:
|
2023-08-29 10:36:42 +00:00
|
|
|
struct ThemeCache {
|
|
|
|
Ref<Texture2D> arrow_down_icon;
|
|
|
|
Ref<Texture2D> arrow_right_icon;
|
|
|
|
} theme_cache;
|
|
|
|
|
2023-08-26 08:08:01 +00:00
|
|
|
FlowContainer *tasks_container;
|
|
|
|
Button *section_header;
|
|
|
|
|
|
|
|
void _on_task_button_pressed(const String &p_task);
|
|
|
|
void _on_task_button_gui_input(const Ref<InputEvent> &p_event, const String &p_task);
|
|
|
|
void _on_header_pressed();
|
|
|
|
|
|
|
|
protected:
|
2024-01-09 12:34:24 +00:00
|
|
|
static void _bind_methods();
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
void _notification(int p_what);
|
2024-01-09 12:34:24 +00:00
|
|
|
|
|
|
|
virtual void _do_update_theme_item_cache();
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void set_filter(String p_filter);
|
|
|
|
void add_task_button(const String &p_name, const Ref<Texture> &icon, const String &p_tooltip, Variant p_meta);
|
|
|
|
|
|
|
|
void set_collapsed(bool p_collapsed);
|
|
|
|
bool is_collapsed() const;
|
|
|
|
|
|
|
|
String get_category_name() const { return section_header->get_text(); }
|
2024-01-09 12:34:24 +00:00
|
|
|
void set_category_name(const String &p_cat) { section_header->set_text(p_cat); }
|
2023-08-26 08:08:01 +00:00
|
|
|
|
2024-01-09 12:34:24 +00:00
|
|
|
TaskPaletteSection();
|
2023-08-26 08:08:01 +00:00
|
|
|
~TaskPaletteSection();
|
|
|
|
};
|
|
|
|
|
|
|
|
class TaskPalette : public PanelContainer {
|
|
|
|
GDCLASS(TaskPalette, PanelContainer)
|
|
|
|
|
|
|
|
private:
|
|
|
|
enum MenuAction {
|
|
|
|
MENU_EDIT_SCRIPT,
|
|
|
|
MENU_OPEN_DOC,
|
|
|
|
MENU_FAVORITE,
|
|
|
|
};
|
|
|
|
|
2023-08-26 13:41:11 +00:00
|
|
|
struct FilterSettings {
|
|
|
|
enum TypeFilter {
|
|
|
|
TYPE_ALL,
|
|
|
|
TYPE_CORE,
|
|
|
|
TYPE_USER,
|
|
|
|
} type_filter;
|
|
|
|
|
|
|
|
enum CategoryFilter {
|
|
|
|
CATEGORY_ALL,
|
|
|
|
CATEGORY_INCLUDE,
|
|
|
|
CATEGORY_EXCLUDE,
|
|
|
|
} category_filter;
|
|
|
|
|
|
|
|
HashSet<String> excluded_categories;
|
|
|
|
} filter_settings;
|
|
|
|
|
2023-08-29 10:36:42 +00:00
|
|
|
struct ThemeCache {
|
|
|
|
Ref<Texture2D> add_to_favorites_icon;
|
|
|
|
Ref<Texture2D> edit_script_icon;
|
|
|
|
Ref<Texture2D> open_doc_icon;
|
|
|
|
Ref<Texture2D> remove_from_favorites_icon;
|
|
|
|
|
|
|
|
Ref<StyleBox> category_choice_background;
|
|
|
|
} theme_cache;
|
|
|
|
|
2023-08-26 08:08:01 +00:00
|
|
|
LineEdit *filter_edit;
|
|
|
|
VBoxContainer *sections;
|
|
|
|
PopupMenu *menu;
|
2023-08-26 13:41:11 +00:00
|
|
|
Button *tool_filters;
|
|
|
|
Button *tool_refresh;
|
|
|
|
|
|
|
|
// Filter popup
|
|
|
|
PopupPanel *filter_popup;
|
|
|
|
Button *type_all;
|
|
|
|
Button *type_core;
|
|
|
|
Button *type_user;
|
|
|
|
Button *category_all;
|
|
|
|
Button *category_include;
|
|
|
|
Button *category_exclude;
|
|
|
|
VBoxContainer *category_choice;
|
|
|
|
Button *select_all;
|
|
|
|
Button *deselect_all;
|
|
|
|
ScrollContainer *category_scroll;
|
|
|
|
VBoxContainer *category_list;
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
String context_task;
|
2023-12-14 22:38:02 +00:00
|
|
|
bool dialog_mode = false;
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
void _menu_action_selected(int p_id);
|
|
|
|
void _on_task_button_pressed(const String &p_task);
|
|
|
|
void _on_task_button_rmb(const String &p_task);
|
|
|
|
void _apply_filter(const String &p_text);
|
2023-08-26 13:41:11 +00:00
|
|
|
void _update_filter_popup();
|
2023-08-26 17:42:17 +00:00
|
|
|
void _show_filter_popup();
|
2023-08-26 13:41:11 +00:00
|
|
|
void _type_filter_changed();
|
|
|
|
void _category_filter_changed();
|
|
|
|
void _set_all_filter_categories(bool p_selected);
|
|
|
|
void _category_item_toggled(bool p_pressed, const String &p_category);
|
|
|
|
void _filter_data_changed();
|
2023-08-26 17:42:17 +00:00
|
|
|
void _draw_filter_popup_background();
|
2023-08-27 10:22:49 +00:00
|
|
|
void _update_filter_button();
|
2023-08-26 13:41:11 +00:00
|
|
|
|
|
|
|
_FORCE_INLINE_ void _set_category_excluded(const String &p_category, bool p_excluded) {
|
|
|
|
if (p_excluded) {
|
|
|
|
filter_settings.excluded_categories.insert(p_category);
|
|
|
|
} else {
|
|
|
|
filter_settings.excluded_categories.erase(p_category);
|
|
|
|
}
|
|
|
|
}
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
protected:
|
2024-01-07 16:33:05 +00:00
|
|
|
virtual void _do_update_theme_item_cache();
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
void _notification(int p_what);
|
2023-08-29 10:36:42 +00:00
|
|
|
static void _bind_methods();
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
void refresh();
|
2023-12-14 22:38:02 +00:00
|
|
|
void use_dialog_mode();
|
|
|
|
void clear_filter() { filter_edit->set_text(""); }
|
2023-08-26 08:08:01 +00:00
|
|
|
|
|
|
|
TaskPalette();
|
|
|
|
~TaskPalette();
|
|
|
|
};
|
|
|
|
|
2024-01-11 10:22:02 +00:00
|
|
|
#endif // ! TASK_PALETTE_H
|
|
|
|
|
|
|
|
#endif // ! TOOLS_ENABLED
|