b4b53f1c5a1456509b13a7b68fc7476b2f0cf0a8
[blender.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         __idname__ = "DATA_PT_context_camera"
14         __label__ = " "
15         
16         def poll(self, context):
17                 return (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 class DATA_PT_camera(DataButtonsPanel):
36         __idname__ = "DATA_PT_camera"
37         __label__ = "Lens"
38
39         def draw(self, context):
40                 layout = self.layout
41                 
42                 cam = context.camera
43
44                 layout.itemS()
45                 layout.itemR(cam, "type", expand=True)
46                         
47                 row = layout.row(align=True)
48                 if cam.type == 'PERSP':
49                         row.itemR(cam, "lens_unit", text="")
50                         if cam.lens_unit == 'MILLIMETERS':
51                                 row.itemR(cam, "lens", text="Angle")
52                         elif cam.lens_unit == 'DEGREES':
53                                 row.itemR(cam, "angle")
54
55                 elif cam.type == 'ORTHO':
56                         row.itemR(cam, "ortho_scale")
57                                 
58                 split = layout.split()
59                         
60                 sub = split.column(align=True)
61                 sub.itemL(text="Shift:")
62                 sub.itemR(cam, "shift_x", text="X")
63                 sub.itemR(cam, "shift_y", text="Y")
64                         
65                 sub = split.column(align=True)
66                 sub.itemL(text="Clipping:")
67                 sub.itemR(cam, "clip_start", text="Start")
68                 sub.itemR(cam, "clip_end", text="End")
69                         
70                 row = layout.row()
71                 row.itemR(cam, "dof_object")
72                 row.itemR(cam, "dof_distance")
73                 
74 class DATA_PT_camera_display(DataButtonsPanel):
75         __idname__ = "DATA_PT_camera_display"
76         __label__ = "Display"
77
78         def draw(self, context):
79                 cam = context.camera
80                 layout = self.layout
81
82                 split = layout.split()
83                 
84                 sub = split.column()
85                 sub.itemR(cam, "show_limits", text="Limits")
86                 sub.itemR(cam, "show_mist", text="Mist")
87                 sub.itemR(cam, "show_title_safe", text="Title Safe")
88                 sub.itemR(cam, "show_name", text="Name")
89                         
90                 col = split.column()
91                 col.itemR(cam, "show_passepartout", text="Passepartout")
92                 colsub = col.column()
93                 colsub.active = cam.show_passepartout
94                 colsub.itemR(cam, "passepartout_alpha", text="Alpha", slider=True)
95                 col.itemR(cam, "draw_size", text="Size")
96                 
97 bpy.types.register(DATA_PT_context_camera)
98 bpy.types.register(DATA_PT_camera)
99 bpy.types.register(DATA_PT_camera_display)