[Bf-blender-cvs] [5f2c5e5bb8c] master: UI: object context menu tweaks for consistency

William Reynish noreply at git.blender.org
Mon Jan 25 11:29:02 CET 2021


Commit: 5f2c5e5bb8c15bf0d6679351e3482f9c38c00935
Author: William Reynish
Date:   Mon Jan 25 21:26:19 2021 +1100
Branches: master
https://developer.blender.org/rB5f2c5e5bb8c15bf0d6679351e3482f9c38c00935

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

===================================================================

M	release/scripts/startup/bl_ui/space_view3d.py

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index ffac19230b5..e653ead21bb 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -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')



More information about the Bf-blender-cvs mailing list