2.5 UI Files:
[blender.git] / release / scripts / startup / bl_ui / properties_data_armature.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 bpy.types import Panel, Menu
22 from rna_prop_ui import PropertyPanel
23
24
25 class ArmatureButtonsPanel():
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "data"
29
30     @classmethod
31     def poll(cls, context):
32         return context.armature
33
34
35 class DATA_PT_context_arm(ArmatureButtonsPanel, Panel):
36     bl_label = ""
37     bl_options = {'HIDE_HEADER'}
38
39     def draw(self, context):
40         layout = self.layout
41
42         ob = context.object
43         arm = context.armature
44         space = context.space_data
45
46         if ob:
47             layout.template_ID(ob, "data")
48         elif arm:
49             layout.template_ID(space, "pin_id")
50
51
52 class DATA_PT_skeleton(ArmatureButtonsPanel, Panel):
53     bl_label = "Skeleton"
54
55     def draw(self, context):
56         layout = self.layout
57
58         arm = context.armature
59
60         layout.prop(arm, "pose_position", expand=True)
61
62         col = layout.column()
63         col.label(text="Layers:")
64         col.prop(arm, "layers", text="")
65         col.label(text="Protected Layers:")
66         col.prop(arm, "layers_protected", text="")
67
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")
73
74         if context.scene.render.engine == "BLENDER_GAME":
75             layout.row().prop(arm, "vert_deformer", expand=True, text="")
76
77 class DATA_PT_display(ArmatureButtonsPanel, Panel):
78     bl_label = "Display"
79
80     def draw(self, context):
81         layout = self.layout
82
83         ob = context.object
84         arm = context.armature
85
86         layout.prop(arm, "draw_type", expand=True)
87
88         split = layout.split()
89
90         col = split.column()
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")
94
95         col = split.column()
96         col.prop(arm, "show_group_colors", text="Colors")
97         if ob:
98             col.prop(ob, "show_x_ray", text="X-Ray")
99         col.prop(arm, "use_deform_delay", text="Delay Refresh")
100
101
102 class DATA_PT_bone_group_specials(Menu):
103     bl_label = "Bone Group Specials"
104
105     def draw(self, context):
106         layout = self.layout
107
108         layout.operator("pose.group_sort", icon='SORTALPHA')
109
110
111 class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
112     bl_label = "Bone Groups"
113
114     @classmethod
115     def poll(cls, context):
116         return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
117
118     def draw(self, context):
119         layout = self.layout
120
121         ob = context.object
122         pose = ob.pose
123         group = pose.bone_groups.active
124
125         row = layout.row()
126
127         rows = 2
128         if group:
129             rows = 5
130         row.template_list(pose, "bone_groups", pose.bone_groups, "active_index", rows=rows)
131
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="")
137         if group:
138             col.separator()
139             col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
140             col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
141
142         if group:
143             col = layout.column()
144             col.active = (ob.proxy is None)
145             col.prop(group, "name")
146
147             split = layout.split()
148             split.active = (ob.proxy is None)
149
150             col = split.column()
151             col.prop(group, "color_set")
152             if group.color_set:
153                 col = split.column()
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="")
158
159         row = layout.row()
160         row.active = (ob.proxy is None)
161
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")
165
166         sub = row.row(align=True)
167         sub.operator("pose.group_select", text="Select")
168         sub.operator("pose.group_deselect", text="Deselect")
169
170
171 class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
172     bl_label = "Pose Library"
173     bl_options = {'DEFAULT_CLOSED'}
174
175     @classmethod
176     def poll(cls, context):
177         return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
178
179     def draw(self, context):
180         layout = self.layout
181
182         ob = context.object
183         poselib = ob.pose_library
184
185         layout.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink")
186
187         if poselib:
188             row = layout.row()
189             row.template_list(poselib, "pose_markers", poselib.pose_markers, "active_index", rows=5)
190
191             col = row.column(align=True)
192             col.active = (poselib.library is None)
193
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="")
197
198             col.operator_context = 'EXEC_DEFAULT'  # exec not invoke, so that menu doesn't need showing
199
200             pose_marker_active = poselib.pose_markers.active
201
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
205
206             layout.operator("poselib.action_sanitise")
207
208
209 # TODO: this panel will soon be depreceated too
210 class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
211     bl_label = "Ghost"
212
213     def draw(self, context):
214         layout = self.layout
215
216         arm = context.armature
217
218         layout.prop(arm, "ghost_type", expand=True)
219
220         split = layout.split()
221
222         col = split.column(align=True)
223
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")
231
232         col = split.column()
233         col.label(text="Display:")
234         col.prop(arm, "show_only_ghost_selected", text="Selected Only")
235
236
237 class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
238     bl_label = "iTaSC parameters"
239     bl_options = {'DEFAULT_CLOSED'}
240
241     @classmethod
242     def poll(cls, context):
243         ob = context.object
244         return (ob and ob.pose)
245
246     def draw(self, context):
247         layout = self.layout
248
249         ob = context.object
250         itasc = ob.pose.ik_param
251
252         layout.prop(ob.pose, "ik_solver")
253
254         if itasc:
255             layout.prop(itasc, "mode", expand=True)
256             simulation = (itasc.mode == 'SIMULATION')
257             if simulation:
258                 layout.label(text="Reiteration:")
259                 layout.prop(itasc, "reiteration_method", expand=True)
260
261             row = layout.row()
262             row.active = not simulation or itasc.reiteration_method != 'NEVER'
263             row.prop(itasc, "precision")
264             row.prop(itasc, "iterations")
265
266             if simulation:
267                 layout.prop(itasc, "use_auto_step")
268                 row = layout.row()
269                 if itasc.use_auto_step:
270                     row.prop(itasc, "step_min", text="Min")
271                     row.prop(itasc, "step_max", text="Max")
272                 else:
273                     row.prop(itasc, "step_count")
274
275             layout.prop(itasc, "solver")
276             if simulation:
277                 layout.prop(itasc, "feedback")
278                 layout.prop(itasc, "velocity_max")
279             if itasc.solver == 'DLS':
280                 row = layout.row()
281                 row.prop(itasc, "damping_max", text="Damp", slider=True)
282                 row.prop(itasc, "damping_epsilon", text="Eps", slider=True)
283
284 from bl_ui.properties_animviz import (
285     MotionPathButtonsPanel,
286     OnionSkinButtonsPanel,
287     )
288
289
290 class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
291     #bl_label = "Bones Motion Paths"
292     bl_context = "data"
293
294     @classmethod
295     def poll(cls, context):
296         # XXX: include posemode check?
297         return (context.object) and (context.armature)
298
299     def draw(self, context):
300         layout = self.layout
301
302         ob = context.object
303
304         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
305
306         layout.separator()
307
308         split = layout.split()
309         split.operator("pose.paths_calculate", text="Calculate Paths")
310         split.operator("pose.paths_clear", text="Clear Paths")
311
312
313 class DATA_PT_onion_skinning(OnionSkinButtonsPanel):  # , Panel): # inherit from panel when ready
314     #bl_label = "Bones Onion Skinning"
315     bl_context = "data"
316
317     @classmethod
318     def poll(cls, context):
319         # XXX: include posemode check?
320         return (context.object) and (context.armature)
321
322     def draw(self, context):
323         ob = context.object
324         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
325
326
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
331
332 if __name__ == "__main__":  # only for live edit.
333     bpy.utils.register_module(__name__)