Run clang-format
This commit is contained in:
parent
f523af2d13
commit
b4974bffd2
|
@ -23,17 +23,17 @@
|
||||||
#include "core/object/script_language.h"
|
#include "core/object/script_language.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
#include "scene/gui/box_container.h"
|
#include "scene/gui/box_container.h"
|
||||||
#include "scene/gui/texture_rect.h"
|
|
||||||
#include "scene/gui/label.h"
|
#include "scene/gui/label.h"
|
||||||
|
#include "scene/gui/texture_rect.h"
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
#include <godot_cpp/classes/editor_interface.hpp>
|
#include <godot_cpp/classes/editor_interface.hpp>
|
||||||
#include <godot_cpp/classes/script.hpp>
|
|
||||||
#include <godot_cpp/classes/h_box_container.hpp>
|
#include <godot_cpp/classes/h_box_container.hpp>
|
||||||
#include <godot_cpp/classes/v_box_container.hpp>
|
|
||||||
#include <godot_cpp/classes/texture_rect.hpp>
|
|
||||||
#include <godot_cpp/classes/label.hpp>
|
#include <godot_cpp/classes/label.hpp>
|
||||||
|
#include <godot_cpp/classes/script.hpp>
|
||||||
|
#include <godot_cpp/classes/texture_rect.hpp>
|
||||||
|
#include <godot_cpp/classes/v_box_container.hpp>
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ void TaskTree::_normalize_drop(TreeItem *item, int type, int &to_pos, Ref<BTTask
|
||||||
to_pos = to_task->get_index();
|
to_pos = to_task->get_index();
|
||||||
{
|
{
|
||||||
Vector<Ref<BTTask>> selected = get_selected_tasks();
|
Vector<Ref<BTTask>> selected = get_selected_tasks();
|
||||||
if (to_task == selected[selected.size()-1]) {
|
if (to_task == selected[selected.size() - 1]) {
|
||||||
to_pos += 1;
|
to_pos += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,13 +574,13 @@ void TaskTree::tree_search_show_and_focus() {
|
||||||
TaskTree::TaskTree() {
|
TaskTree::TaskTree() {
|
||||||
editable = true;
|
editable = true;
|
||||||
updating_tree = false;
|
updating_tree = false;
|
||||||
|
|
||||||
// for Tree + TreeSearch, we want a VBoxContainer. For now, rather than changing this classes type, let's do nesting:
|
// for Tree + TreeSearch, we want a VBoxContainer. For now, rather than changing this classes type, let's do nesting:
|
||||||
// TaskTree -> VBoxContainer -> [Tree, TreeSearchPanel]
|
// TaskTree -> VBoxContainer -> [Tree, TreeSearchPanel]
|
||||||
VBoxContainer * vbox_container = memnew(VBoxContainer);
|
VBoxContainer *vbox_container = memnew(VBoxContainer);
|
||||||
add_child(vbox_container);
|
add_child(vbox_container);
|
||||||
vbox_container->set_anchors_preset(PRESET_FULL_RECT);
|
vbox_container->set_anchors_preset(PRESET_FULL_RECT);
|
||||||
|
|
||||||
tree = memnew(Tree);
|
tree = memnew(Tree);
|
||||||
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
tree->set_v_size_flags(Control::SIZE_EXPAND_FILL);
|
||||||
vbox_container->add_child(tree);
|
vbox_container->add_child(tree);
|
||||||
|
@ -594,7 +594,7 @@ TaskTree::TaskTree() {
|
||||||
tree->set_select_mode(Tree::SelectMode::SELECT_MULTI);
|
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->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);
|
tree_search = memnew(TreeSearch);
|
||||||
vbox_container->add_child(tree_search->search_panel);
|
vbox_container->add_child(tree_search->search_panel);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,19 +22,19 @@
|
||||||
#include "core/math/math_funcs.h"
|
#include "core/math/math_funcs.h"
|
||||||
#include "editor/editor_interface.h"
|
#include "editor/editor_interface.h"
|
||||||
#include "editor/themes/editor_scale.h"
|
#include "editor/themes/editor_scale.h"
|
||||||
#include "scene/resources/font.h"
|
|
||||||
#include "scene/gui/separator.h"
|
#include "scene/gui/separator.h"
|
||||||
#include "scene/resources/style_box_flat.h"
|
|
||||||
#include "scene/main/viewport.h"
|
#include "scene/main/viewport.h"
|
||||||
|
#include "scene/resources/font.h"
|
||||||
|
#include "scene/resources/style_box_flat.h"
|
||||||
#endif // LIMBOAI_MODULE
|
#endif // LIMBOAI_MODULE
|
||||||
|
|
||||||
#ifdef LIMBOAI_GDEXTENSION
|
#ifdef LIMBOAI_GDEXTENSION
|
||||||
#include <godot_cpp/core/math.hpp>
|
|
||||||
#include <godot_cpp/classes/editor_interface.hpp> // for edge scale
|
#include <godot_cpp/classes/editor_interface.hpp> // for edge scale
|
||||||
#include <godot_cpp/classes/font.hpp>
|
#include <godot_cpp/classes/font.hpp>
|
||||||
#include <godot_cpp/classes/h_separator.hpp>
|
#include <godot_cpp/classes/h_separator.hpp>
|
||||||
#include <godot_cpp/classes/style_box_flat.hpp>
|
#include <godot_cpp/classes/style_box_flat.hpp>
|
||||||
#include <godot_cpp/classes/viewport.hpp>
|
#include <godot_cpp/classes/viewport.hpp>
|
||||||
|
#include <godot_cpp/core/math.hpp>
|
||||||
#endif // LIMBOAI_GDEXTENSION
|
#endif // LIMBOAI_GDEXTENSION
|
||||||
|
|
||||||
#define UPPER_BOUND (1 << 15) // for substring search.
|
#define UPPER_BOUND (1 << 15) // for substring search.
|
||||||
|
@ -141,8 +141,7 @@ void TreeSearchPanel::show_and_focus() {
|
||||||
/* ------- TreeSearch ------- */
|
/* ------- TreeSearch ------- */
|
||||||
|
|
||||||
void TreeSearch::_filter_tree(TreeItem *p_tree_item, const String &p_search_mask) {
|
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);
|
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];
|
TreeItem *entry = ordered_tree_items[i];
|
||||||
|
|
||||||
int num_m = number_matches.has(entry) ? number_matches.get(entry) : 0;
|
int num_m = number_matches.has(entry) ? number_matches.get(entry) : 0;
|
||||||
if (num_m == 0){
|
if (num_m == 0) {
|
||||||
continue;;
|
continue;
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
// make sure to also call any draw method already defined.
|
// 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);
|
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
|
// -- this is necessary because of the modularity of this implementation
|
||||||
// cache render properties of entry
|
// cache render properties of entry
|
||||||
String cached_text = entry->get_text(0);
|
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;
|
return;
|
||||||
// call any parent draw methods such as for probability FIRST.
|
// call any parent draw methods such as for probability FIRST.
|
||||||
p_parent_draw_method.call(p_tree_item, p_rect);
|
p_parent_draw_method.call(p_tree_item, p_rect);
|
||||||
|
|
||||||
// first part: outline
|
// first part: outline
|
||||||
if (matching_entries.has(p_tree_item)) {
|
if (matching_entries.has(p_tree_item)) {
|
||||||
|
|
||||||
// font info
|
// font info
|
||||||
Ref<Font> font = p_tree_item->get_custom_font(0);
|
Ref<Font> font = p_tree_item->get_custom_font(0);
|
||||||
if (font.is_null()) {
|
if (font.is_null()) {
|
||||||
|
@ -207,7 +206,7 @@ void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, Rect2 p_rect, Strin
|
||||||
// substring size
|
// substring size
|
||||||
String string_full = p_tree_item->get_text(0);
|
String string_full = p_tree_item->get_text(0);
|
||||||
StringSearchIndices substring_idx = _substring_bounds(string_full, p_search_mask);
|
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);
|
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);
|
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.
|
_select_first_match(); // wrap around.
|
||||||
}
|
}
|
||||||
|
|
||||||
void TreeSearch::on_item_edited(TreeItem * item) {
|
void TreeSearch::on_item_edited(TreeItem *item) {
|
||||||
if (item->get_cell_mode(0) != TreeItem::CELL_MODE_CUSTOM){
|
if (item->get_cell_mode(0) != TreeItem::CELL_MODE_CUSTOM) {
|
||||||
return;
|
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;
|
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.
|
// 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_matching_entries(search_mask);
|
||||||
_update_number_matches();
|
_update_number_matches();
|
||||||
|
|
||||||
|
|
||||||
if (search_mode == TreeSearchMode::HIGHLIGHT) {
|
if (search_mode == TreeSearchMode::HIGHLIGHT) {
|
||||||
_highlight_tree(search_mask);
|
_highlight_tree(search_mask);
|
||||||
if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) {
|
if (!search_panel->is_connected("text_submitted", callable_mp(this, &TreeSearch::_select_next_match))) {
|
||||||
|
|
|
@ -83,13 +83,13 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Tree * tree_reference;
|
Tree *tree_reference;
|
||||||
|
|
||||||
Vector<TreeItem *> ordered_tree_items;
|
Vector<TreeItem *> ordered_tree_items;
|
||||||
Vector<TreeItem *> matching_entries;
|
Vector<TreeItem *> matching_entries;
|
||||||
HashMap<TreeItem *, int> number_matches;
|
HashMap<TreeItem *, int> number_matches;
|
||||||
HashMap<TreeItem *, Callable> callable_cache;
|
HashMap<TreeItem *, Callable> callable_cache;
|
||||||
|
|
||||||
void _filter_tree(TreeItem *tree_item, const String &search_mask);
|
void _filter_tree(TreeItem *tree_item, const String &search_mask);
|
||||||
void _highlight_tree(const String &p_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);
|
void _draw_highlight_item(TreeItem *tree_item, Rect2 rect, String search_mask, Callable parent_draw_method);
|
||||||
|
@ -99,13 +99,12 @@ private:
|
||||||
Vector<TreeItem *> _find_matching_entries(TreeItem *tree_item, const String &search_mask, Vector<TreeItem *> &buffer);
|
Vector<TreeItem *> _find_matching_entries(TreeItem *tree_item, const String &search_mask, Vector<TreeItem *> &buffer);
|
||||||
StringSearchIndices _substring_bounds(const String &searchable, const String &search_mask) const;
|
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_first_match();
|
||||||
void _select_next_match();
|
void _select_next_match();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods(){}
|
static void _bind_methods() {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// we will add everything from TaskTree.h
|
// we will add everything from TaskTree.h
|
||||||
|
|
Loading…
Reference in New Issue