1 # ##### BEGIN GPL LICENSE BLOCK #####
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.
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.
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.
17 # ##### END GPL LICENSE BLOCK #####
21 from bpy.types import Panel, Menu
22 from rna_prop_ui import PropertyPanel
25 class ArmatureButtonsPanel():
26 bl_space_type = 'PROPERTIES'
27 bl_region_type = 'WINDOW'
31 def poll(cls, context):
32 return context.armature
35 class DATA_PT_context_arm(ArmatureButtonsPanel, Panel):
37 bl_options = {'HIDE_HEADER'}
39 def draw(self, context):
43 arm = context.armature
44 space = context.space_data
47 layout.template_ID(ob, "data")
49 layout.template_ID(space, "pin_id")
52 class DATA_PT_skeleton(ArmatureButtonsPanel, Panel):
55 def draw(self, context):
58 arm = context.armature
60 layout.prop(arm, "pose_position", expand=True)
63 col.label(text="Layers:")
64 col.prop(arm, "layers", text="")
65 col.label(text="Protected Layers:")
66 col.prop(arm, "layers_protected", text="")
68 layout.label(text="Deform:")
69 flow = layout.column_flow()
70 flow.prop(arm, "use_deform_vertex_groups", text="Vertex Groups")
71 flow.prop(arm, "use_deform_envelopes", text="Envelopes")
72 flow.prop(arm, "use_deform_preserve_volume", text="Quaternion")
74 if context.scene.render.engine == "BLENDER_GAME":
75 layout.row().prop(arm, "vert_deformer", expand=True)
77 class DATA_PT_display(ArmatureButtonsPanel, Panel):
80 def draw(self, context):
84 arm = context.armature
86 layout.prop(arm, "draw_type", expand=True)
88 split = layout.split()
91 col.prop(arm, "show_names", text="Names")
92 col.prop(arm, "show_axes", text="Axes")
93 col.prop(arm, "show_bone_custom_shapes", text="Shapes")
96 col.prop(arm, "show_group_colors", text="Colors")
98 col.prop(ob, "show_x_ray", text="X-Ray")
99 col.prop(arm, "use_deform_delay", text="Delay Refresh")
102 class DATA_PT_bone_group_specials(Menu):
103 bl_label = "Bone Group Specials"
105 def draw(self, context):
108 layout.operator("pose.group_sort", icon='SORTALPHA')
111 class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
112 bl_label = "Bone Groups"
115 def poll(cls, context):
116 return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
118 def draw(self, context):
123 group = pose.bone_groups.active
130 row.template_list(pose, "bone_groups", pose.bone_groups, "active_index", rows=rows)
132 col = row.column(align=True)
133 col.active = (ob.proxy is None)
134 col.operator("pose.group_add", icon='ZOOMIN', text="")
135 col.operator("pose.group_remove", icon='ZOOMOUT', text="")
136 col.menu("DATA_PT_bone_group_specials", icon='DOWNARROW_HLT', text="")
139 col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
140 col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
143 col = layout.column()
144 col.active = (ob.proxy is None)
145 col.prop(group, "name")
147 split = layout.split()
148 split.active = (ob.proxy is None)
151 col.prop(group, "color_set")
154 sub = col.row(align=True)
155 sub.prop(group.colors, "normal", text="")
156 sub.prop(group.colors, "select", text="")
157 sub.prop(group.colors, "active", text="")
160 row.active = (ob.proxy is None)
162 sub = row.row(align=True)
163 sub.operator("pose.group_assign", text="Assign")
164 sub.operator("pose.group_unassign", text="Remove") # row.operator("pose.bone_group_remove_from", text="Remove")
166 sub = row.row(align=True)
167 sub.operator("pose.group_select", text="Select")
168 sub.operator("pose.group_deselect", text="Deselect")
171 class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
172 bl_label = "Pose Library"
173 bl_options = {'DEFAULT_CLOSED'}
176 def poll(cls, context):
177 return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
179 def draw(self, context):
183 poselib = ob.pose_library
185 layout.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink")
189 row.template_list(poselib, "pose_markers", poselib.pose_markers, "active_index", rows=5)
191 col = row.column(align=True)
192 col.active = (poselib.library is None)
194 # invoke should still be used for 'add', as it is needed to allow
195 # add/replace options to be used properly
196 col.operator("poselib.pose_add", icon='ZOOMIN', text="")
198 col.operator_context = 'EXEC_DEFAULT' # exec not invoke, so that menu doesn't need showing
200 pose_marker_active = poselib.pose_markers.active
202 if pose_marker_active is not None:
203 col.operator("poselib.pose_remove", icon='ZOOMOUT', text="").pose = pose_marker_active.name
204 col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index
206 layout.operator("poselib.action_sanitise")
209 # TODO: this panel will soon be depreceated too
210 class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
213 def draw(self, context):
216 arm = context.armature
218 layout.prop(arm, "ghost_type", expand=True)
220 split = layout.split()
222 col = split.column(align=True)
224 if arm.ghost_type == 'RANGE':
225 col.prop(arm, "ghost_frame_start", text="Start")
226 col.prop(arm, "ghost_frame_end", text="End")
227 col.prop(arm, "ghost_size", text="Step")
228 elif arm.ghost_type == 'CURRENT_FRAME':
229 col.prop(arm, "ghost_step", text="Range")
230 col.prop(arm, "ghost_size", text="Step")
233 col.label(text="Display:")
234 col.prop(arm, "show_only_ghost_selected", text="Selected Only")
237 class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
238 bl_label = "iTaSC parameters"
239 bl_options = {'DEFAULT_CLOSED'}
242 def poll(cls, context):
244 return (ob and ob.pose)
246 def draw(self, context):
250 itasc = ob.pose.ik_param
252 layout.prop(ob.pose, "ik_solver")
255 layout.prop(itasc, "mode", expand=True)
256 simulation = (itasc.mode == 'SIMULATION')
258 layout.label(text="Reiteration:")
259 layout.prop(itasc, "reiteration_method", expand=True)
262 row.active = not simulation or itasc.reiteration_method != 'NEVER'
263 row.prop(itasc, "precision")
264 row.prop(itasc, "iterations")
267 layout.prop(itasc, "use_auto_step")
269 if itasc.use_auto_step:
270 row.prop(itasc, "step_min", text="Min")
271 row.prop(itasc, "step_max", text="Max")
273 row.prop(itasc, "step_count")
275 layout.prop(itasc, "solver")
277 layout.prop(itasc, "feedback")
278 layout.prop(itasc, "velocity_max")
279 if itasc.solver == 'DLS':
281 row.prop(itasc, "damping_max", text="Damp", slider=True)
282 row.prop(itasc, "damping_epsilon", text="Eps", slider=True)
284 from bl_ui.properties_animviz import (
285 MotionPathButtonsPanel,
286 OnionSkinButtonsPanel,
290 class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
291 #bl_label = "Bones Motion Paths"
295 def poll(cls, context):
296 # XXX: include posemode check?
297 return (context.object) and (context.armature)
299 def draw(self, context):
304 self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
308 split = layout.split()
309 split.operator("pose.paths_calculate", text="Calculate Paths")
310 split.operator("pose.paths_clear", text="Clear Paths")
313 class DATA_PT_onion_skinning(OnionSkinButtonsPanel): # , Panel): # inherit from panel when ready
314 #bl_label = "Bones Onion Skinning"
318 def poll(cls, context):
319 # XXX: include posemode check?
320 return (context.object) and (context.armature)
322 def draw(self, context):
324 self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
327 class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
328 COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
329 _context_path = "object.data"
330 _property_type = bpy.types.Armature
332 if __name__ == "__main__": # only for live edit.
333 bpy.utils.register_module(__name__)