2.5 3D_View:
[blender-staging.git] / release / ui / space_view3d_toolbar.py
1
2 import bpy
3
4
5 class View3DPanel(bpy.types.Panel):
6         __space_type__ = "VIEW_3D"
7         __region_type__ = "TOOLS"
8
9 # ********** default tools for objectmode ****************
10
11 class VIEW3D_PT_tools_objectmode(View3DPanel):
12         __context__ = "objectmode"
13         __label__ = "Object Tools"
14
15         def draw(self, context):
16                 layout = self.layout
17                 
18                 layout.itemL(text="Transform:")
19                 
20                 col = layout.column(align=True)
21                 col.itemO("tfm.translate")
22                 col.itemO("tfm.rotate")
23                 col.itemO("tfm.resize", text="Scale")
24                 
25                 layout.itemL(text="Object:")
26                 
27                 col = layout.column(align=True)
28                 col.itemO("object.duplicate")
29                 col.itemO("object.delete")
30                 
31                 active_object= context.active_object
32                 if active_object and active_object.type == 'MESH':
33                         layout.itemL(text="Shading:")
34                 
35                         col = layout.column(align=True)
36                         col.itemO("object.shade_smooth", text="Smooth")
37                         col.itemO("object.shade_flat", text="Flat")
38                 
39                 layout.itemL(text="Keyframes:")
40                 
41                 col = layout.column(align=True)
42                 col.itemO("anim.insert_keyframe_menu", text="Insert")
43                 col.itemO("anim.delete_keyframe_v3d", text="Remove")
44
45 # ********** default tools for editmode_mesh ****************
46
47 class VIEW3D_PT_tools_meshedit(View3DPanel):
48         __context__ = "meshedit"
49         __label__ = "Mesh Tools"
50
51         def draw(self, context):
52                 layout = self.layout
53                 
54                 layout.itemL(text="Transform:")
55                 
56                 col = layout.column(align=True)
57                 col.itemO("tfm.translate")
58                 col.itemO("tfm.rotate")
59                 col.itemO("tfm.resize", text="Scale")
60                 
61                 layout.itemL(text="Mesh:")
62                 
63                 col = layout.column(align=True)
64                 col.itemO("mesh.duplicate")
65                 col.itemO("mesh.delete")
66                 
67                 layout.itemL(text="Modeling:")
68                 
69                 col = layout.column(align=True)
70                 col.itemO("mesh.extrude")
71                 col.itemO("mesh.subdivide")
72                 col.itemO("mesh.spin")
73                 col.itemO("mesh.screw")
74                 
75                 layout.itemL(text="Shading:")
76                 
77                 col = layout.column(align=True)
78                 col.itemO("mesh.faces_shade_smooth", text="Smooth")
79                 col.itemO("mesh.faces_shade_flat", text="Flat")
80                 
81                 layout.itemL(text="UV Mapping:")
82                 
83                 col = layout.column(align=True)
84                 col.itemO("uv.mapping_menu", text="Unwrap")
85                 col.itemO("mesh.uvs_rotate")
86                 col.itemO("mesh.uvs_mirror")
87
88 # ********** default tools for editmode_curve ****************
89
90 class VIEW3D_PT_tools_curveedit(View3DPanel):
91         __context__ = "curveedit"
92         __label__ = "Curve Tools"
93
94         def draw(self, context):
95                 layout = self.layout
96                 
97                 layout.itemL(text="Transform:")
98                 
99                 col = layout.column(align=True)
100                 col.itemO("tfm.translate")
101                 col.itemO("tfm.rotate")
102                 col.itemO("tfm.resize", text="Scale")
103                 
104                 layout.itemL(text="Curve:")
105
106                 col = layout.column(align=True)
107                 col.itemO("curve.duplicate")
108                 col.itemO("curve.delete")
109                 col.itemO("curve.cyclic_toggle")
110                 col.itemO("curve.switch_direction")
111                 
112                 layout.itemL(text="Modeling:")
113
114                 col = layout.column(align=True)
115                 col.itemO("curve.extrude")
116                 col.itemO("curve.subdivide")
117
118 # ********** default tools for editmode_surface ****************
119
120 class VIEW3D_PT_tools_surfaceedit(View3DPanel):
121         __context__ = "surfaceedit"
122         __label__ = "Surface Tools"
123
124         def draw(self, context):
125                 layout = self.layout
126                 
127                 layout.itemL(text="Transform:")
128
129                 col = layout.column(align=True)
130                 col.itemO("tfm.translate")
131                 col.itemO("tfm.rotate")
132                 col.itemO("tfm.resize", text="Scale")
133                 
134                 layout.itemL(text="Curve:")
135
136                 col = layout.column(align=True)
137                 col.itemO("curve.duplicate")
138                 col.itemO("curve.delete")
139                 col.itemO("curve.cyclic_toggle")
140                 col.itemO("curve.switch_direction")
141                 
142                 layout.itemL(text="Modeling:")
143
144                 col = layout.column(align=True)
145                 col.itemO("curve.extrude")
146                 col.itemO("curve.subdivide")
147
148 # ********** default tools for editmode_text ****************
149
150 class VIEW3D_PT_tools_textedit(View3DPanel):
151         __context__ = "textedit"
152         __label__ = "Text Tools"
153
154         def draw(self, context):
155                 layout = self.layout
156
157                 col = layout.column(align=True)
158                 col.itemO("font.text_copy", text="Copy")
159                 col.itemO("font.text_paste", text="Paste")
160                 
161                 col = layout.column()
162                 col.itemO("font.case_set")
163                 col.itemO("font.style_toggle")
164
165 # ********** default tools for editmode_armature ****************
166
167 class VIEW3D_PT_tools_armatureedit(View3DPanel):
168         __context__ = "armatureedit"
169         __label__ = "Armature Tools"
170
171         def draw(self, context):
172                 layout = self.layout
173                 
174                 layout.itemL(text="Transform:")
175                 
176                 col = layout.column(align=True)
177                 col.itemO("tfm.translate")
178                 col.itemO("tfm.rotate")
179                 col.itemO("tfm.resize", text="Scale")
180                 
181                 layout.itemL(text="Bones:")
182
183                 col = layout.column(align=True)
184                 col.itemO("armature.bone_primitive_add", text="Add")
185                 col.itemO("armature.duplicate", text="Duplicate")
186                 col.itemO("armature.delete", text="Delete")
187                 
188                 layout.itemL(text="Modeling:")
189                 layout.itemO("armature.extrude")
190
191 # ********** default tools for editmode_mball ****************
192
193 class VIEW3D_PT_tools_mballedit(View3DPanel):
194         __context__ = "mballedit"
195         __label__ = "Meta Tools"
196
197         def draw(self, context):
198                 layout = self.layout
199                 
200                 layout.itemL(text="Transform:")
201                 
202                 col = layout.column(align=True)
203                 col.itemO("tfm.translate")
204                 col.itemO("tfm.rotate")
205                 col.itemO("tfm.resize", text="Scale")
206
207 # ********** default tools for editmode_lattice ****************
208
209 class VIEW3D_PT_tools_latticeedit(View3DPanel):
210         __context__ = "latticeedit"
211         __label__ = "Lattice Tools"
212
213         def draw(self, context):
214                 layout = self.layout
215                 
216                 layout.itemL(text="Transform:")
217
218                 col = layout.column(align=True)
219                 col.itemO("tfm.translate")
220                 col.itemO("tfm.rotate")
221                 col.itemO("tfm.resize", text="Scale")
222
223 # ********** default tools for posemode ****************
224
225 class VIEW3D_PT_tools_posemode(View3DPanel):
226         __context__ = "posemode"
227         __label__ = "Pose Tools"
228
229         def draw(self, context):
230                 layout = self.layout
231                 
232                 layout.itemL(text="Transform:")
233
234                 col = layout.column(align=True)
235                 col.itemO("tfm.translate")
236                 col.itemO("tfm.rotate")
237                 col.itemO("tfm.resize", text="Scale")
238                 
239                 layout.itemL(text="Bones:")
240
241                 col = layout.column(align=True)
242                 col.itemO("pose.hide", text="Hide")
243                 col.itemO("pose.reveal", text="Reveal")
244                 
245                 layout.itemL(text="Keyframes:")
246                 
247                 col = layout.column(align=True)
248                 col.itemO("anim.insert_keyframe_menu", text="Insert")
249                 col.itemO("anim.delete_keyframe_v3d", text="Remove")
250                 
251                 layout.itemL(text="Pose:")
252                 
253                 col = layout.column(align=True)
254                 col.itemO("pose.copy", text="Copy")
255                 col.itemO("pose.paste", text="Paste")
256                 
257                 layout.itemL(text="Library:")
258                 
259                 col = layout.column(align=True)
260                 col.itemO("poselib.pose_add", text="Add")
261                 col.itemO("poselib.pose_remove", text="Remove")
262
263 # ********** default tools for paint modes ****************
264
265 class PaintPanel(bpy.types.Panel):
266         __space_type__ = "VIEW_3D"
267         __region_type__ = "TOOLS"
268
269         def paint_settings(self, context):
270                 ts = context.tool_settings
271
272                 if context.sculpt_object:
273                         return ts.sculpt
274                 elif context.vertex_paint_object:
275                         return ts.vertex_paint
276                 elif context.weight_paint_object:
277                         return ts.weight_paint
278                 elif context.texture_paint_object:
279                         return ts.image_paint
280                 elif context.particle_edit_object:
281                         return ts.particle_edit
282
283                 return False
284
285 class VIEW3D_PT_tools_brush(PaintPanel):
286         __label__ = "Brush"
287
288         def poll(self, context):
289                 return self.paint_settings(context)
290
291         def draw(self, context):
292                 layout = self.layout
293                 
294                 settings = self.paint_settings(context)
295                 brush = settings.brush
296                 
297                 if not context.particle_edit_object:
298                         layout.split().row().template_ID(settings, "brush")
299                 
300                 # Particle Mode #
301
302                 # XXX This needs a check if psys is editable.
303                 if context.particle_edit_object:
304                         # XXX Select Particle System
305                         layout.column().itemR(settings, "tool", expand=True)
306                         
307                         if settings.tool != 'NONE':
308                                 col = layout.column(align=True)
309                                 col.itemR(brush, "size", slider=True)
310                                 col.itemR(brush, "strength", slider=True)
311                                 
312                         if settings.tool == 'ADD':
313                                 layout.itemR(settings, "add_interpolate")
314                                 
315                                 col = layout.column()
316                                 col.itemR(brush, "steps", slider=True)
317                                 col.itemR(settings, "add_keys", slider=True)
318                         elif settings.tool == 'LENGTH':
319                                 layout.itemR(brush, "length_mode", expand=True)
320                         elif settings.tool == 'PUFF':
321                                 layout.itemR(brush, "puff_mode", expand=True)
322
323                 # Sculpt Mode #
324                 
325                 elif context.sculpt_object:
326                         layout.column().itemR(brush, "sculpt_tool", expand=True)
327                                 
328                         col = layout.column()
329                                 
330                         row = col.row(align=True)
331                         row.itemR(brush, "size", slider=True)
332                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
333                         
334                         if brush.sculpt_tool != 'GRAB':
335                                 row = col.row(align=True)
336                                 row.itemR(brush, "strength", slider=True)
337                                 row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
338                         
339                                 col = layout.column()
340                                 col.itemR(brush, "airbrush")
341                                 if brush.sculpt_tool != 'LAYER':
342                                         col.itemR(brush, "anchored")
343
344                                 if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
345                                         col.itemR(brush, "flip_direction")
346
347                                 if brush.sculpt_tool == 'LAYER':
348                                         col.itemR(brush, "persistent")
349                                         col.itemO("sculpt.set_persistent_base")
350                                 
351                 # Texture Paint Mode #
352                 
353                 elif context.texture_paint_object:
354                         col = layout.column(align=True)
355                         col.item_enumR(settings, "tool", 'DRAW')
356                         col.item_enumR(settings, "tool", 'SOFTEN')
357                         if settings.use_projection:
358                                 col.item_enumR(settings, "tool", 'CLONE')
359                         else:
360                                 col.item_enumR(settings, "tool", 'SMEAR')
361                                 
362                         col = layout.column()
363                         col.itemR(brush, "color", text="")
364                                 
365                         row = col.row(align=True)
366                         row.itemR(brush, "size", slider=True)
367                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
368                         
369                         row = col.row(align=True)
370                         row.itemR(brush, "strength", slider=True)
371                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
372                         
373                         row = col.row(align=True)
374                         row.itemR(brush, "falloff", slider=True)
375                         row.itemR(brush, "falloff_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
376                         
377                         row = col.row(align=True)
378                         row.itemR(brush, "space", text="")
379                         rowsub = row.row(align=True)
380                         rowsub.active = brush.space
381                         rowsub.itemR(brush, "spacing", text="Spacing", slider=True)
382                         rowsub.itemR(brush, "spacing_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
383                         
384                         col = layout.column()
385                         col.itemR(brush, "airbrush")
386                         sub = col.column()
387                         sub.active = brush.airbrush
388                         sub.itemR(brush, "rate")
389                 
390                 # Weight Paint Mode #
391         
392                 elif context.weight_paint_object:
393                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
394                         
395                         col = layout.column()
396                         row = col.row(align=True)
397                         row.itemR(brush, "size", slider=True)
398                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
399                         
400                         row = col.row(align=True)
401                         row.itemR(brush, "strength", slider=True)
402                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
403                 
404                 # Vertex Paint Mode #
405                 
406                 elif context.vertex_paint_object:
407                         col = layout.column()
408                         col.itemR(brush, "color", text="")
409                         
410                         row = col.row(align=True)
411                         row.itemR(brush, "size", slider=True)
412                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
413                         
414                         row = col.row(align=True)
415                         row.itemR(brush, "strength", slider=True)
416                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
417
418 class VIEW3D_PT_tools_brush_curve(PaintPanel):
419         __label__ = "Curve"
420         __default_closed__ = True
421
422         def poll(self, context):
423                 settings = self.paint_settings(context)
424                 return (settings and settings.brush and settings.brush.curve)
425
426         def draw(self, context):
427                 settings = self.paint_settings(context)
428                 brush = settings.brush
429                 layout = self.layout
430
431                 layout.template_curve_mapping(brush.curve)
432                 layout.item_menu_enumO("brush.curve_preset", property="shape")
433                 
434 class VIEW3D_PT_sculpt_options(PaintPanel):
435         __label__ = "Options"
436
437         def poll(self, context):
438                 return context.sculpt_object
439
440         def draw(self, context):
441                 layout = self.layout
442                 sculpt = context.tool_settings.sculpt
443
444                 col = layout.column()
445                 col.itemR(sculpt, "partial_redraw", text="Partial Refresh")
446                 col.itemR(sculpt, "show_brush")
447
448                 split = self.layout.split()
449                 
450                 col = split.column()
451                 col.itemL(text="Symmetry:")
452                 col.itemR(sculpt, "symmetry_x", text="X")
453                 col.itemR(sculpt, "symmetry_y", text="Y")
454                 col.itemR(sculpt, "symmetry_z", text="Z")
455                 
456                 col = split.column()
457                 col.itemL(text="Lock:")
458                 col.itemR(sculpt, "lock_x", text="X")
459                 col.itemR(sculpt, "lock_y", text="Y")
460                 col.itemR(sculpt, "lock_z", text="Z")
461
462 # ********** default tools for weightpaint ****************
463
464 class VIEW3D_PT_tools_weightpaint(View3DPanel):
465         __context__ = "weightpaint"
466         __label__ = "Options"
467
468         def draw(self, context):
469                 layout = self.layout
470                 wpaint = context.tool_settings.weight_paint
471
472                 col = layout.column()
473                 col.itemL(text="Blend:")
474                 col.itemR(wpaint, "mode", text="")
475                 col.itemR(wpaint, "all_faces")
476                 col.itemR(wpaint, "normals")
477                 col.itemR(wpaint, "spray")
478                 col.itemR(wpaint, "vertex_dist", text="Distance")
479
480 # Commented out because the Apply button isn't an operator yet, making these settings useless
481 #               col.itemL(text="Gamma:")
482 #               col.itemR(wpaint, "gamma", text="")
483 #               col.itemL(text="Multiply:")
484 #               col.itemR(wpaint, "mul", text="")
485
486 # Also missing now:
487 # Soft, Vgroup, X-Mirror and "Clear" Operator.
488
489 # ********** default tools for vertexpaint ****************
490
491 class VIEW3D_PT_tools_vertexpaint(View3DPanel):
492         __context__ = "vertexpaint"
493         __label__ = "Options"
494
495         def draw(self, context):
496                 layout = self.layout
497                 vpaint = context.tool_settings.vertex_paint
498
499                 col = layout.column()
500                 col.itemL(text="Blend:")
501                 col.itemR(vpaint, "mode", text="")
502                 col.itemR(vpaint, "all_faces")
503                 col.itemR(vpaint, "normals")
504                 col.itemR(vpaint, "spray")
505                 col.itemR(vpaint, "vertex_dist", text="Distance")
506 # Commented out because the Apply button isn't an operator yet, making these settings useless
507 #               col.itemL(text="Gamma:")
508 #               col.itemR(vpaint, "gamma", text="")
509 #               col.itemL(text="Multiply:")
510 #               col.itemR(vpaint, "mul", text="")
511
512
513 # ********** default tools for texturepaint ****************
514
515 class VIEW3D_PT_tools_texturepaint(View3DPanel):
516         __context__ = "texturepaint"
517         __label__ = "Options"
518
519         def draw(self, context):
520                 layout = self.layout
521                 
522                 ipaint = context.tool_settings.image_paint
523                 settings = context.tool_settings.image_paint
524                 
525                 col = layout.column()
526                 col.itemR(ipaint, "use_projection")
527                 sub = col.column()
528                 sub.active = ipaint.use_projection
529                 sub.itemR(ipaint, "use_occlude")
530                 sub.itemR(ipaint, "use_backface_cull")
531                 sub.itemR(ipaint, "use_normal_falloff")
532                 sub.itemR(ipaint, "use_stencil_layer")
533                 subsub = sub.column()
534                 subsub.active = ipaint.use_stencil_layer
535                 subsub.itemR(ipaint, "invert_stencil")
536                 if settings.tool == 'CLONE':
537                         sub.itemR(ipaint, "use_clone_layer")
538                 
539                 sub.itemR(ipaint, "seam_bleed")
540                 sub.itemR(ipaint, "normal_angle")
541                 
542 # ********** default tools for particle mode ****************
543
544 class VIEW3D_PT_tools_particlemode(View3DPanel):
545         __context__ = "particlemode"
546         __label__ = "Options"
547
548         def draw(self, context):
549                 layout = self.layout
550                 pe = context.tool_settings.particle_edit
551
552                 col = layout.column(align=True)
553                 col.itemR(pe, "emitter_deflect", text="Deflect")
554                 sub = col.row()
555                 sub.active = pe.emitter_deflect
556                 sub.itemR(pe, "emitter_distance", text="Distance")
557                 
558                 col = layout.column(align=True)
559                 col.itemL(text="Keep:")
560                 col.itemR(pe, "keep_lengths", text="Lenghts")
561                 col.itemR(pe, "keep_root", text="Root")
562                 
563                 col = layout.column(align=True)
564                 col.itemL(text="Draw:")
565                 col.itemR(pe, "show_time", text="Time")
566                 col.itemR(pe, "show_children", text="Children")
567
568 bpy.types.register(VIEW3D_PT_tools_objectmode)
569 bpy.types.register(VIEW3D_PT_tools_meshedit)
570 bpy.types.register(VIEW3D_PT_tools_curveedit)
571 bpy.types.register(VIEW3D_PT_tools_surfaceedit)
572 bpy.types.register(VIEW3D_PT_tools_textedit)
573 bpy.types.register(VIEW3D_PT_tools_armatureedit)
574 bpy.types.register(VIEW3D_PT_tools_mballedit)
575 bpy.types.register(VIEW3D_PT_tools_latticeedit)
576 bpy.types.register(VIEW3D_PT_tools_posemode)
577 bpy.types.register(VIEW3D_PT_tools_brush)
578 bpy.types.register(VIEW3D_PT_tools_brush_curve)
579 bpy.types.register(VIEW3D_PT_sculpt_options)
580 bpy.types.register(VIEW3D_PT_tools_vertexpaint)
581 bpy.types.register(VIEW3D_PT_tools_weightpaint)
582 bpy.types.register(VIEW3D_PT_tools_texturepaint)
583 bpy.types.register(VIEW3D_PT_tools_particlemode)