595ac01e5bd04e2de9cdbb7f34d80f563034d0c3
[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_camera(DataButtonsPanel):
13         __show_header__ = False
14         
15         def draw(self, context):
16                 layout = self.layout
17                 
18                 ob = context.object
19                 cam = context.camera
20                 space = context.space_data
21
22                 split = layout.split(percentage=0.65)
23
24                 if ob:
25                         split.template_ID(ob, "data")
26                         split.itemS()
27                 elif cam:
28                         split.template_ID(space, "pin_id")
29                         split.itemS()
30
31 class DATA_PT_camera(DataButtonsPanel):
32         __label__ = "Lens"
33
34         def draw(self, context):
35                 layout = self.layout
36                 
37                 cam = context.camera
38
39                 layout.itemR(cam, "type", expand=True)
40                         
41                 row = layout.row(align=True)
42                 if cam.type == 'PERSP':
43                         row.itemR(cam, "lens_unit", text="")
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
49                 elif cam.type == 'ORTHO':
50                         row.itemR(cam, "ortho_scale")
51
52                 split = layout.split()
53                 split.itemR(cam, "panorama");
54                 split.itemL()
55                                 
56                 split = layout.split()
57                         
58                 sub = split.column(align=True)
59                 sub.itemL(text="Shift:")
60                 sub.itemR(cam, "shift_x", text="X")
61                 sub.itemR(cam, "shift_y", text="Y")
62                         
63                 sub = split.column(align=True)
64                 sub.itemL(text="Clipping:")
65                 sub.itemR(cam, "clip_start", text="Start")
66                 sub.itemR(cam, "clip_end", text="End")
67                         
68                 split = layout.split()
69                 col = split.column()
70                 col.itemL(text="Depth of Field:")
71                 col.itemR(cam, "dof_object", text="")
72                 col = split.column()
73                 col.itemL()
74                 col.itemR(cam, "dof_distance", text="Distance")
75                 
76 class DATA_PT_camera_display(DataButtonsPanel):
77         __label__ = "Display"
78
79         def draw(self, context):
80                 cam = context.camera
81                 layout = self.layout
82
83                 split = layout.split()
84                 
85                 sub = split.column()
86                 sub.itemR(cam, "show_limits", text="Limits")
87                 sub.itemR(cam, "show_mist", text="Mist")
88                 sub.itemR(cam, "show_title_safe", text="Title Safe")
89                 sub.itemR(cam, "show_name", text="Name")
90                         
91                 col = split.column()
92                 col.itemR(cam, "show_passepartout", text="Passepartout")
93                 colsub = col.column()
94                 colsub.active = cam.show_passepartout
95                 colsub.itemR(cam, "passepartout_alpha", text="Alpha", slider=True)
96                 col.itemR(cam, "draw_size", text="Size")
97                 
98 bpy.types.register(DATA_PT_context_camera)
99 bpy.types.register(DATA_PT_camera)
100 bpy.types.register(DATA_PT_camera_display)
101