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