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