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