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