Merge branch 'master' into blender2.8
[blender.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, UIList
22 from .properties_grease_pencil_common import (
23     GreasePencilStrokeEditPanel,
24     GreasePencilStrokeSculptPanel,
25     GreasePencilAppearancePanel,
26 )
27 from .properties_paint_common import (
28     UnifiedPaintPanel,
29     brush_texture_settings,
30     brush_texpaint_common,
31     brush_mask_texture_settings,
32 )
33 from bl_operators.presets import PresetMenu
34
35
36 class View3DPanel:
37     bl_space_type = 'PROPERTIES'
38     bl_region_type = 'WINDOW'
39
40
41 # **************** standard tool clusters ******************
42
43 # Keyframing tools
44 def draw_keyframing_tools(context, layout):
45     col = layout.column(align=True)
46     col.label(text="Keyframes:")
47     row = col.row(align=True)
48     row.operator("anim.keyframe_insert_menu", text="Insert")
49     row.operator("anim.keyframe_delete_v3d", text="Remove")
50
51
52 # Used by vertex & weight paint
53 def draw_vpaint_symmetry(layout, vpaint):
54
55     split = layout.split()
56
57     col = split.column()
58     col.alignment = 'RIGHT'
59     col.label(text="Mirror")
60
61     col = split.column()
62     row = col.row(align=True)
63     row.prop(vpaint, "use_symmetry_x", text="X", toggle=True)
64     row.prop(vpaint, "use_symmetry_y", text="Y", toggle=True)
65     row.prop(vpaint, "use_symmetry_z", text="Z", toggle=True)
66
67     col = layout.column()
68     col.use_property_split = True
69     col.prop(vpaint, "radial_symmetry", text="Radial")
70
71 # Most of these panels should not be visible in GP edit modes
72
73
74 def is_not_gpencil_edit_mode(context):
75     is_gpmode = (
76         context.active_object and
77         context.active_object.mode in {'GPENCIL_EDIT', 'GPENCIL_PAINT', 'GPENCIL_SCULPT', 'GPENCIL_WEIGHT'}
78     )
79     return not is_gpmode
80
81
82 # ********** default tools for editmode_mesh ****************
83
84
85 class VIEW3D_PT_tools_meshedit_options(View3DPanel, Panel):
86     bl_category = "Options"
87     bl_context = ".mesh_edit"  # dot on purpose (access from topbar)
88     bl_label = "Mesh Options"
89
90     @classmethod
91     def poll(cls, context):
92         return context.active_object
93
94     def draw(self, context):
95         layout = self.layout
96
97         layout.use_property_split = True
98         layout.use_property_decorate = False
99
100         ob = context.active_object
101
102         tool_settings = context.tool_settings
103         mesh = ob.data
104
105         col = layout.column(align=True)
106         col.prop(mesh, "use_mirror_x")
107
108         row = col.row(align=True)
109         row.active = ob.data.use_mirror_x
110         row.prop(mesh, "use_mirror_topology")
111
112         layout.prop(tool_settings, "edge_path_mode")
113         layout.prop(tool_settings, "edge_path_live_unwrap")
114         layout.prop(tool_settings, "double_threshold")
115         layout.prop(tool_settings, "use_mesh_automerge")  # , icon='AUTOMERGE_ON'
116
117
118 # ********** default tools for editmode_curve ****************
119
120
121 class VIEW3D_PT_tools_curveedit_options_stroke(View3DPanel, Panel):
122     bl_category = "Options"
123     bl_context = ".curve_edit"  # dot on purpose (access from topbar)
124     bl_label = "Curve Stroke"
125
126     def draw(self, context):
127         layout = self.layout
128
129         tool_settings = context.tool_settings
130         cps = tool_settings.curve_paint_settings
131
132         col = layout.column()
133
134         col.prop(cps, "curve_type")
135
136         if cps.curve_type == 'BEZIER':
137             col.label(text="Bezier Options:")
138             col.prop(cps, "error_threshold")
139             col.prop(cps, "fit_method")
140             col.prop(cps, "use_corners_detect")
141
142             col = layout.column()
143             col.active = cps.use_corners_detect
144             col.prop(cps, "corner_angle")
145
146         col.label(text="Pressure Radius:")
147         row = layout.row(align=True)
148         rowsub = row.row(align=True)
149         rowsub.prop(cps, "radius_min", text="Min")
150         rowsub.prop(cps, "radius_max", text="Max")
151
152         row.prop(cps, "use_pressure_radius", text="", icon_only=True)
153
154         col = layout.column()
155         col.label(text="Taper Radius:")
156         row = layout.row(align=True)
157         row.prop(cps, "radius_taper_start", text="Start")
158         row.prop(cps, "radius_taper_end", text="End")
159
160         col = layout.column()
161         col.label(text="Projection Depth:")
162         row = layout.row(align=True)
163         row.prop(cps, "depth_mode", expand=True)
164
165         col = layout.column()
166         if cps.depth_mode == 'SURFACE':
167             col.prop(cps, "surface_offset")
168             col.prop(cps, "use_offset_absolute")
169             col.prop(cps, "use_stroke_endpoints")
170             if cps.use_stroke_endpoints:
171                 colsub = layout.column(align=True)
172                 colsub.prop(cps, "surface_plane", expand=True)
173
174
175 # ********** default tools for editmode_armature ****************
176
177
178 class VIEW3D_PT_tools_armatureedit_options(View3DPanel, Panel):
179     bl_category = "Options"
180     bl_context = ".armature_edit"  # dot on purpose (access from topbar)
181     bl_label = "Armature Options"
182
183     def draw(self, context):
184         arm = context.active_object.data
185
186         self.layout.prop(arm, "use_mirror_x")
187
188
189 # ********** default tools for pose-mode ****************
190
191 class VIEW3D_PT_tools_posemode_options(View3DPanel, Panel):
192     bl_category = "Options"
193     bl_context = ".posemode"  # dot on purpose (access from topbar)
194     bl_label = "Pose Options"
195
196     def draw(self, context):
197         arm = context.active_object.data
198
199         self.layout.prop(arm, "use_auto_ik")
200         self.layout.prop(arm, "use_mirror_x")
201
202 # ********** default tools for paint modes ****************
203
204
205 class View3DPaintPanel(UnifiedPaintPanel):
206     bl_space_type = 'PROPERTIES'
207     bl_region_type = 'WINDOW'
208
209
210 class VIEW3D_PT_imapaint_tools_missing(Panel, View3DPaintPanel):
211     bl_category = "Tools"
212     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
213     bl_label = "Missing Data"
214
215     @classmethod
216     def poll(cls, context):
217         toolsettings = context.tool_settings.image_paint
218         return context.image_paint_object and not toolsettings.detect_data()
219
220     def draw(self, context):
221         layout = self.layout
222         toolsettings = context.tool_settings.image_paint
223
224         col = layout.column()
225         col.label(text="Missing Data", icon='ERROR')
226         if toolsettings.missing_uvs:
227             col.separator()
228             col.label(text="Missing UVs", icon='INFO')
229             col.label(text="Unwrap the mesh in edit mode or generate a simple UV layer")
230             col.operator("paint.add_simple_uvs")
231
232         if toolsettings.mode == 'MATERIAL':
233             if toolsettings.missing_materials:
234                 col.separator()
235                 col.label(text="Missing Materials", icon='INFO')
236                 col.label(text="Add a material and paint slot below")
237                 col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
238             elif toolsettings.missing_texture:
239                 ob = context.active_object
240                 mat = ob.active_material
241
242                 col.separator()
243                 if mat:
244                     col.label(text="Missing Texture Slots", icon='INFO')
245                     col.label(text="Add a paint slot below")
246                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
247                 else:
248                     col.label(text="Missing Materials", icon='INFO')
249                     col.label(text="Add a material and paint slot below")
250                     col.operator_menu_enum("paint.add_texture_paint_slot", "type", text="Add Paint Slot")
251
252         elif toolsettings.mode == 'IMAGE':
253             if toolsettings.missing_texture:
254                 col.separator()
255                 col.label(text="Missing Canvas", icon='INFO')
256                 col.label(text="Add or assign a canvas image below")
257                 col.label(text="Canvas Image:")
258                 col.template_ID(toolsettings, "canvas", new="image.new", open="image.open")
259
260         if toolsettings.missing_stencil:
261             col.separator()
262             col.label(text="Missing Stencil", icon='INFO')
263             col.label(text="Add or assign a stencil image below")
264             col.label(text="Stencil Image:")
265             col.template_ID(toolsettings, "stencil_image", new="image.new", open="image.open")
266
267
268 # TODO, move to space_view3d.py
269 class VIEW3D_PT_tools_brush(Panel, View3DPaintPanel):
270     bl_context = ".paint_common"  # dot on purpose (access from topbar)
271     bl_label = "Brush"
272
273     @classmethod
274     def poll(cls, context):
275         return cls.paint_settings(context)
276
277     def draw(self, context):
278         layout = self.layout
279
280         toolsettings = context.tool_settings
281         settings = self.paint_settings(context)
282         brush = settings.brush
283
284         if not context.particle_edit_object:
285             col = layout.split().column()
286             col.template_ID_preview(settings, "brush", new="brush.add", rows=3, cols=8)
287
288         # Particle Mode #
289         if context.particle_edit_object:
290             tool = settings.tool
291
292             if tool != 'NONE':
293                 layout.column().prop(settings, "tool")
294                 col = layout.column()
295                 col.prop(brush, "size", slider=True)
296                 if tool == 'ADD':
297                     col.prop(brush, "count")
298
299                     col = layout.column()
300                     col.prop(settings, "use_default_interpolate")
301                     col.prop(brush, "steps", slider=True)
302                     col.prop(settings, "default_key_count", slider=True)
303                 else:
304                     col.prop(brush, "strength", slider=True)
305
306                     if tool == 'LENGTH':
307                         layout.row().prop(brush, "length_mode", expand=True)
308                     elif tool == 'PUFF':
309                         layout.row().prop(brush, "puff_mode", expand=True)
310                         layout.prop(brush, "use_puff_volume")
311
312         # Sculpt Mode #
313
314         elif context.sculpt_object and brush:
315             capabilities = brush.sculpt_capabilities
316
317             col = layout.column()
318
319             col.separator()
320
321             row = col.row(align=True)
322
323             ups = toolsettings.unified_paint_settings
324             if ((ups.use_unified_size and ups.use_locked_size) or
325                     ((not ups.use_unified_size) and brush.use_locked_size)):
326                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='LOCKED')
327                 self.prop_unified_size(row, context, brush, "unprojected_radius", slider=True, text="Radius")
328             else:
329                 self.prop_unified_size(row, context, brush, "use_locked_size", icon='UNLOCKED')
330                 self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
331
332             self.prop_unified_size(row, context, brush, "use_pressure_size")
333
334             # strength, use_strength_pressure, and use_strength_attenuation
335             col.separator()
336             row = col.row(align=True)
337
338             if capabilities.has_space_attenuation:
339                 row.prop(brush, "use_space_attenuation", toggle=True, icon_only=True)
340
341             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
342
343             if capabilities.has_strength_pressure:
344                 self.prop_unified_strength(row, context, brush, "use_pressure_strength")
345
346             # auto_smooth_factor and use_inverse_smooth_pressure
347             if capabilities.has_auto_smooth:
348                 col.separator()
349
350                 row = col.row(align=True)
351                 row.prop(brush, "auto_smooth_factor", slider=True)
352                 row.prop(brush, "use_inverse_smooth_pressure", toggle=True, text="")
353
354             # normal_weight
355             if capabilities.has_normal_weight:
356                 col.separator()
357                 row = col.row(align=True)
358                 row.prop(brush, "normal_weight", slider=True)
359
360             # crease_pinch_factor
361             if capabilities.has_pinch_factor:
362                 col.separator()
363                 row = col.row(align=True)
364                 row.prop(brush, "crease_pinch_factor", slider=True, text="Pinch")
365
366             # rake_factor
367             if capabilities.has_rake_factor:
368                 col.separator()
369                 row = col.row(align=True)
370                 row.prop(brush, "rake_factor", slider=True)
371
372             # use_original_normal and sculpt_plane
373             if capabilities.has_sculpt_plane:
374                 col.separator()
375                 row = col.row(align=True)
376
377                 row.prop(brush, "use_original_normal", toggle=True, icon_only=True)
378
379                 row.prop(brush, "sculpt_plane", text="")
380
381             if brush.sculpt_tool == 'MASK':
382                 col.prop(brush, "mask_tool", text="")
383
384             # plane_offset, use_offset_pressure, use_plane_trim, plane_trim
385             if capabilities.has_plane_offset:
386                 row = col.row(align=True)
387                 row.prop(brush, "plane_offset", slider=True)
388                 row.prop(brush, "use_offset_pressure", text="")
389
390                 col.separator()
391
392                 row = col.row()
393                 row.prop(brush, "use_plane_trim", text="Trim")
394                 row = col.row()
395                 row.active = brush.use_plane_trim
396                 row.prop(brush, "plane_trim", slider=True, text="Distance")
397
398             # height
399             if capabilities.has_height:
400                 row = col.row()
401                 row.prop(brush, "height", slider=True, text="Height")
402
403             # use_frontface
404             col.separator()
405             col.prop(brush, "use_frontface", text="Front Faces Only")
406             col.prop(brush, "use_projected")
407
408             # direction
409             col.separator()
410             col.row().prop(brush, "direction", expand=True)
411
412             # use_accumulate
413             if capabilities.has_accumulate:
414                 col.separator()
415
416                 col.prop(brush, "use_accumulate")
417
418             # use_persistent, set_persistent_base
419             if capabilities.has_persistence:
420                 col.separator()
421
422                 ob = context.sculpt_object
423                 do_persistent = True
424
425                 # not supported yet for this case
426                 for md in ob.modifiers:
427                     if md.type == 'MULTIRES':
428                         do_persistent = False
429                         break
430
431                 if do_persistent:
432                     col.prop(brush, "use_persistent")
433                     col.operator("sculpt.set_persistent_base")
434
435         # Texture Paint Mode #
436
437         elif context.image_paint_object and brush:
438             brush_texpaint_common(self, context, layout, brush, settings, True)
439
440         # Weight Paint Mode #
441         elif context.weight_paint_object and brush:
442
443             col = layout.column()
444
445             row = col.row(align=True)
446             self.prop_unified_weight(row, context, brush, "weight", slider=True, text="Weight")
447
448             row = col.row(align=True)
449             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
450             self.prop_unified_size(row, context, brush, "use_pressure_size")
451
452             row = col.row(align=True)
453             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
454             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
455
456             col.separator()
457             col.prop(brush, "vertex_tool", text="Blend")
458
459             if brush.vertex_tool != 'SMEAR':
460                 col.prop(brush, "use_accumulate")
461                 col.separator()
462
463             col.prop(brush, "use_frontface", text="Front Faces Only")
464             row = col.row()
465             row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
466             sub = row.row()
467             sub.active = brush.use_frontface_falloff
468             sub.prop(brush, "falloff_angle", text="")
469
470             col.prop(brush, "use_projected")
471
472             col = layout.column()
473             col.prop(toolsettings, "use_auto_normalize", text="Auto Normalize")
474             col.prop(toolsettings, "use_multipaint", text="Multi-Paint")
475
476         # Vertex Paint Mode #
477         elif context.vertex_paint_object and brush:
478             col = layout.column()
479             self.prop_unified_color_picker(col, context, brush, "color", value_slider=True)
480             if settings.palette:
481                 col.template_palette(settings, "palette", color=True)
482             row = col.row(align=True)
483             self.prop_unified_color(row, context, brush, "color", text="")
484             self.prop_unified_color(row, context, brush, "secondary_color", text="")
485             row.separator()
486             row.operator("paint.brush_colors_flip", icon='FILE_REFRESH', text="")
487
488             col.separator()
489             row = col.row(align=True)
490             self.prop_unified_size(row, context, brush, "size", slider=True, text="Radius")
491             self.prop_unified_size(row, context, brush, "use_pressure_size")
492
493             row = col.row(align=True)
494             self.prop_unified_strength(row, context, brush, "strength", text="Strength")
495             self.prop_unified_strength(row, context, brush, "use_pressure_strength")
496
497             col.separator()
498             col.prop(brush, "vertex_tool", text="Blend")
499             col.prop(brush, "use_alpha")
500
501             if brush.vertex_tool != 'SMEAR':
502                 col.prop(brush, "use_accumulate")
503                 col.separator()
504
505             col.prop(brush, "use_frontface", text="Front Faces Only")
506             row = col.row()
507             row.prop(brush, "use_frontface_falloff", text="Falloff Angle")
508             sub = row.row()
509             sub.active = brush.use_frontface_falloff
510             sub.prop(brush, "falloff_angle", text="")
511
512             col.prop(brush, "use_projected")
513
514             col.separator()
515             col.template_ID(settings, "palette", new="palette.new")
516
517
518 class TEXTURE_UL_texpaintslots(UIList):
519     def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
520         mat = data
521
522         if self.layout_type in {'DEFAULT', 'COMPACT'}:
523             layout.prop(item, "name", text="", emboss=False, icon_value=icon)
524         elif self.layout_type == 'GRID':
525             layout.alignment = 'CENTER'
526             layout.label(text="")
527
528
529 class VIEW3D_MT_tools_projectpaint_uvlayer(Menu):
530     bl_label = "Clone Layer"
531
532     def draw(self, context):
533         layout = self.layout
534
535         for i, uv_layer in enumerate(context.active_object.data.uv_layers):
536             props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
537             props.data_path = "active_object.data.uv_layers.active_index"
538             props.value = i
539
540
541 # TODO, move to space_view3d.py
542 class VIEW3D_PT_slots_projectpaint(View3DPanel, Panel):
543     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
544     bl_label = "Slots"
545
546     @classmethod
547     def poll(cls, context):
548         brush = context.tool_settings.image_paint.brush
549         ob = context.active_object
550         return (brush is not None and ob is not None)
551
552     def draw(self, context):
553         layout = self.layout
554
555         settings = context.tool_settings.image_paint
556         # brush = settings.brush
557
558         ob = context.active_object
559         col = layout.column()
560
561         col.label(text="Painting Mode:")
562         col.prop(settings, "mode", text="")
563         col.separator()
564
565         if settings.mode == 'MATERIAL':
566             if len(ob.material_slots) > 1:
567                 col.label(text="Materials:")
568                 col.template_list("MATERIAL_UL_matslots", "layers",
569                                   ob, "material_slots",
570                                   ob, "active_material_index", rows=2)
571
572             mat = ob.active_material
573             if mat:
574                 col.label(text="Available Paint Slots:")
575                 col.template_list("TEXTURE_UL_texpaintslots", "",
576                                   mat, "texture_paint_images",
577                                   mat, "paint_active_slot", rows=2)
578
579                 if mat.texture_paint_slots:
580                     slot = mat.texture_paint_slots[mat.paint_active_slot]
581                 else:
582                     slot = None
583
584                 if slot and slot.is_valid:
585                     col.label(text="UV Map:")
586                     col.prop_search(slot, "uv_layer", ob.data, "uv_layers", text="")
587
588         elif settings.mode == 'IMAGE':
589             mesh = ob.data
590             uv_text = mesh.uv_layers.active.name if mesh.uv_layers.active else ""
591             col.label(text="Canvas Image:")
592             col.template_ID(settings, "canvas", new="image.new", open="image.open")
593             col.label(text="UV Map:")
594             col.menu("VIEW3D_MT_tools_projectpaint_uvlayer", text=uv_text, translate=False)
595
596         col.separator()
597         col.operator("image.save_dirty", text="Save All Images")
598
599
600 # TODO, move to space_view3d.py
601 class VIEW3D_PT_stencil_projectpaint(View3DPanel, Panel):
602     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
603     bl_label = "Mask"
604
605     @classmethod
606     def poll(cls, context):
607         brush = context.tool_settings.image_paint.brush
608         ob = context.active_object
609         return (brush is not None and ob is not None)
610
611     def draw_header(self, context):
612         ipaint = context.tool_settings.image_paint
613         self.layout.prop(ipaint, "use_stencil_layer", text="")
614
615     def draw(self, context):
616         layout = self.layout
617         layout.use_property_split = True
618
619         toolsettings = context.tool_settings
620         ipaint = toolsettings.image_paint
621         ob = context.active_object
622         mesh = ob.data
623
624         col = layout.column()
625         col.active = ipaint.use_stencil_layer
626
627         stencil_text = mesh.uv_layer_stencil.name if mesh.uv_layer_stencil else ""
628         split = col.split(factor=0.5)
629         colsub = split.column()
630         colsub.alignment = 'RIGHT'
631         colsub.label(text="UV Layer")
632         split.column().menu("VIEW3D_MT_tools_projectpaint_stencil", text=stencil_text, translate=False)
633
634         # todo this should be combinded into a single row
635         split = col.split(factor=0.5)
636         colsub = split.column()
637         colsub.alignment = 'RIGHT'
638         colsub.label(text="Stencil Image")
639         colsub = split.column()
640         colsub.template_ID(ipaint, "stencil_image", new="image.new", open="image.open")
641
642         row = col.row(align=True)
643         row.prop(ipaint, "stencil_color", text="Display Color")
644         row.prop(ipaint, "invert_stencil", text="", icon='IMAGE_ALPHA')
645
646
647 # TODO, move to space_view3d.py
648 class VIEW3D_PT_tools_brush_overlay(Panel, View3DPaintPanel):
649     bl_context = ".paint_common"  # dot on purpose (access from topbar)
650     bl_label = "Overlay"
651
652     @classmethod
653     def poll(cls, context):
654         settings = cls.paint_settings(context)
655         return (settings and
656                 settings.brush and
657                 (context.sculpt_object or
658                  context.vertex_paint_object or
659                  context.weight_paint_object or
660                  context.image_paint_object))
661
662     def draw(self, context):
663         layout = self.layout
664
665         settings = self.paint_settings(context)
666         brush = settings.brush
667         tex_slot = brush.texture_slot
668         tex_slot_mask = brush.mask_texture_slot
669
670         col = layout.column()
671
672         col.label(text="Curve:")
673
674         row = col.row(align=True)
675         row.prop(
676             brush,
677             "use_cursor_overlay",
678             text="",
679             toggle=True,
680             icon='RESTRICT_VIEW_OFF' if brush.use_cursor_overlay else 'RESTRICT_VIEW_ON',
681         )
682         sub = row.row(align=True)
683         sub.prop(brush, "cursor_overlay_alpha", text="Alpha")
684         sub.prop(brush, "use_cursor_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
685
686         col.active = brush.brush_capabilities.has_overlay
687
688         if context.image_paint_object or context.sculpt_object or context.vertex_paint_object:
689             col.label(text="Texture:")
690             row = col.row(align=True)
691             if tex_slot.map_mode != 'STENCIL':
692                 row.prop(
693                     brush,
694                     "use_primary_overlay",
695                     text="",
696                     toggle=True,
697                     icon='RESTRICT_VIEW_OFF' if brush.use_primary_overlay else 'RESTRICT_VIEW_ON',
698                 )
699
700             sub = row.row(align=True)
701             sub.prop(brush, "texture_overlay_alpha", text="Alpha")
702             sub.prop(brush, "use_primary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
703
704         if context.image_paint_object:
705             col.label(text="Mask Texture:")
706
707             row = col.row(align=True)
708             if tex_slot_mask.map_mode != 'STENCIL':
709                 row.prop(
710                     brush,
711                     "use_secondary_overlay",
712                     text="",
713                     toggle=True,
714                     icon='RESTRICT_VIEW_OFF' if brush.use_secondary_overlay else 'RESTRICT_VIEW_ON',
715                 )
716
717             sub = row.row(align=True)
718             sub.prop(brush, "mask_overlay_alpha", text="Alpha")
719             sub.prop(brush, "use_secondary_overlay_override", toggle=True, text="", icon='BRUSH_DATA')
720
721
722 # TODO, move to space_view3d.py
723 class VIEW3D_PT_tools_brush_texture(Panel, View3DPaintPanel):
724     bl_context = ".paint_common"  # dot on purpose (access from topbar)
725     bl_label = "Texture"
726     bl_options = {'DEFAULT_CLOSED'}
727
728     @classmethod
729     def poll(cls, context):
730         settings = cls.paint_settings(context)
731         return (settings and settings.brush and
732                 (context.sculpt_object or context.image_paint_object or context.vertex_paint_object))
733
734     def draw(self, context):
735         layout = self.layout
736
737         settings = self.paint_settings(context)
738         brush = settings.brush
739
740         col = layout.column()
741
742         col.template_ID_preview(brush, "texture", new="texture.new", rows=3, cols=8)
743
744         brush_texture_settings(col, brush, context.sculpt_object)
745
746
747 # TODO, move to space_view3d.py
748 class VIEW3D_PT_tools_mask_texture(Panel, View3DPaintPanel):
749     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
750     bl_label = "Texture Mask"
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 context.image_paint_object)
757
758     def draw(self, context):
759         layout = self.layout
760
761         brush = context.tool_settings.image_paint.brush
762
763         col = layout.column()
764
765         col.template_ID_preview(brush, "mask_texture", new="texture.new", rows=3, cols=8)
766
767         brush_mask_texture_settings(col, brush)
768
769
770 # TODO, move to space_view3d.py
771 class VIEW3D_PT_tools_brush_stroke(Panel, View3DPaintPanel):
772     bl_context = ".paint_common"  # dot on purpose (access from topbar)
773     bl_label = "Stroke"
774     bl_options = {'DEFAULT_CLOSED'}
775
776     @classmethod
777     def poll(cls, context):
778         settings = cls.paint_settings(context)
779         return (settings and
780                 settings.brush and
781                 (context.sculpt_object or
782                  context.vertex_paint_object or
783                  context.weight_paint_object or
784                  context.image_paint_object))
785
786     def draw(self, context):
787         layout = self.layout
788
789         settings = self.paint_settings(context)
790         brush = settings.brush
791         layout.use_property_split = True
792
793         col = layout.column()
794
795         col.prop(brush, "stroke_method")
796
797         if brush.use_anchor:
798             col.separator()
799             col.prop(brush, "use_edge_to_edge", text="Edge To Edge")
800
801         if brush.use_airbrush:
802             col.separator()
803             col.prop(brush, "rate", text="Rate", slider=True)
804
805         if brush.use_space:
806             col.separator()
807             row = col.row(align=True)
808             row.prop(brush, "spacing", text="Spacing")
809             row.prop(brush, "use_pressure_spacing", toggle=True, text="")
810
811         if brush.use_line or brush.use_curve:
812             col.separator()
813             row = col.row(align=True)
814             row.prop(brush, "spacing", text="Spacing")
815
816         if brush.use_curve:
817             col.separator()
818             col.template_ID(brush, "paint_curve", new="paintcurve.new")
819             col.operator("paintcurve.draw")
820
821         if context.sculpt_object:
822             if brush.sculpt_capabilities.has_jitter:
823                 col.separator()
824
825                 colsub = col.split(factor=0.5)
826                 row = colsub.row(align=True)
827                 row.alignment = 'RIGHT'
828                 row.label(text="Jitter")
829                 row = colsub.row(align=True)
830                 row.prop(brush, "use_relative_jitter", icon_only=True)
831                 if brush.use_relative_jitter:
832                     row.prop(brush, "jitter", slider=True, text="")
833                 else:
834                     row.prop(brush, "jitter_absolute", text="")
835                 row.prop(brush, "use_pressure_jitter", toggle=True, text="")
836
837             if brush.sculpt_capabilities.has_smooth_stroke:
838                 col = layout.column()
839                 col.separator()
840
841                 col.prop(brush, "use_smooth_stroke")
842
843                 sub = col.column()
844                 sub.active = brush.use_smooth_stroke
845                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
846                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
847         else:
848             col.separator()
849
850             row = col.row(align=True)
851             row.prop(brush, "use_relative_jitter", icon_only=True)
852             if brush.use_relative_jitter:
853                 row.prop(brush, "jitter", slider=True)
854             else:
855                 row.prop(brush, "jitter_absolute")
856             row.prop(brush, "use_pressure_jitter", toggle=True, text="")
857
858             col = layout.column()
859             col.separator()
860
861             if brush.brush_capabilities.has_smooth_stroke:
862                 col.prop(brush, "use_smooth_stroke")
863
864                 sub = col.column()
865                 sub.active = brush.use_smooth_stroke
866                 sub.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
867                 sub.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
868
869         layout.prop(settings, "input_samples")
870
871
872 # TODO, move to space_view3d.py
873 class VIEW3D_PT_tools_brush_curve(Panel, View3DPaintPanel):
874     bl_context = ".paint_common"  # dot on purpose (access from topbar)
875     bl_label = "Curve"
876     bl_options = {'DEFAULT_CLOSED'}
877
878     @classmethod
879     def poll(cls, context):
880         settings = cls.paint_settings(context)
881         return (settings and settings.brush and settings.brush.curve)
882
883     def draw(self, context):
884         layout = self.layout
885
886         settings = self.paint_settings(context)
887
888         brush = settings.brush
889
890         layout.template_curve_mapping(brush, "curve", brush=True)
891
892         col = layout.column(align=True)
893         row = col.row(align=True)
894         row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
895         row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
896         row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
897         row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
898         row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
899         row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
900
901
902 # TODO, move to space_view3d.py
903 class VIEW3D_PT_sculpt_dyntopo(Panel, View3DPaintPanel):
904     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
905     bl_label = "Dyntopo"
906     bl_options = {'DEFAULT_CLOSED'}
907     bl_ui_units_x = 12
908
909     @classmethod
910     def poll(cls, context):
911         return (context.sculpt_object and context.tool_settings.sculpt)
912
913     def draw_header(self, context):
914         is_popover = self.is_popover
915         layout = self.layout
916         layout.operator(
917             "sculpt.dynamic_topology_toggle",
918             icon='CHECKBOX_HLT' if context.sculpt_object.use_dynamic_topology_sculpting else 'CHECKBOX_DEHLT',
919             text="",
920             emboss=is_popover,
921         )
922
923     def draw(self, context):
924         layout = self.layout
925         layout.use_property_split = True
926         layout.use_property_decorate = False
927
928         toolsettings = context.tool_settings
929         sculpt = toolsettings.sculpt
930         settings = self.paint_settings(context)
931         brush = settings.brush
932
933         col = layout.column()
934         col.active = context.sculpt_object.use_dynamic_topology_sculpting
935
936         sub = col.column()
937         sub.active = (brush and brush.sculpt_tool != 'MASK')
938         if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
939             row = sub.row(align=True)
940             row.prop(sculpt, "constant_detail_resolution")
941             row.operator("sculpt.sample_detail_size", text="", icon='EYEDROPPER')
942         elif (sculpt.detail_type_method == 'BRUSH'):
943             sub.prop(sculpt, "detail_percent")
944         else:
945             sub.prop(sculpt, "detail_size")
946         sub.prop(sculpt, "detail_refine_method", text="Refine Method")
947         sub.prop(sculpt, "detail_type_method", text="Detailing")
948
949         col.prop(sculpt, "use_smooth_shading")
950
951         col.separator()
952
953         col.prop(sculpt, "symmetrize_direction")
954         col.operator("sculpt.symmetrize")
955         col.operator("sculpt.optimize")
956         if sculpt.detail_type_method in {'CONSTANT', 'MANUAL'}:
957             col.operator("sculpt.detail_flood_fill")
958
959
960 # TODO, move to space_view3d.py
961 class VIEW3D_PT_sculpt_options(Panel, View3DPaintPanel):
962     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
963     bl_label = "Options"
964     bl_options = {'DEFAULT_CLOSED'}
965
966     @classmethod
967     def poll(cls, context):
968         return (context.sculpt_object and context.tool_settings.sculpt)
969
970     def draw(self, context):
971         layout = self.layout
972         # scene = context.scene
973
974         toolsettings = context.tool_settings
975         sculpt = toolsettings.sculpt
976         capabilities = sculpt.brush.sculpt_capabilities
977
978         col = layout.column(align=True)
979         col.active = capabilities.has_gravity
980         col.label(text="Gravity:")
981         col.prop(sculpt, "gravity", slider=True, text="Factor")
982         col.prop(sculpt, "gravity_object")
983         col.separator()
984
985         layout.prop(sculpt, "use_threaded", text="Threaded Sculpt")
986         layout.prop(sculpt, "show_low_resolution")
987         layout.prop(sculpt, "use_deform_only")
988         layout.prop(sculpt, "show_diffuse_color")
989         layout.prop(sculpt, "show_mask")
990
991         self.unified_paint_settings(layout, context)
992
993
994 # TODO, move to space_view3d.py
995 class VIEW3D_PT_sculpt_symmetry(Panel, View3DPaintPanel):
996     bl_context = ".sculpt_mode"  # dot on purpose (access from topbar)
997     bl_label = "Symmetry/Lock"
998     bl_options = {'DEFAULT_CLOSED'}
999
1000     @classmethod
1001     def poll(cls, context):
1002         return (context.sculpt_object and context.tool_settings.sculpt)
1003
1004     def draw(self, context):
1005         layout = self.layout
1006
1007         sculpt = context.tool_settings.sculpt
1008
1009         split = layout.split()
1010
1011         col = split.column()
1012         col.alignment = 'RIGHT'
1013         col.label(text="Mirror")
1014
1015         col = split.column()
1016
1017         row = col.row(align=True)
1018         row.prop(sculpt, "use_symmetry_x", text="X", toggle=True)
1019         row.prop(sculpt, "use_symmetry_y", text="Y", toggle=True)
1020         row.prop(sculpt, "use_symmetry_z", text="Z", toggle=True)
1021
1022         split = layout.split()
1023
1024         col = split.column()
1025         col.alignment = 'RIGHT'
1026         col.label(text="Lock")
1027
1028         col = split.column()
1029
1030         row = col.row(align=True)
1031         row.prop(sculpt, "lock_x", text="X", toggle=True)
1032         row.prop(sculpt, "lock_y", text="Y", toggle=True)
1033         row.prop(sculpt, "lock_z", text="Z", toggle=True)
1034
1035         split = layout.split()
1036
1037         col = split.column()
1038         col.alignment = 'RIGHT'
1039         col.label(text="Tiling")
1040
1041         col = split.column()
1042
1043         row = col.row(align=True)
1044         row.prop(sculpt, "tile_x", text="X", toggle=True)
1045         row.prop(sculpt, "tile_y", text="Y", toggle=True)
1046         row.prop(sculpt, "tile_z", text="Z", toggle=True)
1047
1048         layout.use_property_split = True
1049
1050         layout.prop(sculpt, "use_symmetry_feather", text="Feather")
1051         layout.column().prop(sculpt, "radial_symmetry", text="Radial")
1052         layout.column().prop(sculpt, "tile_offset", text="Tile Offset")
1053
1054
1055 # TODO, move to space_view3d.py
1056 class VIEW3D_PT_tools_brush_appearance(Panel, View3DPaintPanel):
1057     bl_context = ".paint_common"  # dot on purpose (access from topbar)
1058     bl_label = "Appearance"
1059     bl_parent_id = "VIEW3D_PT_tools_brush_overlay"
1060
1061     @classmethod
1062     def poll(cls, context):
1063         settings = cls.paint_settings(context)
1064         return (settings is not None) and (not isinstance(settings, bpy.types.ParticleEdit))
1065
1066     def draw(self, context):
1067         layout = self.layout
1068
1069         settings = self.paint_settings(context)
1070         brush = settings.brush
1071
1072         if brush is None:  # unlikely but can happen
1073             layout.label(text="Brush Unset")
1074             return
1075
1076         col = layout.column()
1077         col.prop(settings, "show_brush")
1078
1079         sub = col.column()
1080         sub.active = settings.show_brush
1081
1082         if context.sculpt_object and context.tool_settings.sculpt:
1083             if brush.sculpt_capabilities.has_secondary_color:
1084                 sub.row().prop(brush, "cursor_color_add", text="Add")
1085                 sub.row().prop(brush, "cursor_color_subtract", text="Subtract")
1086             else:
1087                 sub.prop(brush, "cursor_color_add", text="")
1088         else:
1089             sub.prop(brush, "cursor_color_add", text="")
1090
1091         col.separator()
1092
1093         col = col.column(align=True)
1094         col.prop(brush, "use_custom_icon")
1095         sub = col.column()
1096         sub.active = brush.use_custom_icon
1097         sub.prop(brush, "icon_filepath", text="")
1098
1099 # ********** default tools for weight-paint ****************
1100
1101
1102 # TODO, move to space_view3d.py
1103 class VIEW3D_PT_tools_weightpaint_symmetry(Panel, View3DPaintPanel):
1104     bl_context = ".weightpaint"
1105     bl_options = {'DEFAULT_CLOSED'}
1106     bl_label = "Symmetry"
1107
1108     def draw(self, context):
1109         layout = self.layout
1110         toolsettings = context.tool_settings
1111         wpaint = toolsettings.weight_paint
1112         draw_vpaint_symmetry(layout, wpaint)
1113
1114
1115 # TODO, move to space_view3d.py
1116 class VIEW3D_PT_tools_weightpaint_options(Panel, View3DPaintPanel):
1117     bl_context = ".weightpaint"
1118     bl_label = "Options"
1119
1120     def draw(self, context):
1121         layout = self.layout
1122
1123         tool_settings = context.tool_settings
1124         wpaint = tool_settings.weight_paint
1125
1126         col = layout.column()
1127         col.prop(wpaint, "use_group_restrict")
1128
1129         obj = context.weight_paint_object
1130         if obj.type == 'MESH':
1131             mesh = obj.data
1132             col.prop(mesh, "use_mirror_x")
1133             row = col.row()
1134             row.active = mesh.use_mirror_x
1135             row.prop(mesh, "use_mirror_topology")
1136
1137         col.label(text="Show Zero Weights:")
1138         sub = col.row()
1139         sub.prop(tool_settings, "vertex_group_user", expand=True)
1140
1141         self.unified_paint_settings(col, context)
1142
1143 # ********** default tools for vertex-paint ****************
1144
1145
1146 # TODO, move to space_view3d.py
1147 class VIEW3D_PT_tools_vertexpaint(Panel, View3DPaintPanel):
1148     bl_context = ".vertexpaint"  # dot on purpose (access from topbar)
1149     bl_label = "Options"
1150
1151     def draw(self, context):
1152         layout = self.layout
1153
1154         toolsettings = context.tool_settings
1155
1156         col = layout.column()
1157
1158         self.unified_paint_settings(col, context)
1159
1160
1161 # TODO, move to space_view3d.py
1162 class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
1163     bl_context = ".vertexpaint"  # dot on purpose (access from topbar)
1164     bl_options = {'DEFAULT_CLOSED'}
1165     bl_label = "Symmetry"
1166
1167     def draw(self, context):
1168         layout = self.layout
1169         toolsettings = context.tool_settings
1170         vpaint = toolsettings.vertex_paint
1171         draw_vpaint_symmetry(layout, vpaint)
1172
1173
1174 # ********** default tools for texture-paint ****************
1175
1176
1177 # TODO, move to space_view3d.py
1178 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1179     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1180     bl_label = "External"
1181     bl_options = {'DEFAULT_CLOSED'}
1182
1183     def draw(self, context):
1184         layout = self.layout
1185
1186         toolsettings = context.tool_settings
1187         ipaint = toolsettings.image_paint
1188
1189         col = layout.column()
1190         row = col.split(factor=0.55, align=True)
1191         row.operator("image.project_edit", text="Quick Edit")
1192         row.operator("image.project_apply", text="Apply")
1193
1194         col.row().prop(ipaint, "screen_grab_size", text="")
1195
1196         col.operator("paint.project_image", text="Apply Camera Image")
1197
1198
1199 # TODO, move to space_view3d.py
1200 class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
1201     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1202     bl_label = "Symmetry"
1203     bl_options = {'DEFAULT_CLOSED'}
1204
1205     def draw(self, context):
1206         layout = self.layout
1207
1208         toolsettings = context.tool_settings
1209         ipaint = toolsettings.image_paint
1210
1211         split = layout.split()
1212
1213         col = split.column()
1214         col.alignment = 'RIGHT'
1215         col.label(text="Mirror")
1216
1217         col = split.column()
1218
1219         row = col.row(align=True)
1220         row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
1221         row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
1222         row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
1223
1224
1225 # TODO, move to space_view3d.py
1226 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1227     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1228     bl_label = "Project Paint"
1229
1230     @classmethod
1231     def poll(cls, context):
1232         brush = context.tool_settings.image_paint.brush
1233         return (brush is not None)
1234
1235     def draw(self, context):
1236         layout = self.layout
1237
1238         toolsettings = context.tool_settings
1239         ipaint = toolsettings.image_paint
1240
1241         col = layout.column()
1242
1243         col.prop(ipaint, "use_occlude")
1244         col.prop(ipaint, "use_backface_culling")
1245
1246         row = layout.row()
1247         row.prop(ipaint, "use_normal_falloff")
1248
1249         sub = row.row()
1250         sub.active = (ipaint.use_normal_falloff)
1251         sub.prop(ipaint, "normal_angle", text="")
1252
1253         layout.prop(ipaint, "use_cavity")
1254         if ipaint.use_cavity:
1255             layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1256
1257         layout.prop(ipaint, "seam_bleed")
1258         layout.prop(ipaint, "dither")
1259         self.unified_paint_settings(layout, context)
1260
1261
1262 # TODO, move to space_view3d.py
1263 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1264     bl_label = "Options"
1265
1266     @classmethod
1267     def poll(cls, context):
1268         return (context.image_paint_object and context.tool_settings.image_paint)
1269
1270     def draw(self, context):
1271         layout = self.layout
1272
1273         col = layout.column()
1274         self.unified_paint_settings(col, context)
1275
1276
1277 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1278     bl_label = "Mask Layer"
1279
1280     def draw(self, context):
1281         layout = self.layout
1282         for i, uv_layer in enumerate(context.active_object.data.uv_layers):
1283             props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
1284             props.data_path = "active_object.data.uv_layer_stencil_index"
1285             props.value = i
1286
1287
1288 # TODO, move to space_view3d.py
1289 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1290     """Default tools for particle mode"""
1291     bl_context = ".particlemode"
1292     bl_label = "Options"
1293
1294     def draw(self, context):
1295         layout = self.layout
1296
1297         pe = context.tool_settings.particle_edit
1298         ob = pe.object
1299
1300         layout.prop(pe, "type", text="")
1301
1302         ptcache = None
1303
1304         if pe.type == 'PARTICLES':
1305             if ob.particle_systems:
1306                 if len(ob.particle_systems) > 1:
1307                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1308                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1309
1310                 ptcache = ob.particle_systems.active.point_cache
1311         else:
1312             for md in ob.modifiers:
1313                 if md.type == pe.type:
1314                     ptcache = md.point_cache
1315
1316         if ptcache and len(ptcache.point_caches) > 1:
1317             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1318                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1319
1320         if not pe.is_editable:
1321             layout.label(text="Point cache must be baked")
1322             layout.label(text="in memory to enable editing!")
1323
1324         col = layout.column(align=True)
1325         if pe.is_hair:
1326             col.active = pe.is_editable
1327             col.prop(pe, "use_emitter_deflect", text="Deflect Emitter")
1328             sub = col.row(align=True)
1329             sub.active = pe.use_emitter_deflect
1330             sub.prop(pe, "emitter_distance", text="Distance")
1331
1332         col = layout.column(align=True)
1333         col.active = pe.is_editable
1334         col.label(text="Keep:")
1335         col.prop(pe, "use_preserve_length", text="Lengths")
1336         col.prop(pe, "use_preserve_root", text="Root")
1337         if not pe.is_hair:
1338             col.label(text="Correct:")
1339             col.prop(pe, "use_auto_velocity", text="Velocity")
1340         col.prop(ob.data, "use_mirror_x")
1341
1342         col.prop(pe, "shape_object")
1343         col.operator("particle.shape_cut")
1344
1345         col = layout.column(align=True)
1346         col.active = pe.is_editable
1347         col.label(text="Display:")
1348         col.prop(pe, "display_step", text="Path Steps")
1349         if pe.is_hair:
1350             col.prop(pe, "show_particles", text="Children")
1351         else:
1352             if pe.type == 'PARTICLES':
1353                 col.prop(pe, "show_particles", text="Particles")
1354             col.prop(pe, "use_fade_time")
1355             sub = col.row(align=True)
1356             sub.active = pe.use_fade_time
1357             sub.prop(pe, "fade_frames", slider=True)
1358
1359
1360 class VIEW3D_PT_tools_normal(View3DPanel, Panel):
1361     bl_category = ""
1362     bl_context = ".mesh_edit"
1363     bl_label = "Normal Tools"
1364
1365     def draw(self, context):
1366         layout = self.layout
1367         toolsettings = context.tool_settings
1368
1369         col = layout.column(align=True)
1370         col.label(text="Normal Vector")
1371         col.prop(toolsettings, "normal_vector", text="")
1372
1373         layout.separator()
1374         layout.label(text="Face Strength")
1375         layout.prop(toolsettings, "face_strength", text="")
1376
1377         col = layout.column(align=True)
1378
1379
1380 # ********** grease pencil object tool panels ****************
1381
1382 # Grease Pencil drawing brushes
1383 class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
1384     bl_context = ".greasepencil_paint"
1385     bl_label = "Brush"
1386
1387     @classmethod
1388     def poll(cls, context):
1389         is_3d_view = context.space_data.type == 'VIEW_3D'
1390         if is_3d_view:
1391             if context.gpencil_data is None:
1392                 return False
1393
1394             gpd = context.gpencil_data
1395             return bool(gpd.is_stroke_paint_mode)
1396         else:
1397             return True
1398
1399     @staticmethod
1400     def draw(self, context):
1401         layout = self.layout
1402         layout.use_property_split = True
1403         layout.use_property_decorate = False
1404
1405         ts = context.scene.tool_settings
1406         settings = ts.gpencil_paint
1407
1408         row = layout.row()
1409         col = row.column()
1410         col.template_ID_preview(settings, "brush", new="brush.add_gpencil", rows=3, cols=8)
1411
1412         col = row.column()
1413         brush = context.active_gpencil_brush
1414         gp_settings = brush.gpencil_settings
1415
1416         sub = col.column(align=True)
1417         sub.operator("gpencil.brush_presets_create", icon='HELP', text="")
1418
1419         if brush is not None:
1420             # XXX: Items in "sub" currently show up beside the brush selector in a separate column
1421             if gp_settings.gpencil_brush_type == 'ERASE':
1422                 sub.prop(gp_settings, "default_eraser", text="")
1423
1424             # Brush details
1425             if gp_settings.gpencil_brush_type == 'ERASE':
1426                 col = layout.column(align=True)
1427                 col.prop(brush, "size", text="Radius")
1428
1429                 col.separator()
1430                 row = col.row()
1431                 row.prop(gp_settings, "eraser_mode", expand=True)
1432             elif gp_settings.gpencil_brush_type == 'FILL':
1433                 col = layout.column(align=True)
1434                 col.prop(gp_settings, "gpencil_fill_leak", text="Leak Size")
1435                 col.prop(brush, "size", text="Thickness")
1436                 col.prop(gp_settings, "gpencil_fill_simplyfy_level", text="Simplify")
1437
1438                 col = layout.row(align=True)
1439                 col.template_ID(gp_settings, "material")
1440
1441                 row = layout.row(align=True)
1442                 row.prop(gp_settings, "gpencil_fill_draw_mode", text="Boundary Draw Mode")
1443                 row.prop(gp_settings, "gpencil_fill_show_boundary", text="", icon='GRID')
1444
1445                 col = layout.column(align=True)
1446                 col.enabled = gp_settings.gpencil_fill_draw_mode != 'STROKE'
1447                 col.prop(gp_settings, "gpencil_fill_hide", text="Hide Transparent Lines")
1448                 sub = col.row(align=True)
1449                 sub.enabled = gp_settings.gpencil_fill_hide
1450                 sub.prop(gp_settings, "gpencil_fill_threshold", text="Threshold")
1451             else:  # bgpsettings.gpencil_brush_type == 'DRAW':
1452                 row = layout.row(align=True)
1453                 row.prop(brush, "size", text="Radius")
1454                 row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
1455                 row = layout.row(align=True)
1456                 row.prop(gp_settings, "pen_strength", slider=True)
1457                 row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
1458
1459                 row = layout.row(align=True)
1460                 row.template_ID(gp_settings, "material")
1461
1462
1463 # Grease Pencil drawing brushes options
1464 class VIEW3D_PT_tools_grease_pencil_brush_option(View3DPanel, Panel):
1465     bl_context = ".greasepencil_paint"
1466     bl_label = "Options"
1467     bl_options = {'DEFAULT_CLOSED'}
1468
1469     def draw_header_preset(self, context):
1470         VIEW3D_PT_gpencil_brush_presets.draw_panel_header(self.layout)
1471
1472     @staticmethod
1473     def draw(self, context):
1474         layout = self.layout
1475         layout.use_property_split = True
1476         layout.use_property_decorate = False
1477
1478         brush = context.active_gpencil_brush
1479         gp_settings = brush.gpencil_settings
1480
1481         if brush is not None:
1482             col = layout.column(align=True)
1483             col.prop(gp_settings, "input_samples")
1484             col.separator()
1485
1486             col.prop(gp_settings, "active_smooth_factor")
1487             col.separator()
1488
1489             col.prop(gp_settings, "angle", slider=True)
1490             col.prop(gp_settings, "angle_factor", text="Factor", slider=True)
1491             col.separator()
1492
1493
1494 class VIEW3D_PT_tools_grease_pencil_brush_stabilizer(View3DPanel, Panel):
1495     bl_context = ".greasepencil_paint"
1496     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1497     bl_label = "Stabilizer"
1498     bl_options = {'DEFAULT_CLOSED'}
1499
1500     @classmethod
1501     def poll(cls, context):
1502         brush = context.active_gpencil_brush
1503         gp_settings = brush.gpencil_settings
1504
1505         return brush is not None and gp_settings.gpencil_brush_type == 'DRAW'
1506
1507     def draw_header(self, context):
1508         brush = context.active_gpencil_brush
1509         gp_settings = brush.gpencil_settings
1510         self.layout.prop(gp_settings, "use_stabilizer", text="")
1511
1512     @staticmethod
1513     def draw(self, context):
1514         layout = self.layout
1515         layout.use_property_split = True
1516         layout.use_property_decorate = False
1517
1518         brush = context.active_gpencil_brush
1519         gp_settings = brush.gpencil_settings
1520         layout.active = gp_settings.use_stabilizer
1521
1522         layout.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1523         layout.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1524
1525
1526 class VIEW3D_PT_tools_grease_pencil_brush_settings(View3DPanel, Panel):
1527     bl_context = ".greasepencil_paint"
1528     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1529     bl_label = "Post-processing Settings"
1530     bl_options = {'DEFAULT_CLOSED'}
1531
1532     @classmethod
1533     def poll(cls, context):
1534         brush = context.active_gpencil_brush
1535
1536         return brush is not None
1537
1538     def draw_header(self, context):
1539         brush = context.active_gpencil_brush
1540         gp_settings = brush.gpencil_settings
1541         self.layout.prop(gp_settings, "enable_settings", text="")
1542
1543     @staticmethod
1544     def draw(self, context):
1545         layout = self.layout
1546         layout.use_property_split = True
1547         layout.use_property_decorate = False
1548
1549         brush = context.active_gpencil_brush
1550         gp_settings = brush.gpencil_settings
1551         layout.active = gp_settings.enable_settings
1552
1553         col = layout.column(align=True)
1554         col.prop(gp_settings, "pen_smooth_factor")
1555         col.prop(gp_settings, "pen_thick_smooth_factor")
1556
1557         col = layout.column(align=True)
1558         col.prop(gp_settings, "pen_smooth_steps")
1559         col.prop(gp_settings, "pen_thick_smooth_steps")
1560
1561         col = layout.column(align=True)
1562         col.prop(gp_settings, "pen_subdivision_steps")
1563         col.prop(gp_settings, "random_subdiv", text="Randomness", slider=True)
1564
1565
1566 class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
1567     bl_context = ".greasepencil_paint"
1568     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1569     bl_label = "Random Settings"
1570     bl_options = {'DEFAULT_CLOSED'}
1571
1572     @classmethod
1573     def poll(cls, context):
1574         brush = context.active_gpencil_brush
1575
1576         return brush is not None
1577
1578     def draw_header(self, context):
1579         brush = context.active_gpencil_brush
1580         gp_settings = brush.gpencil_settings
1581         self.layout.prop(gp_settings, "enable_random", text="")
1582
1583     @staticmethod
1584     def draw(self, context):
1585         layout = self.layout
1586         layout.use_property_split = True
1587         layout.use_property_decorate = False
1588
1589         brush = context.active_gpencil_brush
1590         gp_settings = brush.gpencil_settings
1591         layout.active = gp_settings.enable_random
1592
1593         layout.prop(gp_settings, "random_pressure", text="Pressure", slider=True)
1594         layout.prop(gp_settings, "random_strength", text="Strength", slider=True)
1595         layout.prop(gp_settings, "uv_random", text="UV", slider=True)
1596
1597         row = layout.row(align=True)
1598         row.prop(gp_settings, "pen_jitter", slider=True)
1599         row.prop(gp_settings, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
1600
1601
1602 # Grease Pencil drawingcurves
1603 class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
1604     bl_context = ".greasepencil_paint"
1605     bl_label = "Curves"
1606     bl_options = {'DEFAULT_CLOSED'}
1607
1608     @staticmethod
1609     def draw(self, context):
1610         layout = self.layout
1611         layout.use_property_split = True
1612
1613         brush = context.active_gpencil_brush
1614         gp_settings = brush.gpencil_settings
1615
1616         # Brush
1617         layout.label(text="Sensitivity")
1618         layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True)
1619
1620         layout.label(text="Strength")
1621         layout.template_curve_mapping(gp_settings, "curve_strength", brush=True)
1622
1623         layout.label(text="Jitter")
1624         layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True)
1625
1626
1627 # Grease Pencil create shapes
1628 class VIEW3D_PT_tools_grease_pencil_shapes(View3DPanel, Panel):
1629     bl_space_type = 'VIEW_3D'
1630     bl_region_type = 'HEADER'
1631     bl_label = "Shapes"
1632
1633     @classmethod
1634     def poll(cls, context):
1635         ob = context.active_object
1636         return ob and ob.type == 'GPENCIL'
1637
1638     @staticmethod
1639     def draw(self, context):
1640         layout = self.layout
1641         layout.use_property_split = True
1642
1643         col = layout.column(align=True)
1644         col.operator("gpencil.primitive", text="Line", icon='IPO_CONSTANT').type = 'LINE'
1645         col.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
1646         col.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
1647
1648         layout.operator("object.gpencil_add", text="Monkey", icon='MONKEY').type = 'MONKEY'
1649
1650
1651 # Grease Pencil stroke editing tools
1652 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1653     bl_space_type = 'VIEW_3D'
1654
1655
1656 # Grease Pencil stroke interpolation tools
1657 class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
1658     bl_space_type = 'VIEW_3D'
1659     bl_region_type = 'HEADER'
1660     bl_label = "Interpolate"
1661
1662     @classmethod
1663     def poll(cls, context):
1664         if context.gpencil_data is None:
1665             return False
1666
1667         gpd = context.gpencil_data
1668         return bool(context.editable_gpencil_strokes) and bool(gpd.use_stroke_edit_mode)
1669
1670     @staticmethod
1671     def draw(self, context):
1672         layout = self.layout
1673         settings = context.tool_settings.gpencil_interpolate
1674
1675         col = layout.column(align=True)
1676         col.label(text="Interpolate Strokes")
1677         col.operator("gpencil.interpolate", text="Interpolate")
1678         col.operator("gpencil.interpolate_sequence", text="Sequence")
1679         col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
1680
1681         col = layout.column(align=True)
1682         col.label(text="Options:")
1683         col.prop(settings, "interpolate_all_layers")
1684         col.prop(settings, "interpolate_selected_only")
1685
1686         col = layout.column(align=True)
1687         col.label(text="Sequence Options:")
1688         col.prop(settings, "type")
1689         if settings.type == 'CUSTOM':
1690             # TODO: Options for loading/saving curve presets?
1691             col.template_curve_mapping(settings, "interpolation_curve", brush=True)
1692         elif settings.type != 'LINEAR':
1693             col.prop(settings, "easing")
1694
1695             if settings.type == 'BACK':
1696                 layout.prop(settings, "back")
1697             elif setting.type == 'ELASTIC':
1698                 sub = layout.column(align=True)
1699                 sub.prop(settings, "amplitude")
1700                 sub.prop(settings, "period")
1701
1702
1703 # Grease Pencil stroke sculpting tools
1704 class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, View3DPanel, Panel):
1705     bl_context = ".greasepencil_sculpt"
1706     bl_category = "Tools"
1707     bl_label = "Sculpt Strokes"
1708
1709
1710 # Grease Pencil weight painting tools
1711 class VIEW3D_PT_tools_grease_pencil_weight_paint(View3DPanel, Panel):
1712     bl_context = ".greasepencil_weight"
1713     bl_category = "Tools"
1714     bl_label = "Weight Paint"
1715
1716     @staticmethod
1717     def draw(self, context):
1718         layout = self.layout
1719         layout.use_property_split = True
1720         layout.use_property_decorate = False
1721
1722         gpd = context.gpencil_data
1723         settings = context.tool_settings.gpencil_sculpt
1724         tool = settings.tool
1725         brush = settings.brush
1726
1727         layout.template_icon_view(settings, "weight_tool", show_labels=True)
1728
1729         col = layout.column()
1730         col.prop(brush, "size", slider=True)
1731         row = col.row(align=True)
1732         row.prop(brush, "strength", slider=True)
1733         row.prop(brush, "use_pressure_strength", text="")
1734
1735         col.prop(brush, "use_falloff")
1736
1737
1738 # Grease Pencil Brush Appeareance (one for each mode)
1739 class VIEW3D_PT_tools_grease_pencil_paint_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1740     bl_context = ".greasepencil_paint"
1741     bl_label = "Appearance"
1742
1743
1744 class VIEW3D_PT_tools_grease_pencil_sculpt_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1745     bl_context = ".greasepencil_sculpt"
1746     bl_label = "Appearance"
1747
1748
1749 class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1750     bl_context = ".greasepencil_weight"
1751     bl_label = "Appearance"
1752
1753
1754 class VIEW3D_PT_gpencil_brush_presets(PresetMenu):
1755     """Brush settings"""
1756     bl_label = "Brush Presets"
1757     preset_subdir = "gpencil_brush"
1758     preset_operator = "script.execute_preset"
1759     preset_add_operator = "scene.gpencil_brush_preset_add"
1760
1761
1762 classes = (
1763     VIEW3D_PT_tools_meshedit_options,
1764     VIEW3D_PT_tools_curveedit_options_stroke,
1765     VIEW3D_PT_tools_armatureedit_options,
1766     VIEW3D_PT_tools_posemode_options,
1767     VIEW3D_PT_imapaint_tools_missing,
1768     VIEW3D_PT_tools_brush,
1769     TEXTURE_UL_texpaintslots,
1770     VIEW3D_MT_tools_projectpaint_uvlayer,
1771     VIEW3D_PT_slots_projectpaint,
1772     VIEW3D_PT_stencil_projectpaint,
1773     VIEW3D_PT_tools_brush_overlay,
1774     VIEW3D_PT_tools_brush_texture,
1775     VIEW3D_PT_tools_mask_texture,
1776     VIEW3D_PT_tools_brush_stroke,
1777     VIEW3D_PT_tools_brush_curve,
1778     VIEW3D_PT_sculpt_dyntopo,
1779     VIEW3D_PT_sculpt_options,
1780     VIEW3D_PT_sculpt_symmetry,
1781     VIEW3D_PT_tools_brush_appearance,
1782     VIEW3D_PT_tools_weightpaint_symmetry,
1783     VIEW3D_PT_tools_weightpaint_options,
1784     VIEW3D_PT_tools_vertexpaint,
1785     VIEW3D_PT_tools_vertexpaint_symmetry,
1786     VIEW3D_PT_tools_imagepaint_external,
1787     VIEW3D_PT_tools_imagepaint_symmetry,
1788     VIEW3D_PT_tools_projectpaint,
1789     VIEW3D_MT_tools_projectpaint_stencil,
1790     VIEW3D_PT_tools_particlemode,
1791
1792     VIEW3D_PT_gpencil_brush_presets,
1793     VIEW3D_PT_tools_grease_pencil_brush,
1794     VIEW3D_PT_tools_grease_pencil_brush_option,
1795     VIEW3D_PT_tools_grease_pencil_brush_settings,
1796     VIEW3D_PT_tools_grease_pencil_brush_stabilizer,
1797     VIEW3D_PT_tools_grease_pencil_brush_random,
1798     VIEW3D_PT_tools_grease_pencil_brushcurves,
1799     VIEW3D_PT_tools_grease_pencil_shapes,
1800     VIEW3D_PT_tools_grease_pencil_sculpt,
1801     VIEW3D_PT_tools_grease_pencil_weight_paint,
1802     VIEW3D_PT_tools_grease_pencil_paint_appearance,
1803     VIEW3D_PT_tools_grease_pencil_sculpt_appearance,
1804     VIEW3D_PT_tools_grease_pencil_weight_appearance,
1805     VIEW3D_PT_tools_grease_pencil_interpolate,
1806     VIEW3D_PT_tools_normal,
1807 )
1808
1809 if __name__ == "__main__":  # only for live edit.
1810     from bpy.utils import register_class
1811     for cls in classes:
1812         register_class(cls)