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