2.5: Armature
[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         __idname__ = "BONE_PT_context_bone"
14         __no_header__ = True
15
16         def draw(self, context):
17                 layout = self.layout
18                 bone = context.bone
19                 if not bone:
20                         bone = context.edit_bone
21                 
22                 split = layout.split(percentage=0.06)
23                 split.itemL(text="", icon="ICON_BONE_DATA")
24                 split.itemR(bone, "name", text="")
25
26 class BONE_PT_transform(BoneButtonsPanel):
27         __idname__ = "BONE_PT_transform"
28         __label__ = "Transform"
29
30         def draw(self, context):
31                 layout = self.layout
32                 ob = context.object
33                 bone = context.bone
34
35                 if not bone:
36                         bone = context.edit_bone
37
38                         row = layout.row()
39                         row.column().itemR(bone, "head")
40                         row.column().itemR(bone, "tail")
41
42                         col = row.column()
43                         sub = col.column(align=True)
44                         sub.itemL(text="Roll:")
45                         sub.itemR(bone, "roll", text="")
46                         sub.itemL()
47                         sub.itemR(bone, "locked")
48                         sub.itemS()
49                 else:
50                         pchan = ob.pose.pose_channels[context.bone.name]
51
52                         layout.itemR(pchan, "rotation_mode")
53
54                         row = layout.row()
55                         col = row.column()
56                         col.itemR(pchan, "location")
57                         col.active = not (bone.parent and bone.connected)
58
59                         col = row.column()
60                         if pchan.rotation_mode == 'QUATERNION':
61                                 col.itemR(pchan, "rotation", text="Rotation")
62                         else:
63                                 col.itemR(pchan, "euler_rotation", text="Rotation")
64
65                         row.column().itemR(pchan, "scale")
66
67                         if pchan.rotation_mode == 'QUATERNION':
68                                 col = layout.column(align=True)
69                                 col.itemL(text="Euler:")
70                                 col.row().itemR(pchan, "euler_rotation", text="")
71
72 class BONE_PT_bone(BoneButtonsPanel):
73         __idname__ = "BONE_PT_bone"
74         __label__ = "Bone"
75
76
77         def draw(self, context):
78                 layout = self.layout
79                 bone = context.bone
80                 arm = context.armature
81                 if not bone:
82                         bone = context.edit_bone
83
84                 split = layout.split()
85
86                 sub = split.column()
87                 sub.itemL(text="Parent:")
88                 if context.bone:
89                         sub.itemR(bone, "parent", text="")
90                 else:
91                         sub.item_pointerR(bone, "parent", arm, "edit_bones", text="")
92                 row = sub.row()
93                 row.itemR(bone, "connected")
94                 row.active = bone.parent != None
95
96                 sub.itemL(text="Layers:")
97                 sub.template_layers(bone, "layer")
98
99                 sub = split.column()
100
101                 sub.itemL(text="Inherit:")
102                 sub.itemR(bone, "hinge", text="Rotation")
103                 sub.itemR(bone, "inherit_scale", text="Scale")
104                 
105                 sub.itemL(text="Display:")
106                 sub.itemR(bone, "draw_wire", text="Wireframe")
107                 sub.itemR(bone, "hidden", text="Hide")
108
109 class BONE_PT_deform(BoneButtonsPanel):
110         __idname__ = "BONE_PT_deform"
111         __label__ = "Deform"
112
113         def draw_header(self, context):
114                 layout = self.layout
115                 bone = context.bone
116                 if not bone:
117                         bone = context.edit_bone
118                         
119                 layout.itemR(bone, "deform", text="")
120
121         def draw(self, context):
122                 layout = self.layout
123                 bone = context.bone
124                 if not bone:
125                         bone = context.edit_bone
126         
127                 layout.active = bone.deform
128                         
129                 split = layout.split()
130
131                 col = split.column()
132                 col.itemL(text="Envelope:")
133                 sub = col.column(align=True)
134                 sub.itemR(bone, "envelope_distance", text="Distance")
135                 sub.itemR(bone, "envelope_weight", text="Weight")
136                 col.itemR(bone, "multiply_vertexgroup_with_envelope", text="Multiply")
137
138                 sub = col.column(align=True)
139                 sub.itemL(text="Radius:")
140                 sub.itemR(bone, "head_radius", text="Head")
141                 sub.itemR(bone, "tail_radius", text="Tail")
142
143                 col = split.column()
144                 col.itemL(text="Curved Bones:")
145                 sub = col.column(align=True)
146                 sub.itemR(bone, "bbone_segments", text="Segments")
147                 sub.itemR(bone, "bbone_in", text="Ease In")
148                 sub.itemR(bone, "bbone_out", text="Ease Out")
149                 
150                 col.itemL(text="Offset:")
151                 col.itemR(bone, "cyclic_offset")
152
153 bpy.types.register(BONE_PT_context_bone)
154 bpy.types.register(BONE_PT_transform)
155 bpy.types.register(BONE_PT_bone)
156 bpy.types.register(BONE_PT_deform)
157