34a6964ef23c95e173b02a32a878ca61fc5c798c
[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         __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
42                 if arm:
43                         split = layout.split()
44
45                         col = split.column()
46                         col.itemR(arm, "rest_position")
47
48                         sub = col.column()
49                         sub.itemL(text="Deform:")
50                         sub.itemR(arm, "deform_vertexgroups", text="Vertes Groups")
51                         sub.itemR(arm, "deform_envelope", text="Envelopes")
52                         sub.itemR(arm, "deform_quaternion", text="Quaternion")
53                         sub.itemR(arm, "deform_bbone_rest", text="B-Bones Rest")
54                         #sub.itemR(arm, "x_axis_mirror")
55                         #sub.itemR(arm, "auto_ik")
56                         
57                         sub = split.column()
58                         sub.itemL(text="Layers:")
59                         sub.template_layers(arm, "layer")
60                         sub.itemL(text="Protected Layers:")
61                         sub.template_layers(arm, "layer_protection")
62
63 class DATA_PT_display(DataButtonsPanel):
64         __label__ = "Display"
65         
66         def draw(self, context):
67                 layout = self.layout
68                 arm = context.armature
69
70                 layout.row().itemR(arm, "drawtype", expand=True)
71
72                 sub = layout.column_flow()
73                 sub.itemR(arm, "draw_names", text="Names")
74                 sub.itemR(arm, "draw_axes", text="Axes")
75                 sub.itemR(arm, "draw_custom_bone_shapes", text="Shapes")
76                 sub.itemR(arm, "draw_group_colors", text="Colors")
77                 sub.itemR(arm, "delay_deform", text="Delay Refresh")
78
79 class DATA_PT_bone_groups(DataButtonsPanel):
80         __label__ = "Bone Groups"
81         
82         def poll(self, context):
83                 return (context.object and context.object.type=='ARMATURE' and context.object.pose)
84
85         def draw(self, context):
86                 layout = self.layout
87                 ob = context.object
88                 pose= ob.pose
89                 
90                 row = layout.row()
91                 
92                 row.template_list(pose, "bone_groups", pose, "active_bone_group_index")
93                 
94                 col = row.column(align=True)
95                 col.active = (ob.proxy == None)
96                 col.itemO("pose.group_add", icon="ICON_ZOOMIN", text="")
97                 col.itemO("pose.group_remove", icon="ICON_ZOOMOUT", text="")
98                 
99                 group = pose.active_bone_group
100                 if group:
101                         col = layout.column()
102                         col.active= (ob.proxy == None)
103                         col.itemR(group, "name")
104                         
105                         split = layout.split(0.5)
106                         split.active= (ob.proxy == None)
107                         split.itemR(group, "color_set")
108                         if group.color_set:
109                                 split.template_triColorSet(group, "colors")
110                 
111                 row = layout.row(align=True)
112                 row.active= (ob.proxy == None)
113                 
114                 row.itemO("pose.group_assign", text="Assign")
115                 row.itemO("pose.group_remove", text="Remove") #row.itemO("pose.bone_group_remove_from", text="Remove")
116                 #row.itemO("object.bone_group_select", text="Select")
117                 #row.itemO("object.bone_group_deselect", text="Deselect")
118
119 class DATA_PT_paths(DataButtonsPanel):
120         __label__ = "Paths"
121
122         def draw(self, context):
123                 layout = self.layout
124                 arm = context.armature
125
126                 split = layout.split()
127                 
128                 sub = split.column()
129                 sub.itemR(arm, "paths_show_around_current_frame", text="Around Frame")
130                 col = sub.column(align=True)
131                 if (arm.paths_show_around_current_frame):
132                         col.itemR(arm, "path_before_current", text="Before")
133                         col.itemR(arm, "path_after_current", text="After")
134                 else:
135                         col.itemR(arm, "path_start_frame", text="Start")
136                         col.itemR(arm, "path_end_frame", text="End")
137
138                 col.itemR(arm, "path_size", text="Step")        
139                 sub.itemR(arm, "paths_calculate_head_positions", text="Head")
140                 
141                 sub = split.column()
142                 sub.itemL(text="Show:")
143                 sub.itemR(arm, "paths_show_frame_numbers", text="Frame Numbers")
144                 sub.itemR(arm, "paths_highlight_keyframes", text="Keyframes")
145                 sub.itemR(arm, "paths_show_keyframe_numbers", text="Keyframe Numbers")
146
147 class DATA_PT_ghost(DataButtonsPanel):
148         __label__ = "Ghost"
149
150         def draw(self, context):
151                 layout = self.layout
152                 arm = context.armature
153
154                 split = layout.split()
155
156                 sub = split.column()
157                 sub.itemR(arm, "ghost_type", text="Scope")
158
159                 col = sub.column(align=True)
160                 if arm.ghost_type == 'RANGE':
161                         col.itemR(arm, "ghost_start_frame", text="Start")
162                         col.itemR(arm, "ghost_end_frame", text="End")
163                         col.itemR(arm, "ghost_size", text="Step")
164                 elif arm.ghost_type == 'CURRENT_FRAME':
165                         col.itemR(arm, "ghost_step", text="Range")
166                         col.itemR(arm, "ghost_size", text="Step")
167
168                 sub = split.column()
169                 sub.itemR(arm, "ghost_only_selected", text="Selected Only")
170
171 bpy.types.register(DATA_PT_context_arm)
172 bpy.types.register(DATA_PT_skeleton)
173 bpy.types.register(DATA_PT_display)
174 bpy.types.register(DATA_PT_bone_groups)
175 bpy.types.register(DATA_PT_paths)
176 bpy.types.register(DATA_PT_ghost)