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