[Bf-extensions-cvs] [6757a2a] master: fix context: no objects, T48181 cleanup

meta-androcto noreply at git.blender.org
Sun Apr 24 18:24:40 CEST 2016


Commit: 6757a2a54e168e079af4ff2fd2dddadd51899869
Author: meta-androcto
Date:   Mon Apr 25 02:24:21 2016 +1000
Branches: master
https://developer.blender.org/rBA6757a2a54e168e079af4ff2fd2dddadd51899869

fix context: no objects, T48181 cleanup

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

M	space_view3d_spacebar_menu.py

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

diff --git a/space_view3d_spacebar_menu.py b/space_view3d_spacebar_menu.py
index a72ee94..74ec597 100644
--- a/space_view3d_spacebar_menu.py
+++ b/space_view3d_spacebar_menu.py
@@ -47,8 +47,25 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
         scene = context.scene
         obj = context.object
 
+### No Object Selected ###
+        if not context.active_object:
+            layout.operator_context = 'INVOKE_REGION_WIN'
+            layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
+            layout.separator()
+            layout.menu("VIEW3D_MT_AddMenu", icon='OBJECT_DATAMODE')
+            layout.menu("VIEW3D_MT_View_Directions", icon='ZOOM_ALL')
+            layout.menu("VIEW3D_MT_View_Navigation", icon='ROTATE')
+            layout.menu("VIEW3D_MT_View_Toggle", icon='SPLITSCREEN')
+            layout.operator("view3d.snap_cursor_to_center",
+                            text="Cursor to Center")
+            layout.operator("view3d.snap_cursor_to_grid",
+                            text="Cursor to Grid")
+            layout.menu("VIEW3D_MT_UndoS", icon='ARROW_LEFTRIGHT')
+            layout.operator("view3d.toolshelf", icon='MENU_PANEL')
+            layout.operator("view3d.properties", icon='MENU_PANEL')
+
 ### Mesh Object Mode ###
-        if obj.type == 'MESH' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'OBJECT'}:
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -71,7 +88,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Mesh Edit Mode ##
-        if obj.type == 'MESH' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'EDIT'}:
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
             layout.menu("VIEW3D_MT_View_Menu", icon='ZOOM_ALL')
@@ -92,7 +109,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Sculpt Mode ##
-        if obj.type == 'MESH' and obj.mode in {'SCULPT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'SCULPT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -109,7 +126,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Vertex Paint ##
-        if obj.type == 'MESH' and obj.mode in {'VERTEX_PAINT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'VERTEX_PAINT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -123,7 +140,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Weight Paint Menu ##
-        if obj.type == 'MESH' and obj.mode in {'WEIGHT_PAINT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'WEIGHT_PAINT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -136,7 +153,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Texture Paint ##
-        if obj.type == 'MESH' and obj.mode in {'TEXTURE_PAINT'}:
+        if context.object is not None and obj.type == 'MESH' and obj.mode in {'TEXTURE_PAINT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -148,7 +165,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Curve Object Mode ###
-        if obj.type == 'CURVE' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'CURVE' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -173,7 +190,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Edit Curve ##
-        if obj.type == 'CURVE' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'CURVE' and obj.mode in {'EDIT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -199,7 +216,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Surface Object Mode ###
-        if obj.type == 'SURFACE' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'SURFACE' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -224,7 +241,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Edit Surface ##
-        if obj.type == 'SURFACE' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'SURFACE' and obj.mode in {'EDIT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -249,7 +266,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Metaball Object Mode ###
-        if obj.type == 'META' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'META' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -274,7 +291,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Edit Metaball ##
-        if obj.type == 'META' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'META' and obj.mode in {'EDIT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -298,7 +315,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Text Object Mode ###
-        if obj.type == 'FONT' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'FONT' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -322,7 +339,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Text Edit Mode ###
-        if obj.type == 'FONT' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'FONT' and obj.mode in {'EDIT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -337,7 +354,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Camera Object Mode ###
-        if obj.type == 'CAMERA' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'CAMERA' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -358,7 +375,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Lamp Object Mode ###
-        if obj.type == 'LAMP' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'LAMP' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -379,7 +396,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Armature Object Mode ###
-        if obj.type == 'ARMATURE' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'ARMATURE' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -402,7 +419,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Armature Edit ##
-        if obj.type == 'ARMATURE' and obj.mode in {'EDIT'}:
+        if context.object is not None and obj.type == 'ARMATURE' and obj.mode in {'EDIT'}:
 
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
             layout.separator()
@@ -430,7 +447,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Armature Pose ##
-        if obj.type == 'ARMATURE' and obj.mode in {'POSE'}:
+        if context.object is not None and obj.type == 'ARMATURE' and obj.mode in {'POSE'}:
 
             arm = context.active_object.data
 
@@ -459,7 +476,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ### Lattice Object Mode ###
-        if obj.type == 'LATTICE' and obj.mode in {'OBJECT'}:
+        if context.object is not None and obj.type == 'LATTICE' and obj.mode in {'OBJECT'}:
 
             layout.operator_context = 'INVOKE_REGION_WIN'
             layout.operator("wm.search_menu", text="Search", icon='VIEWZOOM')
@@ -484,7 +501,7 @@ class VIEW3D_MT_Space_Dynamic_Menu(bpy.types.Menu):
             layout.operator("view3d.properties", icon='MENU_PANEL')
 
 ## Edit Lattice ##
-        if obj.typ

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list