ad34d8673500176cf0a0d6810dafcebda95edca2
[blender.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                         col = layout.column()
105                         col.itemR(group, "name")
106                         
107                         split = layout.split(0.5)
108                         split.itemR(group, "color_set")
109                         if group.color_set:
110                                 split.template_triColorSet(group, "colors")
111                 
112                 row = layout.row(align=True)
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         __idname__ = "DATA_PT_paths"
121         __label__ = "Paths"
122
123         def draw(self, context):
124                 layout = self.layout
125                 arm = context.armature
126
127                 split = layout.split()
128                 
129                 sub = split.column()
130                 sub.itemR(arm, "paths_show_around_current_frame", text="Around Frame")
131                 col = sub.column(align=True)
132                 if (arm.paths_show_around_current_frame):
133                         col.itemR(arm, "path_before_current", text="Before")
134                         col.itemR(arm, "path_after_current", text="After")
135                 else:
136                         col.itemR(arm, "path_start_frame", text="Start")
137                         col.itemR(arm, "path_end_frame", text="End")
138
139                 col.itemR(arm, "path_size", text="Step")        
140                 sub.itemR(arm, "paths_calculate_head_positions", text="Head")
141                 
142                 sub = split.column()
143                 sub.itemL(text="Show:")
144                 sub.itemR(arm, "paths_show_frame_numbers", text="Frame Numbers")
145                 sub.itemR(arm, "paths_highlight_keyframes", text="Keyframes")
146                 sub.itemR(arm, "paths_show_keyframe_numbers", text="Keyframe Numbers")
147
148 class DATA_PT_ghost(DataButtonsPanel):
149         __idname__ = "DATA_PT_ghost"
150         __label__ = "Ghost"
151
152         def draw(self, context):
153                 layout = self.layout
154                 arm = context.armature
155
156                 split = layout.split()
157
158                 sub = split.column()
159                 sub.itemR(arm, "ghost_type", text="Scope")
160
161                 col = sub.column(align=True)
162                 if arm.ghost_type == 'RANGE':
163                         col.itemR(arm, "ghost_start_frame", text="Start")
164                         col.itemR(arm, "ghost_end_frame", text="End")
165                         col.itemR(arm, "ghost_size", text="Step")
166                 elif arm.ghost_type == 'CURRENT_FRAME':
167                         col.itemR(arm, "ghost_step", text="Range")
168                         col.itemR(arm, "ghost_size", text="Step")
169
170                 sub = split.column()
171                 sub.itemR(arm, "ghost_only_selected", text="Selected Only")
172
173 bpy.types.register(DATA_PT_context_arm)
174 bpy.types.register(DATA_PT_skeleton)
175 bpy.types.register(DATA_PT_display)
176 bpy.types.register(DATA_PT_bone_groups)
177 bpy.types.register(DATA_PT_paths)
178 bpy.types.register(DATA_PT_ghost)