2.5 Button Files:
[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 in ('DRAW', 'PINCH', 'INFLATE', 'LAYER', 'CLAY'):
373                                         col.itemR(brush, "flip_direction")
374                                 
375                 # Texture Paint Mode #
376                 
377                 elif context.texture_paint_object:
378                         col = layout.column(align=True)
379                         col.item_enumR(settings, "tool", 'DRAW')
380                         col.item_enumR(settings, "tool", 'SOFTEN')
381                         if settings.use_projection:
382                                 col.item_enumR(settings, "tool", 'CLONE')
383                         else:
384                                 col.item_enumR(settings, "tool", 'SMEAR')
385                                 
386                         col = layout.column()
387                         col.itemR(brush, "color", text="")
388                                 
389                         row = col.row(align=True)
390                         row.itemR(brush, "size", slider=True)
391                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
392                         
393                         row = col.row(align=True)
394                         row.itemR(brush, "strength", slider=True)
395                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
396                         
397                         row = col.row(align=True)
398                         row.itemR(brush, "falloff", slider=True)
399                         row.itemR(brush, "falloff_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
400                         
401                         row = col.row(align=True)
402                         row.itemR(brush, "space", text="")
403                         rowsub = row.row(align=True)
404                         rowsub.active = brush.space
405                         rowsub.itemR(brush, "spacing", text="Spacing", slider=True)
406                         rowsub.itemR(brush, "spacing_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
407                         
408                         col = layout.column()
409                         col.itemR(brush, "airbrush")
410                         sub = col.column()
411                         sub.active = brush.airbrush
412                         sub.itemR(brush, "rate")
413                 
414                 # Weight Paint Mode #
415         
416                 elif context.weight_paint_object:
417                         layout.itemR(context.tool_settings, "vertex_group_weight", text="Weight", slider=True)
418                         
419                         col = layout.column()
420                         row = col.row(align=True)
421                         row.itemR(brush, "size", slider=True)
422                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
423                         
424                         row = col.row(align=True)
425                         row.itemR(brush, "strength", slider=True)
426                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
427                 
428                 # Vertex Paint Mode #
429                 
430                 elif context.vertex_paint_object:
431                         col = layout.column()
432                         col.itemR(brush, "color", text="")
433                         
434                         row = col.row(align=True)
435                         row.itemR(brush, "size", slider=True)
436                         row.itemR(brush, "size_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
437                         
438                         row = col.row(align=True)
439                         row.itemR(brush, "strength", slider=True)
440                         row.itemR(brush, "strength_pressure", toggle=True, icon='ICON_BRUSH_DATA', text="")
441
442 class VIEW3D_PT_tools_brush_curve(PaintPanel):
443         __label__ = "Curve"
444         __default_closed__ = True
445
446         def poll(self, context):
447                 settings = self.paint_settings(context)
448                 return (settings and settings.brush and settings.brush.curve)
449
450         def draw(self, context):
451                 settings = self.paint_settings(context)
452                 brush = settings.brush
453                 layout = self.layout
454
455                 layout.template_curve_mapping(brush.curve)
456                 
457 class VIEW3D_PT_sculpt_options(PaintPanel):
458         __label__ = "Options"
459
460         def poll(self, context):
461                 return context.sculpt_object
462
463         def draw(self, context):
464                 layout = self.layout
465                 sculpt = context.tool_settings.sculpt
466
467                 col = layout.column()
468                 col.itemR(sculpt, "partial_redraw", text="Partial Refresh")
469                 col.itemR(sculpt, "show_brush")
470
471                 split = self.layout.split()
472                 
473                 col = split.column()
474                 col.itemL(text="Symmetry:")
475                 col.itemR(sculpt, "symmetry_x", text="X")
476                 col.itemR(sculpt, "symmetry_y", text="Y")
477                 col.itemR(sculpt, "symmetry_z", text="Z")
478                 
479                 col = split.column()
480                 col.itemL(text="Lock:")
481                 col.itemR(sculpt, "lock_x", text="X")
482                 col.itemR(sculpt, "lock_y", text="Y")
483                 col.itemR(sculpt, "lock_z", text="Z")
484
485 # ********** default tools for weightpaint ****************
486
487 class View3DPanel(bpy.types.Panel):
488         __space_type__ = "VIEW_3D"
489         __region_type__ = "TOOLS"
490         __context__ = "weight_paint"
491
492 class VIEW3D_PT_weight_paint_options(View3DPanel):
493         __label__ = "Options"
494
495         def draw(self, context):
496                 layout = self.layout
497                 wpaint = context.tool_settings.weight_paint
498
499                 col = layout.column()
500                 col.itemL(text="Blend:")
501                 col.itemR(wpaint, "mode", text="")
502                 col.itemR(wpaint, "all_faces")
503                 col.itemR(wpaint, "normals")
504                 col.itemR(wpaint, "spray")
505                 col.itemR(wpaint, "vertex_dist", text="Distance")
506
507 # Commented out because the Apply button isn't an operator yet, making these settings useless
508 #               col.itemL(text="Gamma:")
509 #               col.itemR(wpaint, "gamma", text="")
510 #               col.itemL(text="Multiply:")
511 #               col.itemR(wpaint, "mul", text="")
512
513 # Also missing now:
514 # Soft, Vgroup, X-Mirror and "Clear" Operator.
515
516 # ********** default tools for vertexpaint ****************
517
518 class View3DPanel(bpy.types.Panel):
519         __space_type__ = "VIEW_3D"
520         __region_type__ = "TOOLS"
521
522 class VIEW3D_PT_vertex_paint_options(View3DPanel):
523         __context__ = "vertex_paint"
524         __label__ = "Options"
525
526         def draw(self, context):
527                 layout = self.layout
528                 vpaint = context.tool_settings.vertex_paint
529
530                 col = layout.column()
531                 col.itemL(text="Blend:")
532                 col.itemR(vpaint, "mode", text="")
533                 col.itemR(vpaint, "all_faces")
534                 col.itemR(vpaint, "normals")
535                 col.itemR(vpaint, "spray")
536                 col.itemR(vpaint, "vertex_dist", text="Distance")
537 # Commented out because the Apply button isn't an operator yet, making these settings useless
538 #               col.itemL(text="Gamma:")
539 #               col.itemR(vpaint, "gamma", text="")
540 #               col.itemL(text="Multiply:")
541 #               col.itemR(vpaint, "mul", text="")
542
543
544 # ********** default tools for texturepaint ****************
545
546 class View3DPanel(bpy.types.Panel):
547         __space_type__ = "VIEW_3D"
548         __region_type__ = "TOOLS"
549         __context__ = "texture_paint"
550
551 class VIEW3D_PT_tools_texture_paint(View3DPanel):
552         __label__ = "Options"
553
554         def draw(self, context):
555                 layout = self.layout
556                 
557                 ipaint = context.tool_settings.image_paint
558                 settings = context.tool_settings.image_paint
559                 
560                 col = layout.column()
561                 col.itemR(ipaint, "use_projection")
562                 sub = col.column()
563                 sub.active = ipaint.use_projection
564                 sub.itemR(ipaint, "use_occlude")
565                 sub.itemR(ipaint, "use_backface_cull")
566                 sub.itemR(ipaint, "use_normal_falloff")
567                 sub.itemR(ipaint, "use_stencil_layer")
568                 subsub = sub.column()
569                 subsub.active = ipaint.use_stencil_layer
570                 subsub.itemR(ipaint, "invert_stencil")
571                 if settings.tool == 'CLONE':
572                         sub.itemR(ipaint, "use_clone_layer")
573                 
574                 sub.itemR(ipaint, "seam_bleed")
575                 sub.itemR(ipaint, "normal_angle")
576                 
577 # ********** default tools for particle mode ****************
578
579 class View3DPanel(bpy.types.Panel):
580         __space_type__ = "VIEW_3D"
581         __region_type__ = "TOOLS"
582         __context__ = "particle_mode"
583
584 class VIEW3D_PT_tools_particle_edit(View3DPanel):
585         __label__ = "Options"
586
587         def draw(self, context):
588                 layout = self.layout
589                 pe = context.tool_settings.particle_edit
590
591                 col = layout.column(align=True)
592                 col.itemR(pe, "emitter_deflect", text="Deflect")
593                 sub = col.row()
594                 sub.active = pe.emitter_deflect
595                 sub.itemR(pe, "emitter_distance", text="Distance")
596                 
597                 col = layout.column(align=True)
598                 col.itemL(text="Keep:")
599                 col.itemR(pe, "keep_lengths", text="Lenghts")
600                 col.itemR(pe, "keep_root", text="Root")
601                 
602                 col = layout.column(align=True)
603                 col.itemL(text="Draw:")
604                 col.itemR(pe, "show_time", text="Time")
605                 col.itemR(pe, "show_children", text="Children")
606
607 bpy.types.register(VIEW3D_PT_tools_objectmode)
608 bpy.types.register(VIEW3D_PT_tools_editmode_mesh)
609 bpy.types.register(VIEW3D_PT_tools_editmode_curve)
610 bpy.types.register(VIEW3D_PT_tools_editmode_surface)
611 bpy.types.register(VIEW3D_PT_tools_editmode_text)
612 bpy.types.register(VIEW3D_PT_tools_editmode_armature)
613 bpy.types.register(VIEW3D_PT_tools_editmode_mball)
614 bpy.types.register(VIEW3D_PT_tools_editmode_lattice)
615 bpy.types.register(VIEW3D_PT_tools_posemode)
616 bpy.types.register(VIEW3D_PT_tools_brush)
617 bpy.types.register(VIEW3D_PT_tools_brush_curve)
618 bpy.types.register(VIEW3D_PT_sculpt_options)
619 bpy.types.register(VIEW3D_PT_vertex_paint_options)
620 bpy.types.register(VIEW3D_PT_weight_paint_options)
621 bpy.types.register(VIEW3D_PT_tools_texture_paint)
622 bpy.types.register(VIEW3D_PT_tools_particle_edit)