Compare commits

..

1 Commits

Author SHA1 Message Date
monxa 64f17b6b4a
Merge af15dde4c8 into 134bb3214a 2024-09-26 07:53:22 +02:00
5 changed files with 17 additions and 32 deletions

View File

@ -35,7 +35,6 @@
#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> #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.
@ -59,16 +58,14 @@ void TreeSearchPanel::_initialize_controls() {
this->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_WIDE); this->set_anchors_and_offsets_preset(LayoutPreset::PRESET_BOTTOM_WIDE);
this->set_v_size_flags(SIZE_SHRINK_CENTER); // Do not expand vertically this->set_v_size_flags(SIZE_SHRINK_CENTER); // Do not expand vertically
// hack add separator to the left so line edit doesn't clip.
line_edit_search->set_h_size_flags(SIZE_EXPAND_FILL); line_edit_search->set_h_size_flags(SIZE_EXPAND_FILL);
_add_spacer(0.25); // otherwise the lineedits expand margin touches the left border. _add_spacer(0.25); // otherwise the lineedits expand margin touches the left border.
add_child(line_edit_search); add_child(line_edit_search);
_add_spacer(0.25);
add_child(check_button_filter_highlight); add_child(check_button_filter_highlight);
add_child(label_filter); add_child(label_filter);
_add_spacer();
_add_spacer(0.25);
add_child(close_button); add_child(close_button);
_add_spacer(0.25); _add_spacer(0.25);
} }
@ -367,6 +364,7 @@ TreeSearch::StringSearchIndices TreeSearch::_substring_bounds(const String &p_se
void TreeSearch::_select_item(TreeItem *p_item) { void TreeSearch::_select_item(TreeItem *p_item) {
if (!p_item) if (!p_item)
return; return;
tree_reference->set_selected(p_item, 0);
// first unfold ancestors // first unfold ancestors
TreeItem * ancestor = p_item->get_parent(); TreeItem * ancestor = p_item->get_parent();
@ -375,13 +373,9 @@ void TreeSearch::_select_item(TreeItem *p_item) {
ancestor->set_collapsed(false); ancestor->set_collapsed(false);
ancestor = ancestor->get_parent(); ancestor = ancestor->get_parent();
} }
// then scroll to [item] // then scroll to [item]
tree_reference->scroll_to_item(p_item); tree_reference->scroll_to_item(p_item);
// ...and select it
tree_reference->deselect_all();
tree_reference->set_selected(p_item, 0);
} }
void TreeSearch::_select_first_match() { void TreeSearch::_select_first_match() {

View File

@ -95,6 +95,7 @@ private:
void _update_ordered_tree_items(TreeItem *p_tree_item); void _update_ordered_tree_items(TreeItem *p_tree_item);
void _update_number_matches(); void _update_number_matches();
Vector<TreeItem *> _find_matching_entries(TreeItem *p_tree_item, const String &p_search_mask, Vector<TreeItem *> &p_buffer); Vector<TreeItem *> _find_matching_entries(TreeItem *p_tree_item, const String &p_search_mask, Vector<TreeItem *> &p_buffer);
StringSearchIndices _substring_bounds(const String &p_searchable, const String &p_search_mask) const; StringSearchIndices _substring_bounds(const String &p_searchable, const String &p_search_mask) const;
@ -104,7 +105,6 @@ private:
template<typename T> template<typename T>
bool _vector_has_bsearch(Vector<T*> p_vec, T* element); bool _vector_has_bsearch(Vector<T*> p_vec, T* element);
protected: protected:
static void _bind_methods() {} static void _bind_methods() {}
@ -119,3 +119,5 @@ public:
#endif // TREE_SEARCH_H #endif // TREE_SEARCH_H
#endif // ! TOOLS_ENABLED #endif // ! TOOLS_ENABLED

View File

@ -263,21 +263,6 @@ void LimboHSM::_validate_property(PropertyInfo &p_property) const {
void LimboHSM::_notification(int p_what) { void LimboHSM::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_POST_ENTER_TREE: { case NOTIFICATION_POST_ENTER_TREE: {
if (was_active && is_root()) {
// Re-activate the root HSM if it was previously active.
// Typically, this happens when the node is re-entered scene repeatedly (e.g., re-parenting, pooling).
set_active(true);
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (is_root()) {
// Remember active status for re-parenting and exit state machine
// to release resources and signal connections if active.
was_active = active;
if (is_active()) {
_exit();
}
}
} break; } break;
case NOTIFICATION_PROCESS: { case NOTIFICATION_PROCESS: {
_update(get_process_delta_time()); _update(get_process_delta_time());

View File

@ -55,7 +55,6 @@ private:
LimboState *previous_active; LimboState *previous_active;
LimboState *next_active; LimboState *next_active;
bool updating = false; bool updating = false;
bool was_active = false;
HashMap<TransitionKey, Transition, TransitionKeyHasher> transitions; HashMap<TransitionKey, Transition, TransitionKeyHasher> transitions;

View File

@ -190,6 +190,11 @@ void LimboState::_notification(int p_what) {
_update_blackboard_plan(); _update_blackboard_plan();
} }
} break; } break;
case NOTIFICATION_PREDELETE: {
if (is_active()) {
_exit();
}
} break;
} }
} }