A few fixes:
[blender.git] / release / scripts / ui / buttons_object.py
1
2 import bpy
3
4 class ObjectButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
6         __region_type__ = 'WINDOW'
7         __context__ = "object"
8
9 class OBJECT_PT_context_object(ObjectButtonsPanel):
10         __show_header__ = False
11
12         def draw(self, context):
13                 layout = self.layout
14                 
15                 ob = context.object
16                 
17                 row = layout.row()
18                 row.itemL(text="", icon='ICON_OBJECT_DATA')
19                 row.itemR(ob, "name", text="")
20
21 class OBJECT_PT_transform(ObjectButtonsPanel):
22         __label__ = "Transform"
23
24         def draw(self, context):
25                 layout = self.layout
26                 
27                 ob = context.object
28                 
29                 row = layout.row()
30                 
31                 row.column().itemR(ob, "location")
32                 if ob.rotation_mode == 'QUATERNION':
33                         row.column().itemR(ob, "rotation_quaternion", text="Rotation")
34                 elif ob.rotation_mode == 'AXIS_ANGLE':
35                         #row.column().itemL(text="Rotation")
36                         #row.column().itemR(pchan, "rotation_angle", text="Angle")
37                         #row.column().itemR(pchan, "rotation_axis", text="Axis")
38                         row.column().itemR(ob, "rotation_axis_angle", text="Rotation")
39                 else:
40                         row.column().itemR(ob, "rotation_euler", text="Rotation")
41                         
42                 row.column().itemR(ob, "scale")
43                 
44                 layout.itemR(ob, "rotation_mode")
45                 
46 class OBJECT_PT_transform_locks(ObjectButtonsPanel):
47         __label__ = "Transform Locks"
48         __default_closed__ = True
49         
50         def draw(self, context):
51                 layout = self.layout
52                 
53                 ob = context.object
54                 
55                 row = layout.row()
56                 
57                 col = row.column()
58                 col.itemR(ob, "lock_location")
59                 
60                 col = row.column()
61                 if ob.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
62                         col.itemR(ob, "lock_rotations_4d", text="Lock Rotation")
63                         if ob.lock_rotations_4d:
64                                 col.itemR(ob, "lock_rotation_w", text="W")
65                         col.itemR(ob, "lock_rotation", text="")
66                 else:
67                         col.itemR(ob, "lock_rotation", text="Rotation")
68                 
69                 row.column().itemR(ob, "lock_scale")
70
71 class OBJECT_PT_relations(ObjectButtonsPanel):
72         __label__ = "Relations"
73
74         def draw(self, context):
75                 layout = self.layout
76                 
77                 ob = context.object
78
79                 split = layout.split()
80                 
81                 col = split.column()
82                 col.itemR(ob, "layers")
83                 col.itemS()
84                 col.itemR(ob, "pass_index")
85
86                 col = split.column()
87                 col.itemL(text="Parent:")
88                 col.itemR(ob, "parent", text="")
89
90                 sub = col.column()
91                 split = sub.split(percentage=0.3)
92                 split.itemL(text="Type:")
93                 split.itemR(ob, "parent_type", text="")
94                 parent = ob.parent
95                 if parent and ob.parent_type == 'BONE' and parent.type == 'ARMATURE':
96                         sub.item_pointerR(ob, "parent_bone", parent.data, "bones", text="")
97                 sub.active = parent != None
98
99 class OBJECT_PT_groups(ObjectButtonsPanel):
100         __label__ = "Groups"
101
102         def draw(self, context):
103                 layout = self.layout
104                 
105                 ob = context.object
106
107                 split = layout.split()
108                 split.item_menu_enumO("object.group_add", "group", text="Add to Group")
109                 split.itemL()
110
111                 for group in bpy.data.groups:
112                         if ob.name in group.objects:
113                                 col = layout.column(align=True)
114
115                                 col.set_context_pointer("group", group)
116
117                                 row = col.box().row()
118                                 row.itemR(group, "name", text="")
119                                 row.itemO("object.group_remove", text="", icon='VICON_X')
120
121                                 split = col.box().split()
122                                 split.column().itemR(group, "layer", text="Dupli")
123                                 split.column().itemR(group, "dupli_offset", text="")
124
125 class OBJECT_PT_display(ObjectButtonsPanel):
126         __label__ = "Display"
127
128         def draw(self, context):
129                 layout = self.layout
130                 
131                 ob = context.object
132                 
133                 split = layout.split()
134                 col = split.column()
135                 col.itemR(ob, "max_draw_type", text="Type")
136                 col = split.column()
137                 row = col.row()
138                 row.itemR(ob, "draw_bounds", text="Bounds")
139                 row.itemR(ob, "draw_bounds_type", text="")
140
141                 flow = layout.column_flow()
142                 flow.itemR(ob, "draw_name", text="Name")
143                 flow.itemR(ob, "draw_axis", text="Axis")
144                 flow.itemR(ob, "draw_wire", text="Wire")
145                 flow.itemR(ob, "draw_texture_space", text="Texture Space")
146                 flow.itemR(ob, "x_ray", text="X-Ray")
147                 flow.itemR(ob, "draw_transparent", text="Transparency")
148
149 class OBJECT_PT_duplication(ObjectButtonsPanel):
150         __label__ = "Duplication"
151
152         def draw(self, context):
153                 layout = self.layout
154                 
155                 ob = context.object
156
157                 layout.itemR(ob, "dupli_type", expand=True)
158
159                 if ob.dupli_type == 'FRAMES':
160                         split = layout.split()
161                         
162                         col = split.column(align=True)
163                         col.itemR(ob, "dupli_frames_start", text="Start")
164                         col.itemR(ob, "dupli_frames_end", text="End")
165                         
166                         col = split.column(align=True)
167                         col.itemR(ob, "dupli_frames_on", text="On")
168                         col.itemR(ob, "dupli_frames_off", text="Off")
169                         
170                         layout.itemR(ob, "dupli_frames_no_speed", text="No Speed")
171
172                 elif ob.dupli_type == 'VERTS':
173                         layout.itemR(ob, "dupli_verts_rotation", text="Rotation")
174
175                 elif ob.dupli_type == 'FACES':
176                         row = layout.row()
177                         row.itemR(ob, "dupli_faces_scale", text="Scale")
178                         row.itemR(ob, "dupli_faces_inherit_scale", text="Inherit Scale")
179
180                 elif ob.dupli_type == 'GROUP':
181                         layout.itemR(ob, "dupli_group", text="Group")
182
183 class OBJECT_PT_animation(ObjectButtonsPanel):
184         __label__ = "Animation"
185
186         def draw(self, context):
187                 layout = self.layout
188                 
189                 ob = context.object
190                 
191                 split = layout.split()
192                 
193                 col = split.column()
194                 col.itemL(text="Time Offset:")
195                 col.itemR(ob, "time_offset_edit", text="Edit")
196                 row = col.row()
197                 row.itemR(ob, "time_offset_particle", text="Particle")
198                 row.active = len(ob.particle_systems) != 0
199                 row = col.row()
200                 row.itemR(ob, "time_offset_parent", text="Parent")
201                 row.active = ob.parent != None
202                 row = col.row()
203                 row.itemR(ob, "slow_parent")
204                 row.active = ob.parent != None
205                 col.itemR(ob, "time_offset", text="Offset")
206
207                 col = split.column()
208                 col.itemL(text="Track:")
209                 col.itemR(ob, "track", text="")
210                 col.itemR(ob, "track_axis", text="Axis")
211                 col.itemR(ob, "up_axis", text="Up Axis")
212                 row = col.row()
213                 row.itemR(ob, "track_override_parent", text="Override Parent")
214                 row.active = ob.parent != None
215
216 bpy.types.register(OBJECT_PT_context_object)
217 bpy.types.register(OBJECT_PT_transform)
218 bpy.types.register(OBJECT_PT_transform_locks)
219 bpy.types.register(OBJECT_PT_relations)
220 bpy.types.register(OBJECT_PT_groups)
221 bpy.types.register(OBJECT_PT_display)
222 bpy.types.register(OBJECT_PT_duplication)
223 bpy.types.register(OBJECT_PT_animation)