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