7ca70029e490947c35569ff53ec74555a089656b
[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         __no_header__ = True
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         __idname__ = "DATA_PT_camera"
34         __label__ = "Lens"
35
36         def draw(self, context):
37                 layout = self.layout
38                 
39                 cam = context.camera
40
41                 layout.itemR(cam, "type", expand=True)
42                         
43                 row = layout.row(align=True)
44                 if cam.type == 'PERSP':
45                         row.itemR(cam, "lens_unit", text="")
46                         if cam.lens_unit == 'MILLIMETERS':
47                                 row.itemR(cam, "lens", text="Angle")
48                         elif cam.lens_unit == 'DEGREES':
49                                 row.itemR(cam, "angle")
50
51                 elif cam.type == 'ORTHO':
52                         row.itemR(cam, "ortho_scale")
53
54                 split = layout.split()
55                 split.itemR(cam, "panorama");
56                 split.itemL()
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                 split = layout.split()
71                 col = split.column()
72                 col.itemL(text="Depth of Field:")
73                 col.itemR(cam, "dof_object", text="")
74                 col = split.column()
75                 col.itemL()
76                 col.itemR(cam, "dof_distance", text="Distance")
77                 
78 class DATA_PT_camera_display(DataButtonsPanel):
79         __idname__ = "DATA_PT_camera_display"
80         __label__ = "Display"
81
82         def draw(self, context):
83                 cam = context.camera
84                 layout = self.layout
85
86                 split = layout.split()
87                 
88                 sub = split.column()
89                 sub.itemR(cam, "show_limits", text="Limits")
90                 sub.itemR(cam, "show_mist", text="Mist")
91                 sub.itemR(cam, "show_title_safe", text="Title Safe")
92                 sub.itemR(cam, "show_name", text="Name")
93                         
94                 col = split.column()
95                 col.itemR(cam, "show_passepartout", text="Passepartout")
96                 colsub = col.column()
97                 colsub.active = cam.show_passepartout
98                 colsub.itemR(cam, "passepartout_alpha", text="Alpha", slider=True)
99                 col.itemR(cam, "draw_size", text="Size")
100                 
101 bpy.types.register(DATA_PT_context_camera)
102 bpy.types.register(DATA_PT_camera)
103 bpy.types.register(DATA_PT_camera_display)
104