Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-09-10 22:54:35 +0300
committerHans Goudey <h.goudey@me.com>2020-09-10 22:54:35 +0300
commit4e636376ca798b99c88d0b19e89b9c4a30956ffe (patch)
treeb1744aa45b4e268d28f0bc8a55cb856bbe31f81f
parentdeabcf00f2a0c496a28fafee1eefae69f01625db (diff)
Property Search: Set expansion for subpanels based on results
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_panel.c28
-rw-r--r--source/blender/editors/screen/area.c12
3 files changed, 29 insertions, 13 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 65b2e2c8484..ad9446f92c7 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1692,7 +1692,7 @@ void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y);
int UI_panel_size_y(const struct Panel *panel);
bool UI_panel_is_dragging(const struct Panel *panel);
bool UI_panel_matches_search_filter(const struct Panel *panel);
-void UI_panel_set_expansion_from_seach_filter(const struct bContext *C, struct Panel *panel);
+void UI_panels_set_expansion_from_seach_filter(const struct bContext *C, struct ARegion *region);
bool UI_panel_category_is_visible(const struct ARegion *region);
void UI_panel_category_add(struct ARegion *region, const char *name);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 6e6de0932e7..8d63bc40ea1 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -831,17 +831,35 @@ bool UI_panel_matches_search_filter(const Panel *panel)
return search_filter_matches;
}
-/**
- * Uses the panel's search filter flag to set its expansion,
- * activating animation if it was closed or opened.
- */
-void UI_panel_set_expansion_from_seach_filter(const bContext *C, Panel *panel)
+static void panel_set_expansion_from_seach_filter_recursive(const bContext *C, Panel *panel)
{
short start_flag = panel->flag;
SET_FLAG_FROM_TEST(panel->flag, !UI_panel_matches_search_filter(panel), PNL_CLOSED);
if (start_flag != panel->flag) {
panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
}
+
+ /* If the panel is filtered (removed) we need to check that its children are too. */
+ LISTBASE_FOREACH (Panel *, child_panel, &panel->children) {
+ if (panel->type == NULL || (panel->type->flag & PNL_NO_HEADER)) {
+ continue;
+ }
+ panel_set_expansion_from_seach_filter_recursive(C, child_panel);
+ }
+}
+
+/**
+ * Uses the panel's search filter flag to set its expansion,
+ * activating animation if it was closed or opened.
+ */
+void UI_panels_set_expansion_from_seach_filter(const bContext *C, ARegion *region)
+{
+ LISTBASE_FOREACH (Panel *, panel, &region->panels) {
+ if (panel->type == NULL || (panel->type->flag & PNL_NO_HEADER)) {
+ continue;
+ }
+ panel_set_expansion_from_seach_filter_recursive(C, panel);
+ }
}
/** \} */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e114f598872..067fec01e05 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2903,13 +2903,11 @@ void ED_region_panels_layout_ex(const bContext *C,
}
}
- if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE &&
- region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
- LISTBASE_FOREACH (Panel *, panel, &region->panels) {
- if (panel->type == NULL || (panel->type->flag & PNL_NO_HEADER)) {
- continue; /* Some panels don't have a type. */
- }
- UI_panel_set_expansion_from_seach_filter(C, panel);
+ /* Update panel expansion based on property search results. */
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
+ /* Don't use the last update from the deactivation, or all the panels will be left closed. */
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
+ UI_panels_set_expansion_from_seach_filter(C, region);
}
}