2.5 Paint:
[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                 paint = context.sculpt_object or context.vertex_paint_object
296
297                 if not context.particle_edit_object:
298                         col = layout.split().column()
299                         if paint:
300                                 row = col.row()
301                                 row.template_list(settings, "brushes", settings, "active_brush_index", rows=2)
302                                 
303                                 sub_col = row.column(align=True)
304                                 sub_col.itemO("paint.brush_slot_add", icon="ICON_ZOOMIN", text="")
305                                 sub_col.itemO("paint.brush_slot_remove", icon="ICON_ZOOMOUT", text="")
306
307                 if context.sculpt_object:
308                         col.template_ID(settings, "brush")
309                         col.item_menu_enumO("sculpt.brush_add", "sculpt_tool");
310                 else:
311                         col.template_ID(settings, "brush", new="brush.add")
312                 
313                 # Particle Mode #
314
315                 # XXX This needs a check if psys is editable.
316                 if context.particle_edit_object:
317                         # XXX Select Particle System
318                         layout.column().itemR(settings, "tool", expand=True)
319                         
320                         if settings.tool != 'NONE':
321                                 col = layout.column()
322                                 col.itemR(brush, "size", slider=True)
323                                 col.itemR(brush, "strength", slider=True)
324                                 
325                         if settings.tool == 'ADD':
326                                 
327                                 col = layout.column()
328                                 col.itemR(settings, "add_interpolate")
329                                 sub = col.column(align=True)
330                                 sub.active = settings.add_interpolate
331                                 sub.itemR(brush, "steps", slider=True)
332                                 sub.itemR(settings, "add_keys", slider=True)
333                         elif settings.tool == 'LENGTH':
334                                 layout.itemR(brush, "length_mode", expand=True)
335                         elif settings.tool == 'PUFF':
336                                 layout.itemR(brush, "puff_mode", expand=True)
337
338                 # Sculpt Mode #
339                 
340                 elif context.sculpt_object and settings.brush:
341                         col = layout.column()
342                                 
343                         row = col.row(align=True)
344                         row.itemR(brush, "size", slider=True)
345                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
346                         
347                         if brush.sculpt_tool != 'GRAB':
348                                 row = col.row(align=True)
349                                 row.itemR(brush, "strength", slider=True)
350                                 row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
351                         
352                                 col = layout.column()
353                                 col.itemR(brush, "airbrush")
354                                 if brush.sculpt_tool != 'LAYER':
355                                         col.itemR(brush, "anchored")
356
357                                 if brush.sculpt_tool in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
358                                         col.itemR(brush, "flip_direction")
359
360                                 if brush.sculpt_tool == 'LAYER':
361                                         col.itemR(brush, "persistent")
362                                         col.itemO("sculpt.set_persistent_base")
363
364                         col.itemR(brush, "sculpt_tool")
365                                 
366                 # Texture Paint Mode #
367                 
368                 elif context.texture_paint_object:
369                         col = layout.column(align=True)
370                         col.item_enumR(settings, "tool", 'DRAW')
371                         col.item_enumR(settings, "tool", 'SOFTEN')
372                         if settings.use_projection:
373                                 col.item_enumR(settings, "tool", 'CLONE')
374                         else:
375                                 col.item_enumR(settings, "tool", 'SMEAR')
376                                 
377                         col = layout.column()
378                         col.itemR(brush, "color", text="")
379                                 
380                         row = col.row(align=True)
381                         row.itemR(brush, "size", slider=True)
382                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
383                         
384                         row = col.row(align=True)
385                         row.itemR(brush, "strength", slider=True)
386                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
387                         
388                         row = col.row(align=True)
389                         row.itemR(brush, "falloff", slider=True)
390                         row.itemR(brush, "falloff_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
391                         
392                         row = col.row(align=True)
393                         row.itemR(brush, "space", text="")
394                         rowsub = row.row(align=True)
395                         rowsub.active = brush.space
396                         rowsub.itemR(brush, "spacing", text="Spacing", slider=True)
397                         rowsub.itemR(brush, "spacing_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
398                         
399                         col = layout.column()
400                         col.itemR(brush, "airbrush")
401                         sub = col.column()
402                         sub.active = brush.airbrush
403                         sub.itemR(brush, "rate")
404                 
405                 # Weight Paint Mode #
406         
407                 elif context.weight_paint_object:
408                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
409                         
410                         col = layout.column()
411                         row = col.row(align=True)
412                         row.itemR(brush, "size", slider=True)
413                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
414                         
415                         row = col.row(align=True)
416                         row.itemR(brush, "strength", slider=True)
417                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
418                 
419                 # Vertex Paint Mode #
420                 
421                 elif context.vertex_paint_object:
422                         col = layout.column()
423                         col.itemR(brush, "color", text="")
424                         
425                         row = col.row(align=True)
426                         row.itemR(brush, "size", slider=True)
427                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
428                         
429                         row = col.row(align=True)
430                         row.itemR(brush, "strength", slider=True)
431                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
432
433 class VIEW3D_PT_tools_brush_curve(PaintPanel):
434         __label__ = "Curve"
435         __default_closed__ = True
436
437         def poll(self, context):
438                 settings = self.paint_settings(context)
439                 return (settings and settings.brush and settings.brush.curve)
440
441         def draw(self, context):
442                 settings = self.paint_settings(context)
443                 brush = settings.brush
444                 layout = self.layout
445
446                 layout.template_curve_mapping(brush.curve)
447                 layout.item_menu_enumO("brush.curve_preset", property="shape")
448                 
449 class VIEW3D_PT_sculpt_options(PaintPanel):
450         __label__ = "Options"
451
452         def poll(self, context):
453                 return context.sculpt_object
454
455         def draw(self, context):
456                 layout = self.layout
457                 sculpt = context.tool_settings.sculpt
458
459                 col = layout.column()
460                 col.itemR(sculpt, "partial_redraw", text="Partial Refresh")
461                 col.itemR(sculpt, "show_brush")
462
463                 split = self.layout.split()
464                 
465                 col = split.column()
466                 col.itemL(text="Symmetry:")
467                 col.itemR(sculpt, "symmetry_x", text="X")
468                 col.itemR(sculpt, "symmetry_y", text="Y")
469                 col.itemR(sculpt, "symmetry_z", text="Z")
470                 
471                 col = split.column()
472                 col.itemL(text="Lock:")
473                 col.itemR(sculpt, "lock_x", text="X")
474                 col.itemR(sculpt, "lock_y", text="Y")
475                 col.itemR(sculpt, "lock_z", text="Z")
476
477 # ********** default tools for weightpaint ****************
478
479 class VIEW3D_PT_tools_weightpaint(View3DPanel):
480         __context__ = "weightpaint"
481         __label__ = "Options"
482
483         def draw(self, context):
484                 layout = self.layout
485                 wpaint = context.tool_settings.weight_paint
486
487                 col = layout.column()
488                 col.itemL(text="Blend:")
489                 col.itemR(wpaint, "mode", text="")
490                 col.itemR(wpaint, "all_faces")
491                 col.itemR(wpaint, "normals")
492                 col.itemR(wpaint, "spray")
493                 col.itemR(wpaint, "vertex_dist", text="Distance")
494
495 # Commented out because the Apply button isn't an operator yet, making these settings useless
496 #               col.itemL(text="Gamma:")
497 #               col.itemR(wpaint, "gamma", text="")
498 #               col.itemL(text="Multiply:")
499 #               col.itemR(wpaint, "mul", text="")
500
501 # Also missing now:
502 # Soft, Vgroup, X-Mirror and "Clear" Operator.
503
504 # ********** default tools for vertexpaint ****************
505
506 class VIEW3D_PT_tools_vertexpaint(View3DPanel):
507         __context__ = "vertexpaint"
508         __label__ = "Options"
509
510         def draw(self, context):
511                 layout = self.layout
512                 vpaint = context.tool_settings.vertex_paint
513
514                 col = layout.column()
515                 col.itemL(text="Blend:")
516                 col.itemR(vpaint, "mode", text="")
517                 col.itemR(vpaint, "all_faces")
518                 col.itemR(vpaint, "normals")
519                 col.itemR(vpaint, "spray")
520                 col.itemR(vpaint, "vertex_dist", text="Distance")
521 # Commented out because the Apply button isn't an operator yet, making these settings useless
522 #               col.itemL(text="Gamma:")
523 #               col.itemR(vpaint, "gamma", text="")
524 #               col.itemL(text="Multiply:")
525 #               col.itemR(vpaint, "mul", text="")
526
527
528 # ********** default tools for texturepaint ****************
529
530 class VIEW3D_PT_tools_texturepaint(View3DPanel):
531         __context__ = "texturepaint"
532         __label__ = "Options"
533
534         def draw(self, context):
535                 layout = self.layout
536                 
537                 ipaint = context.tool_settings.image_paint
538                 settings = context.tool_settings.image_paint
539                 
540                 col = layout.column()
541                 col.itemR(ipaint, "use_projection")
542                 sub = col.column()
543                 sub.active = ipaint.use_projection
544                 sub.itemR(ipaint, "use_occlude")
545                 sub.itemR(ipaint, "use_backface_cull")
546                 sub.itemR(ipaint, "use_normal_falloff")
547                 sub.itemR(ipaint, "use_stencil_layer")
548                 subsub = sub.column()
549                 subsub.active = ipaint.use_stencil_layer
550                 subsub.itemR(ipaint, "invert_stencil")
551                 if settings.tool == 'CLONE':
552                         sub.itemR(ipaint, "use_clone_layer")
553                 
554                 sub.itemR(ipaint, "seam_bleed")
555                 sub.itemR(ipaint, "normal_angle")
556                 
557 # ********** default tools for particle mode ****************
558
559 class VIEW3D_PT_tools_particlemode(View3DPanel):
560         __context__ = "particlemode"
561         __label__ = "Options"
562
563         def draw(self, context):
564                 layout = self.layout
565                 pe = context.tool_settings.particle_edit
566
567                 col = layout.column(align=True)
568                 col.itemR(pe, "emitter_deflect", text="Deflect")
569                 sub = col.row()
570                 sub.active = pe.emitter_deflect
571                 sub.itemR(pe, "emitter_distance", text="Distance")
572                 
573                 col = layout.column(align=True)
574                 col.itemL(text="Keep:")
575                 col.itemR(pe, "keep_lengths", text="Lenghts")
576                 col.itemR(pe, "keep_root", text="Root")
577                 
578                 col = layout.column(align=True)
579                 col.itemL(text="Display:")
580                 col.itemR(pe, "show_time", text="Time")
581                 col.itemR(pe, "show_children", text="Children")
582
583 bpy.types.register(VIEW3D_PT_tools_objectmode)
584 bpy.types.register(VIEW3D_PT_tools_meshedit)
585 bpy.types.register(VIEW3D_PT_tools_curveedit)
586 bpy.types.register(VIEW3D_PT_tools_surfaceedit)
587 bpy.types.register(VIEW3D_PT_tools_textedit)
588 bpy.types.register(VIEW3D_PT_tools_armatureedit)
589 bpy.types.register(VIEW3D_PT_tools_mballedit)
590 bpy.types.register(VIEW3D_PT_tools_latticeedit)
591 bpy.types.register(VIEW3D_PT_tools_posemode)
592 bpy.types.register(VIEW3D_PT_tools_brush)
593 bpy.types.register(VIEW3D_PT_tools_brush_curve)
594 bpy.types.register(VIEW3D_PT_sculpt_options)
595 bpy.types.register(VIEW3D_PT_tools_vertexpaint)
596 bpy.types.register(VIEW3D_PT_tools_weightpaint)
597 bpy.types.register(VIEW3D_PT_tools_texturepaint)
598 bpy.types.register(VIEW3D_PT_tools_particlemode)