remove narrow ui feature
[blender.git] / release / scripts / ui / properties_data_bone.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from rna_prop_ui import PropertyPanel
22
23
24 class BoneButtonsPanel():
25     bl_space_type = 'PROPERTIES'
26     bl_region_type = 'WINDOW'
27     bl_context = "bone"
28
29     @staticmethod
30     def poll(context):
31         return (context.bone or context.edit_bone)
32
33
34 class BONE_PT_context_bone(BoneButtonsPanel, bpy.types.Panel):
35     bl_label = ""
36     bl_show_header = False
37
38     def draw(self, context):
39         layout = self.layout
40
41         bone = context.bone
42         if not bone:
43             bone = context.edit_bone
44
45         row = layout.row()
46         row.label(text="", icon='BONE_DATA')
47         row.prop(bone, "name", text="")
48
49
50 class BONE_PT_custom_props(BoneButtonsPanel, PropertyPanel, bpy.types.Panel):
51
52     @property
53     def _context_path(self):
54         obj = bpy.context.object
55         if obj and obj.mode == 'POSE':
56             return "active_pose_bone"
57         else:
58             return "active_bone"
59
60
61 class BONE_PT_transform(BoneButtonsPanel, bpy.types.Panel):
62     bl_label = "Transform"
63
64     def draw(self, context):
65         layout = self.layout
66
67         ob = context.object
68         bone = context.bone
69
70         if not bone:
71             bone = context.edit_bone
72             row = layout.row()
73             row.column().prop(bone, "head")
74             row.column().prop(bone, "tail")
75
76             col = row.column()
77             sub = col.column(align=True)
78             sub.label(text="Roll:")
79             sub.prop(bone, "roll", text="")
80             sub.label()
81             sub.prop(bone, "lock")
82
83         else:
84             pchan = ob.pose.bones[context.bone.name]
85
86             row = layout.row()
87             col = row.column()
88             col.prop(pchan, "location")
89             col.active = not (bone.parent and bone.connected)
90
91             col = row.column()
92             if pchan.rotation_mode == 'QUATERNION':
93                 col.prop(pchan, "rotation_quaternion", text="Rotation")
94             elif pchan.rotation_mode == 'AXIS_ANGLE':
95                 #col.label(text="Rotation")
96                 #col.prop(pchan, "rotation_angle", text="Angle")
97                 #col.prop(pchan, "rotation_axis", text="Axis")
98                 col.prop(pchan, "rotation_axis_angle", text="Rotation")
99             else:
100                 col.prop(pchan, "rotation_euler", text="Rotation")
101
102             row.column().prop(pchan, "scale")
103
104             layout.prop(pchan, "rotation_mode")
105
106
107 class BONE_PT_transform_locks(BoneButtonsPanel, bpy.types.Panel):
108     bl_label = "Transform Locks"
109     bl_default_closed = True
110
111     @staticmethod
112     def poll(context):
113         return context.bone
114
115     def draw(self, context):
116         layout = self.layout
117
118         ob = context.object
119         bone = context.bone
120         pchan = ob.pose.bones[context.bone.name]
121
122         row = layout.row()
123         col = row.column()
124         col.prop(pchan, "lock_location")
125         col.active = not (bone.parent and bone.connected)
126
127         col = row.column()
128         if pchan.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
129             col.prop(pchan, "lock_rotations_4d", text="Lock Rotation")
130             if pchan.lock_rotations_4d:
131                 col.prop(pchan, "lock_rotation_w", text="W")
132             col.prop(pchan, "lock_rotation", text="")
133         else:
134             col.prop(pchan, "lock_rotation", text="Rotation")
135
136         row.column().prop(pchan, "lock_scale")
137
138
139 class BONE_PT_relations(BoneButtonsPanel, bpy.types.Panel):
140     bl_label = "Relations"
141
142     def draw(self, context):
143         layout = self.layout
144
145         ob = context.object
146         bone = context.bone
147         arm = context.armature
148
149         if not bone:
150             bone = context.edit_bone
151             pchan = None
152         else:
153             pchan = ob.pose.bones[context.bone.name]
154
155         split = layout.split()
156
157         col = split.column()
158         col.label(text="Layers:")
159         col.prop(bone, "layer", text="")
160
161         col.separator()
162
163         if ob and pchan:
164             col.label(text="Bone Group:")
165             col.prop_object(pchan, "bone_group", ob.pose, "bone_groups", text="")
166
167         col = split.column()
168         col.label(text="Parent:")
169         if context.bone:
170             col.prop(bone, "parent", text="")
171         else:
172             col.prop_object(bone, "parent", arm, "edit_bones", text="")
173
174         sub = col.column()
175         sub.active = (bone.parent is not None)
176         sub.prop(bone, "connected")
177         sub.prop(bone, "hinge", text="Inherit Rotation")
178         sub.prop(bone, "inherit_scale", text="Inherit Scale")
179         sub = col.column()
180         sub.active = (not bone.parent or not bone.connected)
181         sub.prop(bone, "local_location", text="Local Location")
182
183
184 class BONE_PT_display(BoneButtonsPanel, bpy.types.Panel):
185     bl_label = "Display"
186
187     @staticmethod
188     def poll(context):
189         return context.bone
190
191     def draw(self, context):
192         layout = self.layout
193
194         ob = context.object
195         bone = context.bone
196
197         if not bone:
198             bone = context.edit_bone
199             pchan = None
200         else:
201             pchan = ob.pose.bones[context.bone.name]
202
203         if ob and pchan:
204
205             split = layout.split()
206
207             col = split.column()
208             col.prop(bone, "draw_wire", text="Wireframe")
209             col.prop(bone, "hide", text="Hide")
210
211             col = split.column()
212
213             col.label(text="Custom Shape:")
214             col.prop(pchan, "custom_shape", text="")
215             if pchan.custom_shape:
216                 col.prop_object(pchan, "custom_shape_transform", ob.pose, "bones", text="At")
217
218
219 class BONE_PT_inverse_kinematics(BoneButtonsPanel, bpy.types.Panel):
220     bl_label = "Inverse Kinematics"
221     bl_default_closed = True
222
223     @staticmethod
224     def poll(context):
225         return context.active_pose_bone
226
227     def draw(self, context):
228         layout = self.layout
229
230         ob = context.object
231         bone = context.bone
232         pchan = ob.pose.bones[bone.name]
233
234         row = layout.row()
235         row.prop(ob.pose, "ik_solver")
236
237         split = layout.split(percentage=0.25)
238         split.prop(pchan, "ik_dof_x", text="X")
239         split.active = pchan.has_ik
240         row = split.row()
241         row.prop(pchan, "ik_stiffness_x", text="Stiffness", slider=True)
242         row.active = pchan.ik_dof_x and pchan.has_ik
243
244         split = layout.split(percentage=0.25)
245         sub = split.row()
246
247         sub.prop(pchan, "ik_limit_x", text="Limit")
248         sub.active = pchan.ik_dof_x and pchan.has_ik
249         sub = split.row(align=True)
250         sub.prop(pchan, "ik_min_x", text="")
251         sub.prop(pchan, "ik_max_x", text="")
252         sub.active = pchan.ik_dof_x and pchan.ik_limit_x and pchan.has_ik
253
254         split = layout.split(percentage=0.25)
255         split.prop(pchan, "ik_dof_y", text="Y")
256         split.active = pchan.has_ik and pchan.has_ik
257         row = split.row()
258         row.prop(pchan, "ik_stiffness_y", text="Stiffness", slider=True)
259         row.active = pchan.ik_dof_y and pchan.has_ik
260
261         split = layout.split(percentage=0.25)
262         sub = split.row()
263
264         sub.prop(pchan, "ik_limit_y", text="Limit")
265         sub.active = pchan.ik_dof_y and pchan.has_ik
266
267         sub = split.row(align=True)
268         sub.prop(pchan, "ik_min_y", text="")
269         sub.prop(pchan, "ik_max_y", text="")
270         sub.active = pchan.ik_dof_y and pchan.ik_limit_y and pchan.has_ik
271
272         split = layout.split(percentage=0.25)
273         split.prop(pchan, "ik_dof_z", text="Z")
274         split.active = pchan.has_ik and pchan.has_ik
275         sub = split.row()
276         sub.prop(pchan, "ik_stiffness_z", text="Stiffness", slider=True)
277         sub.active = pchan.ik_dof_z and pchan.has_ik
278
279         split = layout.split(percentage=0.25)
280         sub = split.row()
281
282         sub.prop(pchan, "ik_limit_z", text="Limit")
283         sub.active = pchan.ik_dof_z and pchan.has_ik
284         sub = split.row(align=True)
285         sub.prop(pchan, "ik_min_z", text="")
286         sub.prop(pchan, "ik_max_z", text="")
287         sub.active = pchan.ik_dof_z and pchan.ik_limit_z and pchan.has_ik
288         split = layout.split()
289         split.prop(pchan, "ik_stretch", text="Stretch", slider=True)
290         split.label()
291         split.active = pchan.has_ik
292
293         if ob.pose.ik_solver == 'ITASC':
294             split = layout.split()
295             col = split.column()
296             col.prop(pchan, "ik_rot_control", text="Control Rotation")
297             col.active = pchan.has_ik
298             col = split.column()
299             col.prop(pchan, "ik_rot_weight", text="Weight", slider=True)
300             col.active = pchan.has_ik
301             # not supported yet
302             #row = layout.row()
303             #row.prop(pchan, "ik_lin_control", text="Joint Size")
304             #row.prop(pchan, "ik_lin_weight", text="Weight", slider=True)
305
306
307 class BONE_PT_deform(BoneButtonsPanel, bpy.types.Panel):
308     bl_label = "Deform"
309     bl_default_closed = True
310
311     def draw_header(self, context):
312         bone = context.bone
313
314         if not bone:
315             bone = context.edit_bone
316
317         self.layout.prop(bone, "deform", text="")
318
319     def draw(self, context):
320         layout = self.layout
321
322         bone = context.bone
323
324         if not bone:
325             bone = context.edit_bone
326
327         layout.active = bone.deform
328
329         split = layout.split()
330
331         col = split.column()
332         col.label(text="Envelope:")
333
334         sub = col.column(align=True)
335         sub.prop(bone, "envelope_distance", text="Distance")
336         sub.prop(bone, "envelope_weight", text="Weight")
337         col.prop(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
338
339         sub = col.column(align=True)
340         sub.label(text="Radius:")
341         sub.prop(bone, "head_radius", text="Head")
342         sub.prop(bone, "tail_radius", text="Tail")
343
344         col = split.column()
345         col.label(text="Curved Bones:")
346
347         sub = col.column(align=True)
348         sub.prop(bone, "bbone_segments", text="Segments")
349         sub.prop(bone, "bbone_in", text="Ease In")
350         sub.prop(bone, "bbone_out", text="Ease Out")
351
352         col.label(text="Offset:")
353         col.prop(bone, "cyclic_offset")
354
355
356 def register():
357     pass
358
359
360 def unregister():
361     pass
362
363 if __name__ == "__main__":
364     register()