UI: object context menu tweaks for consistency

Currently, the object context menu includes some inconsistencies
between object types. This is a small patch that fixes these.

- Adds the same ability to Join and Set Origin
  to all supported object types.
- Adds Set Active Camera for cameras.
- Adds Adjust Stroke Width for GP Objects.
- Adds Trace Image to Grease Pencil for Image Empties.

Reviewed By: #grease_pencil

Ref D10144
This commit is contained in:
William Reynish 2021-01-25 21:26:19 +11:00 committed by Campbell Barton
parent 7cb65a1e67
commit 5f2c5e5bb8
Notes: blender-bot 2023-02-13 11:53:31 +01:00
Referenced by commit a6f275cad3, Fix T88808: Set Origin missing from Text object in 2.93
1 changed files with 38 additions and 31 deletions

View File

@ -2383,28 +2383,16 @@ class VIEW3D_MT_object_context_menu(Menu):
'''
# If something is selected
if obj is not None and obj.type in {'MESH', 'CURVE', 'SURFACE'}:
layout.operator("object.shade_smooth", text="Shade Smooth")
layout.operator("object.shade_flat", text="Shade Flat")
layout.separator()
# Individual object types.
if obj is None:
pass
elif obj.type == 'MESH':
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
layout.operator_context = 'INVOKE_DEFAULT'
# If more than one object is selected
if selected_objects_len > 1:
layout.operator("object.join")
layout.separator()
elif obj.type == 'CAMERA':
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("view3d.object_as_camera", text="Set Active Camera")
if obj.data.type == 'PERSP':
props = layout.operator("wm.context_modal_mouse", text="Adjust Focal Length")
props.data_path_iter = "selected_editable_objects"
@ -2447,22 +2435,7 @@ class VIEW3D_MT_object_context_menu(Menu):
props.data_path_iter = "selected_editable_objects"
props.data_path_item = "data.offset"
props.input_scale = 0.01
props.header_text = "Width Size: %.3f"
layout.separator()
layout.operator("object.convert", text="Convert to Mesh").target = 'MESH'
layout.operator("object.convert", text="Convert to Grease Pencil").target = 'GPENCIL'
layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
layout.separator()
elif obj.type == 'GPENCIL':
layout.operator("gpencil.convert", text="Convert to Path").type = 'PATH'
layout.operator("gpencil.convert", text="Convert to Bezier Curve").type = 'CURVE'
layout.operator("gpencil.convert", text="Convert to Polygon Curve").type = 'POLY'
layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
props.header_text = "Offset: %.3f"
layout.separator()
@ -2477,6 +2450,11 @@ class VIEW3D_MT_object_context_menu(Menu):
layout.separator()
if obj.empty_display_type == 'IMAGE':
layout.operator("gpencil.trace_image")
layout.separator()
elif obj.type == 'LIGHT':
light = obj.data
@ -2534,6 +2512,35 @@ class VIEW3D_MT_object_context_menu(Menu):
layout.separator()
# Shared among some object types.
if obj is not None:
if obj.type in {'MESH', 'CURVE', 'SURFACE'}:
layout.operator("object.shade_smooth", text="Shade Smooth")
layout.operator("object.shade_flat", text="Shade Flat")
layout.separator()
if obj.type in {'MESH', 'CURVE', 'SURFACE', 'ARMATURE', 'GPENCIL'}:
if selected_objects_len > 1:
layout.operator("object.join")
if obj.type in {'MESH', 'CURVE', 'SURFACE', 'POINTCLOUD', 'META', 'FONT'}:
layout.operator_menu_enum("object.convert", "target")
if obj.type == 'GPENCIL':
layout.operator_menu_enum("gpencil.convert", "type", text="Convert To")
if (
obj.type in {'MESH', 'CURVE', 'SURFACE', 'GPENCIL', 'LATTICE', 'ARMATURE', 'META'} or
(obj.type == 'EMPTY' and obj.instance_collection is not None)
):
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator_menu_enum("object.origin_set", text="Set Origin", property="type")
layout.operator_context = 'INVOKE_DEFAULT'
layout.separator()
# Shared among all object types
layout.operator("view3d.copybuffer", text="Copy Objects", icon='COPYDOWN')
layout.operator("view3d.pastebuffer", text="Paste Objects", icon='PASTEDOWN')