From f22ea2e0ae5ec7a7c355cb9bbf3b803ae1d6a9f3 Mon Sep 17 00:00:00 2001 From: Guillermo Venegas Date: Thu, 10 Jul 2025 07:57:21 +0200 Subject: [PATCH] Refactor: UI: Remove uiItemEnumO* functions Similar to other removed UI layout functions, this removes uiItemEnumO* functions and replaces them by calling `uiLayout::op` and writing enum properties to the returned RNA pointer. Part of: #117604 Pull Request: https://projects.blender.org/blender/blender/pulls/141632 --- .../editors/armature/armature_relations.cc | 20 ++- .../editors/include/UI_interface_layout.hh | 27 ---- .../editors/interface/interface_layout.cc | 129 ------------------ .../interface_template_color_picker.cc | 12 +- .../editors/object/object_relations.cc | 43 +++--- .../blender/editors/space_node/node_group.cc | 6 +- source/blender/editors/space_text/text_ops.cc | 53 +++---- source/blender/editors/util/ed_util.cc | 7 - .../intern/MOD_grease_pencil_dash.cc | 13 +- .../intern/MOD_grease_pencil_time.cc | 13 +- source/blender/nodes/NOD_socket_items_ui.hh | 8 +- 11 files changed, 76 insertions(+), 255 deletions(-) diff --git a/source/blender/editors/armature/armature_relations.cc b/source/blender/editors/armature/armature_relations.cc index 80906fc2a81..5a3b534eee2 100644 --- a/source/blender/editors/armature/armature_relations.cc +++ b/source/blender/editors/armature/armature_relations.cc @@ -1015,13 +1015,13 @@ static wmOperatorStatus armature_parent_set_invoke(bContext *C, uiLayout *row_offset = &layout->row(false); row_offset->enabled_set(enable_offset); - uiItemEnumO( - row_offset, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_OFFSET); + PointerRNA op_ptr = row_offset->op("ARMATURE_OT_parent_set", IFACE_("Keep Offset"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", ARM_PAR_OFFSET); uiLayout *row_connect = &layout->row(false); row_connect->enabled_set(enable_connect); - uiItemEnumO( - row_connect, "ARMATURE_OT_parent_set", std::nullopt, ICON_NONE, "type", ARM_PAR_CONNECT); + op_ptr = row_connect->op("ARMATURE_OT_parent_set", IFACE_("Connected"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", ARM_PAR_CONNECT); UI_popup_menu_end(C, pup); @@ -1135,17 +1135,13 @@ static wmOperatorStatus armature_parent_clear_invoke(bContext *C, uiLayout *row_clear = &layout->row(false); row_clear->enabled_set(enable_clear); - uiItemEnumO( - row_clear, "ARMATURE_OT_parent_clear", std::nullopt, ICON_NONE, "type", ARM_PAR_CLEAR); + PointerRNA op_ptr = row_clear->op("ARMATURE_OT_parent_clear", IFACE_("Clear Parent"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", ARM_PAR_CLEAR); uiLayout *row_disconnect = &layout->row(false); row_disconnect->enabled_set(enable_disconnect); - uiItemEnumO(row_disconnect, - "ARMATURE_OT_parent_clear", - std::nullopt, - ICON_NONE, - "type", - ARM_PAR_CLEAR_DISCONNECT); + op_ptr = row_clear->op("ARMATURE_OT_parent_clear", IFACE_("Disconnect Bone"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", ARM_PAR_CLEAR_DISCONNECT); UI_popup_menu_end(C, pup); diff --git a/source/blender/editors/include/UI_interface_layout.hh b/source/blender/editors/include/UI_interface_layout.hh index 25c74b69630..84d0672a4eb 100644 --- a/source/blender/editors/include/UI_interface_layout.hh +++ b/source/blender/editors/include/UI_interface_layout.hh @@ -839,33 +839,6 @@ bool uiLayoutEndsWithPanelHeader(const uiLayout &layout); /* items */ -void uiItemEnumO_ptr(uiLayout *layout, - wmOperatorType *ot, - std::optional name, - int icon, - blender::StringRefNull propname, - int value); -void uiItemEnumO(uiLayout *layout, - blender::StringRefNull opname, - std::optional name, - int icon, - blender::StringRefNull propname, - int value); -/** - * For use in cases where we have. - */ -void uiItemEnumO_value(uiLayout *layout, - blender::StringRefNull name, - int icon, - blender::StringRefNull opname, - blender::StringRefNull propname, - int value); -void uiItemEnumO_string(uiLayout *layout, - blender::StringRef name, - int icon, - blender::StringRefNull opname, - blender::StringRefNull propname, - const char *value_str); void uiItemsEnumO(uiLayout *layout, blender::StringRefNull opname, blender::StringRefNull propname); diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 3ca67c92759..7d90613d3ff 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -1393,69 +1393,6 @@ PointerRNA uiLayout::op(const blender::StringRefNull opname, return this->op(ot, name, icon, context, flag); } -static StringRef ui_menu_enumpropname(uiLayout *layout, - PointerRNA *ptr, - PropertyRNA *prop, - int retval) -{ - bool free; - const EnumPropertyItem *item; - RNA_property_enum_items( - static_cast(layout->block()->evil_C), ptr, prop, &item, nullptr, &free); - - const char *name; - if (RNA_enum_name(item, retval, &name)) { - name = CTX_IFACE_(RNA_property_translation_context(prop), name); - } - else { - name = ""; - } - - if (free) { - MEM_freeN(item); - } - - return name; -} - -void uiItemEnumO_ptr(uiLayout *layout, - wmOperatorType *ot, - std::optional name, - int icon, - const StringRefNull propname, - int value) -{ - PointerRNA ptr; - WM_operator_properties_create_ptr(&ptr, ot); - - PropertyRNA *prop = RNA_struct_find_property(&ptr, propname.c_str()); - if (prop == nullptr) { - RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname.c_str()); - return; - } - name = name.value_or(ui_menu_enumpropname(layout, &ptr, prop, value)); - - ptr = layout->op(ot, name, icon, layout->root_->opcontext, UI_ITEM_NONE); - RNA_property_enum_set(&ptr, prop, value); -} -void uiItemEnumO(uiLayout *layout, - const StringRefNull opname, - const std::optional name, - int icon, - const StringRefNull propname, - int value) -{ - wmOperatorType *ot = WM_operatortype_find(opname.c_str(), false); /* print error next */ - - if (ot) { - uiItemEnumO_ptr(layout, ot, name, icon, propname, value); - } - else { - ui_item_disabled(layout, opname.c_str()); - RNA_warning("unknown operator '%s'", opname.c_str()); - } -} - BLI_INLINE bool ui_layout_is_radial(const uiLayout *layout) { return (layout->type_ == uiItemType::LayoutRadial) || @@ -1679,72 +1616,6 @@ void uiItemsEnumO(uiLayout *layout, const StringRefNull opname, const StringRefN uiItemsFullEnumO(layout, opname, propname, nullptr, layout->root_->opcontext, UI_ITEM_NONE); } -void uiItemEnumO_value(uiLayout *layout, - const StringRefNull name, - int icon, - const StringRefNull opname, - const StringRefNull propname, - int value) -{ - wmOperatorType *ot = WM_operatortype_find(opname.c_str(), false); /* print error next */ - UI_OPERATOR_ERROR_RET(ot, opname.c_str(), return); - - PointerRNA ptr; - WM_operator_properties_create_ptr(&ptr, ot); - - /* enum lookup */ - PropertyRNA *prop = RNA_struct_find_property(&ptr, propname.c_str()); - if (prop == nullptr) { - RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname.c_str()); - return; - } - ptr = layout->op(ot, name, icon, layout->root_->opcontext, UI_ITEM_NONE); - RNA_property_enum_set(&ptr, prop, value); -} - -void uiItemEnumO_string(uiLayout *layout, - const StringRef name, - int icon, - const StringRefNull opname, - const StringRefNull propname, - const char *value_str) -{ - wmOperatorType *ot = WM_operatortype_find(opname.c_str(), false); /* print error next */ - UI_OPERATOR_ERROR_RET(ot, opname.c_str(), return); - - PointerRNA ptr; - WM_operator_properties_create_ptr(&ptr, ot); - - PropertyRNA *prop = RNA_struct_find_property(&ptr, propname.c_str()); - if (prop == nullptr) { - RNA_warning("%s.%s not found", RNA_struct_identifier(ptr.type), propname.c_str()); - return; - } - - /* enum lookup */ - /* no need for translations here */ - const EnumPropertyItem *item; - bool free; - RNA_property_enum_items( - static_cast(layout->block()->evil_C), &ptr, prop, &item, nullptr, &free); - - int value; - if (item == nullptr || RNA_enum_value_from_id(item, value_str, &value) == 0) { - if (free) { - MEM_freeN(item); - } - RNA_warning( - "%s.%s, enum %s not found", RNA_struct_identifier(ptr.type), propname.c_str(), value_str); - return; - } - - if (free) { - MEM_freeN(item); - } - ptr = layout->op(ot, name, icon, layout->root_->opcontext, UI_ITEM_NONE); - RNA_property_enum_set(&ptr, prop, value); -} - PointerRNA uiLayout::op(wmOperatorType *ot, const std::optional name, int icon) { return this->op(ot, name, icon, root_->opcontext, UI_ITEM_NONE); diff --git a/source/blender/editors/interface/templates/interface_template_color_picker.cc b/source/blender/editors/interface/templates/interface_template_color_picker.cc index 4b18d7c4249..bc6329853e2 100644 --- a/source/blender/editors/interface/templates/interface_template_color_picker.cc +++ b/source/blender/editors/interface/templates/interface_template_color_picker.cc @@ -221,13 +221,17 @@ static void ui_template_palette_menu(bContext * /*C*/, uiLayout *layout, void * layout->label(IFACE_("Sort By:"), ICON_NONE); row = &layout->row(false); - uiItemEnumO_value(row, IFACE_("Hue"), ICON_NONE, "PALETTE_OT_sort", "type", 1); + PointerRNA op_ptr = row->op("PALETTE_OT_sort", IFACE_("Hue"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", 1); row = &layout->row(false); - uiItemEnumO_value(row, IFACE_("Saturation"), ICON_NONE, "PALETTE_OT_sort", "type", 2); + op_ptr = row->op("PALETTE_OT_sort", IFACE_("Saturation"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", 2); row = &layout->row(false); - uiItemEnumO_value(row, IFACE_("Value"), ICON_NONE, "PALETTE_OT_sort", "type", 3); + op_ptr = row->op("PALETTE_OT_sort", IFACE_("Value"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", 3); row = &layout->row(false); - uiItemEnumO_value(row, IFACE_("Luminance"), ICON_NONE, "PALETTE_OT_sort", "type", 4); + op_ptr = row->op("PALETTE_OT_sort", IFACE_("Luminance"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", 4); } void uiTemplatePalette(uiLayout *layout, diff --git a/source/blender/editors/object/object_relations.cc b/source/blender/editors/object/object_relations.cc index ece7452e6a2..eb1bcc26cb7 100644 --- a/source/blender/editors/object/object_relations.cc +++ b/source/blender/editors/object/object_relations.cc @@ -950,11 +950,7 @@ static wmOperatorStatus parent_set_invoke_menu(bContext *C, wmOperatorType *ot) uiPopupMenu *pup = UI_popup_menu_begin(C, IFACE_("Set Parent To"), ICON_NONE); uiLayout *layout = UI_popup_menu_layout(pup); - PointerRNA opptr; -#if 0 - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_OBJECT); -#else - opptr = layout->op(ot, IFACE_("Object"), ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); + PointerRNA opptr = layout->op(ot, IFACE_("Object"), ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", false); @@ -962,7 +958,6 @@ static wmOperatorStatus parent_set_invoke_menu(bContext *C, wmOperatorType *ot) ot, IFACE_("Object (Keep Transform)"), ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&opptr, "type", PAR_OBJECT); RNA_boolean_set(&opptr, "keep_transform", true); -#endif PointerRNA op_ptr = layout->op( "OBJECT_OT_parent_no_inverse_set", IFACE_("Object (Without Inverse)"), ICON_NONE); @@ -1007,27 +1002,37 @@ static wmOperatorStatus parent_set_invoke_menu(bContext *C, wmOperatorType *ot) if (parent->type == OB_ARMATURE) { if (can_support.armature_deform) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_ARMATURE); + op_ptr = layout->op(ot, IFACE_("Armature Deform"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_ARMATURE); } if (can_support.empty_groups) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_ARMATURE_NAME); + op_ptr = layout->op(ot, IFACE_(" With Empty Groups"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_ARMATURE_NAME); } if (can_support.envelope_weights) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_ARMATURE_ENVELOPE); + op_ptr = layout->op(ot, IFACE_(" With Envelope Weights"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_ARMATURE_ENVELOPE); } if (can_support.automatic_weights) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_ARMATURE_AUTO); + op_ptr = layout->op(ot, IFACE_(" With Automatic Weights"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_ARMATURE_AUTO); } - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_BONE); - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_BONE_RELATIVE); + op_ptr = layout->op(ot, IFACE_("Bone"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_BONE); + op_ptr = layout->op(ot, IFACE_("Bone Relative"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_BONE_RELATIVE); } else if (parent->type == OB_CURVES_LEGACY) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_CURVE); - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_FOLLOW); - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_PATH_CONST); + op_ptr = layout->op(ot, IFACE_("Curve Deform"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_CURVE); + op_ptr = layout->op(ot, IFACE_("Follow Path"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_FOLLOW); + op_ptr = layout->op(ot, IFACE_("Path Constraint"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_PATH_CONST); } else if (parent->type == OB_LATTICE) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_LATTICE); + op_ptr = layout->op(ot, IFACE_("Lattice Deform"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_LATTICE); } else if (parent->type == OB_MESH) { if (can_support.attach_surface) { @@ -1037,8 +1042,10 @@ static wmOperatorStatus parent_set_invoke_menu(bContext *C, wmOperatorType *ot) /* vertex parenting */ if (OB_TYPE_SUPPORT_PARVERT(parent->type)) { - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_VERTEX); - uiItemEnumO_ptr(layout, ot, std::nullopt, ICON_NONE, "type", PAR_VERTEX_TRI); + op_ptr = layout->op(ot, IFACE_("Vertex"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_VERTEX); + op_ptr = layout->op(ot, IFACE_("Vertex (Triangle)"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", PAR_VERTEX_TRI); } UI_popup_menu_end(C, pup); diff --git a/source/blender/editors/space_node/node_group.cc b/source/blender/editors/space_node/node_group.cc index 46d8d47c487..b60be9272e8 100644 --- a/source/blender/editors/space_node/node_group.cc +++ b/source/blender/editors/space_node/node_group.cc @@ -681,8 +681,10 @@ static wmOperatorStatus node_group_separate_invoke(bContext *C, uiLayout *layout = UI_popup_menu_layout(pup); layout->operator_context_set(WM_OP_EXEC_DEFAULT); - uiItemEnumO(layout, "NODE_OT_group_separate", std::nullopt, ICON_NONE, "type", NODE_GS_COPY); - uiItemEnumO(layout, "NODE_OT_group_separate", std::nullopt, ICON_NONE, "type", NODE_GS_MOVE); + PointerRNA op_ptr = layout->op("NODE_OT_group_separate", IFACE_("Copy"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", NODE_GS_COPY); + op_ptr = layout->op("NODE_OT_group_separate", IFACE_("Move"), ICON_NONE); + RNA_enum_set(&op_ptr, "type", NODE_GS_MOVE); UI_popup_menu_end(C, pup); diff --git a/source/blender/editors/space_text/text_ops.cc b/source/blender/editors/space_text/text_ops.cc index 0c83002b212..0b6d2a328a9 100644 --- a/source/blender/editors/space_text/text_ops.cc +++ b/source/blender/editors/space_text/text_ops.cc @@ -4183,53 +4183,34 @@ static wmOperatorStatus text_resolve_conflict_invoke(bContext *C, pup = UI_popup_menu_begin( C, IFACE_("File Modified Outside and Inside Blender"), ICON_NONE); layout = UI_popup_menu_layout(pup); - uiItemEnumO_ptr(layout, - op->type, - IFACE_("Reload from disk (ignore local changes)"), - ICON_NONE, - "resolution", - RESOLVE_RELOAD); - uiItemEnumO_ptr(layout, - op->type, - IFACE_("Save to disk (ignore outside changes)"), - ICON_NONE, - "resolution", - RESOLVE_SAVE); - uiItemEnumO_ptr(layout, - op->type, - IFACE_("Make text internal (separate copy)"), - ICON_NONE, - "resolution", - RESOLVE_MAKE_INTERNAL); + PointerRNA op_ptr = layout->op( + op->type, IFACE_("Reload from disk (ignore local changes)"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_RELOAD); + op_ptr = layout->op(op->type, IFACE_("Save to disk (ignore outside changes)"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_SAVE); + op_ptr = layout->op(op->type, IFACE_("Make text internal (separate copy)"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_MAKE_INTERNAL); UI_popup_menu_end(C, pup); } else { pup = UI_popup_menu_begin(C, IFACE_("File Modified Outside Blender"), ICON_NONE); layout = UI_popup_menu_layout(pup); - uiItemEnumO_ptr( - layout, op->type, IFACE_("Reload from disk"), ICON_NONE, "resolution", RESOLVE_RELOAD); - uiItemEnumO_ptr(layout, - op->type, - IFACE_("Make text internal (separate copy)"), - ICON_NONE, - "resolution", - RESOLVE_MAKE_INTERNAL); - uiItemEnumO_ptr( - layout, op->type, IFACE_("Ignore"), ICON_NONE, "resolution", RESOLVE_IGNORE); + PointerRNA op_ptr = layout->op(op->type, IFACE_("Reload from disk"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_RELOAD); + op_ptr = layout->op(op->type, IFACE_("Make text internal (separate copy)"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_MAKE_INTERNAL); + op_ptr = layout->op(op->type, IFACE_("Ignore"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_IGNORE); UI_popup_menu_end(C, pup); } break; case 2: pup = UI_popup_menu_begin(C, IFACE_("File Deleted Outside Blender"), ICON_NONE); layout = UI_popup_menu_layout(pup); - uiItemEnumO_ptr(layout, - op->type, - IFACE_("Make text internal"), - ICON_NONE, - "resolution", - RESOLVE_MAKE_INTERNAL); - uiItemEnumO_ptr( - layout, op->type, IFACE_("Recreate file"), ICON_NONE, "resolution", RESOLVE_SAVE); + PointerRNA op_ptr = layout->op(op->type, IFACE_("Make text internal"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_MAKE_INTERNAL); + op_ptr = layout->op(op->type, IFACE_("Recreate file"), ICON_NONE); + RNA_enum_set(&op_ptr, "resolution", RESOLVE_SAVE); UI_popup_menu_end(C, pup); break; } diff --git a/source/blender/editors/util/ed_util.cc b/source/blender/editors/util/ed_util.cc index ec2de5de8f5..ff8bcf9fcbc 100644 --- a/source/blender/editors/util/ed_util.cc +++ b/source/blender/editors/util/ed_util.cc @@ -392,7 +392,6 @@ void unpack_menu(bContext *C, break; case PF_CMP_EQUAL: SNPRINTF(line, IFACE_("Use %s (identical)"), local_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_USE_LOCAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -400,13 +399,11 @@ void unpack_menu(bContext *C, break; case PF_CMP_DIFFERS: SNPRINTF(line, IFACE_("Use %s (differs)"), local_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_USE_LOCAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); SNPRINTF(line, IFACE_("Overwrite %s"), local_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_WRITE_LOCAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); @@ -418,27 +415,23 @@ void unpack_menu(bContext *C, switch (BKE_packedfile_compare_to_file(blendfile_path, abs_name, pf)) { case PF_CMP_NOFILE: SNPRINTF(line, IFACE_("Create %s"), abs_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_WRITE_ORIGINAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_CMP_EQUAL: SNPRINTF(line, IFACE_("Use %s (identical)"), abs_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_USE_ORIGINAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_CMP_DIFFERS: SNPRINTF(line, IFACE_("Use %s (differs)"), abs_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_USE_ORIGINAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); SNPRINTF(line, IFACE_("Overwrite %s"), abs_name); - // uiItemEnumO_ptr(layout, ot, line, ICON_NONE, "method", PF_WRITE_ORIGINAL); props_ptr = layout->op(ot, line, ICON_NONE, WM_OP_EXEC_DEFAULT, UI_ITEM_NONE); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc b/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc index 17804956535..71148c66665 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_dash.cc @@ -424,14 +424,11 @@ static void panel_draw(const bContext *C, Panel *panel) sub->op("OBJECT_OT_grease_pencil_dash_modifier_segment_remove", "", ICON_REMOVE); col->separator(); sub = &col->column(true); - uiItemEnumO_string( - sub, "", ICON_TRIA_UP, "OBJECT_OT_grease_pencil_dash_modifier_segment_move", "type", "UP"); - uiItemEnumO_string(sub, - "", - ICON_TRIA_DOWN, - "OBJECT_OT_grease_pencil_dash_modifier_segment_move", - "type", - "DOWN"); + PointerRNA op_ptr = layout->op( + "OBJECT_OT_grease_pencil_dash_modifier_segment_move", "", ICON_TRIA_UP); + RNA_enum_set(&op_ptr, "type", /* blender::ed::object::DashSegmentMoveDirection::Up */ -1); + op_ptr = layout->op("OBJECT_OT_grease_pencil_dash_modifier_segment_move", "", ICON_TRIA_DOWN); + RNA_enum_set(&op_ptr, "type", /* blender::ed::object::DashSegmentMoveDirection::Down */ 1); if (dmd->segment_active_index >= 0 && dmd->segment_active_index < dmd->segments_num) { PointerRNA ds_ptr = RNA_pointer_create_discrete(ptr->owner_id, diff --git a/source/blender/modifiers/intern/MOD_grease_pencil_time.cc b/source/blender/modifiers/intern/MOD_grease_pencil_time.cc index 5d295883d9a..5c76b17e3ba 100644 --- a/source/blender/modifiers/intern/MOD_grease_pencil_time.cc +++ b/source/blender/modifiers/intern/MOD_grease_pencil_time.cc @@ -571,14 +571,11 @@ static void panel_draw(const bContext *C, Panel *panel) sub->op("OBJECT_OT_grease_pencil_time_modifier_segment_remove", "", ICON_REMOVE); col->separator(); sub = &col->column(true); - uiItemEnumO_string( - sub, "", ICON_TRIA_UP, "OBJECT_OT_grease_pencil_time_modifier_segment_move", "type", "UP"); - uiItemEnumO_string(sub, - "", - ICON_TRIA_DOWN, - "OBJECT_OT_grease_pencil_time_modifier_segment_move", - "type", - "DOWN"); + PointerRNA op_ptr = layout->op( + "OBJECT_OT_grease_pencil_dash_modifier_segment_move", "", ICON_TRIA_UP); + RNA_enum_set(&op_ptr, "type", /* blender::ed::object::DashSegmentMoveDirection::Up */ -1); + op_ptr = layout->op("OBJECT_OT_grease_pencil_dash_modifier_segment_move", "", ICON_TRIA_DOWN); + RNA_enum_set(&op_ptr, "type", /* blender::ed::object::DashSegmentMoveDirection::Down */ 1); if (tmd->segments().index_range().contains(tmd->segment_active_index)) { PointerRNA segment_ptr = RNA_pointer_create_discrete( diff --git a/source/blender/nodes/NOD_socket_items_ui.hh b/source/blender/nodes/NOD_socket_items_ui.hh index 02a190654b9..76fdbfd5313 100644 --- a/source/blender/nodes/NOD_socket_items_ui.hh +++ b/source/blender/nodes/NOD_socket_items_ui.hh @@ -90,10 +90,10 @@ static void draw_items_list_with_operators(const bContext *C, } { uiLayout *up_down_col = &ops_col->column(true); - uiItemEnumO( - up_down_col, Accessor::operator_idnames::move_item, "", ICON_TRIA_UP, "direction", 0); - uiItemEnumO( - up_down_col, Accessor::operator_idnames::move_item, "", ICON_TRIA_DOWN, "direction", 1); + PointerRNA op_ptr = up_down_col->op(Accessor::operator_idnames::move_item, "", ICON_TRIA_UP); + RNA_enum_set(&op_ptr, "direction", 0); + op_ptr = up_down_col->op(Accessor::operator_idnames::move_item, "", ICON_TRIA_DOWN); + RNA_enum_set(&op_ptr, "direction", 1); } }