54d3b61c665c21af118dc446dc16b86f8b257773
[blender-staging.git] / release / scripts / startup / bl_ui / space_view3d_toolbar.py
1 # ##### BEGIN GPL LICENSE BLOCK #####
2 #
3 #  This program is free software; you can redistribute it and/or
4 #  modify it under the terms of the GNU General Public License
5 #  as published by the Free Software Foundation; either version 2
6 #  of the License, or (at your option) any later version.
7 #
8 #  This program is distributed in the hope that it will be useful,
9 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 #  GNU General Public License for more details.
12 #
13 #  You should have received a copy of the GNU General Public License
14 #  along with this program; if not, write to the Free Software Foundation,
15 #  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 #
17 # ##### END GPL LICENSE BLOCK #####
18
19 # <pep8 compliant>
20 import bpy
21 from bpy.types import Menu, Panel
22 from bl_ui.properties_paint_common import UnifiedPaintPanel
23 from bl_ui.properties_paint_common import brush_texture_settings
24 from bl_ui.properties_paint_common import brush_mask_texture_settings
25
26
27 class View3DPanel():
28     bl_space_type = 'VIEW_3D'
29     bl_region_type = 'TOOLS'
30
31
32 # **************** standard tool clusters ******************
33
34 # History/Repeat tools
35 def draw_repeat_tools(context, layout):
36     col = layout.column(align=True)
37     col.label(text="Repeat:")
38     col.operator("screen.repeat_last")
39     col.operator("screen.repeat_history", text="History...")
40
41
42 # Keyframing tools
43 def draw_keyframing_tools(context, layout):
44     col = layout.column(align=True)
45     col.label(text="Keyframes:")
46     row = col.row()
47     row.operator("anim.keyframe_insert_menu", text="Insert")
48     row.operator("anim.keyframe_delete_v3d", text="Remove")
49
50
51 # Grease Pencil tools
52 def draw_gpencil_tools(context, layout):
53     col = layout.column(align=True)
54
55     col.label(text="Grease Pencil:")
56
57     row = col.row()
58     row.operator("gpencil.draw", text="Draw").mode = 'DRAW'
59     row.operator("gpencil.draw", text="Line").mode = 'DRAW_STRAIGHT'
60
61     row = col.row()
62     row.operator("gpencil.draw", text="Poly").mode = 'DRAW_POLY'
63     row.operator("gpencil.draw", text="Erase").mode = 'ERASER'
64
65     row = col.row()
66     row.prop(context.tool_settings, "use_grease_pencil_sessions")
67
68     col.operator("view3d.ruler")
69
70
71 # ********** default tools for object-mode ****************
72
73 class VIEW3D_PT_tools_objectmode(View3DPanel, Panel):
74     bl_context = "objectmode"
75     bl_label = "Object Tools"
76
77     def draw(self, context):
78         layout = self.layout
79
80         col = layout.column(align=True)
81         col.label(text="Transform:")
82         col.operator("transform.translate")
83         col.operator("transform.rotate")
84         col.operator("transform.resize", text="Scale")
85
86         col = layout.column(align=True)
87         col.operator("object.origin_set", text="Origin")
88
89         col = layout.column(align=True)
90         col.label(text="Object:")
91         col.operator("object.duplicate_move")
92         col.operator("object.delete")
93         col.operator("object.join")
94
95         active_object = context.active_object
96         if active_object and active_object.type in {'MESH', 'CURVE', 'SURFACE'}:
97
98             col = layout.column(align=True)
99             col.label(text="Shading:")
100             row = col.row(align=True)
101             row.operator("object.shade_smooth", text="Smooth")
102             row.operator("object.shade_flat", text="Flat")
103
104         draw_keyframing_tools(context, layout)
105
106         col = layout.column(align=True)
107         col.label(text="Motion Paths:")
108         row = col.row(align=True)
109         row.operator("object.paths_calculate", text="Calculate")
110         row.operator("object.paths_clear", text="Clear")
111
112         draw_repeat_tools(context, layout)
113
114         draw_gpencil_tools(context, layout)
115         col = layout.column(align=True)
116
117
118 class VIEW3D_PT_tools_rigidbody(View3DPanel, Panel):
119     bl_context = "objectmode"
120     bl_label = "Rigid Body Tools"
121     bl_options = {'DEFAULT_CLOSED'}
122
123     def draw(self, context):
124         layout = self.layout
125
126         col = layout.column(align=True)
127         col.label(text="Add/Remove:")
128         row = col.row()
129         row.operator("rigidbody.objects_add", text="Add Active").type = 'ACTIVE'
130         row.operator("rigidbody.objects_add", text="Add Passive").type = 'PASSIVE'
131         row = col.row()
132         row.operator("rigidbody.objects_remove", text="Remove")
133
134         col = layout.column(align=True)
135         col.label(text="Object Tools:")
136         col.operator("rigidbody.shape_change", text="Change Shape")
137         col.operator("rigidbody.mass_calculate", text="Calculate Mass")
138         col.operator("rigidbody.object_settings_copy", text="Copy from Active")
139         col.operator("rigidbody.bake_to_keyframes", text="Bake To Keyframes")
140         col.label(text="Constraints:")
141         col.operator("rigidbody.connect", text="Connect")
142
143 # ********** default tools for editmode_mesh ****************
144
145
146 class VIEW3D_PT_tools_meshedit(View3DPanel, Panel):
147     bl_context = "mesh_edit"
148     bl_label = "Mesh Tools"
149
150     def draw(self, context):
151         layout = self.layout
152
153         col = layout.column(align=True)
154         col.label(text="Transform:")
155         col.operator("transform.translate")
156         col.operator("transform.rotate")
157         col.operator("transform.resize", text="Scale")
158         col.operator("transform.shrink_fatten", text="Shrink/Fatten")
159         col.operator("transform.push_pull", text="Push/Pull")
160
161         col = layout.column(align=True)
162         col.label(text="Deform:")
163         col.operator("transform.edge_slide")
164         col.operator("mesh.noise")
165         col.operator("mesh.vertices_smooth")
166
167         col = layout.column(align=True)
168         col.label(text="Add:")
169         col.operator("view3d.edit_mesh_extrude_move_normal", text="Extrude Region")
170         col.operator("view3d.edit_mesh_extrude_individual_move", text="Extrude Individual")
171         col.operator("mesh.subdivide")
172         col.operator("mesh.loopcut_slide")
173         col.operator("mesh.duplicate_move", text="Duplicate")
174         col.operator("mesh.spin")
175         col.operator("mesh.screw")
176
177         row = col.row(align=True)
178         props = row.operator("mesh.knife_tool", text="Knife")
179         props.use_occlude_geometry = True
180         props.only_selected = False
181         props = row.operator("mesh.knife_tool", text="Select")
182         props.use_occlude_geometry = False
183         props.only_selected = True
184         col.operator("mesh.knife_project")
185
186         col = layout.column(align=True)
187         col.label(text="Remove:")
188         col.menu("VIEW3D_MT_edit_mesh_delete")
189         col.operator("mesh.merge")
190         col.operator("mesh.remove_doubles")
191
192         col = layout.column(align=True)
193         col.label(text="Normals:")
194         col.operator("mesh.normals_make_consistent", text="Recalculate")
195         col.operator("mesh.flip_normals", text="Flip Direction")
196
197         col = layout.column(align=True)
198         col.label(text="UV Mapping:")
199         col.operator("wm.call_menu", text="Unwrap").name = "VIEW3D_MT_uv_map"
200         col.operator("mesh.mark_seam").clear = False
201         col.operator("mesh.mark_seam", text="Clear Seam").clear = True
202
203         col = layout.column(align=True)
204         col.label(text="Shading:")
205         row = col.row(align=True)
206         row.operator("mesh.faces_shade_smooth", text="Smooth")
207         row.operator("mesh.faces_shade_flat", text="Flat")
208
209         draw_repeat_tools(context, layout)
210
211         draw_gpencil_tools(context, layout)
212
213
214 class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
215     bl_context = "mesh_edit"
216     bl_label = "Mesh Options"
217
218     @classmethod
219     def poll(cls, context):
220         return context.active_object
221
222     def draw(self, context):
223         layout = self.layout
224
225         ob = context.active_object
226
227         tool_settings = context.tool_settings
228         mesh = ob.data
229
230         col = layout.column(align=True)
231         col.active = tool_settings.proportional_edit == 'DISABLED'
232         col.prop(mesh, "use_mirror_x")
233
234         row = col.row()
235         row.active = ob.data.use_mirror_x
236         row.prop(mesh, "use_mirror_topology")
237
238         col = layout.column(align=True)
239         col.label("Edge Select Mode:")
240         col.prop(tool_settings, "edge_path_mode", text="")
241         col.prop(tool_settings, "edge_path_live_unwrap")
242         col.label("Double Threshold:")
243         col.prop(tool_settings, "double_threshold", text="")
244
245 # ********** default tools for editmode_curve ****************
246
247
248 class VIEW3D_PT_tools_curveedit(View3DPanel, Panel):
249     bl_context = "curve_edit"
250     bl_label = "Curve Tools"
251
252     def draw(self, context):
253         layout = self.layout
254
255         col = layout.column(align=True)
256         col.label(text="Transform:")
257         col.operator("transform.translate")
258         col.operator("transform.rotate")
259         col.operator("transform.resize", text="Scale")
260
261         col = layout.column(align=True)
262         col.operator("transform.tilt", text="Tilt")
263         col.operator("transform.transform", text="Scale Feather").mode = 'CURVE_SHRINKFATTEN'
264
265         col = layout.column(align=True)
266         col.label(text="Curve:")
267         col.operator("curve.duplicate_move", text="Duplicate")
268         col.operator("curve.delete")
269         col.operator("curve.cyclic_toggle")
270         col.operator("curve.switch_direction")
271         col.operator("curve.spline_type_set")
272         col.operator("curve.radius_set")
273         col.operator("curve.smooth_radius")
274
275         col = layout.column(align=True)
276         col.label(text="Handles:")
277         row = col.row()
278         row.operator("curve.handle_type_set", text="Auto").type = 'AUTOMATIC'
279         row.operator("curve.handle_type_set", text="Vector").type = 'VECTOR'
280         row = col.row()
281         row.operator("curve.handle_type_set", text="Align").type = 'ALIGNED'
282         row.operator("curve.handle_type_set", text="Free").type = 'FREE_ALIGN'
283
284         col = layout.column(align=True)
285         col.label(text="Modeling:")
286         col.operator("curve.extrude_move", text="Extrude")
287         col.operator("curve.subdivide")
288         col.operator("curve.smooth")
289
290         draw_repeat_tools(context, layout)
291
292         draw_gpencil_tools(context, layout)
293
294 # ********** default tools for editmode_surface ****************
295
296
297 class VIEW3D_PT_tools_surfaceedit(View3DPanel, Panel):
298     bl_context = "surface_edit"
299     bl_label = "Surface Tools"
300
301     def draw(self, context):
302         layout = self.layout
303
304         col = layout.column(align=True)
305         col.label(text="Transform:")
306         col.operator("transform.translate")
307         col.operator("transform.rotate")
308         col.operator("transform.resize", text="Scale")
309
310         col = layout.column(align=True)
311         col.label(text="Curve:")
312         col.operator("curve.duplicate_move", text="Duplicate")
313         col.operator("curve.delete")
314         col.operator("curve.cyclic_toggle")
315         col.operator("curve.switch_direction")
316
317         col = layout.column(align=True)
318         col.label(text="Modeling:")
319         col.operator("curve.extrude", text="Extrude")
320         col.operator("curve.subdivide")
321
322         draw_repeat_tools(context, layout)
323
324         draw_gpencil_tools(context, layout)
325
326 # ********** default tools for editmode_text ****************
327
328
329 class VIEW3D_PT_tools_textedit(View3DPanel, Panel):
330     bl_context = "text_edit"
331     bl_label = "Text Tools"
332
333     def draw(self, context):
334         layout = self.layout
335
336         col = layout.column(align=True)
337         col.label(text="Text Edit:")
338         col.operator("font.text_copy", text="Copy")
339         col.operator("font.text_cut", text="Cut")
340         col.operator("font.text_paste", text="Paste")
341
342         col = layout.column(align=True)
343         col.label(text="Set Case:")
344         col.operator("font.case_set", text="To Upper").case = 'UPPER'
345         col.operator("font.case_set", text="To Lower").case = 'LOWER'
346
347         col = layout.column(align=True)
348         col.label(text="Style:")
349         col.operator("font.style_toggle", text="Bold").style = 'BOLD'
350         col.operator("font.style_toggle", text="Italic").style = 'ITALIC'
351         col.operator("font.style_toggle", text="Underline").style = 'UNDERLINE'
352
353         draw_repeat_tools(context, layout)
354
355
356 # ********** default tools for editmode_armature ****************
357
358
359 class VIEW3D_PT_tools_armatureedit(View3DPanel, Panel):
360     bl_context = "armature_edit"
361     bl_label = "Armature Tools"
362
363     def draw(self, context):
364         layout = self.layout
365
366         col = layout.column(align=True)
367         col.label(text="Transform:")
368         col.operator("transform.translate")
369         col.operator("transform.rotate")
370         col.operator("transform.resize", text="Scale")
371
372         col = layout.column(align=True)
373         col.label(text="Bones:")
374         col.operator("armature.bone_primitive_add", text="Add")
375         col.operator("armature.duplicate_move", text="Duplicate")
376         col.operator("armature.delete", text="Delete")
377
378         col = layout.column(align=True)
379         col.label(text="Modeling:")
380         col.operator("armature.extrude_move")
381         col.operator("armature.subdivide", text="Subdivide")
382
383         draw_repeat_tools(context, layout)
384
385         draw_gpencil_tools(context, layout)
386
387
388 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
389     bl_context = "armature_edit"
390     bl_label = "Armature Options"
391
392     def draw(self, context):
393         arm = context.active_object.data
394
395         self.layout.prop(arm, "use_mirror_x")
396
397 # ********** default tools for editmode_mball ****************
398
399
400 class VIEW3D_PT_tools_mballedit(View3DPanel, Panel):
401     bl_context = "mball_edit"
402     bl_label = "Meta Tools"
403
404     def draw(self, context):
405         layout = self.layout
406
407         col = layout.column(align=True)
408         col.label(text="Transform:")
409         col.operator("transform.translate")
410         col.operator("transform.rotate")
411         col.operator("transform.resize", text="Scale")
412
413         draw_repeat_tools(context, layout)
414
415         draw_gpencil_tools(context, layout)
416
417 # ********** default tools for editmode_lattice ****************
418
419
420 class VIEW3D_PT_tools_latticeedit(View3DPanel, Panel):
421     bl_context = "lattice_edit"
422     bl_label = "Lattice Tools"
423
424     def draw(self, context):
425         layout = self.layout
426
427         col = layout.column(align=True)
428         col.label(text="Transform:")
429         col.operator("transform.translate")
430         col.operator("transform.rotate")
431         col.operator("transform.resize", text="Scale")
432
433         col = layout.column(align=True)
434         col.operator("lattice.make_regular")
435
436         draw_repeat_tools(context, layout)
437
438         draw_gpencil_tools(context, layout)
439
440
441 # ********** default tools for pose-mode ****************
442
443
444 class VIEW3D_PT_tools_posemode(View3DPanel, Panel):
445     bl_context = "posemode"
446     bl_label = "Pose Tools"
447
448     def draw(self, context):
449         layout = self.layout
450
451         col = layout.column(align=True)
452         col.label(text="Transform:")
453         col.operator("transform.translate")
454         col.operator("transform.rotate")
455         col.operator("transform.resize", text="Scale")
456
457         col = layout.column(align=True)
458         col.label(text="In-Between:")
459         row = col.row()
460         row.operator("pose.push", text="Push")
461         row.operator("pose.relax", text="Relax")
462         col.operator("pose.breakdown", text="Breakdowner")
463
464         col = layout.column(align=True)
465         col.label(text="Pose:")
466         row = col.row()
467         row.operator("pose.copy", text="Copy")
468         row.operator("pose.paste", text="Paste")
469
470         col = layout.column(align=True)
471         col.operator("poselib.pose_add", text="Add To Library")
472
473         draw_keyframing_tools(context, layout)
474
475         col = layout.column(align=True)
476         col.label(text="Motion Paths:")
477         row = col.row(align=True)
478         row.operator("pose.paths_calculate", text="Calculate")
479         row.operator("pose.paths_clear", text="Clear")
480
481         draw_repeat_tools(context, layout)
482
483         draw_gpencil_tools(context, layout)
484
485
486 class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
487     bl_context = "posemode"
488     bl_label = "Pose Options"
489
490     def draw(self, context):
491         arm = context.active_object.data
492
493         self.layout.prop(arm, "use_auto_ik")
494
495 # ********** default tools for paint modes ****************
496
497
498 class View3DPaintPanel(UnifiedPaintPanel):
499     bl_space_type = 'VIEW_3D'
500     bl_region_type = 'TOOLS'
501
502
503 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
504     bl_label = "Brush"
505
506     @classmethod
507     def poll(cls, context):
508         return cls.paint_settings(context)
509
510     def draw(self, context):
511         layout = self.layout
512
513         toolsettings = context.tool_settings
514         settings = self.paint_settings(context)
515         brush = settings.brush
516
517         if not context.particle_edit_object:
518             col = layout.split().column()
519             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
520
521         # Particle Mode #
522         if context.particle_edit_object:
523             tool = settings.tool
524
525             layout.column().prop(settings, "tool", expand=True)
526
527             if tool != 'NONE':
528                 col = layout.column()
529                 col.prop(brush, "size", slider=True)
530                 if tool != 'ADD':
531                     col.prop(brush, "strength", slider=True)
532
533             if tool == 'ADD':
534                 col.prop(brush, "count")
535                 col = layout.column()
536                 col.prop(settings, "use_default_interpolate")
537                 sub = col.column(align=True)
538                 sub.active = settings.use_default_interpolate
539                 sub.prop(brush, "steps", slider=True)
540                 sub.prop(settings, "default_key_count", slider=True)
541             elif tool == 'LENGTH':
542                 layout.prop(brush, "length_mode", expand=True)
543             elif tool == 'PUFF':
544                 layout.prop(brush, "puff_mode", expand=True)
545                 layout.prop(brush, "use_puff_volume")
546
547         # Sculpt Mode #
548
549         elif context.sculpt_object and brush:
550             capabilities = brush.sculpt_capabilities
551
552             col = layout.column()
553
554             col.separator()
555
556             row = col.row(align=True)
557
558             ups = toolsettings.unified_paint_settings
559             if     ((ups.use_unified_size and ups.use_locked_size) or
560                     ((not ups.use_unified_size) and brush.use_locked_size)):
561                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
562                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
563             else:
564                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
565                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
566
567             self.prop_unified_size(row, context, brush, "use_pressure_size")
568
569             # strength, use_strength_pressure, and use_strength_attenuation
570             if capabilities.has_strength:
571                 col.separator()
572                 row = col.row(align=True)
573
574                 if capabilities.has_space_attenuation:
575                     if brush.use_space_attenuation:
576                         row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='LOCKED')
577                     else:
578                         row.prop(brush, "use_space_attenuation", toggle=True, text="", icon='UNLOCKED')
579
580                 self.prop_unified_strength(row, context, brush, "strength", text="Strength")
581                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
582
583             # auto_smooth_factor and use_inverse_smooth_pressure
584             if capabilities.has_auto_smooth:
585                 col.separator()
586
587                 row = col.row(align=True)
588                 row.prop(brush, "auto_smooth_factor", slider=True)
589                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
590
591             # normal_weight
592             if capabilities.has_normal_weight:
593                 col.separator()
594                 row = col.row(align=True)
595                 row.prop(brush, "normal_weight", slider=True)
596
597             # crease_pinch_factor
598             if capabilities.has_pinch_factor:
599                 col.separator()
600                 row = col.row(align=True)
601                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
602
603             # use_original_normal and sculpt_plane
604             if capabilities.has_sculpt_plane:
605                 row = col.row(align=True)
606                 col.separator()
607
608                 if brush.use_original_normal:
609                     row.prop(brush, "use_original_normal", toggle=True, text="", icon='LOCKED')
610                 else:
611                     row.prop(brush, "use_original_normal", toggle=True, text="", icon='UNLOCKED')
612
613                 row.prop(brush, "sculpt_plane", text="")
614
615             if brush.sculpt_tool == 'MASK':
616                 col.prop(brush, "mask_tool", text="")
617
618             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
619             if capabilities.has_plane_offset:
620                 row = col.row(align=True)
621                 row.prop(brush, "plane_offset", slider=True)
622                 row.prop(brush, "use_offset_pressure", text="")
623
624                 col.separator()
625
626                 row = col.row()
627                 row.prop(brush, "use_plane_trim", text="Trim")
628                 row = col.row()
629                 row.active = brush.use_plane_trim
630                 row.prop(brush, "plane_trim", slider=True, text="Distance")
631
632             # height
633             if capabilities.has_height:
634                 row = col.row()
635                 row.prop(brush, "height", slider=True, text="Height")
636
637             # use_frontface
638             col.separator()
639             row = col.row()
640             row.prop(brush, "use_frontface", text="Front Faces Only")
641
642             # direction
643             col.separator()
644             col.row().prop(brush, "direction", expand=True)
645
646             # use_accumulate
647             if capabilities.has_accumulate:
648                 col.separator()
649
650                 col.prop(brush, "use_accumulate")
651
652             # use_persistent, set_persistent_base
653             if capabilities.has_persistence:
654                 col.separator()
655
656                 ob = context.sculpt_object
657                 do_persistent = True
658
659                 # not supported yet for this case
660                 for md in ob.modifiers:
661                     if md.type == 'MULTIRES':
662                         do_persistent = False
663
664                 if do_persistent:
665                     col.prop(brush, "use_persistent")
666                     col.operator("sculpt.set_persistent_base")
667
668         # Texture Paint Mode #
669
670         elif context.image_paint_object and brush:
671             col = layout.column()
672             col.template_color_picker(brush, "color", value_slider=True)
673             col.prop(brush, "color", text="")
674
675             row = col.row(align=True)
676             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
677             self.prop_unified_size(row, context, brush, "use_pressure_size")
678
679             row = col.row(align=True)
680             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
681             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
682
683             row = col.row(align=True)
684             if(brush.use_relative_jitter):
685                 row.prop(brush, "use_relative_jitter", text="", icon='LOCKED')
686                 row.prop(brush, "jitter", slider=True)
687             else:
688                 row.prop(brush, "use_relative_jitter", text="", icon='UNLOCKED')
689                 row.prop(brush, "jitter_absolute")
690             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
691
692             col.prop(brush, "blend", text="Blend")
693
694             col = layout.column()
695             col.active = (brush.blend not in {'ERASE_ALPHA', 'ADD_ALPHA'})
696             col.prop(brush, "use_alpha")
697
698         # Weight Paint Mode #
699         elif context.weight_paint_object and brush:
700             layout.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
701             layout.prop(toolsettings, "use_multipaint", text="Multi-Paint")
702
703             col = layout.column()
704
705             row = col.row(align=True)
706             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
707
708             row = col.row(align=True)
709             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
710             self.prop_unified_size(row, context, brush, "use_pressure_size")
711
712             row = col.row(align=True)
713             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
714             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
715
716             row = col.row(align=True)
717             if(brush.use_relative_jitter):
718                 row.prop(brush, "use_relative_jitter", text="", icon='LOCKED')
719                 row.prop(brush, "jitter", slider=True)
720             else:
721                 row.prop(brush, "use_relative_jitter", text="", icon='UNLOCKED')
722                 row.prop(brush, "jitter_absolute")
723             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
724
725             col.prop(brush, "vertex_tool", text="Blend")
726
727         # Vertex Paint Mode #
728         elif context.vertex_paint_object and brush:
729             col = layout.column()
730             col.template_color_picker(brush, "color", value_slider=True)
731             col.prop(brush, "color", text="")
732
733             row = col.row(align=True)
734             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
735             self.prop_unified_size(row, context, brush, "use_pressure_size")
736
737             row = col.row(align=True)
738             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
739             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
740
741             # XXX - TODO
742             #row = col.row(align=True)
743             #row.prop(brush, "jitter", slider=True)
744             #row.prop(brush, "use_pressure_jitter", toggle=True, text="")
745
746             col.prop(brush, "vertex_tool", text="Blend")
747
748
749 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
750     bl_label = "Texture"
751     bl_options = {'DEFAULT_CLOSED'}
752
753     @classmethod
754     def poll(cls, context):
755         settings = cls.paint_settings(context)
756         return (settings and settings.brush and
757                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
758
759     def draw(self, context):
760         layout = self.layout
761
762         settings = self.paint_settings(context)
763         brush = settings.brush
764         tex_slot = brush.texture_slot
765
766         col = layout.column()
767
768         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
769
770         brush_texture_settings(col, brush, context.sculpt_object)
771
772         # use_texture_overlay and texture_overlay_alpha
773         col = layout.column(align=True)
774         col.active = brush.brush_capabilities.has_overlay
775         col.label(text="Overlay:")
776
777         row = col.row()
778         if brush.use_texture_overlay:
779             row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_OFF')
780         else:
781             row.prop(brush, "use_texture_overlay", toggle=True, text="", icon='RESTRICT_VIEW_ON')
782         sub = row.row()
783         sub.prop(brush, "texture_overlay_alpha", text="Alpha")
784
785
786 class VIEW3D_PT_tools_mask_texture(View3DPanel, Panel):
787     bl_context = "imagepaint"
788     bl_label = "Texture Mask"
789     bl_options = {'DEFAULT_CLOSED'}
790
791     @classmethod
792     def poll(cls, context):
793         brush = context.tool_settings.image_paint.brush
794         return (context.image_paint_object and brush and brush.image_tool != 'SOFTEN')
795
796     def draw_header(self, context):
797         brush = context.tool_settings.image_paint.brush
798         tex_slot_alpha = brush.mask_texture_slot
799         self.layout.prop(brush, 'use_mask', text="")
800
801     def draw(self, context):
802         layout = self.layout
803
804         brush = context.tool_settings.image_paint.brush
805         tex_slot_alpha = brush.mask_texture_slot
806
807         col = layout.column()
808
809         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
810
811         brush_mask_texture_settings(col, brush)
812
813
814 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
815     bl_label = "Stroke"
816     bl_options = {'DEFAULT_CLOSED'}
817
818     @classmethod
819     def poll(cls, context):
820         settings = cls.paint_settings(context)
821         return (settings and
822                 settings.brush and
823                 (context.sculpt_object or
824                  context.vertex_paint_object or
825                  context.weight_paint_object or
826                  context.image_paint_object))
827
828     def draw(self, context):
829         layout = self.layout
830
831         settings = self.paint_settings(context)
832         brush = settings.brush
833         image_paint = context.image_paint_object
834
835         col = layout.column()
836
837         if context.sculpt_object:
838             col.label(text="Stroke Method:")
839             col.prop(brush, "stroke_method", text="")
840
841             if brush.use_anchor:
842                 col.separator()
843                 col.prop(brush, "use_edge_to_edge", "Edge To Edge")
844
845             if brush.use_airbrush:
846                 col.separator()
847                 col.prop(brush, "rate", text="Rate", slider=True)
848
849             if brush.use_space:
850                 col.separator()
851                 row = col.row(align=True)
852                 row.active = brush.use_space
853                 row.prop(brush, "spacing", text="Spacing")
854                 row.prop(brush, "use_pressure_spacing", toggle=True, text="")
855
856             if brush.sculpt_capabilities.has_smooth_stroke:
857                 col = layout.column()
858                 col.separator()
859
860                 col.prop(brush, "use_smooth_stroke")
861
862                 sub = col.column()
863                 sub.active = brush.use_smooth_stroke
864                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
865                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
866
867             if brush.sculpt_capabilities.has_jitter:
868                 col.separator()
869
870                 row = col.row(align=True)
871                 if(brush.use_relative_jitter):
872                     row.prop(brush, "use_relative_jitter", text="", icon='LOCKED')
873                     row.prop(brush, "jitter", slider=True)
874                 else:
875                     row.prop(brush, "use_relative_jitter", text="", icon='UNLOCKED')
876                     row.prop(brush, "jitter_absolute")
877                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
878
879         else:
880             col.prop(brush, "use_airbrush")
881
882             row = col.row()
883             row.active = brush.use_airbrush and (not brush.use_space) and (not brush.use_anchor)
884             row.prop(brush, "rate", slider=True)
885
886             col.separator()
887
888             col.prop(brush, "use_smooth_stroke")
889
890             col = layout.column()
891             col.active = brush.use_smooth_stroke
892             col.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
893             col.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
894
895             col.separator()
896
897             col = layout.column()
898             col.active = brush.brush_capabilities.has_spacing
899             col.prop(brush, "use_space")
900
901             row = col.row(align=True)
902             row.active = brush.use_space
903             row.prop(brush, "spacing", text="Spacing")
904             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
905
906
907 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
908     bl_label = "Curve"
909     bl_options = {'DEFAULT_CLOSED'}
910
911     @classmethod
912     def poll(cls, context):
913         settings = cls.paint_settings(context)
914         return (settings and settings.brush and settings.brush.curve)
915
916     def draw(self, context):
917         layout = self.layout
918
919         settings = self.paint_settings(context)
920
921         brush = settings.brush
922
923         layout.template_curve_mapping(brush, "curve", brush=True)
924
925         row = layout.row(align=True)
926         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
927         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
928         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
929         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
930         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
931         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
932
933
934 class VIEW3D_PT_sculpt_topology(Panel, View3DPaintPanel):
935     bl_label = "Topology"
936     bl_options = {'DEFAULT_CLOSED'}
937
938     @classmethod
939     def poll(cls, context):
940         return (context.sculpt_object and context.tool_settings.sculpt)
941
942     def draw(self, context):
943         layout = self.layout
944
945         toolsettings = context.tool_settings
946         sculpt = toolsettings.sculpt
947
948         if context.sculpt_object.use_dynamic_topology_sculpting:
949             layout.operator("sculpt.dynamic_topology_toggle", icon='X', text="Disable Dynamic")
950         else:
951             layout.operator("sculpt.dynamic_topology_toggle", icon='SCULPT_DYNTOPO', text="Enable Dynamic")
952
953         col = layout.column()
954         col.active = context.sculpt_object.use_dynamic_topology_sculpting
955         col.prop(sculpt, "detail_size")
956         col.prop(sculpt, "use_smooth_shading")
957         col.prop(sculpt, "use_edge_collapse")
958         col.operator("sculpt.optimize")
959         col.separator()
960         col.prop(sculpt, "symmetrize_direction")
961         col.operator("sculpt.symmetrize")
962
963
964 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
965     bl_label = "Options"
966     bl_options = {'DEFAULT_CLOSED'}
967
968     @classmethod
969     def poll(cls, context):
970         return (context.sculpt_object and context.tool_settings.sculpt)
971
972     def draw(self, context):
973         layout = self.layout
974
975         toolsettings = context.tool_settings
976         sculpt = toolsettings.sculpt
977
978         layout.label(text="Lock:")
979         row = layout.row(align=True)
980         row.prop(sculpt, "lock_x", text="X", toggle=True)
981         row.prop(sculpt, "lock_y", text="Y", toggle=True)
982         row.prop(sculpt, "lock_z", text="Z", toggle=True)
983
984         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
985         layout.prop(sculpt, "show_low_resolution")
986         layout.prop(sculpt, "show_brush")
987         layout.prop(sculpt, "use_deform_only")
988         layout.prop(sculpt, "show_diffuse_color")
989
990         layout.prop(sculpt, "input_samples")
991
992         self.unified_paint_settings(layout, context)
993
994
995 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
996     bl_label = "Symmetry"
997     bl_options = {'DEFAULT_CLOSED'}
998
999     @classmethod
1000     def poll(cls, context):
1001         return (context.sculpt_object and context.tool_settings.sculpt)
1002
1003     def draw(self, context):
1004         layout = self.layout
1005
1006         sculpt = context.tool_settings.sculpt
1007
1008         col = layout.column(align=True)
1009         col.label(text="Mirror:")
1010         row = col.row()
1011         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1012         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1013         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1014
1015         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1016         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1017
1018
1019 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1020     bl_label = "Appearance"
1021     bl_options = {'DEFAULT_CLOSED'}
1022
1023     @classmethod
1024     def poll(cls, context):
1025         toolsettings = context.tool_settings
1026         return ((context.sculpt_object and toolsettings.sculpt) or
1027                 (context.vertex_paint_object and toolsettings.vertex_paint) or
1028                 (context.weight_paint_object and toolsettings.weight_paint) or
1029                 (context.image_paint_object and toolsettings.image_paint))
1030
1031     def draw(self, context):
1032         layout = self.layout
1033
1034         settings = self.paint_settings(context)
1035         brush = settings.brush
1036
1037         if brush is None:  # unlikely but can happen
1038             layout.label(text="Brush Unset")
1039             return
1040
1041         col = layout.column()
1042
1043         if context.sculpt_object and context.tool_settings.sculpt:
1044             if brush.sculpt_capabilities.has_secondary_color:
1045                 col.prop(brush, "cursor_color_add", text="Add Color")
1046                 col.prop(brush, "cursor_color_subtract", text="Subtract Color")
1047             else:
1048                 col.prop(brush, "cursor_color_add", text="Color")
1049         else:
1050             col.prop(brush, "cursor_color_add", text="Color")
1051
1052         col = layout.column(align=True)
1053         col.prop(brush, "use_custom_icon")
1054         if brush.use_custom_icon:
1055             col.prop(brush, "icon_filepath", text="")
1056
1057 # ********** default tools for weight-paint ****************
1058
1059
1060 class VIEW3D_PT_tools_weightpaint(View3DPanel, Panel):
1061     bl_context = "weightpaint"
1062     bl_label = "Weight Tools"
1063
1064     def draw(self, context):
1065         layout = self.layout
1066
1067         ob = context.active_object
1068
1069         col = layout.column()
1070         col.active = ob.vertex_groups.active is not None
1071         col.operator("object.vertex_group_normalize_all", text="Normalize All")
1072         col.operator("object.vertex_group_normalize", text="Normalize")
1073         col.operator("object.vertex_group_mirror", text="Mirror")
1074         col.operator("object.vertex_group_invert", text="Invert")
1075         col.operator("object.vertex_group_clean", text="Clean")
1076         col.operator("object.vertex_group_levels", text="Levels")
1077         col.operator("object.vertex_group_blend", text="Blend")
1078         col.operator("object.vertex_group_transfer_weight", text="Transfer Weights")
1079         col.operator("object.vertex_group_limit_total", text="Limit Total")
1080         col.operator("object.vertex_group_fix", text="Fix Deforms")
1081         col.operator("paint.weight_gradient")
1082
1083
1084 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1085     bl_context = "weightpaint"
1086     bl_label = "Options"
1087
1088     def draw(self, context):
1089         layout = self.layout
1090
1091         tool_settings = context.tool_settings
1092         wpaint = tool_settings.weight_paint
1093
1094         col = layout.column()
1095
1096         col.prop(wpaint, "use_all_faces")
1097         col.prop(wpaint, "use_normal")
1098         col.prop(wpaint, "use_spray")
1099         col.prop(wpaint, "use_group_restrict")
1100
1101         obj = context.weight_paint_object
1102         if obj.type == 'MESH':
1103             mesh = obj.data
1104             col.prop(mesh, "use_mirror_x")
1105             col.prop(mesh, "use_mirror_topology")
1106
1107         col.prop(wpaint, "input_samples")
1108
1109         col.label("Show Zero Weights:")
1110         rowsub = col.row()
1111         rowsub.active = (not tool_settings.use_multipaint)
1112         rowsub.prop(tool_settings, "vertex_group_user", expand=True)
1113
1114         self.unified_paint_settings(col, context)
1115
1116 # Commented out because the Apply button isn't an operator yet, making these settings useless
1117 #~         col.label(text="Gamma:")
1118 #~         col.prop(wpaint, "gamma", text="")
1119 #~         col.label(text="Multiply:")
1120 #~         col.prop(wpaint, "mul", text="")
1121
1122 # Also missing now:
1123 # Soft, Vertex-Group, X-Mirror and "Clear" Operator.
1124
1125 # ********** default tools for vertex-paint ****************
1126
1127
1128 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1129     bl_context = "vertexpaint"
1130     bl_label = "Options"
1131
1132     def draw(self, context):
1133         layout = self.layout
1134
1135         toolsettings = context.tool_settings
1136         vpaint = toolsettings.vertex_paint
1137
1138         col = layout.column()
1139         #col.prop(vpaint, "mode", text="")
1140         col.prop(vpaint, "use_all_faces")
1141         col.prop(vpaint, "use_normal")
1142         col.prop(vpaint, "use_spray")
1143
1144         col.prop(vpaint, "input_samples")
1145
1146         self.unified_paint_settings(col, context)
1147
1148 # Commented out because the Apply button isn't an operator yet, making these settings useless
1149 #~         col.label(text="Gamma:")
1150 #~         col.prop(vpaint, "gamma", text="")
1151 #~         col.label(text="Multiply:")
1152 #~         col.prop(vpaint, "mul", text="")
1153
1154 # ********** default tools for texture-paint ****************
1155
1156
1157 class VIEW3D_PT_tools_projectpaint(View3DPanel, Panel):
1158     bl_context = "imagepaint"
1159     bl_label = "Project Paint"
1160
1161     @classmethod
1162     def poll(cls, context):
1163         brush = context.tool_settings.image_paint.brush
1164         return (brush is not None)
1165
1166     def draw(self, context):
1167         layout = self.layout
1168
1169         ob = context.active_object
1170         mesh = ob.data
1171         toolsettings = context.tool_settings
1172         ipaint = toolsettings.image_paint
1173         settings = toolsettings.image_paint
1174
1175         layout.prop(ipaint, "input_samples")
1176
1177         col = layout.column()
1178         col.prop(ipaint, "use_occlude")
1179         col.prop(ipaint, "use_backface_culling")
1180
1181         row = layout.row()
1182         row.prop(ipaint, "use_normal_falloff")
1183  
1184         sub = row.row()
1185         sub.active = (ipaint.use_normal_falloff)
1186         sub.prop(ipaint, "normal_angle", text="")
1187
1188         split = layout.split()
1189
1190         split.prop(ipaint, "use_stencil_layer", text="Stencil")
1191
1192         row = split.row()
1193         row.active = (ipaint.use_stencil_layer)
1194         stencil_text = mesh.uv_texture_stencil.name if mesh.uv_texture_stencil else ""
1195         row.menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
1196         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
1197
1198         col = layout.column()
1199         col.active = (settings.brush.image_tool == 'CLONE')
1200         col.prop(ipaint, "use_clone_layer", text="Clone from UV map")
1201         clone_text = mesh.uv_texture_clone.name if mesh.uv_texture_clone else ""
1202         col.menu("VIEW3D_MT_tools_projectpaint_clone", text=clone_text, translate=False)
1203
1204         layout.prop(ipaint, "seam_bleed")
1205
1206         col = layout.column()
1207         col.label(text="External Editing:")
1208
1209         row = col.split(align=True, percentage=0.55)
1210         row.operator("image.project_edit", text="Quick Edit")
1211         row.operator("image.project_apply", text="Apply")
1212
1213         col.row().prop(ipaint, "screen_grab_size", text="")
1214
1215         col.operator("paint.project_image", text="Apply Camera Image")
1216         col.operator("image.save_dirty", text="Save All Edited")
1217         
1218
1219 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1220     bl_label = "Options"
1221     bl_options = {'DEFAULT_CLOSED'}
1222
1223     @classmethod
1224     def poll(cls, context):
1225         return (context.image_paint_object and context.tool_settings.image_paint)
1226
1227     def draw(self, context):
1228         layout = self.layout
1229
1230         col = layout.column()
1231         self.unified_paint_settings(col, context)
1232
1233
1234 class VIEW3D_MT_tools_projectpaint_clone(Menu):
1235     bl_label = "Clone Layer"
1236
1237     def draw(self, context):
1238         layout = self.layout
1239
1240         for i, tex in enumerate(context.active_object.data.uv_textures):
1241             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1242             props.data_path = "active_object.data.uv_texture_clone_index"
1243             props.value = i
1244
1245
1246 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1247     bl_label = "Mask Layer"
1248
1249     def draw(self, context):
1250         layout = self.layout
1251         for i, tex in enumerate(context.active_object.data.uv_textures):
1252             props = layout.operator("wm.context_set_int", text=tex.name, translate=False)
1253             props.data_path = "active_object.data.uv_texture_stencil_index"
1254             props.value = i
1255
1256
1257 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1258     """Default tools for particle mode"""
1259     bl_context = "particlemode"
1260     bl_label = "Options"
1261
1262     def draw(self, context):
1263         layout = self.layout
1264
1265         pe = context.tool_settings.particle_edit
1266         ob = pe.object
1267
1268         layout.prop(pe, "type", text="")
1269
1270         ptcache = None
1271
1272         if pe.type == 'PARTICLES':
1273             if ob.particle_systems:
1274                 if len(ob.particle_systems) > 1:
1275                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1276                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1277
1278                 ptcache = ob.particle_systems.active.point_cache
1279         else:
1280             for md in ob.modifiers:
1281                 if md.type == pe.type:
1282                     ptcache = md.point_cache
1283
1284         if ptcache and len(ptcache.point_caches) > 1:
1285             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1286                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1287
1288         if not pe.is_editable:
1289             layout.label(text="Point cache must be baked")
1290             layout.label(text="in memory to enable editing!")
1291
1292         col = layout.column(align=True)
1293         if pe.is_hair:
1294             col.active = pe.is_editable
1295             col.prop(pe, "use_emitter_deflect", text="Deflect emitter")
1296             sub = col.row()
1297             sub.active = pe.use_emitter_deflect
1298             sub.prop(pe, "emitter_distance", text="Distance")
1299
1300         col = layout.column(align=True)
1301         col.active = pe.is_editable
1302         col.label(text="Keep:")
1303         col.prop(pe, "use_preserve_length", text="Lengths")
1304         col.prop(pe, "use_preserve_root", text="Root")
1305         if not pe.is_hair:
1306             col.label(text="Correct:")
1307             col.prop(pe, "use_auto_velocity", text="Velocity")
1308         col.prop(ob.data, "use_mirror_x")
1309
1310         col = layout.column(align=True)
1311         col.active = pe.is_editable
1312         col.label(text="Draw:")
1313         col.prop(pe, "draw_step", text="Path Steps")
1314         if pe.is_hair:
1315             col.prop(pe, "show_particles", text="Children")
1316         else:
1317             if pe.type == 'PARTICLES':
1318                 col.prop(pe, "show_particles", text="Particles")
1319             col.prop(pe, "use_fade_time")
1320             sub = col.row()
1321             sub.active = pe.use_fade_time
1322             sub.prop(pe, "fade_frames", slider=True)
1323
1324 if __name__ == "__main__":  # only for live edit.
1325     bpy.utils.register_module(__name__)