2.5 Data Buttons:
authorThomas Dinges <blender@dingto.org>
Mon, 4 May 2009 15:53:55 +0000 (15:53 +0000)
committerThomas Dinges <blender@dingto.org>
Mon, 4 May 2009 15:53:55 +0000 (15:53 +0000)
* Added camera buttons.
* Added poll to check on active object type.

ToDo:
* Lens Unit "lens" and "angle" don't update each other. Needs RNA fix.
* Buttons only work for default camera now, needs better context.

release/ui/buttons_data.py

index b141b3fb8c31f3f73a3cb6b13cebefc6be4bd528..011741653fc546ddd356f6f791ce8d79a027f670 100644 (file)
@@ -9,6 +9,10 @@ class DataButtonsPanel(bpy.types.Panel):
 class DATA_PT_modifiers(DataButtonsPanel):
        __idname__ = "DATA_PT_modifiers"
        __label__ = "Modifiers"
+       
+       def poll(self, context):
+               ob = context.active_object
+               return (ob and ob.type == "MESH")
 
        def draw(self, context):
                ob = context.active_object
@@ -52,5 +56,80 @@ class DATA_PT_modifiers(DataButtonsPanel):
                layout.itemR(md, "b_bone_rest")
                layout.itemR(md, "multi_modifier")
 
+class DATA_PT_cameralens(DataButtonsPanel):
+       __idname__ = "DATA_PT_camera"
+       __label__ = "Lens"
+       
+       def poll(self, context):
+               ob = context.active_object
+               return (ob and ob.type == "CAMERA")
+
+       def draw(self, context):
+               cam = context.main.cameras[0]
+               layout = self.layout
+
+               if not cam:
+                       return
+               
+               layout.row()
+               layout.itemR(cam, "type", expand=True)
+               
+               layout.row()
+               if cam.type == 'PERSP':
+                       layout.itemR(cam, "lens_unit")
+                       if cam.lens_unit == 'MILLIMETERS':
+                               layout.itemR(cam, "lens", text="Angle")
+                       if cam.lens_unit == 'DEGREES':
+                               layout.itemR(cam, "angle")
+               if cam.type == 'ORTHO':
+                       layout.itemR(cam, "ortho_scale")
+               
+               layout.column_flow()
+               layout.itemL(text="Shift:")
+               layout.itemR(cam, "shift_x", text="X")
+               layout.itemR(cam, "shift_y", text="Y")
+               layout.itemL(text="Clipping:")
+               layout.itemR(cam, "clip_start", text="Start")
+               layout.itemR(cam, "clip_end", text="End")
+               
+               layout.row()
+               layout.itemR(cam, "dof_object")
+               layout.itemR(cam, "dof_distance")
+               
+class DATA_PT_cameradisplay(DataButtonsPanel):
+       __idname__ = "DATA_PT_cameradisplay"
+       __label__ = "Display"
+       
+       def poll(self, context):
+               ob = context.active_object
+               return (ob and ob.type == "CAMERA")
+
+       def draw(self, context):
+               cam = context.main.cameras[0]
+               layout = self.layout
+
+               if not cam:
+                       return
+                       
+               layout.split(number=2)
+               
+               sub = layout.sub(0)
+               sub.column_flow()
+               sub.itemR(cam, "show_limits", text="Limits")
+               sub.itemR(cam, "show_mist", text="Mist")
+               sub.itemR(cam, "show_title_safe", text="Title Safe")
+               sub.itemR(cam, "show_name", text="Name")
+               
+               sub = layout.sub(1)
+               subsub = sub.box()
+               subsub.row()
+               subsub.itemR(cam, "show_passepartout", text="Passepartout")
+               subsub.row()
+               subsub.itemR(cam, "passepartout_alpha", text="Alpha")
+               sub.row()
+               sub.itemR(cam, "draw_size", text="Size")
+               
 bpy.types.register(DATA_PT_modifiers)
+bpy.types.register(DATA_PT_cameralens)
+bpy.types.register(DATA_PT_cameradisplay)