remove use of gettext: _("...") style translation now its handled by rna.
[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)
76
77
78 class DATA_PT_display(ArmatureButtonsPanel, Panel):
79     bl_label = "Display"
80
81     def draw(self, context):
82         layout = self.layout
83
84         ob = context.object
85         arm = context.armature
86
87         layout.prop(arm, "draw_type", expand=True)
88
89         split = layout.split()
90
91         col = split.column()
92         col.prop(arm, "show_names", text="Names")
93         col.prop(arm, "show_axes", text="Axes")
94         col.prop(arm, "show_bone_custom_shapes", text="Shapes")
95
96         col = split.column()
97         col.prop(arm, "show_group_colors", text="Colors")
98         if ob:
99             col.prop(ob, "show_x_ray", text="X-Ray")
100         col.prop(arm, "use_deform_delay", text="Delay Refresh")
101
102
103 class DATA_PT_bone_group_specials(Menu):
104     bl_label = "Bone Group Specials"
105
106     def draw(self, context):
107         layout = self.layout
108
109         layout.operator("pose.group_sort", icon='SORTALPHA')
110
111
112 class DATA_PT_bone_groups(ArmatureButtonsPanel, Panel):
113     bl_label = "Bone Groups"
114
115     @classmethod
116     def poll(cls, context):
117         return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
118
119     def draw(self, context):
120         layout = self.layout
121
122         ob = context.object
123         pose = ob.pose
124         group = pose.bone_groups.active
125
126         row = layout.row()
127
128         rows = 2
129         if group:
130             rows = 5
131         row.template_list(pose, "bone_groups", pose.bone_groups, "active_index", rows=rows)
132
133         col = row.column(align=True)
134         col.active = (ob.proxy is None)
135         col.operator("pose.group_add", icon='ZOOMIN', text="")
136         col.operator("pose.group_remove", icon='ZOOMOUT', text="")
137         col.menu("DATA_PT_bone_group_specials", icon='DOWNARROW_HLT', text="")
138         if group:
139             col.separator()
140             col.operator("pose.group_move", icon='TRIA_UP', text="").direction = 'UP'
141             col.operator("pose.group_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
142
143         if group:
144             col = layout.column()
145             col.active = (ob.proxy is None)
146             col.prop(group, "name")
147
148             split = layout.split()
149             split.active = (ob.proxy is None)
150
151             col = split.column()
152             col.prop(group, "color_set")
153             if group.color_set:
154                 col = split.column()
155                 sub = col.row(align=True)
156                 sub.prop(group.colors, "normal", text="")
157                 sub.prop(group.colors, "select", text="")
158                 sub.prop(group.colors, "active", text="")
159
160         row = layout.row()
161         row.active = (ob.proxy is None)
162
163         sub = row.row(align=True)
164         sub.operator("pose.group_assign", text="Assign")
165         sub.operator("pose.group_unassign", text="Remove")  # row.operator("pose.bone_group_remove_from", text="Remove")
166
167         sub = row.row(align=True)
168         sub.operator("pose.group_select", text="Select")
169         sub.operator("pose.group_deselect", text="Deselect")
170
171
172 class DATA_PT_pose_library(ArmatureButtonsPanel, Panel):
173     bl_label = "Pose Library"
174     bl_options = {'DEFAULT_CLOSED'}
175
176     @classmethod
177     def poll(cls, context):
178         return (context.object and context.object.type == 'ARMATURE' and context.object.pose)
179
180     def draw(self, context):
181         layout = self.layout
182
183         ob = context.object
184         poselib = ob.pose_library
185
186         layout.template_ID(ob, "pose_library", new="poselib.new", unlink="poselib.unlink")
187
188         if poselib:
189             # list of poses in pose library
190             row = layout.row()
191             row.template_list(poselib, "pose_markers", poselib.pose_markers, "active_index", rows=5)
192
193             # column of operators for active pose
194             # - goes beside list
195             col = row.column(align=True)
196             col.active = (poselib.library is None)
197
198             # invoke should still be used for 'add', as it is needed to allow
199             # add/replace options to be used properly
200             col.operator("poselib.pose_add", icon='ZOOMIN', text="")
201
202             col.operator_context = 'EXEC_DEFAULT'  # exec not invoke, so that menu doesn't need showing
203
204             pose_marker_active = poselib.pose_markers.active
205
206             if pose_marker_active is not None:
207                 col.operator("poselib.pose_remove", icon='ZOOMOUT', text="").pose = pose_marker_active.name
208                 col.operator("poselib.apply_pose", icon='ZOOM_SELECTED', text="").pose_index = poselib.pose_markers.active_index
209
210             col.operator("poselib.action_sanitise", icon='HELP', text="")  # XXX: put in menu?
211
212             # properties for active marker
213             if pose_marker_active is not None:
214                 layout.prop(pose_marker_active, "name")
215
216
217 # TODO: this panel will soon be depreceated too
218 class DATA_PT_ghost(ArmatureButtonsPanel, Panel):
219     bl_label = "Ghost"
220
221     def draw(self, context):
222         layout = self.layout
223
224         arm = context.armature
225
226         layout.prop(arm, "ghost_type", expand=True)
227
228         split = layout.split()
229
230         col = split.column(align=True)
231
232         if arm.ghost_type == 'RANGE':
233             col.prop(arm, "ghost_frame_start", text="Start")
234             col.prop(arm, "ghost_frame_end", text="End")
235             col.prop(arm, "ghost_size", text="Step")
236         elif arm.ghost_type == 'CURRENT_FRAME':
237             col.prop(arm, "ghost_step", text="Range")
238             col.prop(arm, "ghost_size", text="Step")
239
240         col = split.column()
241         col.label(text="Display:")
242         col.prop(arm, "show_only_ghost_selected", text="Selected Only")
243
244
245 class DATA_PT_iksolver_itasc(ArmatureButtonsPanel, Panel):
246     bl_label = "iTaSC parameters"
247     bl_options = {'DEFAULT_CLOSED'}
248
249     @classmethod
250     def poll(cls, context):
251         ob = context.object
252         return (ob and ob.pose)
253
254     def draw(self, context):
255         layout = self.layout
256
257         ob = context.object
258         itasc = ob.pose.ik_param
259
260         layout.prop(ob.pose, "ik_solver")
261
262         if itasc:
263             layout.prop(itasc, "mode", expand=True)
264             simulation = (itasc.mode == 'SIMULATION')
265             if simulation:
266                 layout.label(text="Reiteration:")
267                 layout.prop(itasc, "reiteration_method", expand=True)
268
269             row = layout.row()
270             row.active = not simulation or itasc.reiteration_method != 'NEVER'
271             row.prop(itasc, "precision")
272             row.prop(itasc, "iterations")
273
274             if simulation:
275                 layout.prop(itasc, "use_auto_step")
276                 row = layout.row()
277                 if itasc.use_auto_step:
278                     row.prop(itasc, "step_min", text="Min")
279                     row.prop(itasc, "step_max", text="Max")
280                 else:
281                     row.prop(itasc, "step_count")
282
283             layout.prop(itasc, "solver")
284             if simulation:
285                 layout.prop(itasc, "feedback")
286                 layout.prop(itasc, "velocity_max")
287             if itasc.solver == 'DLS':
288                 row = layout.row()
289                 row.prop(itasc, "damping_max", text="Damp", slider=True)
290                 row.prop(itasc, "damping_epsilon", text="Eps", slider=True)
291
292 from bl_ui.properties_animviz import (
293     MotionPathButtonsPanel,
294     OnionSkinButtonsPanel,
295     )
296
297
298 class DATA_PT_motion_paths(MotionPathButtonsPanel, Panel):
299     #bl_label = "Bones Motion Paths"
300     bl_context = "data"
301
302     @classmethod
303     def poll(cls, context):
304         # XXX: include posemode check?
305         return (context.object) and (context.armature)
306
307     def draw(self, context):
308         layout = self.layout
309
310         ob = context.object
311
312         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
313
314         layout.separator()
315
316         split = layout.split()
317         split.operator("pose.paths_calculate", text="Calculate Paths")
318         split.operator("pose.paths_clear", text="Clear Paths")
319
320
321 class DATA_PT_onion_skinning(OnionSkinButtonsPanel):  # , Panel): # inherit from panel when ready
322     #bl_label = "Bones Onion Skinning"
323     bl_context = "data"
324
325     @classmethod
326     def poll(cls, context):
327         # XXX: include posemode check?
328         return (context.object) and (context.armature)
329
330     def draw(self, context):
331         ob = context.object
332         self.draw_settings(context, ob.pose.animation_visualisation, bones=True)
333
334
335 class DATA_PT_custom_props_arm(ArmatureButtonsPanel, PropertyPanel, Panel):
336     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_GAME'}
337     _context_path = "object.data"
338     _property_type = bpy.types.Armature
339
340 if __name__ == "__main__":  # only for live edit.
341     bpy.utils.register_module(__name__)