[Bf-blender-cvs] [caa79adffb8] property-search-ui-v2: Property Search: Update panel expansion while searching
Hans Goudey
noreply at git.blender.org
Thu Aug 20 22:06:25 CEST 2020
Commit: caa79adffb803c2fe17cadd0f2bedbbe2aee8827
Author: Hans Goudey
Date: Thu Aug 20 16:06:11 2020 -0400
Branches: property-search-ui-v2
https://developer.blender.org/rBcaa79adffb803c2fe17cadd0f2bedbbe2aee8827
Property Search: Update panel expansion while searching
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/screen/area.c
M source/blender/editors/space_buttons/space_buttons.c
M source/blender/makesdna/DNA_screen_types.h
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 5a8fb685b5e..57b39eef867 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1686,6 +1686,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);
bool UI_panel_is_active(const struct Panel *panel);
bool UI_panel_category_is_visible(const struct ARegion *region);
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 0b4e45b1d7b..fa2983d64a9 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -861,6 +861,19 @@ bool UI_panel_is_active(const Panel *panel)
return panel->runtime_flag & PNL_ACTIVE;
}
+/**
+ * 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)
+{
+ 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);
+ }
+}
+
/**************************** drawing *******************************/
/* triangle 'icon' for panel header */
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 10a44b58dc9..23edb226511 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -496,6 +496,9 @@ void ED_region_do_layout(bContext *C, ARegion *region)
UI_SetTheme(area ? area->spacetype : 0, at->regionid);
at->layout(C, region);
+
+ /* Clear temporary update flag. */
+ region->flag &= ~RGN_FLAG_SEARCH_FILTER_UPDATE;
}
/* only exported for WM */
@@ -761,6 +764,8 @@ char *ED_area_search_filter_get(const bContext *C)
void ED_region_search_filter_update(const bContext *C, ARegion *region)
{
+ region->flag |= RGN_FLAG_SEARCH_FILTER_UPDATE;
+
const char *search_filter = ED_area_search_filter_get(C);
SET_FLAG_FROM_TEST(region->flag, search_filter[0] != '\0', RGN_FLAG_SEARCH_FILTER_ACTIVE);
}
@@ -2895,6 +2900,16 @@ 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, ®ion->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);
+ }
+ }
+
/* align panels and return size */
UI_panels_end(C, region, &x, &y);
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 8659853becf..3a9964844ef 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -396,7 +396,7 @@ static void property_search_all_tabs(const bContext *C,
UI_blocklist_free(C_copy, ®ion_copy->uiblocks);
}
- if (!current_tab_has_search_match) {
+ if (!current_tab_has_search_match && main_region->flag & RGN_FLAG_SEARCH_FILTER_UPDATE) {
property_search_move_to_next_tab_with_results(sbuts, context_tabs_array, tabs_tot);
}
@@ -412,7 +412,7 @@ static void buttons_main_region_layout(const bContext *C, ARegion *region)
/* draw entirely, view changes should be handled here */
SpaceProperties *sbuts = CTX_wm_space_properties(C);
- if (sbuts->search_string != NULL && sbuts->search_string[0] != '\0') {
+ if (region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE) {
property_search_all_tabs(C, sbuts, region);
}
else {
diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h
index bc9970594a7..099c7fb80ad 100644
--- a/source/blender/makesdna/DNA_screen_types.h
+++ b/source/blender/makesdna/DNA_screen_types.h
@@ -690,6 +690,12 @@ enum {
RGN_FLAG_HIDDEN_BY_USER = (1 << 7),
/** Property search filter is active. */
RGN_FLAG_SEARCH_FILTER_ACTIVE = (1 << 8),
+ /**
+ * Update the expansion of the region's panels and switch contexts. Only Set
+ * temporarily when the search filter is updated so that interactions are still
+ * interactive, cleared at the end of the region's layout pass.
+ */
+ RGN_FLAG_SEARCH_FILTER_UPDATE = (1 << 9),
};
/** #ARegion.do_draw */
More information about the Bf-blender-cvs
mailing list