forked from bartvdbraak/blender
UI: allow to extend camera as a menu
Needed for T46853
This commit is contained in:
parent
4f4a484b9b
commit
1600b93fb8
@ -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):
|
||||
"""
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user