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