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
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')
-rw-r--r--source/blender/editors/animation/keyframing.c2
-rw-r--r--source/blender/editors/animation/keyingsets.c2
-rw-r--r--source/blender/editors/curve/editcurve.c2
-rw-r--r--source/blender/editors/gpencil/gpencil_data.c2
-rw-r--r--source/blender/editors/include/UI_interface.h2
-rw-r--r--source/blender/editors/interface/interface_layout.c21
-rw-r--r--source/blender/editors/interface/interface_region_menu_pie.c2
-rw-r--r--source/blender/editors/space_info/info_ops.c2
-rw-r--r--source/blender/editors/space_outliner/outliner_tools.c2
-rw-r--r--source/blender/editors/transform/transform_ops.c2
-rw-r--r--source/blender/makesrna/intern/rna_ui_api.c12
11 files changed, 36 insertions, 15 deletions
diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c
index fb4c0ae0758..9104096119b 100644
--- a/source/blender/editors/animation/keyframing.c
+++ b/source/blender/editors/animation/keyframing.c
@@ -1968,7 +1968,7 @@ static int insert_key_menu_invoke(bContext *C, wmOperator *op, const wmEvent *UN
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, WM_operatortype_name(op->type, op->ptr), ICON_NONE);
layout = UI_popup_menu_layout(pup);
- uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type");
+ uiItemsEnumO(layout, "ANIM_OT_keyframe_insert_menu", "type", false);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c
index 876740b889a..558a7be1df8 100644
--- a/source/blender/editors/animation/keyingsets.c
+++ b/source/blender/editors/animation/keyingsets.c
@@ -479,7 +479,7 @@ static int keyingset_active_menu_invoke(bContext *C, wmOperator *op, const wmEve
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
- uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type");
+ uiItemsEnumO(layout, "ANIM_OT_keying_set_active_set", "type", false);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c
index e6815582a04..05b35fef86b 100644
--- a/source/blender/editors/curve/editcurve.c
+++ b/source/blender/editors/curve/editcurve.c
@@ -5940,7 +5940,7 @@ static int toggle_cyclic_invoke(bContext *C, wmOperator *op, const wmEvent *UNUS
if (nu->type == CU_NURBS) {
pup = UI_popup_menu_begin(C, IFACE_("Direction"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
- uiItemsEnumO(layout, op->type->idname, "direction");
+ uiItemsEnumO(layout, op->type->idname, "direction", false);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
}
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 6c003b85edd..f97ee81132f 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1403,7 +1403,7 @@ static int gpencil_layer_change_invoke(bContext *C, wmOperator *op, const wmEven
/* call the menu, which will call this operator again, hence the canceled */
pup = UI_popup_menu_begin(C, op->type->name, ICON_NONE);
layout = UI_popup_menu_layout(pup);
- uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer");
+ uiItemsEnumO(layout, "GPENCIL_OT_layer_change", "layer", false);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h
index d5d489b1742..47b8cb1ac3a 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -2212,7 +2212,7 @@ void uiItemEnumO_string(uiLayout *layout,
const char *opname,
const char *propname,
const char *value);
-void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname);
+void uiItemsEnumO(uiLayout *layout, const char *opname, const char *propname, int flag);
void uiItemBooleanO(uiLayout *layout,
const char *name,
int icon,
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);
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 30f36509b41..dda4d8a6c78 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -256,7 +256,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
layout = UI_popup_menu_layout(pup);
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
- uiItemsEnumO(layout, "FILE_OT_unpack_all", "method");
+ uiItemsEnumO(layout, "FILE_OT_unpack_all", "method", false);
UI_popup_menu_end(C, pup);
diff --git a/source/blender/editors/space_outliner/outliner_tools.c b/source/blender/editors/space_outliner/outliner_tools.c
index 0743e841794..99ef5132716 100644
--- a/source/blender/editors/space_outliner/outliner_tools.c
+++ b/source/blender/editors/space_outliner/outliner_tools.c
@@ -2658,7 +2658,7 @@ static int outliner_operator_menu(bContext *C, const char *opname)
/* set this so the default execution context is the same as submenus */
uiLayoutSetOperatorContext(layout, WM_OP_INVOKE_REGION_WIN);
- uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop));
+ uiItemsEnumO(layout, ot->idname, RNA_property_identifier(ot->prop), false);
uiItemS(layout);
diff --git a/source/blender/editors/transform/transform_ops.c b/source/blender/editors/transform/transform_ops.c
index d35c2f07482..2141d9ffdd6 100644
--- a/source/blender/editors/transform/transform_ops.c
+++ b/source/blender/editors/transform/transform_ops.c
@@ -187,7 +187,7 @@ static int select_orientation_invoke(bContext *C,
pup = UI_popup_menu_begin(C, IFACE_("Orientation"), ICON_NONE);
layout = UI_popup_menu_layout(pup);
- uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation");
+ uiItemsEnumO(layout, "TRANSFORM_OT_select_orientation", "orientation", false);
UI_popup_menu_end(C, pup);
return OPERATOR_INTERFACE;
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);