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:
authorHans Goudey <h.goudey@me.com>2020-10-13 20:43:28 +0300
committerHans Goudey <h.goudey@me.com>2020-10-13 20:43:28 +0300
commit96dd299055a1ce35819480f3c4b938f8e6f91537 (patch)
treeb2a1149e4e9da41c967595f947314e33dd5ec6ea /source/blender/editors/interface/interface_layout.c
parent9fe581758851c98a8e43f0e8a02d70551352682d (diff)
UI: Add highlight arguments to tab buttons
This adds arguments to `uiLayout.prop_tabs_enum` and the C equivalent (`uiItemTabsEnumR_prop`) to gray out tabs based on a boolean array. For property search in multiple tabs, we need a way to show which tabs have a search result, but we still need to show which tab is active. Differential Revision: https://developer.blender.org/D8858
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r--source/blender/editors/interface/interface_layout.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index b13dd24ea4b..98b1c020d95 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -886,6 +886,8 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
uiBlock *block,
PointerRNA *ptr,
PropertyRNA *prop,
+ PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
const char *uiname,
const int h,
const bool icon_only)
@@ -894,9 +896,24 @@ static void ui_item_enum_expand_tabs(uiLayout *layout,
ui_item_enum_expand_exec(layout, block, ptr, prop, uiname, h, UI_BTYPE_TAB, icon_only);
BLI_assert(last != block->buttons.last);
+
for (uiBut *tab = last ? last->next : block->buttons.first; tab; tab = tab->next) {
UI_but_drawflag_enable(tab, ui_but_align_opposite_to_area_align_get(CTX_wm_region(C)));
}
+
+ const bool use_custom_highlight = (prop_highlight != NULL);
+
+ if (use_custom_highlight) {
+ const int highlight_array_len = RNA_property_array_length(ptr_highlight, prop_highlight);
+ bool *highlight_array = alloca(sizeof(bool) * highlight_array_len);
+ RNA_property_boolean_get_array(ptr_highlight, prop_highlight, highlight_array);
+ int i = 0;
+ for (uiBut *tab_but = last ? last->next : block->buttons.first;
+ (tab_but != NULL) && (i < highlight_array_len);
+ tab_but = tab_but->next, i++) {
+ SET_FLAG_FROM_TEST(tab_but->flag, !highlight_array[i], UI_BUT_INACTIVE);
+ }
+ }
}
/* callback for keymap item change button */
@@ -3474,13 +3491,19 @@ void uiItemMenuEnumR(
uiItemMenuEnumR_prop(layout, ptr, prop, name, icon);
}
-void uiItemTabsEnumR_prop(
- uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop, bool icon_only)
+void uiItemTabsEnumR_prop(uiLayout *layout,
+ bContext *C,
+ PointerRNA *ptr,
+ PropertyRNA *prop,
+ PointerRNA *ptr_highlight,
+ PropertyRNA *prop_highlight,
+ bool icon_only)
{
uiBlock *block = layout->root->block;
UI_block_layout_set_current(block, layout);
- ui_item_enum_expand_tabs(layout, C, block, ptr, prop, NULL, UI_UNIT_Y, icon_only);
+ ui_item_enum_expand_tabs(
+ layout, C, block, ptr, prop, ptr_highlight, prop_highlight, NULL, UI_UNIT_Y, icon_only);
}
/** \} */