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