2.5 Buttons:
[blender.git] / release / ui / buttons_data.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 class DATA_PT_modifiers(DataButtonsPanel):
10         __idname__ = "DATA_PT_modifiers"
11         __label__ = "Modifiers"
12         
13         def poll(self, context):
14                 ob = context.active_object
15                 return (ob and ob.type in ("MESH", "CURVE", "SURFACE", "TEXT", "LATTICE"))
16
17         def draw(self, context):
18                 ob = context.active_object
19                 layout = self.layout
20
21                 if not ob:
22                         return
23
24                 layout.row()
25                 layout.item_menu_enumO("OBJECT_OT_modifier_add", "type")
26
27                 for md in ob.modifiers:
28                         sub = layout.box()
29
30                         sub.row()
31                         sub.itemR(md, "expanded", text="")
32                         sub.itemR(md, "name", text="")
33
34                         sub.itemR(md, "render", text="")
35                         sub.itemR(md, "realtime", text="")
36                         sub.itemR(md, "editmode", text="")
37                         sub.itemR(md, "on_cage", text="")
38
39                         if md.expanded:
40                                 sub.row()
41                                 sub.itemS()
42
43                                 if md.type == "ARMATURE":
44                                         self.armature(sub, md)
45
46         def armature(self, layout, md):
47                 layout.column()
48                 layout.itemR(md, "object")
49                 layout.row()
50                 layout.itemR(md, "vertex_group")
51                 layout.itemR(md, "invert")
52                 layout.column_flow()
53                 layout.itemR(md, "use_vertex_groups")
54                 layout.itemR(md, "use_bone_envelopes")
55                 layout.itemR(md, "quaternion")
56                 layout.itemR(md, "b_bone_rest")
57                 layout.itemR(md, "multi_modifier")
58
59 class DATA_PT_cameralens(DataButtonsPanel):
60         __idname__ = "DATA_PT_camera"
61         __label__ = "Lens"
62         
63         def poll(self, context):
64                 ob = context.active_object
65                 return (ob and ob.type == "CAMERA")
66
67         def draw(self, context):
68                 cam = context.main.cameras[0]
69                 layout = self.layout
70
71                 if not cam:
72                         return
73                 
74                 layout.row()
75                 layout.itemR(cam, "type", expand=True)
76                 
77                 layout.row()
78                 if cam.type == 'PERSP':
79                         layout.itemR(cam, "lens_unit")
80                         if cam.lens_unit == 'MILLIMETERS':
81                                 layout.itemR(cam, "lens", text="Angle")
82                         if cam.lens_unit == 'DEGREES':
83                                 layout.itemR(cam, "angle")
84                 if cam.type == 'ORTHO':
85                         layout.itemR(cam, "ortho_scale")
86                 
87                 layout.column_flow()
88                 layout.itemL(text="Shift:")
89                 layout.itemR(cam, "shift_x", text="X")
90                 layout.itemR(cam, "shift_y", text="Y")
91                 layout.itemL(text="Clipping:")
92                 layout.itemR(cam, "clip_start", text="Start")
93                 layout.itemR(cam, "clip_end", text="End")
94                 
95                 layout.row()
96                 layout.itemR(cam, "dof_object")
97                 layout.itemR(cam, "dof_distance")
98                 
99 class DATA_PT_cameradisplay(DataButtonsPanel):
100         __idname__ = "DATA_PT_cameradisplay"
101         __label__ = "Display"
102         
103         def poll(self, context):
104                 ob = context.active_object
105                 return (ob and ob.type == "CAMERA")
106
107         def draw(self, context):
108                 cam = context.main.cameras[0]
109                 layout = self.layout
110
111                 if not cam:
112                         return
113                         
114                 layout.split(number=2)
115                 
116                 sub = layout.sub(0)
117                 sub.column_flow()
118                 sub.itemR(cam, "show_limits", text="Limits")
119                 sub.itemR(cam, "show_mist", text="Mist")
120                 sub.itemR(cam, "show_title_safe", text="Title Safe")
121                 sub.itemR(cam, "show_name", text="Name")
122                 
123                 sub = layout.sub(1)
124                 subsub = sub.box()
125                 subsub.row()
126                 subsub.itemR(cam, "show_passepartout", text="Passepartout")
127                 subsub.row()
128                 subsub.itemR(cam, "passepartout_alpha", text="Alpha")
129                 sub.row()
130                 sub.itemR(cam, "draw_size", text="Size")
131                 
132 bpy.types.register(DATA_PT_modifiers)
133 bpy.types.register(DATA_PT_cameralens)
134 bpy.types.register(DATA_PT_cameradisplay)
135