2.5 - Restoring Bone Groups
[blender-staging.git] / release / ui / buttons_data_armature.py
1
2 import bpy
3  
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "data"
8         
9         def poll(self, context):
10                 return (context.armature != None)
11
12 class DATA_PT_context_arm(DataButtonsPanel):
13         __idname__ = "DATA_PT_context_arm"
14         __no_header__ = True
15         
16         def draw(self, context):
17                 layout = self.layout
18                 
19                 ob = context.object
20                 arm = context.armature
21                 space = context.space_data
22
23                 split = layout.split(percentage=0.65)
24
25                 if ob:
26                         split.template_ID(ob, "data")
27                         split.itemS()
28                 elif arm:
29                         split.template_ID(space, "pin_id")
30                         split.itemS()
31
32 class DATA_PT_skeleton(DataButtonsPanel):
33         __idname__ = "DATA_PT_skeleton"
34         __label__ = "Skeleton"
35         
36         def draw(self, context):
37                 layout = self.layout
38                 
39                 ob = context.object
40                 arm = context.armature
41                 space = context.space_data
42
43
44                 if arm:
45                         split = layout.split()
46
47                         col = split.column()
48                         col.itemR(arm, "rest_position")
49
50                         sub = col.column()
51                         sub.itemL(text="Deform:")
52                         sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups")
53                         sub.itemR(arm, "deform_envelope", text="Envelopes")
54                         sub.itemR(arm, "deform_quaternion", text="Quaternion")
55                         sub.itemR(arm, "deform_bbone_rest", text="B-Bones Rest")
56                         #sub.itemR(arm, "x_axis_mirror")
57                         #sub.itemR(arm, "auto_ik")
58                         
59                         sub = split.column()
60                         sub.itemL(text="Layers:")
61                         sub.template_layers(arm, "layer")
62                         sub.itemL(text="Protected Layers:")
63                         sub.template_layers(arm, "layer_protection")
64
65 class DATA_PT_display(DataButtonsPanel):
66         __idname__ = "DATA_PT_display"
67         __label__ = "Display"
68         
69         def draw(self, context):
70                 layout = self.layout
71                 arm = context.armature
72
73                 layout.row().itemR(arm, "drawtype", expand=True)
74
75                 sub = layout.column_flow()
76                 sub.itemR(arm, "draw_names", text="Names")
77                 sub.itemR(arm, "draw_axes", text="Axes")
78                 sub.itemR(arm, "draw_custom_bone_shapes", text="Shapes")
79                 sub.itemR(arm, "draw_group_colors", text="Colors")
80                 sub.itemR(arm, "delay_deform", text="Delay Refresh")
81
82 class DATA_PT_bone_groups(DataButtonsPanel):
83         __idname__ = "DATA_PT_bone_groups"
84         __label__ = "Bone Groups"
85         
86         def poll(self, context):
87                 return (context.object and context.object.type=='ARMATURE' and context.object.pose)
88
89         def draw(self, context):
90                 layout = self.layout
91                 ob = context.object
92                 pose= ob.pose
93                 
94                 row = layout.row()
95                 
96                 row.template_list(pose, "bone_groups", pose, "active_bone_group_index")
97                 
98                 col = row.column(align=True)
99                 col.itemO("pose.group_add", icon="ICON_ZOOMIN", text="")
100                 col.itemO("pose.group_remove", icon="ICON_ZOOMOUT", text="")
101                 
102                 group = pose.active_bone_group
103                 if group:
104                         row = layout.row()
105                         row.itemR(group, "name")
106                 
107                 row = layout.row(align=True)
108                 
109                 row.itemO("pose.group_assign", text="Assign")
110                 row.itemO("pose.group_remove", text="Remove") #row.itemO("pose.bone_group_remove_from", text="Remove")
111                 #row.itemO("object.bone_group_select", text="Select")
112                 #row.itemO("object.bone_group_deselect", text="Deselect")
113
114 class DATA_PT_paths(DataButtonsPanel):
115         __idname__ = "DATA_PT_paths"
116         __label__ = "Paths"
117
118         def draw(self, context):
119                 layout = self.layout
120                 arm = context.armature
121
122                 split = layout.split()
123                 
124                 sub = split.column()
125                 sub.itemR(arm, "paths_show_around_current_frame", text="Around Frame")
126                 col = sub.column(align=True)
127                 if (arm.paths_show_around_current_frame):
128                         col.itemR(arm, "path_before_current", text="Before")
129                         col.itemR(arm, "path_after_current", text="After")
130                 else:
131                         col.itemR(arm, "path_start_frame", text="Start")
132                         col.itemR(arm, "path_end_frame", text="End")
133
134                 col.itemR(arm, "path_size", text="Step")        
135                 sub.itemR(arm, "paths_calculate_head_positions", text="Head")
136                 
137                 sub = split.column()
138                 sub.itemL(text="Show:")
139                 sub.itemR(arm, "paths_show_frame_numbers", text="Frame Numbers")
140                 sub.itemR(arm, "paths_highlight_keyframes", text="Keyframes")
141                 sub.itemR(arm, "paths_show_keyframe_numbers", text="Keyframe Numbers")
142
143 class DATA_PT_ghost(DataButtonsPanel):
144         __idname__ = "DATA_PT_ghost"
145         __label__ = "Ghost"
146
147         def draw(self, context):
148                 layout = self.layout
149                 arm = context.armature
150
151                 split = layout.split()
152
153                 sub = split.column()
154                 sub.itemR(arm, "ghost_type", text="Scope")
155
156                 col = sub.column(align=True)
157                 if arm.ghost_type == 'RANGE':
158                         col.itemR(arm, "ghost_start_frame", text="Start")
159                         col.itemR(arm, "ghost_end_frame", text="End")
160                         col.itemR(arm, "ghost_size", text="Step")
161                 elif arm.ghost_type == 'CURRENT_FRAME':
162                         col.itemR(arm, "ghost_step", text="Range")
163                         col.itemR(arm, "ghost_size", text="Step")
164
165                 sub = split.column()
166                 sub.itemR(arm, "ghost_only_selected", text="Selected Only")
167
168 bpy.types.register(DATA_PT_context_arm)
169 bpy.types.register(DATA_PT_skeleton)
170 bpy.types.register(DATA_PT_display)
171 bpy.types.register(DATA_PT_bone_groups)
172 bpy.types.register(DATA_PT_paths)
173 bpy.types.register(DATA_PT_ghost)