[Bf-blender-cvs] [db76f34ed6d] property-search-ui: UI: Start towards property search in public branch
Hans Goudey
noreply at git.blender.org
Fri Jun 12 00:07:31 CEST 2020
Commit: db76f34ed6dc0d13aa4799d0e7726789ea79c892
Author: Hans Goudey
Date: Thu Jun 11 18:07:24 2020 -0400
Branches: property-search-ui
https://developer.blender.org/rBdb76f34ed6dc0d13aa4799d0e7726789ea79c892
UI: Start towards property search in public branch
This is VERY WIP, but I will continue work in this branch. Implementation
starts with a few things:
- A pass at the end of the layout system to scan buttons based on a
search string set by the properties space. Buttons which don't fit
the filter are removed from the layouts.
- A pass after the filter to move buttons that are still in layouts
to a single column "search layout." There is currently a bug with
this that adds too much space in between items.
- An attempt to only show panels that haven't been completely
filtered by the previous two steps. This is quite buggy right now:
panels don't animate properly and sometimes it fails.
- An attempt at a keymap item "ctrl-F" to activate the search button.
"alt-F" should probably clear the button too.
===================================================================
M release/scripts/presets/keyconfig/keymap_data/blender_default.py
M release/scripts/startup/bl_ui/space_properties.py
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
M source/blender/editors/space_buttons/buttons_context.c
M source/blender/editors/space_buttons/buttons_intern.h
M source/blender/editors/space_buttons/buttons_ops.c
M source/blender/editors/space_buttons/space_buttons.c
M source/blender/makesdna/DNA_screen_types.h
M source/blender/makesdna/DNA_space_types.h
M source/blender/makesrna/intern/rna_space.c
===================================================================
diff --git a/release/scripts/presets/keyconfig/keymap_data/blender_default.py b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
index bbbe520441c..bd6b1b1d3e5 100644
--- a/release/scripts/presets/keyconfig/keymap_data/blender_default.py
+++ b/release/scripts/presets/keyconfig/keymap_data/blender_default.py
@@ -725,6 +725,7 @@ def km_property_editor(_params):
{"properties": [("direction", 'PREV'), ], },),
("screen.space_context_cycle", {"type": 'WHEELDOWNMOUSE', "value": 'PRESS', "ctrl": True},
{"properties": [("direction", 'NEXT'), ], },),
+ ("buttons.start_filter", {"type": 'F', "value": 'PRESS', "ctrl": True}, None),
])
return keymap
diff --git a/release/scripts/startup/bl_ui/space_properties.py b/release/scripts/startup/bl_ui/space_properties.py
index 7d9ca687524..673f0fae7e0 100644
--- a/release/scripts/startup/bl_ui/space_properties.py
+++ b/release/scripts/startup/bl_ui/space_properties.py
@@ -23,11 +23,21 @@ from bpy.types import Header, Panel
class PROPERTIES_HT_header(Header):
bl_space_type = 'PROPERTIES'
- def draw(self, _context):
+ def draw(self, context):
layout = self.layout
+ view = context.space_data
layout.template_header()
+ layout.separator_spacer()
+ layout.prop(view, "filter_text", icon='VIEWZOOM', text="")
+ layout.separator_spacer()
+
+ # Note: pin ID doesn't properly work with this simple button in python yet.
+ row = layout.row()
+ row.emboss = 'NONE'
+ row.prop(view, "use_pin_id", icon=('PINNED' if view.use_pin_id else 'UNPINNED'), text="")
+
class PROPERTIES_PT_navigation_bar(Panel):
bl_space_type = 'PROPERTIES'
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index 59dcc9a8ace..8979ce1b6f1 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -158,6 +158,8 @@ enum {
UI_BLOCK_POPOVER_ONCE = 1 << 22,
/** Always show keymaps, even for non-menus. */
UI_BLOCK_SHOW_SHORTCUT_ALWAYS = 1 << 23,
+ /** All items have been removed from the block by the search filter. */
+ UI_BLOCK_FILTERED_EMPTY = 1 << 24,
};
/** #uiPopupBlockHandle.menuretval */
@@ -1706,6 +1708,8 @@ void UI_panel_category_draw_all(struct ARegion *region, const char *category_id_
struct PanelType *UI_paneltype_find(int space_id, int region_id, const char *idname);
+void UI_panels_remove_search_filtered(struct ARegion *region);
+
/* Polyinstantiated panels for representing a list of data. */
struct Panel *UI_panel_add_instanced(struct ScrArea *area,
struct ARegion *region,
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 04c259ab092..629bb1d2eab 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -1698,20 +1698,17 @@ static void ui_but_predefined_extra_operator_icons_add(uiBut *but)
void UI_block_update_from_old(const bContext *C, uiBlock *block)
{
- uiBut *but_old;
- uiBut *but;
-
- if (!block->oldblock) {
+ if (block->oldblock == NULL) {
return;
}
- but_old = block->oldblock->buttons.first;
+ uiBut *but_old = block->oldblock->buttons.first;
if (BLI_listbase_is_empty(&block->oldblock->butstore) == false) {
UI_butstore_update(block);
}
- for (but = block->buttons.first; but; but = but->next) {
+ for (uiBut *but = block->buttons.first; but; but = but->next) {
if (ui_but_update_from_old_block(C, block, &but, &but_old)) {
ui_but_update(but);
@@ -3367,17 +3364,29 @@ void UI_block_region_set(uiBlock *block, ARegion *region)
uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, short dt)
{
+ // printf("UI_BLOCK_BEGIN\n");
uiBlock *block;
wmWindow *window;
Scene *scn;
window = CTX_wm_window(C);
scn = CTX_data_scene(C);
+ ScrArea *area = CTX_wm_area(C);
block = MEM_callocN(sizeof(uiBlock), "uiBlock");
block->active = 1;
block->dt = dt;
block->evil_C = (void *)C; /* XXX */
+ if ((region && region->regiontype == RGN_TYPE_WINDOW) &&
+ (area && area->spacetype == SPACE_PROPERTIES)) {
+ /* HANS-TODO: Generalize. */
+ SpaceProperties *sbuts = CTX_wm_space_properties(C);
+ block->search_filter = sbuts->search_string;
+ // printf(" Adding search string: %s\n", block->search_filter);
+ }
+ else {
+ block->search_filter = NULL;
+ }
if (scn) {
/* store display device name, don't lookup for transformations yet
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 6cd990ec2b0..d80fb0ff51d 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -79,6 +79,8 @@ enum {
UI_HAS_ICON = (1 << 3),
UI_HIDDEN = (1 << 4),
UI_SELECT_DRAW = (1 << 5), /* Display selected, doesn't impact interaction. */
+ /** Filtered by the search string */
+ UI_FILTERED = (1 << 12),
/* warn: rest of uiBut->flag in UI_interface.h */
};
@@ -454,6 +456,8 @@ struct uiBlock {
*/
char display_device[64];
+ char *search_filter;
+
struct PieMenuData pie_data;
};
@@ -738,6 +742,7 @@ extern void ui_draw_aligned_panel(struct uiStyle *style,
const rcti *rect,
const bool show_pin,
const bool show_background);
+void ui_panel_set_search_filtered(struct Panel *panel, const bool value);
/* interface_draw.c */
extern void ui_draw_dropshadow(
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index 6aefef197df..92b1b21c207 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -140,6 +140,7 @@ enum {
* Enabled by default, depends on 'UI_ITEM_PROP_SEP'. */
UI_ITEM_PROP_DECORATE = 1 << 5,
UI_ITEM_PROP_DECORATE_NO_PAD = 1 << 6,
+ UI_ITEM_USE_SEARCH_FILTER = 1 << 7,
};
typedef struct uiButtonItem {
@@ -176,6 +177,8 @@ struct uiLayout {
char emboss;
/** for fixed width or height to avoid UI size changes */
float units[2];
+
+ bool property_search_layout_temp_debug;
};
typedef struct uiLayoutItemFlow {
@@ -4638,8 +4641,9 @@ static void ui_litem_init_from_parent(uiLayout *litem, uiLayout *layout, int ali
litem->redalert = layout->redalert;
litem->w = layout->w;
litem->emboss = layout->emboss;
- litem->item.flag = (layout->item.flag &
- (UI_ITEM_PROP_SEP | UI_ITEM_PROP_DECORATE | UI_ITEM_INSIDE_PROP_SEP));
+ /* Only pass certain flags to child layouts. */
+ litem->item.flag = (layout->item.flag & (UI_ITEM_PROP_SEP | UI_ITEM_PROP_DECORATE |
+ UI_ITEM_INSIDE_PROP_SEP | UI_ITEM_USE_SEARCH_FILTER));
if (layout->child_items_layout) {
BLI_addtail(&layout->child_items_layout->items, litem);
@@ -5343,8 +5347,7 @@ uiLayout *UI_block_layout(uiBlock *block,
layout = MEM_callocN(sizeof(uiLayout), "uiLayout");
layout->item.type = (type == UI_LAYOUT_VERT_BAR) ? ITEM_LAYOUT_COLUMN : ITEM_LAYOUT_ROOT;
- /* Only used when 'UI_ITEM_PROP_SEP' is set. */
- layout->item.flag = UI_ITEM_PROP_DECORATE;
+ layout->item.flag = UI_ITEM_PROP_DECORATE | UI_ITEM_USE_SEARCH_FILTER;
layout->x = x;
layout->y = y;
@@ -5451,12 +5454,234 @@ void uiLayoutSetFunc(uiLayout *layout, uiMenuHandleFunc handlefunc, void *argv)
layout->root->argv = argv;
}
-void UI_block_layout_resolve(uiBlock *block, int *r_x, int *r_y)
+static bool ui_layout_search_filter_clean(uiLayout *labels,
+ uiLayout *properties,
+ uiLayout *decorators,
+ uiLayout *layout)
{
- uiLayoutRoot *root;
+ // printf("UI_LAYOUT_SEARCH_FILTER_CLEAN\n");
+ BLI_assert(layout->item.type != ITEM_BUTTON);
+
+ bool empty = true;
+
+ if ((layout->item.flag & UI_ITEM_USE_SEARCH_FILTER) == 0) {
+ return false;
+ }
+
+ /* TODO: FIGURE OUT WHY THERE ARE STILL EMPTY LAYOUTS AFTER THIS FUNCTION RUNS ON A ROOT. */
+ /* Remove filtered button items. */
+ LISTBASE_FOREACH_MUTABLE (uiItem *, item, &layout->items) {
+ if (item->type == ITEM_BUTTON) {
+ uiButtonItem *button_item = (uiButtonItem *)item;
+
+ /* Free item and the button if it has been filtered. */
+ if (button_item->but->flag & UI_FILTERED) {
+ // ui_but_free(NULL, button_item->but);
+ button_item->but->flag |= UI_HIDDEN;
+ BLI_remlink(&layout->items, item);
+ MEM_freeN(item);
+ continue;
+ }
+ else {
+ empty = false;
+ }
+ }
+ else {
+ /* If this item isn't a button it may contain other items, so recursively search them. */
+ uiLayout *child_layout = (uiLayout *)item;
+ empty &= ui_layout_search_filter_clean(labels, properties, decorators, child_layout);
+
+ if (empty && !ELEM(child_layout, labels, properties, decorators)) {
+ BLI_remlink(&layout->items, item);
+ MEM_freeN(item);
+ continue;
+ }
+ }
+ }
+
+ if (empty) {
+ return true;
+ }
+
+ /* Move unfiltered items to the root layouts. */
+ LISTBASE_FOREACH (uiItem *, item, &layout->items) {
+ if (item->type == ITEM_BUTTON) {
+ uiButtonItem *button_item = (uiButtonItem *)item;
+
+ /* Move the item. */
+ BLI_remlink(&layout->items, item);
+ BLI_addtail(&properties->items, item);
+
+ /* Add a label if the text isn't contained in the button. */
+ if (button_item->but->rnaprop) {
+ if (ELEM(button_item->but->type,
+ UI_BTYPE_CHECKBOX,
+ UI_BTYPE_TOGGLE_N,
+ UI_BTYPE_ICON_TOGGLE_N,
+ UI_BTYPE_CHECKBOX_N,
+ UI_BTYPE_LABEL)) {
+ /* Toggle buttons with no outside label have their text changed to the RNA name. */
+ uiItemL(labels, "", ICON_NONE);
+ }
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list