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:
Diffstat (limited to 'source/blender/editors/screen/area.c')
-rw-r--r--source/blender/editors/screen/area.c82
1 files changed, 76 insertions, 6 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index e7f5f5646cb..f6c54e87410 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -492,6 +492,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 */
@@ -736,6 +739,37 @@ void ED_area_tag_refresh(ScrArea *area)
/* *************************************************************** */
+/**
+ * Returns the search string if the space type and region type support property search.
+ */
+const char *ED_area_region_search_filter_get(const ScrArea *area, const ARegion *region)
+{
+ /* Only the properties editor has a search string for now. */
+ if (area->spacetype == SPACE_PROPERTIES) {
+ SpaceProperties *sbuts = area->spacedata.first;
+ if (region->regiontype == RGN_TYPE_WINDOW) {
+ return sbuts->runtime->search_string;
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * Set the temporary update flag for property search.
+ */
+void ED_region_search_filter_update(const ScrArea *area, ARegion *region)
+{
+ region->flag |= RGN_FLAG_SEARCH_FILTER_UPDATE;
+
+ const char *search_filter = ED_area_region_search_filter_get(area, region);
+ SET_FLAG_FROM_TEST(region->flag,
+ region->regiontype == RGN_TYPE_WINDOW && search_filter[0] != '\0',
+ RGN_FLAG_SEARCH_FILTER_ACTIVE);
+}
+
+/* *************************************************************** */
+
/* use NULL to disable it */
void ED_area_status_text(ScrArea *area, const char *str)
{
@@ -2558,7 +2592,9 @@ static void ed_panel_draw(const bContext *C,
Panel *panel,
int w,
int em,
- char *unique_panel_str)
+ char *unique_panel_str,
+ const char *search_filter,
+ bool search_only)
{
const uiStyle *style = UI_style_get_dpi();
@@ -2571,10 +2607,14 @@ static void ed_panel_draw(const bContext *C,
strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN);
}
uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS);
+ UI_block_set_search_filter(block, search_filter);
+ UI_block_set_search_only(block, search_only);
bool open;
panel = UI_panel_begin(region, lb, block, pt, panel, &open);
+ const bool search_filter_active = search_filter != NULL && search_filter[0] != '\0';
+
/* bad fixed values */
int xco, yco, h = 0;
int headerend = w - UI_UNIT_X;
@@ -2590,9 +2630,11 @@ static void ed_panel_draw(const bContext *C,
1,
0,
style);
+ uiLayoutRootSetSearchOnly(panel->layout, search_only);
pt->draw_header_preset(C, panel);
+ UI_block_apply_search_filter(block);
UI_block_layout_resolve(block, &xco, &yco);
UI_block_translate(block, headerend - xco, 0);
panel->layout = NULL;
@@ -2620,9 +2662,11 @@ static void ed_panel_draw(const bContext *C,
panel->layout = UI_block_layout(
block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, labelx, labely, UI_UNIT_Y, 1, 0, style);
}
+ uiLayoutRootSetSearchOnly(panel->layout, search_only);
pt->draw_header(C, panel);
+ UI_block_apply_search_filter(block);
UI_block_layout_resolve(block, &xco, &yco);
panel->labelofs = xco - labelx;
panel->layout = NULL;
@@ -2631,7 +2675,7 @@ static void ed_panel_draw(const bContext *C,
panel->labelofs = 0;
}
- if (open) {
+ if (open || search_filter_active) {
short panelContext;
/* panel context can either be toolbar region or normal panels region */
@@ -2655,9 +2699,11 @@ static void ed_panel_draw(const bContext *C,
em,
0,
style);
+ uiLayoutRootSetSearchOnly(panel->layout, search_only || !open);
pt->draw(C, panel);
+ UI_block_apply_search_filter(block);
UI_block_layout_resolve(block, &xco, &yco);
panel->layout = NULL;
@@ -2669,13 +2715,22 @@ static void ed_panel_draw(const bContext *C,
UI_block_end(C, block);
/* Draw child panels. */
- if (open) {
+ if (open || search_filter_active) {
LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) {
- ed_panel_draw(C, region, &panel->children, child_pt, child_panel, w, em, unique_panel_str);
+ ed_panel_draw(C,
+ region,
+ &panel->children,
+ child_pt,
+ child_panel,
+ w,
+ em,
+ unique_panel_str,
+ search_filter,
+ !open);
}
}
}
@@ -2815,6 +2870,9 @@ void ED_region_panels_layout_ex(const bContext *C,
/* create panels */
UI_panels_begin(C, region);
+ /* Get search string for property search. */
+ const char *search_filter = ED_area_region_search_filter_get(area, region);
+
/* set view2d view matrix - UI_block_begin() stores it */
UI_view2d_view_ortho(v2d);
@@ -2846,7 +2904,9 @@ void ED_region_panels_layout_ex(const bContext *C,
panel,
(pt->flag & PNL_DRAW_BOX) ? w_box_panel : w,
em,
- NULL);
+ NULL,
+ search_filter,
+ false);
}
/* Draw "polyinstantaited" panels that don't have a 1 to 1 correspondence with their types. */
@@ -2879,7 +2939,17 @@ void ED_region_panels_layout_ex(const bContext *C,
panel,
(panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w,
em,
- unique_panel_str);
+ unique_panel_str,
+ search_filter,
+ false);
+ }
+ }
+
+ /* 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);
}
}