Patch from William
[blender-staging.git] / release / ui / buttons_data_camera.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8
9         def poll(self, context):
10                 return (context.camera != None)
11                 
12 class DATA_PT_context(DataButtonsPanel):
13         __idname__ = "DATA_PT_context"
14         __label__ = " "
15         
16         def poll(self, context):
17                 return (context.object and context.object.type == 'CAMERA')
18
19         def draw(self, context):
20                 layout = self.layout
21                 
22                 ob = context.object
23                 cam = context.camera
24                 space = context.space_data
25
26                 split = layout.split(percentage=0.65)
27
28                 if ob:
29                         split.template_ID(ob, "data")
30                         split.itemS()
31                 elif arm:
32                         split.template_ID(space, "pin_id")
33                         split.itemS()
34
35
36 class DATA_PT_camera(DataButtonsPanel):
37         __idname__ = "DATA_PT_camera"
38         __label__ = "Lens"
39         
40         def poll(self, context):
41                 return (context.object and context.object.type == 'CAMERA')
42
43         def draw(self, context):
44                 layout = self.layout
45                 
46                 ob = context.object
47                 cam = context.camera
48                 space = context.space_data
49
50                 if cam:
51                         layout.itemS()
52                         layout.itemR(cam, "type", expand=True)
53                         
54                         row = layout.row(align=True)
55                         if cam.type == 'PERSP':
56                                 row.itemR(cam, "lens_unit", text="")
57                                 if cam.lens_unit == 'MILLIMETERS':
58                                         row.itemR(cam, "lens", text="Angle")
59                                 elif cam.lens_unit == 'DEGREES':
60                                         row.itemR(cam, "angle")
61
62                         elif cam.type == 'ORTHO':
63                                 row.itemR(cam, "ortho_scale")
64                                 
65                         split = layout.split()
66                         
67                         sub = split.column(align=True)
68                         sub.itemL(text="Shift:")
69                         sub.itemR(cam, "shift_x", text="X")
70                         sub.itemR(cam, "shift_y", text="Y")
71                         
72                         sub = split.column(align=True)
73                         sub.itemL(text="Clipping:")
74                         sub.itemR(cam, "clip_start", text="Start")
75                         sub.itemR(cam, "clip_end", text="End")
76                         
77                         row = layout.row()
78                         row.itemR(cam, "dof_object")
79                         row.itemR(cam, "dof_distance")
80                 
81 class DATA_PT_camera_display(DataButtonsPanel):
82         __idname__ = "DATA_PT_camera_display"
83         __label__ = "Display"
84
85         def draw(self, context):
86                 cam = context.camera
87                 layout = self.layout
88
89                 split = layout.split()
90                 
91                 sub = split.column()
92                 sub.itemR(cam, "show_limits", text="Limits")
93                 sub.itemR(cam, "show_mist", text="Mist")
94                 sub.itemR(cam, "show_title_safe", text="Title Safe")
95                 sub.itemR(cam, "show_name", text="Name")
96                         
97                 col = split.column()
98                 col.itemR(cam, "show_passepartout", text="Passepartout")
99                 colsub = col.column()
100                 colsub.active = cam.show_passepartout
101                 colsub.itemR(cam, "passepartout_alpha", text="Alpha", slider=True)
102                 col.itemR(cam, "draw_size", text="Size")
103                 
104 bpy.types.register(DATA_PT_context)
105 bpy.types.register(DATA_PT_camera)
106 bpy.types.register(DATA_PT_camera_display)