UI: allow to extend camera as a menu
authorCampbell Barton <ideasman42@gmail.com>
Thu, 23 Mar 2017 09:42:44 +0000 (20:42 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 23 Mar 2017 09:45:02 +0000 (20:45 +1100)
Needed for T46853

release/scripts/modules/bpy_types.py
release/scripts/startup/bl_ui/space_view3d.py

index 5eb8b9465682a79cc306ff97c6ee4fe3266bb6bb..600b29a6b2bef80a925d557ce6e1389a8ead4e0a 100644 (file)
@@ -682,6 +682,10 @@ class _GenericUI:
 
         return draw_funcs
 
+    @classmethod
+    def is_extended(cls):
+        return bool(getattr(cls.draw, "_draw_funcs", None))
+
     @classmethod
     def append(cls, draw_func):
         """
index b718228e7b2c830d2c9f3858fd5b2c91b0bdc5fe..e17d237b06052e79297aa097e2a574eccb75834b 100644 (file)
@@ -1206,6 +1206,16 @@ class INFO_MT_lamp_add(Menu):
         layout.operator_enum("object.lamp_add", "type")
 
 
+class INFO_MT_camera_add(Menu):
+    bl_idname = "INFO_MT_camera_add"
+    bl_label = "Camera"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.operator_context = 'EXEC_REGION_WIN'
+        layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
+
+
 class INFO_MT_add(Menu):
     bl_label = "Add"
 
@@ -1237,7 +1247,11 @@ class INFO_MT_add(Menu):
         layout.operator("object.speaker_add", text="Speaker", icon='OUTLINER_OB_SPEAKER')
         layout.separator()
 
-        layout.operator("object.camera_add", text="Camera", icon='OUTLINER_OB_CAMERA')
+        if INFO_MT_camera_add.is_extended():
+            layout.menu("INFO_MT_camera_add", icon='OUTLINER_OB_CAMERA')
+        else:
+            INFO_MT_camera_add.draw(self, context)
+
         layout.menu("INFO_MT_lamp_add", icon='OUTLINER_OB_LAMP')
         layout.separator()