diff options
author | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-15 16:40:38 +0300 |
---|---|---|
committer | Nathan Craddock <nzcraddock@gmail.com> | 2020-09-15 16:40:38 +0300 |
commit | 93b8040f57297133e7b90c8dfb05088490425cb2 (patch) | |
tree | 588f4095d1c3b04262351d8267dbc9a3de39dc4e /source/blender/makesrna | |
parent | e17df47303e1fc85276124d447d2ea405e1f0465 (diff) |
UI: Add `icon_only` argument to operator_enum
Add an option to only draw icons for operator_enum menus. This is used
for drawing inline icon buttons in the outliner context menu for
collection color tagging.
Part of T77408
Differential Revision: https://developer.blender.org/D8880
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/intern/rna_ui_api.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/source/blender/makesrna/intern/rna_ui_api.c b/source/blender/makesrna/intern/rna_ui_api.c index 8dfa54b95da..76d76b0a913 100644 --- a/source/blender/makesrna/intern/rna_ui_api.c +++ b/source/blender/makesrna/intern/rna_ui_api.c @@ -346,6 +346,15 @@ static PointerRNA rna_uiItemOMenuHold(uiLayout *layout, return opptr; } +static void rna_uiItemsEnumO(uiLayout *layout, + const char *opname, + const char *propname, + const bool icon_only) +{ + int flag = icon_only ? UI_ITEM_R_ICON_ONLY : 0; + uiItemsFullEnumO(layout, opname, propname, NULL, uiLayoutGetOperatorContext(layout), flag); +} + static void rna_uiItemMenuEnumO(uiLayout *layout, bContext *C, const char *opname, @@ -972,11 +981,12 @@ void RNA_api_ui_layout(StructRNA *srna) "Item. Places a button into the layout to call an Operator"); } - func = RNA_def_function(srna, "operator_enum", "uiItemsEnumO"); + func = RNA_def_function(srna, "operator_enum", "rna_uiItemsEnumO"); parm = RNA_def_string(func, "operator", NULL, 0, "", "Identifier of the operator"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); parm = RNA_def_string(func, "property", NULL, 0, "", "Identifier of property in operator"); RNA_def_parameter_flags(parm, 0, PARM_REQUIRED); + RNA_def_boolean(func, "icon_only", false, "", "Draw only icons in buttons, no text"); func = RNA_def_function(srna, "operator_menu_enum", "rna_uiItemMenuEnumO"); RNA_def_function_flag(func, FUNC_USE_CONTEXT); |