diff options
author | Hans Goudey <h.goudey@me.com> | 2020-09-15 19:25:49 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-09-15 19:25:49 +0300 |
commit | 8bcdcab659fb688d976a50d892dcb4285ff2a180 (patch) | |
tree | d85178a6bda0ca80bc62ae6d85428d6f0ed12c5a /source/blender/editors/interface/interface.c | |
parent | 7a0a60dde8b4bf120ab7977e476bf5c82b2a63ad (diff) |
UI: Single tab property search
This adds a search bar to the properties editor. The full search for
every tab isn't included in this patch, but the interaction with
panels, searching behavior, UI, region level, and DNA changes are
included here.
The block-level search works by iterating over the block's button
groups and checking whether they match the search. If they do, they
are tagged with a flag, and the block's panel is tagged too. For
every update (text edit), the panel's expansion is set to whether
the panel has a result or not. The search also checks for matching
strings inside enums and in panel labels.
One complication to this that isn't immediately apparent is that
closed panel's subpanels have to be searched too. This adds some
complexity to the area-level panel layout code.
Possible Future Improvements:
- Use the new fuzzy search in BLI
- Reset panels to their expansion before the search started if
the user escape out of the text box.
- Open all child panels of a panel with expansion.
Differential Revision: https://developer.blender.org/D8856
Diffstat (limited to 'source/blender/editors/interface/interface.c')
-rw-r--r-- | source/blender/editors/interface/interface.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index b9a001a9571..5d20846c528 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -1995,8 +1995,12 @@ void UI_block_draw(const bContext *C, uiBlock *block) } } } - ui_draw_aligned_panel( - &style, block, &rect, UI_panel_category_is_visible(region), show_background); + ui_draw_aligned_panel(&style, + block, + &rect, + UI_panel_category_is_visible(region), + show_background, + region->flag & RGN_FLAG_SEARCH_FILTER_ACTIVE); } BLF_batch_draw_begin(); @@ -3541,6 +3545,25 @@ void UI_block_theme_style_set(uiBlock *block, char theme_style) block->theme_style = theme_style; } +bool UI_block_is_search_only(const uiBlock *block) +{ + return block->flag & UI_BLOCK_SEARCH_ONLY; +} + +/** + * Use when a block must be searched to give accurate results + * for the whole region but shouldn't be displayed. + */ +void UI_block_set_search_only(uiBlock *block, bool search_only) +{ + SET_FLAG_FROM_TEST(block->flag, search_only, UI_BLOCK_SEARCH_ONLY); +} + +void UI_block_set_search_filter(uiBlock *block, const char *search_filter) +{ + block->search_filter = search_filter; +} + static void ui_but_build_drawstr_float(uiBut *but, double value) { size_t slen = 0; |