Move Inverse Kinematics panel to Constraint context. Make iTaSC parameter panel more...
[blender-staging.git] / release / scripts / ui / buttons_data_bone.py
1
2 import bpy
3  
4 class BoneButtonsPanel(bpy.types.Panel):
5         __space_type__ = 'PROPERTIES'
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                 
18                 bone = context.bone
19                 if not bone:
20                         bone = context.edit_bone
21                 
22                 row = layout.row()
23                 row.itemL(text="", icon='ICON_BONE_DATA')
24                 row.itemR(bone, "name", text="")
25
26 class BONE_PT_transform(BoneButtonsPanel):
27         __label__ = "Transform"
28
29         def draw(self, context):
30                 layout = self.layout
31                 
32                 ob = context.object
33                 bone = context.bone
34                 if not bone:
35                         bone = context.edit_bone
36
37                         row = layout.row()
38                         row.column().itemR(bone, "head")
39                         row.column().itemR(bone, "tail")
40
41                         col = row.column()
42                         sub = col.column(align=True)
43                         sub.itemL(text="Roll:")
44                         sub.itemR(bone, "roll", text="")
45                         sub.itemL()
46                         sub.itemR(bone, "locked")
47
48                 else:
49                         pchan = ob.pose.pose_channels[context.bone.name]
50
51                         layout.itemR(pchan, "rotation_mode")
52
53                         row = layout.row()
54                         col = row.column()
55                         col.itemR(pchan, "location")
56                         col.active = not (bone.parent and bone.connected)
57
58                         col = row.column()
59                         if pchan.rotation_mode == 'QUATERNION':
60                                 col.itemR(pchan, "rotation_quaternion", text="Rotation")
61                         elif pchan.rotation_mode == 'AXIS_ANGLE':
62                                 #col.itemL(text="Rotation")
63                                 #col.itemR(pchan, "rotation_angle", text="Angle")
64                                 #col.itemR(pchan, "rotation_axis", text="Axis")
65                                 col.itemR(pchan, "rotation_axis_angle", text="Rotation")
66                         else:
67                                 col.itemR(pchan, "rotation_euler", text="Rotation")
68
69                         row.column().itemR(pchan, "scale")
70                                 
71 class BONE_PT_transform_locks(BoneButtonsPanel):
72         __label__ = "Transform Locks"
73         __default_closed__ = True
74         
75         def poll(self, context):
76                 return context.bone
77         
78         def draw(self, context):
79                 layout = self.layout
80                 
81                 ob = context.object
82                 bone = context.bone
83                 pchan = ob.pose.pose_channels[context.bone.name]
84                 
85                 row = layout.row()
86                 col = row.column()
87                 col.itemR(pchan, "lock_location")
88                 col.active = not (bone.parent and bone.connected)
89                 
90                 col = row.column()
91                 if pchan.rotation_mode in ('QUATERNION', 'AXIS_ANGLE'):
92                         col.itemR(pchan, "lock_rotations_4d", text="Lock Rotation")
93                         if pchan.lock_rotations_4d:
94                                 col.itemR(pchan, "lock_rotation_w", text="W")
95                         col.itemR(pchan, "lock_rotation", text="")
96                 else:
97                         col.itemR(pchan, "lock_rotation", text="Rotation")
98                 
99                 row.column().itemR(pchan, "lock_scale")
100
101 class BONE_PT_bone(BoneButtonsPanel):
102         __label__ = "Bone"
103
104         def draw(self, context):
105                 layout = self.layout
106                 
107                 ob = context.object
108                 bone = context.bone
109                 arm = context.armature
110                 
111                 if not bone:
112                         bone = context.edit_bone
113                         pchan = None
114                 else:
115                         pchan = ob.pose.pose_channels[context.bone.name]
116
117                 split = layout.split()
118
119                 col = split.column()
120                 col.itemL(text="Parent:")
121                 if context.bone:
122                         col.itemR(bone, "parent", text="")
123                 else:
124                         col.item_pointerR(bone, "parent", arm, "edit_bones", text="")
125                 
126                 row = col.row()
127                 row.active = bone.parent != None
128                 row.itemR(bone, "connected")
129                 
130                 col.itemL(text="Layers:")
131                 col.itemR(bone, "layer", text="")
132                 
133                 col = split.column()
134                 col.itemL(text="Inherit:")
135                 col.itemR(bone, "hinge", text="Rotation")
136                 col.itemR(bone, "inherit_scale", text="Scale")
137                 col.itemL(text="Display:")
138                 col.itemR(bone, "draw_wire", text="Wireframe")
139                 col.itemR(bone, "hidden", text="Hide")
140                 
141                 if ob and pchan:
142                         split = layout.split()
143                         
144                         col = split.column()
145                         col.itemL(text="Bone Group:")
146                         col.item_pointerR(pchan, "bone_group", ob.pose, "bone_groups", text="")
147                         
148                         col = split.column()
149                         col.itemL(text="Custom Shape:")
150                         col.itemR(pchan, "custom_shape", text="")
151
152 class BONE_PT_deform(BoneButtonsPanel):
153         __label__ = "Deform"
154         __default_closed__ = True
155
156         def draw_header(self, context):
157                 bone = context.bone
158                 
159                 if not bone:
160                         bone = context.edit_bone
161                         
162                 self.layout.itemR(bone, "deform", text="")
163
164         def draw(self, context):
165                 layout = self.layout
166                 
167                 bone = context.bone
168                 
169                 if not bone:
170                         bone = context.edit_bone
171         
172                 layout.active = bone.deform
173                         
174                 split = layout.split()
175
176                 col = split.column()
177                 col.itemL(text="Envelope:")
178                 
179                 sub = col.column(align=True)
180                 sub.itemR(bone, "envelope_distance", text="Distance")
181                 sub.itemR(bone, "envelope_weight", text="Weight")
182                 col.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
183
184                 sub = col.column(align=True)
185                 sub.itemL(text="Radius:")
186                 sub.itemR(bone, "head_radius", text="Head")
187                 sub.itemR(bone, "tail_radius", text="Tail")
188
189                 col = split.column()
190                 col.itemL(text="Curved Bones:")
191                 
192                 sub = col.column(align=True)
193                 sub.itemR(bone, "bbone_segments", text="Segments")
194                 sub.itemR(bone, "bbone_in", text="Ease In")
195                 sub.itemR(bone, "bbone_out", text="Ease Out")
196                 
197                 col.itemL(text="Offset:")
198                 col.itemR(bone, "cyclic_offset")
199
200
201 bpy.types.register(BONE_PT_context_bone)
202 bpy.types.register(BONE_PT_transform)
203 bpy.types.register(BONE_PT_transform_locks)
204 bpy.types.register(BONE_PT_bone)
205 bpy.types.register(BONE_PT_deform)