0f072b3607d97e7948725b9da032fa67bc519499
[blender-staging.git] / release / ui / buttons_data_bone.py
1
2 import bpy
3  
4 class BoneButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "bone"
8         
9         def poll(self, context):
10                 return (context.bone or context.edit_bone)
11
12 class BONE_PT_context_bone(BoneButtonsPanel):
13         __show_header__ = False
14
15         def draw(self, context):
16                 layout = self.layout
17                 bone = context.bone
18                 if not bone:
19                         bone = context.edit_bone
20                 
21                 row = layout.row()
22                 row.itemL(text="", icon="ICON_BONE_DATA")
23                 row.itemR(bone, "name", text="")
24
25 class BONE_PT_transform(BoneButtonsPanel):
26         __label__ = "Transform"
27
28         def draw(self, context):
29                 layout = self.layout
30                 ob = context.object
31                 bone = context.bone
32
33                 if not bone:
34                         bone = context.edit_bone
35
36                         row = layout.row()
37                         row.column().itemR(bone, "head")
38                         row.column().itemR(bone, "tail")
39
40                         col = row.column()
41                         sub = col.column(align=True)
42                         sub.itemL(text="Roll:")
43                         sub.itemR(bone, "roll", text="")
44                         sub.itemL()
45                         sub.itemR(bone, "locked")
46                         sub.itemS()
47                 else:
48                         pchan = ob.pose.pose_channels[context.bone.name]
49
50                         layout.itemR(pchan, "rotation_mode")
51
52                         row = layout.row()
53                         col = row.column()
54                         col.itemR(pchan, "location")
55                         col.active = not (bone.parent and bone.connected)
56
57                         col = row.column()
58                         if pchan.rotation_mode == 'QUATERNION':
59                                 col.itemR(pchan, "rotation", text="Rotation")
60                         else:
61                                 col.itemR(pchan, "euler_rotation", text="Rotation")
62
63                         row.column().itemR(pchan, "scale")
64
65                         if pchan.rotation_mode == 'QUATERNION':
66                                 col = layout.column(align=True)
67                                 col.itemL(text="Euler:")
68                                 col.row().itemR(pchan, "euler_rotation", text="")
69
70 class BONE_PT_bone(BoneButtonsPanel):
71         __label__ = "Bone"
72
73
74         def draw(self, context):
75                 layout = self.layout
76                 bone = context.bone
77                 arm = context.armature
78                 if not bone:
79                         bone = context.edit_bone
80
81                 split = layout.split()
82
83                 sub = split.column()
84                 sub.itemL(text="Parent:")
85                 if context.bone:
86                         sub.itemR(bone, "parent", text="")
87                 else:
88                         sub.item_pointerR(bone, "parent", arm, "edit_bones", text="")
89                 row = sub.row()
90                 row.itemR(bone, "connected")
91                 row.active = bone.parent != None
92
93                 sub.itemL(text="Layers:")
94                 sub.template_layers(bone, "layer")
95
96                 sub = split.column()
97
98                 sub.itemL(text="Inherit:")
99                 sub.itemR(bone, "hinge", text="Rotation")
100                 sub.itemR(bone, "inherit_scale", text="Scale")
101                 
102                 sub.itemL(text="Display:")
103                 sub.itemR(bone, "draw_wire", text="Wireframe")
104                 sub.itemR(bone, "hidden", text="Hide")
105
106 class BONE_PT_inverse_kinematics(BoneButtonsPanel):
107         __label__ = "Inverse Kinematics"
108         __default_closed__ = True
109         
110         def poll(self, context):
111                 ob = context.object
112                 bone = context.bone
113
114                 if ob and context.bone:
115                         pchan = ob.pose.pose_channels[context.bone.name]
116                         return pchan.has_ik
117                 
118                 return False
119
120         def draw(self, context):
121                 layout = self.layout
122                 ob = context.object
123                 bone = context.bone
124                 pchan = ob.pose.pose_channels[context.bone.name]
125
126                 split = layout.split(percentage=0.25)
127                 split.itemR(pchan, "ik_dof_x", text="X")
128                 row = split.row()
129                 row.itemR(pchan, "ik_stiffness_x", text="Stiffness")
130                 row.active = pchan.ik_dof_x
131
132                 split = layout.split(percentage=0.25)
133                 row = split.row()
134                 row.itemR(pchan, "ik_limit_x", text="Limit")
135                 row.active = pchan.ik_dof_x
136                 row = split.row(align=True)
137                 row.itemR(pchan, "ik_min_x", text="")
138                 row.itemR(pchan, "ik_max_x", text="")
139                 row.active = pchan.ik_dof_x and pchan.ik_limit_x
140
141                 split = layout.split(percentage=0.25)
142                 split.itemR(pchan, "ik_dof_y", text="Y")
143                 row = split.row()
144                 row.itemR(pchan, "ik_stiffness_y", text="Stiffness")
145                 row.active = pchan.ik_dof_y
146
147                 split = layout.split(percentage=0.25)
148                 row = split.row()
149                 row.itemR(pchan, "ik_limit_y", text="Limit")
150                 row.active = pchan.ik_dof_y
151                 row = split.row(align=True)
152                 row.itemR(pchan, "ik_min_y", text="")
153                 row.itemR(pchan, "ik_max_y", text="")
154                 row.active = pchan.ik_dof_y and pchan.ik_limit_y
155
156                 split = layout.split(percentage=0.25)
157                 split.itemR(pchan, "ik_dof_z", text="Z")
158                 row = split.row()
159                 row.itemR(pchan, "ik_stiffness_z", text="Stiffness")
160                 row.active = pchan.ik_dof_z
161
162                 split = layout.split(percentage=0.25)
163                 row = split.row()
164                 row.itemR(pchan, "ik_limit_z", text="Limit")
165                 row.active = pchan.ik_dof_z
166                 row = split.row(align=True)
167                 row.itemR(pchan, "ik_min_z", text="")
168                 row.itemR(pchan, "ik_max_z", text="")
169                 row.active = pchan.ik_dof_z and pchan.ik_limit_z
170
171                 split = layout.split()
172                 split.itemR(pchan, "ik_stretch", text="Stretch")
173                 split.itemL()
174
175 class BONE_PT_deform(BoneButtonsPanel):
176         __label__ = "Deform"
177         __default_closed__ = True
178
179         def draw_header(self, context):
180                 layout = self.layout
181                 bone = context.bone
182                 if not bone:
183                         bone = context.edit_bone
184                         
185                 layout.itemR(bone, "deform", text="")
186
187         def draw(self, context):
188                 layout = self.layout
189                 bone = context.bone
190                 if not bone:
191                         bone = context.edit_bone
192         
193                 layout.active = bone.deform
194                         
195                 split = layout.split()
196
197                 col = split.column()
198                 col.itemL(text="Envelope:")
199                 sub = col.column(align=True)
200                 sub.itemR(bone, "envelope_distance", text="Distance")
201                 sub.itemR(bone, "envelope_weight", text="Weight")
202                 col.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
203
204                 sub = col.column(align=True)
205                 sub.itemL(text="Radius:")
206                 sub.itemR(bone, "head_radius", text="Head")
207                 sub.itemR(bone, "tail_radius", text="Tail")
208
209                 col = split.column()
210                 col.itemL(text="Curved Bones:")
211                 sub = col.column(align=True)
212                 sub.itemR(bone, "bbone_segments", text="Segments")
213                 sub.itemR(bone, "bbone_in", text="Ease In")
214                 sub.itemR(bone, "bbone_out", text="Ease Out")
215                 
216                 col.itemL(text="Offset:")
217                 col.itemR(bone, "cyclic_offset")
218
219 bpy.types.register(BONE_PT_context_bone)
220 bpy.types.register(BONE_PT_transform)
221 bpy.types.register(BONE_PT_bone)
222 bpy.types.register(BONE_PT_deform)
223 bpy.types.register(BONE_PT_inverse_kinematics)
224