[Bf-blender-cvs] [c95d6de3b3f] property-search-ui: Property Search: Improve interaction with panels
Hans Goudey
noreply at git.blender.org
Fri Jun 19 13:41:21 CEST 2020
Commit: c95d6de3b3f13219155fc6d5e61d037bb79285da
Author: Hans Goudey
Date: Fri Jun 19 07:41:12 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rBc95d6de3b3f13219155fc6d5e61d037bb79285da
Property Search: Improve interaction with panels
===================================================================
M source/blender/editors/include/UI_interface.h
M source/blender/editors/interface/interface.c
M source/blender/editors/interface/interface_intern.h
M source/blender/editors/interface/interface_layout.c
M source/blender/editors/interface/interface_panel.c
M source/blender/editors/screen/area.c
===================================================================
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 2353106c908..94dcb7f9a74 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -681,6 +681,8 @@ enum {
void UI_block_theme_style_set(uiBlock *block, char theme_style);
char UI_block_emboss_get(uiBlock *block);
void UI_block_emboss_set(uiBlock *block, char dt);
+bool UI_block_has_search_filter(uiBlock *block);
+void UI_block_set_search_only(uiBlock *block, bool search_only);
void UI_block_free(const struct bContext *C, uiBlock *block);
void UI_blocklist_free(const struct bContext *C, struct ListBase *lb);
@@ -1915,6 +1917,7 @@ int uiLayoutGetEmboss(uiLayout *layout);
bool uiLayoutGetPropSep(uiLayout *layout);
bool uiLayoutGetPropDecorate(uiLayout *layout);
bool uiLayoutGetPropSearch(uiLayout *layout);
+void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only);
/* layout specifiers */
uiLayout *uiLayoutRow(uiLayout *layout, bool align);
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 23716012a66..8d49e486f4c 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -3436,6 +3436,16 @@ void UI_block_theme_style_set(uiBlock *block, char theme_style)
block->theme_style = theme_style;
}
+bool UI_block_has_search_filter(uiBlock *block)
+{
+ return block->search_filter != NULL && block->search_filter[0] != '\0';
+}
+
+void UI_block_set_search_only(uiBlock *block, bool search_only)
+{
+ block->search_only = search_only;
+}
+
static void ui_but_build_drawstr_float(uiBut *but, double value)
{
size_t slen = 0;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 56af671b651..15805153d38 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -456,6 +456,7 @@ struct uiBlock {
char display_device[64];
char *search_filter;
+ bool search_only;
struct PieMenuData pie_data;
};
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 54282664116..53279ad1af3 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -85,6 +85,8 @@ typedef struct uiLayoutRoot {
int type;
int opcontext;
+ bool search_only;
+
int emw, emh;
int padding;
@@ -5065,6 +5067,11 @@ int uiLayoutGetEmboss(uiLayout *layout)
}
}
+void uiLayoutRootSetSearchOnly(uiLayout *layout, bool search_only)
+{
+ layout->root->search_only = search_only;
+}
+
/** \} */
/* -------------------------------------------------------------------- */
@@ -5148,6 +5155,23 @@ static void debug_print_layout(uiItem *item, int depth)
}
#endif /* DEBUG_LAYOUT_ROOTS */
+static void ui_layout_free_hide_buttons(uiLayout *layout)
+{
+ LISTBASE_FOREACH_MUTABLE (uiItem *, item, &layout->items) {
+ if (item->type == ITEM_BUTTON) {
+ uiButtonItem *button_item = (uiButtonItem *)item;
+ BLI_assert(button_item->but != NULL);
+ button_item->but->flag |= UI_HIDDEN;
+ MEM_freeN(item);
+ }
+ else {
+ ui_layout_free_hide_buttons((uiLayout *)item);
+ }
+ }
+
+ MEM_freeN(layout);
+}
+
/**
* Tag all buttons with whether they matched the search filter or not.
*
@@ -5232,6 +5256,11 @@ static bool ui_layout_search_filter_clean_recursive(uiLayout *layout)
*/
static bool ui_block_search_filter_clean(uiBlock *block)
{
+
+ if (block->panel && STREQ(block->panel->panelname, "VIEWLAYER_PT_eevee_layer_passes")) {
+ printf(" ");
+ }
+
bool all_roots_empty = true;
LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) {
/* Find exceptions to search layout. */
@@ -5259,8 +5288,6 @@ static void ui_layout_search_build_recursive(uiLayout *layout,
{
BLI_assert(uiLayoutGetPropSearch(layout) || !BLI_listbase_is_empty(&layout->items));
- uiLayoutSetPropSep(layout, true);
-
bool is_horizontal = uiLayoutGetLocalDir(layout) == UI_LAYOUT_HORIZONTAL &&
(layout->item.type != ITEM_LAYOUT_ROOT);
// bool is_horizontal = uiLayoutGetLocalDir(layout) == UI_LAYOUT_HORIZONTAL;
@@ -5365,13 +5392,22 @@ static bool ui_block_search_layout(uiBlock *block)
/* Remove filtered buttons and now-empty layouts. */
bool all_roots_empty = ui_block_search_filter_clean(block);
+ /* Remove search only layout roots before the next step. */
+ LISTBASE_FOREACH_MUTABLE (uiLayoutRoot *, root, &block->layouts) {
+ if (root->search_only) {
+ ui_layout_free_hide_buttons(root->layout);
+ BLI_remlink(&block->layouts, root);
+ MEM_freeN(root);
+ }
+ }
+
/* Change layouts to the single column search layout. */
- if (!all_roots_empty) {
+ if (!all_roots_empty && !block->search_only) {
ui_block_build_search_layout(block);
}
/* Set empty flags. */
- SET_FLAG_FROM_TEST(block->flag, all_roots_empty, UI_BLOCK_FILTERED_EMPTY);
+ SET_FLAG_FROM_TEST(block->flag, all_roots_empty || block->search_only, UI_BLOCK_FILTERED_EMPTY);
if (block->panel != NULL) {
ui_panel_set_search_filtered(block->panel, all_roots_empty);
}
@@ -5385,7 +5421,7 @@ static bool ui_block_search_layout(uiBlock *block)
}
#endif
- return all_roots_empty;
+ return all_roots_empty || block->search_only;
}
/** \} */
diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index f7291b943d5..9f5a74cb25b 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -1441,7 +1441,7 @@ static void align_sub_panels(Panel *panel)
int ofsy = panel->ofsy + panel->sizey - panel->blocksizey;
LISTBASE_FOREACH (Panel *, pachild, &panel->children) {
- if (pachild->runtime_flag & PNL_ACTIVE) {
+ if (pachild->runtime_flag & PNL_ACTIVE && !UI_panel_is_search_filtered(pachild)) {
pachild->ofsx = panel->ofsx;
pachild->ofsy = ofsy - get_panel_size_y(pachild);
ofsy -= get_panel_real_size_y(pachild);
@@ -1726,15 +1726,15 @@ void UI_panels_draw(const bContext *C, ARegion *region)
* UI blocks are added in reverse order and we need child panels
* to draw on top. */
LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) {
- if (block->active && block->panel && !(block->panel->flag & PNL_SELECT) &&
- !UI_panel_is_search_filtered(block->panel)) {
+ if (block->active && !block->search_only && block->panel &&
+ !(block->panel->flag & PNL_SELECT) && !UI_panel_is_search_filtered(block->panel)) {
UI_block_draw(C, block);
}
}
LISTBASE_FOREACH_BACKWARD (uiBlock *, block, ®ion->uiblocks) {
- if (block->active && block->panel && (block->panel->flag & PNL_SELECT) &&
- !UI_panel_is_search_filtered(block->panel)) {
+ if (block->active && !block->search_only && block->panel &&
+ (block->panel->flag & PNL_SELECT) && !UI_panel_is_search_filtered(block->panel)) {
UI_block_draw(C, block);
}
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index 848787d9da1..8a7816263f2 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -2363,7 +2363,8 @@ static void ed_panel_draw(const bContext *C,
int w,
int em,
bool vertical,
- char *unique_panel_str)
+ char *unique_panel_str,
+ bool search_only)
{
const uiStyle *style = UI_style_get_dpi();
@@ -2376,6 +2377,7 @@ static void ed_panel_draw(const bContext *C,
strncat(block_name, unique_panel_str, LIST_PANEL_UNIQUE_STR_LEN);
}
uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS);
+ UI_block_set_search_only(block, search_only);
bool open;
panel = UI_panel_begin(area, region, lb, block, pt, panel, &open);
@@ -2395,6 +2397,7 @@ static void ed_panel_draw(const bContext *C,
1,
0,
style);
+ uiLayoutRootSetSearchOnly(panel->layout, search_only);
pt->draw_header_preset(C, panel);
@@ -2426,6 +2429,7 @@ 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);
@@ -2437,7 +2441,7 @@ static void ed_panel_draw(const bContext *C,
panel->labelofs = 0;
}
- if (open) {
+ if (open || UI_block_has_search_filter(block) || search_only) {
short panelContext;
/* panel context can either be toolbar region or normal panels region */
@@ -2461,6 +2465,7 @@ static void ed_panel_draw(const bContext *C,
em,
0,
style);
+ uiLayoutRootSetSearchOnly(panel->layout, search_only || !open);
pt->draw(C, panel);
@@ -2475,7 +2480,7 @@ static void ed_panel_draw(const bContext *C,
UI_block_end(C, block);
/* Draw child panels. */
- if (open) {
+ if (open || UI_block_has_search_filter(block)) {
LISTBASE_FOREACH (LinkData *, link, &pt->children) {
PanelType *child_pt = link->data;
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
@@ -2490,7 +2495,8 @@ static void ed_panel_draw(const bContext *C,
w,
em,
vertical,
- unique_panel_str);
+ unique_panel_str,
+ !open);
}
}
}
@@ -2651,7 +2657,8 @@ void ED_region_panels_layout_ex(const bContext *C,
(pt->flag & PNL_DRAW_BOX) ? w_box_panel : w,
em,
vertical,
- N
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list