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:
authorNathan Craddock <nzcraddock@gmail.com>2020-09-15 16:40:38 +0300
committerNathan Craddock <nzcraddock@gmail.com>2020-09-15 16:40:38 +0300
commit93b8040f57297133e7b90c8dfb05088490425cb2 (patch)
tree588f4095d1c3b04262351d8267dbc9a3de39dc4e /source/blender/editors/interface
parente17df47303e1fc85276124d447d2ea405e1f0465 (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/editors/interface')
-rw-r--r--source/blender/editors/interface/interface_layout.c21
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c2
2 files changed, 17 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c
index f00ce7ee923..7f631923054 100644
--- a/source/blender/editors/interface/interface_layout.c
+++ b/source/blender/editors/interface/interface_layout.c
@@ -1214,6 +1214,10 @@ static uiBut *uiItemFullO_ptr_ex(uiLayout *layout,
but->flag |= UI_SELECT_DRAW;
}
+ if (flag & UI_ITEM_R_ICON_ONLY) {
+ UI_but_drawflag_disable(but, UI_BUT_ICON_LEFT);
+ }
+
if (layout->redalert) {
UI_but_flag_enable(but, UI_BUT_REDALERT);
}
@@ -1501,7 +1505,14 @@ void uiItemsFullEnumO_items(uiLayout *layout,
}
RNA_property_enum_set(&tptr, prop, item->value);
- uiItemFullO_ptr(target, ot, item->name, item->icon, tptr.data, context, flag, NULL);
+ uiItemFullO_ptr(target,
+ ot,
+ (flag & UI_ITEM_R_ICON_ONLY) ? NULL : item->name,
+ item->icon,
+ tptr.data,
+ context,
+ flag,
+ NULL);
ui_but_tip_from_enum_item(block->buttons.last, item);
}
@@ -1509,7 +1520,7 @@ void uiItemsFullEnumO_items(uiLayout *layout,
if (item->name) {
uiBut *but;
- if (item != item_array && !radial && split) {
+ if (item != item_array && !radial && split != NULL) {
target = uiLayoutColumn(split, layout->align);
/* inconsistent, but menus with labels do not look good flipped */
@@ -1625,9 +1636,9 @@ void uiItemsFullEnumO(uiLayout *layout,
}
}
-void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname)
+void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname, int flag)
{
- uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, 0);
+ uiItemsFullEnumO(layout, opname, propname, NULL, layout->root->opcontext, flag);
}
/* for use in cases where we have */
@@ -3399,7 +3410,7 @@ static void menu_item_enum_opname_menu(bContext *UNUSED(C), uiLayout *layout, vo
MenuItemLevel *lvl = (MenuItemLevel *)(((uiBut *)arg)->func_argN);
uiLayoutSetOperatorContext(layout, lvl->opcontext);
- uiItemsEnumO(layout, lvl->opname, lvl->propname);
+ uiItemsEnumO(layout, lvl->opname, lvl->propname, false);
layout->root->block->flag |= UI_BLOCK_IS_FLIP;
diff --git a/source/blender/editors/interface/interface_region_menu_pie.c b/source/blender/editors/interface/interface_region_menu_pie.c
index 631f395390f..a3d8e0820b7 100644
--- a/source/blender/editors/interface/interface_region_menu_pie.c
+++ b/source/blender/editors/interface/interface_region_menu_pie.c
@@ -261,7 +261,7 @@ int UI_pie_menu_invoke_from_operator_enum(struct bContext *C,
layout = UI_pie_menu_layout(pie);
layout = uiLayoutRadial(layout);
- uiItemsEnumO(layout, opname, propname);
+ uiItemsEnumO(layout, opname, propname, false);
UI_pie_menu_end(C, pie);