diff --git a/editor/task_tree.cpp b/editor/task_tree.cpp index 167ce1f..ca8e4fe 100644 --- a/editor/task_tree.cpp +++ b/editor/task_tree.cpp @@ -23,17 +23,17 @@ #include "core/object/script_language.h" #include "editor/themes/editor_scale.h" #include "scene/gui/box_container.h" -#include "scene/gui/texture_rect.h" #include "scene/gui/label.h" +#include "scene/gui/texture_rect.h" #endif // LIMBOAI_MODULE #ifdef LIMBOAI_GDEXTENSION #include -#include #include -#include -#include #include +#include +#include +#include using namespace godot; #endif // LIMBOAI_GDEXTENSION @@ -437,7 +437,7 @@ void TaskTree::_normalize_drop(TreeItem *item, int type, int &to_pos, Refget_index(); { Vector> selected = get_selected_tasks(); - if (to_task == selected[selected.size()-1]) { + if (to_task == selected[selected.size() - 1]) { to_pos += 1; } } @@ -574,13 +574,13 @@ void TaskTree::tree_search_show_and_focus() { TaskTree::TaskTree() { editable = true; updating_tree = false; - + // for Tree + TreeSearch, we want a VBoxContainer. For now, rather than changing this classes type, let's do nesting: // TaskTree -> VBoxContainer -> [Tree, TreeSearchPanel] - VBoxContainer * vbox_container = memnew(VBoxContainer); + VBoxContainer *vbox_container = memnew(VBoxContainer); add_child(vbox_container); vbox_container->set_anchors_preset(PRESET_FULL_RECT); - + tree = memnew(Tree); tree->set_v_size_flags(Control::SIZE_EXPAND_FILL); vbox_container->add_child(tree); @@ -594,7 +594,7 @@ TaskTree::TaskTree() { tree->set_select_mode(Tree::SelectMode::SELECT_MULTI); tree->set_drag_forwarding(callable_mp(this, &TaskTree::_get_drag_data_fw), callable_mp(this, &TaskTree::_can_drop_data_fw), callable_mp(this, &TaskTree::_drop_data_fw)); - + tree_search = memnew(TreeSearch); vbox_container->add_child(tree_search->search_panel); } diff --git a/editor/tree_search.cpp b/editor/tree_search.cpp index 23ba40e..faa5763 100644 --- a/editor/tree_search.cpp +++ b/editor/tree_search.cpp @@ -22,19 +22,19 @@ #include "core/math/math_funcs.h" #include "editor/editor_interface.h" #include "editor/themes/editor_scale.h" -#include "scene/resources/font.h" #include "scene/gui/separator.h" -#include "scene/resources/style_box_flat.h" #include "scene/main/viewport.h" +#include "scene/resources/font.h" +#include "scene/resources/style_box_flat.h" #endif // LIMBOAI_MODULE #ifdef LIMBOAI_GDEXTENSION -#include #include // for edge scale #include #include #include #include +#include #endif // LIMBOAI_GDEXTENSION #define UPPER_BOUND (1 << 15) // for substring search. @@ -141,8 +141,7 @@ void TreeSearchPanel::show_and_focus() { /* ------- TreeSearch ------- */ void TreeSearch::_filter_tree(TreeItem *p_tree_item, const String &p_search_mask) { - for (int i = 0; i < ordered_tree_items.size(); i++){ - + for (int i = 0; i < ordered_tree_items.size(); i++) { } PRINT_LINE("filter tree not yet implemented!", p_search_mask); } @@ -153,8 +152,9 @@ void TreeSearch::_highlight_tree(const String &p_search_mask) { TreeItem *entry = ordered_tree_items[i]; int num_m = number_matches.has(entry) ? number_matches.get(entry) : 0; - if (num_m == 0){ - continue;; + if (num_m == 0) { + continue; + ; } // make sure to also call any draw method already defined. @@ -164,7 +164,7 @@ void TreeSearch::_highlight_tree(const String &p_search_mask) { } Callable draw_callback = callable_mp(this, &TreeSearch::_draw_highlight_item).bind(p_search_mask, parent_draw_method); - + // -- this is necessary because of the modularity of this implementation // cache render properties of entry String cached_text = entry->get_text(0); @@ -189,10 +189,9 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Strin return; // call any parent draw methods such as for probability FIRST. p_parent_draw_method.call(p_tree_item, p_rect); - + // first part: outline if (matching_entries.has(p_tree_item)) { - // font info Ref font = p_tree_item->get_custom_font(0); if (font.is_null()) { @@ -207,7 +206,7 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Strin // substring size String string_full = p_tree_item->get_text(0); StringSearchIndices substring_idx = _substring_bounds(string_full, p_search_mask); - + String substring_match = string_full.substr(substring_idx.lower, substring_idx.upper - substring_idx.lower); Vector2 substring_match_size = font->get_string_size(substring_match, HORIZONTAL_ALIGNMENT_LEFT, -1.f, font_size); @@ -409,16 +408,16 @@ void TreeSearch::_select_next_match() { _select_first_match(); // wrap around. } -void TreeSearch::on_item_edited(TreeItem * item) { - if (item->get_cell_mode(0) != TreeItem::CELL_MODE_CUSTOM){ +void TreeSearch::on_item_edited(TreeItem *item) { + if (item->get_cell_mode(0) != TreeItem::CELL_MODE_CUSTOM) { return; } - if (!callable_cache.has(item) || item->get_custom_draw_callback(0) == callable_cache.get(item)){ + if (!callable_cache.has(item) || item->get_custom_draw_callback(0) == callable_cache.get(item)) { return; } - item->set_custom_draw_callback(0,callable_cache.get(item)); + item->set_custom_draw_callback(0, callable_cache.get(item)); } // Call this as a post-processing step for the already constructed tree. @@ -440,7 +439,6 @@ void TreeSearch::update_search(Tree *p_tree) { _update_matching_entries(search_mask); _update_number_matches(); - if (search_mode == TreeSearchMode::HIGHLIGHT) { _highlight_tree(search_mask); if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) { diff --git a/editor/tree_search.h b/editor/tree_search.h index 80ddd0d..0b4300f 100644 --- a/editor/tree_search.h +++ b/editor/tree_search.h @@ -83,13 +83,13 @@ private: } }; - Tree * tree_reference; + Tree *tree_reference; Vector ordered_tree_items; Vector matching_entries; HashMap number_matches; HashMap callable_cache; - + void _filter_tree(TreeItem *tree_item, const String &search_mask); void _highlight_tree(const String &p_search_mask); void _draw_highlight_item(TreeItem *tree_item, Rect2 rect, String search_mask, Callable parent_draw_method); @@ -99,13 +99,12 @@ private: Vector _find_matching_entries(TreeItem *tree_item, const String &search_mask, Vector &buffer); StringSearchIndices _substring_bounds(const String &searchable, const String &search_mask) const; - void _select_item(TreeItem * item); + void _select_item(TreeItem *item); void _select_first_match(); void _select_next_match(); - protected: - static void _bind_methods(){} + static void _bind_methods() {} public: // we will add everything from TaskTree.h