rna UI api rename...
[blender.git] / release / scripts / 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21
22 narrowui = 180
23
24
25 class DataButtonsPanel(bpy.types.Panel):
26     bl_space_type = 'PROPERTIES'
27     bl_region_type = 'WINDOW'
28     bl_context = "data"
29
30     def poll(self, context):
31         return context.armature
32
33
34 class DATA_PT_context_arm(DataButtonsPanel):
35     bl_label = ""
36     bl_show_header = False
37
38     def draw(self, context):
39         layout = self.layout
40
41         ob = context.object
42         arm = context.armature
43         space = context.space_data
44         wide_ui = context.region.width > narrowui
45
46         if wide_ui:
47             split = layout.split(percentage=0.65)
48             if ob:
49                 split.template_ID(ob, "data")
50                 split.separator()
51             elif arm:
52                 split.template_ID(space, "pin_id")
53                 split.separator()
54         else:
55             layout.template_ID(ob, "data")
56
57
58 class DATA_PT_skeleton(DataButtonsPanel):
59     bl_label = "Skeleton"
60
61     def draw(self, context):
62         layout = self.layout
63
64         arm = context.armature
65         wide_ui = context.region.width > narrowui
66
67         layout.prop(arm, "pose_position", expand=True)
68
69         split = layout.split()
70
71         col = split.column()
72         col.label(text="Layers:")
73         col.prop(arm, "layer", text="")
74         col.label(text="Protected Layers:")
75         col.prop(arm, "layer_protection", text="")
76
77         if wide_ui:
78             col = split.column()
79         col.label(text="Deform:")
80         col.prop(arm, "deform_vertexgroups", text="Vertex Groups")
81         col.prop(arm, "deform_envelope", text="Envelopes")
82         col.prop(arm, "deform_quaternion", text="Quaternion")
83         col.prop(arm, "deform_bbone_rest", text="B-Bones Rest")
84
85
86 class DATA_PT_display(DataButtonsPanel):
87     bl_label = "Display"
88
89     def draw(self, context):
90         layout = self.layout
91
92         arm = context.armature
93         wide_ui = context.region.width > narrowui
94
95         if wide_ui:
96             layout.row().prop(arm, "drawtype", expand=True)
97         else:
98             layout.row().prop(arm, "drawtype", text="")
99
100         split = layout.split()
101
102         col = split.column()
103         col.prop(arm, "draw_names", text="Names")
104         col.prop(arm, "draw_axes", text="Axes")
105         col.prop(arm, "draw_custom_bone_shapes", text="Shapes")
106
107         if wide_ui:
108             col = split.column()
109         col.prop(arm, "draw_group_colors", text="Colors")
110         col.prop(arm, "delay_deform", text="Delay Refresh")
111
112
113 class DATA_PT_bone_groups(DataButtonsPanel):
114     bl_label = "Bone Groups"
115
116     def poll(self, 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         wide_ui = context.region.width > narrowui
125
126         row = layout.row()
127         row.template_list(pose, "bone_groups", pose, "active_bone_group_index", rows=2)
128
129         col = row.column(align=True)
130         col.active = (ob.proxy is None)
131         col.operator("pose.group_add", icon='ICON_ZOOMIN', text="")
132         col.operator("pose.group_remove", icon='ICON_ZOOMOUT', text="")
133
134         group = pose.active_bone_group
135         if group:
136             col = layout.column()
137             col.active = (ob.proxy is None)
138             col.prop(group, "name")
139
140             split = layout.split()
141             split.active = (ob.proxy is None)
142
143             col = split.column()
144             col.prop(group, "color_set")
145             if group.color_set:
146                 if wide_ui:
147                     col = split.column()
148                 col.template_triColorSet(group, "colors")
149
150         row = layout.row(align=True)
151         row.active = (ob.proxy is None)
152
153         row.operator("pose.group_assign", text="Assign")
154         row.operator("pose.group_remove", text="Remove") #row.operator("pose.bone_group_remove_from", text="Remove")
155         #row.operator("object.bone_group_select", text="Select")
156         #row.operator("object.bone_group_deselect", text="Deselect")
157
158
159 class DATA_PT_paths(DataButtonsPanel):
160     bl_label = "Paths"
161
162     def draw(self, context):
163         layout = self.layout
164
165         arm = context.armature
166         wide_ui = context.region.width > narrowui
167
168         if wide_ui:
169             layout.prop(arm, "paths_type", expand=True)
170         else:
171             layout.prop(arm, "paths_type", text="")
172
173         split = layout.split()
174
175         col = split.column()
176         sub = col.column(align=True)
177         if (arm.paths_type == 'CURRENT_FRAME'):
178             sub.prop(arm, "path_before_current", text="Before")
179             sub.prop(arm, "path_after_current", text="After")
180         elif (arm.paths_type == 'RANGE'):
181             sub.prop(arm, "path_start_frame", text="Start")
182             sub.prop(arm, "path_end_frame", text="End")
183
184         sub.prop(arm, "path_size", text="Step")
185         col.row().prop(arm, "paths_location", expand=True)
186
187         if wide_ui:
188             col = split.column()
189         col.label(text="Display:")
190         col.prop(arm, "paths_show_frame_numbers", text="Frame Numbers")
191         col.prop(arm, "paths_highlight_keyframes", text="Keyframes")
192         col.prop(arm, "paths_show_keyframe_numbers", text="Keyframe Numbers")
193
194         layout.separator()
195
196         split = layout.split()
197
198         col = split.column()
199         col.operator("pose.paths_calculate", text="Calculate Paths")
200
201         if wide_ui:
202             col = split.column()
203         col.operator("pose.paths_clear", text="Clear Paths")
204
205
206 class DATA_PT_ghost(DataButtonsPanel):
207     bl_label = "Ghost"
208
209     def draw(self, context):
210         layout = self.layout
211
212         arm = context.armature
213         wide_ui = context.region.width > narrowui
214
215         if wide_ui:
216             layout.prop(arm, "ghost_type", expand=True)
217         else:
218             layout.prop(arm, "ghost_type", text="")
219
220         split = layout.split()
221
222         col = split.column()
223
224         sub = col.column(align=True)
225         if arm.ghost_type == 'RANGE':
226             sub.prop(arm, "ghost_start_frame", text="Start")
227             sub.prop(arm, "ghost_end_frame", text="End")
228             sub.prop(arm, "ghost_size", text="Step")
229         elif arm.ghost_type == 'CURRENT_FRAME':
230             sub.prop(arm, "ghost_step", text="Range")
231             sub.prop(arm, "ghost_size", text="Step")
232
233         if wide_ui:
234             col = split.column()
235         col.label(text="Display:")
236         col.prop(arm, "ghost_only_selected", text="Selected Only")
237
238 bpy.types.register(DATA_PT_context_arm)
239 bpy.types.register(DATA_PT_skeleton)
240 bpy.types.register(DATA_PT_display)
241 bpy.types.register(DATA_PT_bone_groups)
242 bpy.types.register(DATA_PT_paths)
243 bpy.types.register(DATA_PT_ghost)