Compare commits
52 Commits
72b588af8f
...
debc0d5d75
Author | SHA1 | Date |
---|---|---|
monxa | debc0d5d75 | |
Alexander Montag | a83eebbdc7 | |
Alexander Montag | f00d1bfb40 | |
Alexander Montag | 88a617aa42 | |
Alexander Montag | a07b143d68 | |
Alexander Montag | b7b6312184 | |
Alexander Montag | ec6c4c3036 | |
Alexander Montag | b53e470c60 | |
Alexander Montag | c38e66d008 | |
Alexander Montag | 709ecafb83 | |
Alexander Montag | 146635126a | |
Alexander Montag | 540bb585a8 | |
Alexander Montag | 4f7996b1ea | |
Alexander Montag | 74cf9855a7 | |
Alexander Montag | e6e1addbcb | |
Alexander Montag | 8d781da1a6 | |
Alexander Montag | 683834f58e | |
Alexander Montag | 10c8f58ca9 | |
Alexander Montag | 20be87904a | |
Alexander Montag | e8de3adc50 | |
Alexander Montag | f7d546fc3c | |
Alexander Montag | 585d9663d6 | |
Alexander Montag | 5a66160bce | |
Alexander Montag | 6200f61162 | |
monxa | e68e0236e9 | |
Alexander Montag | cb163ebc38 | |
Alexander Montag | c909582480 | |
Alexander Montag | 68514e2e13 | |
Alexander Montag | acb2bcc901 | |
Alexander Montag | a31b8b7520 | |
Alexander Montag | 62460496e4 | |
Alexander Montag | cd85e6dd30 | |
Alexander Montag | 3b73f24f33 | |
Alexander Montag | 329e90dfc6 | |
Alexander Montag | 84b2a60521 | |
Alexander Montag | cc8f099d82 | |
Alexander Montag | 380f80c2b3 | |
Alexander Montag | ffe344d166 | |
Alexander Montag | 9a1641e8ab | |
Alexander Montag | 47706e9480 | |
Alexander Montag | 0fc11bf05b | |
Alexander Montag | af15dde4c8 | |
Alexander Montag | 1145ce0252 | |
Alexander Montag | 8d29f16963 | |
Alexander Montag | b8259c6ee7 | |
Alexander Montag | aed8892760 | |
Alexander Montag | 8c323956e3 | |
Alexander Montag | 18a6bbeae6 | |
Alexander Montag | b4974bffd2 | |
Alexander Montag | f523af2d13 | |
Alexander Montag | a80b737319 | |
Alexander Montag | 7c4a462a69 |
|
@ -21,6 +21,7 @@
|
|||
#include "core/math/math_funcs.h"
|
||||
#include "editor/editor_interface.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/separator.h"
|
||||
#include "scene/main/viewport.h"
|
||||
#include "scene/resources/font.h"
|
||||
#include "scene/resources/style_box_flat.h"
|
||||
|
@ -29,6 +30,7 @@
|
|||
#ifdef LIMBOAI_GDEXTENSION
|
||||
#include <godot_cpp/classes/editor_interface.hpp> // for edge scale
|
||||
#include <godot_cpp/classes/font.hpp>
|
||||
#include <godot_cpp/classes/h_separator.hpp>
|
||||
#include <godot_cpp/classes/style_box_flat.hpp>
|
||||
#include <godot_cpp/classes/viewport.hpp>
|
||||
#include <godot_cpp/core/math.hpp>
|
||||
|
@ -63,7 +65,7 @@ void TreeSearch::_filter_tree() {
|
|||
}
|
||||
|
||||
void TreeSearch::_filter_tree(TreeItem *p_item, bool p_parent_matching) {
|
||||
bool visible = (number_matches.has(p_item) && (number_matches.get(p_item) > 0)) || p_parent_matching;
|
||||
bool visible = number_matches.has(p_item) | p_parent_matching;
|
||||
|
||||
p_item->set_visible(visible);
|
||||
|
||||
|
@ -116,13 +118,13 @@ void TreeSearch::_highlight_tree_item(TreeItem *p_tree_item) {
|
|||
}
|
||||
|
||||
Callable draw_callback = callable_mp(this, &TreeSearch::_draw_highlight_item).bind(parent_draw_method);
|
||||
callable_cache[p_tree_item] = draw_callback;
|
||||
|
||||
// This is necessary because of the modularity of this implementation.
|
||||
// Cache render properties of entry.
|
||||
String cached_text = p_tree_item->get_text(0);
|
||||
Ref<Texture2D> cached_icon = p_tree_item->get_icon(0);
|
||||
int cached_max_width = p_tree_item->get_icon_max_width(0);
|
||||
callable_cache[p_tree_item] = draw_callback;
|
||||
|
||||
// This removes render properties in entry.
|
||||
p_tree_item->set_custom_draw_callback(0, draw_callback);
|
||||
|
@ -134,7 +136,7 @@ void TreeSearch::_highlight_tree_item(TreeItem *p_tree_item) {
|
|||
p_tree_item->set_icon_max_width(0, cached_max_width);
|
||||
}
|
||||
|
||||
// Custom draw callback for highlighting (bind the parent_draw_method to this)
|
||||
// Custom draw callback for highlighting (bind the parent_drw_method to this)
|
||||
void TreeSearch::_draw_highlight_item(TreeItem *p_tree_item, const Rect2 p_rect, const Callable p_parent_draw_method) {
|
||||
if (!p_tree_item) {
|
||||
return;
|
||||
|
@ -237,30 +239,15 @@ void TreeSearch::_update_ordered_tree_items(TreeItem *p_tree_item) {
|
|||
}
|
||||
|
||||
void TreeSearch::_update_number_matches() {
|
||||
ERR_FAIL_COND(!tree_reference);
|
||||
|
||||
number_matches.clear();
|
||||
number_matches.reserve(ordered_tree_items.size());
|
||||
|
||||
_update_number_matches(tree_reference->get_root());
|
||||
for (int i = 0; i < matching_entries.size(); i++) {
|
||||
TreeItem *item = matching_entries[i];
|
||||
while (item) {
|
||||
int previous_match_cnt = number_matches.has(item) ? number_matches.get(item) : 0;
|
||||
number_matches[item] = previous_match_cnt + 1;
|
||||
item = item->get_parent();
|
||||
}
|
||||
|
||||
void TreeSearch::_update_number_matches(TreeItem *item) {
|
||||
for (int i = 0; i < item->get_child_count(); i++) {
|
||||
TreeItem *child = item->get_child(i);
|
||||
_update_number_matches(child);
|
||||
}
|
||||
int count = _vector_has_bsearch(matching_entries, item) ? 1 : 0;
|
||||
|
||||
for (int i = 0; i < item->get_child_count(); i++) {
|
||||
TreeItem *child = item->get_child(i);
|
||||
count += number_matches.has(child) ? number_matches.get(child) : 0;
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
number_matches[item] = count;
|
||||
}
|
||||
|
||||
String TreeSearch::_get_search_mask() const {
|
||||
|
|
|
@ -76,13 +76,12 @@ private:
|
|||
void _highlight_tree();
|
||||
void _highlight_tree_item(TreeItem *p_tree_item);
|
||||
|
||||
// Custom draw-Callback (bind inherited Callable).
|
||||
// custom draw-Callback (bind inherited Callable).
|
||||
void _draw_highlight_item(TreeItem *p_tree_item, const Rect2 p_rect, const Callable p_parent_draw_method);
|
||||
|
||||
void _update_matching_entries(const String &p_search_mask);
|
||||
void _update_ordered_tree_items(TreeItem *p_tree_item);
|
||||
void _update_number_matches();
|
||||
void _update_number_matches(TreeItem *item);
|
||||
|
||||
void _find_matching_entries(TreeItem *p_tree_item, const String &p_search_mask, Vector<TreeItem *> &p_accum) const;
|
||||
String _get_search_mask() const;
|
||||
|
|
Loading…
Reference in New Issue