NLA SoC: Action-line is now drawn with green colouring when a strip is being tweaked...
[blender.git] / release / ui / buttons_data_modifier.py
1
2 import bpy
3
4 class DataButtonsPanel(bpy.types.Panel):
5         __space_type__ = "BUTTONS_WINDOW"
6         __region_type__ = "WINDOW"
7         __context__ = "modifier"
8
9         def poll(self, context):
10                 ob = context.active_object
11                 return (ob and ob.type in ('MESH', 'CURVE', 'SURFACE', 'TEXT', 'LATTICE'))
12                 
13 class DATA_PT_modifiers(DataButtonsPanel):
14         __idname__ = "DATA_PT_modifiers"
15         __label__ = "Modifiers"
16
17         def draw(self, context):
18                 ob = context.active_object
19                 layout = self.layout
20
21                 row = layout.row()
22                 row.item_menu_enumO("OBJECT_OT_modifier_add", "type")
23                 row.itemL();
24
25                 for md in ob.modifiers:
26                         box = layout.template_modifier(context, md)
27
28                         if md.expanded:
29                                 if md.type == 'ARMATURE':
30                                         self.armature(box, md)
31                                 if md.type == 'ARRAY':
32                                         self.array(box, md)
33                                 if md.type == 'BEVEL':
34                                         self.bevel(box, md)
35                                 if md.type == 'BOOLEAN':
36                                         self.boolean(box, md)
37                                 if md.type == 'BUILD':
38                                         self.build(box, md)
39                                 if md.type == 'CAST':
40                                         self.cast(box, md)
41                                 if md.type == 'CLOTH':
42                                         self.cloth(box, md)
43                                 if md.type == 'COLLISION':
44                                         self.collision(box, md)
45                                 if md.type == 'CURVE':
46                                         self.curve(box, md)
47                                 if md.type == 'DECIMATE':
48                                         self.decimate(box, md)
49                                 if md.type == 'DISPLACE':
50                                         self.displace(box, md)
51                                 if md.type == 'EDGE_SPLIT':
52                                         self.edgesplit(box, md)
53                                 if md.type == 'EXPLODE':
54                                         self.explode(box, md)
55                                 if md.type == 'FLUID_SIMULATION':
56                                         self.fluid(box, md)
57                                 if md.type == 'HOOK':
58                                         self.hook(box, md)
59                                 if md.type == 'LATTICE':
60                                         self.lattice(box, md)
61                                 if md.type == 'MASK':
62                                         self.mask(box, md)
63                                 if md.type == 'MESH_DEFORM':
64                                         self.meshdeform(box, md)
65                                 if md.type == 'MIRROR':
66                                         self.mirror(box, md)
67                                 if md.type == 'MULTIRES':
68                                         self.multires(box, md)
69                                 if md.type == 'PARTICLE_INSTANCE':
70                                         self.particleinstance(box, md)
71                                 if md.type == 'PARTICLE_SYSTEM':
72                                         self.particlesystem(box, md)
73                                 if md.type == 'SHRINKWRAP':
74                                         self.shrinkwrap(box, md)
75                                 if md.type == 'SIMPLE_DEFORM':
76                                         self.simpledeform(box, md)
77                                 if md.type == 'SMOOTH':
78                                         self.smooth(box, md)
79                                 if md.type == 'SOFTBODY':
80                                         self.softbody(box, md)
81                                 if md.type == 'SUBSURF':
82                                         self.subsurf(box, md)
83                                 if md.type == 'UV_PROJECT':
84                                         self.uvproject(box, md)
85                                 if md.type == 'WAVE':
86                                         self.wave(box, md)
87                                                         
88         def armature(self, layout, md):
89                 layout.itemR(md, "object")
90                 row = layout.row()
91                 row.itemR(md, "vertex_group")
92                 row.itemR(md, "invert")
93                 flow = layout.column_flow()
94                 flow.itemR(md, "use_vertex_groups", text="Vertex Groups")
95                 flow.itemR(md, "use_bone_envelopes", text="Bone Envelopes")
96                 flow.itemR(md, "quaternion")
97                 flow.itemR(md, "multi_modifier")
98                 
99         def array(self, layout, md):
100                 layout.itemR(md, "fit_type")
101                 if md.fit_type == 'FIXED_COUNT':
102                         layout.itemR(md, "count")
103                 if md.fit_type == 'FIT_LENGTH':
104                         layout.itemR(md, "length")
105                 if md.fit_type == 'FIT_CURVE':
106                                 layout.itemR(md, "curve")
107                 
108                 split = layout.split()
109                 
110                 col = split.column()
111                 col = col.column()
112                 col.itemR(md, "constant_offset")
113                 colsub = col.column()
114                 colsub.active = md.constant_offset
115                 colsub.itemR(md, "constant_offset_displacement", text="Displacement")
116                 sub = col.row().itemR(md, "merge_adjacent_vertices", text="Merge")
117                 colsub = col.column()
118                 colsub.active = md.merge_adjacent_vertices
119                 colsub.itemR(md, "merge_end_vertices", text="First Last")
120                 colsub.itemR(md, "merge_distance", text="Distance")
121                 
122                 col = split.column()
123                 col = col.column()
124                 col.itemR(md, "relative_offset")
125                 colsub = col.column()
126                 colsub.active = md.relative_offset
127                 colsub.itemR(md, "relative_offset_displacement", text="Displacement")
128                 col = col.column()
129                 col.itemR(md, "add_offset_object")
130                 colsub = col.column()
131                 colsub.active = md.add_offset_object
132                 colsub.itemR(md, "offset_object")
133                 
134                 col = layout.column()
135                 col.itemR(md, "start_cap")
136                 col.itemR(md, "end_cap")
137         
138         def bevel(self, layout, md):
139                 row = layout.row()
140                 row.itemR(md, "width")
141                 row.itemR(md, "only_vertices")
142                 
143                 layout.itemL(text="Limit Method:")
144                 row = layout.row()
145                 row.itemR(md, "limit_method", expand=True)
146                 if md.limit_method == 'ANGLE':
147                         row = layout.row()
148                         row.itemR(md, "angle")
149                 if md.limit_method == 'WEIGHT':
150                         row = layout.row()
151                         row.itemR(md, "edge_weight_method", expand=True)
152                         
153         def boolean(self, layout, md):
154                 layout.itemR(md, "operation")
155                 layout.itemR(md, "object")
156                 
157         def build(self, layout, md):
158                 split = layout.split()
159                 
160                 col = split.column()
161                 col.itemR(md, "start")
162                 col.itemR(md, "length")
163
164                 col = split.column()
165                 col.itemR(md, "randomize")
166                 colsub = col.column()
167                 colsub.active = md.randomize
168                 colsub.itemR(md, "seed")
169                         
170                 
171                         
172         def cast(self, layout, md):
173                 layout.itemR(md, "cast_type")
174                 col = layout.column_flow()
175                 col.itemR(md, "x")
176                 col.itemR(md, "y")
177                 col.itemR(md, "z")
178                 col.itemR(md, "factor")
179                 col.itemR(md, "radius")
180                 col.itemR(md, "size")
181                 layout.itemR(md, "vertex_group")
182                 #Missing: "OB" and "From Radius"
183                 
184         def cloth(self, layout, md):
185                 layout.itemL(text="See Cloth panel.")
186                 
187         def collision(self, layout, md):
188                 layout.itemL(text="See Collision panel.")
189                 
190         def curve(self, layout, md):
191                 layout.itemR(md, "curve")
192                 layout.itemR(md, "vertex_group")
193                 layout.itemR(md, "deform_axis")
194                 
195         def decimate(self, layout, md):
196                 layout.itemR(md, "ratio")
197                 layout.itemR(md, "face_count")
198                 
199         def displace(self, layout, md):
200                 layout.itemR(md, "vertex_group")
201                 layout.itemR(md, "texture")
202                 layout.itemR(md, "midlevel")
203                 layout.itemR(md, "strength")
204                 layout.itemR(md, "texture_coordinates")
205                 if md.texture_coordinates == 'OBJECT':
206                         layout.itemR(md, "texture_coordinate_object", text="Object")
207                 if md.texture_coordinates == 'UV':
208                         layout.itemR(md, "uv_layer")
209         
210         def edgesplit(self, layout, md):
211                 split = layout.split()
212                 
213                 col = split.column()
214                 col.itemR(md, "use_edge_angle", text="Edge Angle")
215                 colsub = col.column()
216                 colsub.active = md.use_edge_angle
217                 colsub.itemR(md, "split_angle")
218                 col = split.column()
219                 col.itemR(md, "use_sharp", text="Sharp Edges")
220                 
221         def explode(self, layout, md):
222                 layout.itemR(md, "vertex_group")
223                 layout.itemR(md, "protect")
224                 layout.itemR(md, "split_edges")
225                 layout.itemR(md, "unborn")
226                 layout.itemR(md, "alive")
227                 layout.itemR(md, "dead")
228                 # Missing: "Refresh" and "Clear Vertex Group" ?
229                 
230         def fluid(self, layout, md):
231                 layout.itemL(text="See Fluidsim panel.")
232                 
233         def hook(self, layout, md):
234                 layout.itemR(md, "falloff")
235                 layout.itemR(md, "force", slider=True)
236                 layout.itemR(md, "object")
237                 layout.itemR(md, "vertex_group")
238                 # Missing: "Reset" and "Recenter"
239                 
240         def lattice(self, layout, md):
241                 layout.itemR(md, "lattice")
242                 layout.itemR(md, "vertex_group")
243                 
244         def mask(self, layout, md):
245                 layout.itemR(md, "mode")
246                 if md.mode == 'ARMATURE':
247                         layout.itemR(md, "armature")
248                 if md.mode == 'VERTEX_GROUP':
249                         layout.itemR(md, "vertex_group")
250                 layout.itemR(md, "inverse")
251                 
252         def meshdeform(self, layout, md):
253                 layout.itemR(md, "mesh")
254                 layout.itemR(md, "vertex_group")
255                 layout.itemR(md, "invert")
256                 layout.itemR(md, "precision")
257                 layout.itemR(md, "dynamic")
258                 # Missing: "Bind"
259                 
260         def mirror(self, layout, md):
261                 layout.itemR(md, "merge_limit")
262                 split = layout.split()
263                 
264                 sub = split.column()
265                 sub.itemR(md, "x")
266                 sub.itemR(md, "y")
267                 sub.itemR(md, "z")
268                 sub = split.column()
269                 sub.itemL(text="Textures:")
270                 sub.itemR(md, "mirror_u")
271                 sub.itemR(md, "mirror_v")
272                 sub = split.column()
273                 sub.itemR(md, "clip", text="Do Clipping")
274                 sub.itemR(md, "mirror_vertex_groups", text="Vertex Group")
275                 
276                 layout.itemR(md, "mirror_object")
277                 
278         def multires(self, layout, md):
279                 layout.itemR(md, "subdivision_type")
280                 layout.itemO("OBJECT_OT_multires_subdivide", text="Subdivide")
281                 layout.itemR(md, "level")
282         
283         def particleinstance(self, layout, md):
284                 layout.itemR(md, "object")
285                 layout.itemR(md, "particle_system_number")
286                 
287                 col = layout.column_flow()
288                 col.itemR(md, "normal")
289                 col.itemR(md, "children")
290                 col.itemR(md, "path")
291                 col.itemR(md, "unborn")
292                 col.itemR(md, "alive")
293                 col.itemR(md, "dead")
294                 
295         def particlesystem(self, layout, md):
296                 layout.itemL(text="See Particle panel.")
297                 
298         def shrinkwrap(self, layout, md):
299                 layout.itemR(md, "target")
300                 layout.itemR(md, "vertex_group")
301                 layout.itemR(md, "offset")
302                 layout.itemR(md, "subsurf_levels")
303                 layout.itemR(md, "mode")
304                 if md.mode == 'PROJECT':
305                         layout.itemR(md, "subsurf_levels")
306                         layout.itemR(md, "auxiliary_target")
307                 
308                         row = layout.row()
309                         row.itemR(md, "x")
310                         row.itemR(md, "y")
311                         row.itemR(md, "z")
312                 
313                         col = layout.column_flow()
314                         col.itemR(md, "negative")
315                         col.itemR(md, "positive")
316                         col.itemR(md, "cull_front_faces")
317                         col.itemR(md, "cull_back_faces")
318                 if md.mode == 'NEAREST_SURFACEPOINT':
319                         layout.itemR(md, "keep_above_surface")
320                 # To-Do: Validate if structs
321                 
322         def simpledeform(self, layout, md):
323                 layout.itemR(md, "mode")
324                 layout.itemR(md, "vertex_group")
325                 layout.itemR(md, "origin")
326                 layout.itemR(md, "relative")
327                 layout.itemR(md, "factor")
328                 layout.itemR(md, "limits")
329                 if md.mode in ('TAPER', 'STRETCH'):
330                         layout.itemR(md, "lock_x_axis")
331                         layout.itemR(md, "lock_y_axis")
332         
333         def smooth(self, layout, md):
334                 split = layout.split()
335                 sub = split.column()
336                 sub.itemR(md, "x")
337                 sub.itemR(md, "y")
338                 sub.itemR(md, "z")
339                 sub = split.column()
340                 sub.itemR(md, "factor")
341                 sub.itemR(md, "repeat")
342                 
343                 layout.itemR(md, "vertex_group")
344                 
345         def softbody(self, layout, md):
346                 layout.itemL(text="See Softbody panel.")
347         
348         def subsurf(self, layout, md):
349                 layout.itemR(md, "subdivision_type")
350                 col = layout.column_flow()
351                 col.itemR(md, "levels", text="Preview")
352                 col.itemR(md, "render_levels", text="Render")
353                 col.itemR(md, "optimal_draw", text="Optimal Display")
354                 col.itemR(md, "subsurf_uv")
355         
356         def uvproject(self, layout, md):
357                 layout.itemR(md, "uv_layer")
358                 layout.itemR(md, "projectors")
359                 layout.itemR(md, "image")
360                 layout.itemR(md, "horizontal_aspect_ratio")
361                 layout.itemR(md, "vertical_aspect_ratio")
362                 layout.itemR(md, "override_image")
363                 #"Projectors" don't work.
364                 
365         def wave(self, layout, md):
366                 split = layout.split()
367                 
368                 sub = split.column()
369                 sub.itemL(text="Motion:")
370                 sub.itemR(md, "x")
371                 sub.itemR(md, "y")
372                 sub.itemR(md, "cyclic")
373                 
374                 sub = split.column()
375                 sub.itemR(md, "normals")
376                 row = sub.row(align=True)
377                 row.active = md.normals
378                 row.itemR(md, "x_normal", text="X", toggle=True)
379                 row.itemR(md, "y_normal", text="Y", toggle=True)
380                 row.itemR(md, "z_normal", text="Z", toggle=True)
381                 
382                 col = layout.column_flow()
383                 col.itemR(md, "time_offset")
384                 col.itemR(md, "lifetime")
385                 col.itemR(md, "damping_time")
386                 col.itemR(md, "falloff_radius")
387                 col.itemR(md, "start_position_x")
388                 col.itemR(md, "start_position_y")
389                 
390                 layout.itemR(md, "start_position_object")
391                 layout.itemR(md, "vertex_group")
392                 layout.itemR(md, "texture")
393                 layout.itemR(md, "texture_coordinates")
394                 if md.texture_coordinates == 'MAP_UV':
395                         layout.itemR(md, "uv_layer")
396                 if md.texture_coordinates == 'OBJECT':
397                         layout.itemR(md, "texture_coordinates_object")
398                 
399                 col = layout.column_flow()
400                 col.itemR(md, "speed", slider=True)
401                 col.itemR(md, "height", slider=True)
402                 col.itemR(md, "width", slider=True)
403                 col.itemR(md, "narrowness", slider=True)
404
405 bpy.types.register(DATA_PT_modifiers)