Cleanup: inline icon conditional
[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         vpaint = toolsettings.vertex_paint
1156
1157         col = layout.column()
1158
1159         self.unified_paint_settings(col, context)
1160
1161
1162 # TODO, move to space_view3d.py
1163 class VIEW3D_PT_tools_vertexpaint_symmetry(Panel, View3DPaintPanel):
1164     bl_context = ".vertexpaint"  # dot on purpose (access from topbar)
1165     bl_options = {'DEFAULT_CLOSED'}
1166     bl_label = "Symmetry"
1167
1168     def draw(self, context):
1169         layout = self.layout
1170         toolsettings = context.tool_settings
1171         vpaint = toolsettings.vertex_paint
1172         draw_vpaint_symmetry(layout, vpaint)
1173
1174
1175 # ********** default tools for texture-paint ****************
1176
1177
1178 # TODO, move to space_view3d.py
1179 class VIEW3D_PT_tools_imagepaint_external(Panel, View3DPaintPanel):
1180     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1181     bl_label = "External"
1182     bl_options = {'DEFAULT_CLOSED'}
1183
1184     def draw(self, context):
1185         layout = self.layout
1186
1187         toolsettings = context.tool_settings
1188         ipaint = toolsettings.image_paint
1189
1190         col = layout.column()
1191         row = col.split(factor=0.55, align=True)
1192         row.operator("image.project_edit", text="Quick Edit")
1193         row.operator("image.project_apply", text="Apply")
1194
1195         col.row().prop(ipaint, "screen_grab_size", text="")
1196
1197         col.operator("paint.project_image", text="Apply Camera Image")
1198
1199
1200 # TODO, move to space_view3d.py
1201 class VIEW3D_PT_tools_imagepaint_symmetry(Panel, View3DPaintPanel):
1202     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1203     bl_label = "Symmetry"
1204     bl_options = {'DEFAULT_CLOSED'}
1205
1206     def draw(self, context):
1207         layout = self.layout
1208
1209         toolsettings = context.tool_settings
1210         ipaint = toolsettings.image_paint
1211
1212         split = layout.split()
1213
1214         col = split.column()
1215         col.alignment = 'RIGHT'
1216         col.label(text="Mirror")
1217
1218         col = split.column()
1219
1220         row = col.row(align=True)
1221         row.prop(ipaint, "use_symmetry_x", text="X", toggle=True)
1222         row.prop(ipaint, "use_symmetry_y", text="Y", toggle=True)
1223         row.prop(ipaint, "use_symmetry_z", text="Z", toggle=True)
1224
1225
1226 # TODO, move to space_view3d.py
1227 class VIEW3D_PT_tools_projectpaint(View3DPaintPanel, Panel):
1228     bl_context = ".imagepaint"  # dot on purpose (access from topbar)
1229     bl_label = "Project Paint"
1230
1231     @classmethod
1232     def poll(cls, context):
1233         brush = context.tool_settings.image_paint.brush
1234         return (brush is not None)
1235
1236     def draw(self, context):
1237         layout = self.layout
1238
1239         toolsettings = context.tool_settings
1240         ipaint = toolsettings.image_paint
1241
1242         col = layout.column()
1243
1244         col.prop(ipaint, "use_occlude")
1245         col.prop(ipaint, "use_backface_culling")
1246
1247         row = layout.row()
1248         row.prop(ipaint, "use_normal_falloff")
1249
1250         sub = row.row()
1251         sub.active = (ipaint.use_normal_falloff)
1252         sub.prop(ipaint, "normal_angle", text="")
1253
1254         layout.prop(ipaint, "use_cavity")
1255         if ipaint.use_cavity:
1256             layout.template_curve_mapping(ipaint, "cavity_curve", brush=True)
1257
1258         layout.prop(ipaint, "seam_bleed")
1259         layout.prop(ipaint, "dither")
1260         self.unified_paint_settings(layout, context)
1261
1262
1263 # TODO, move to space_view3d.py
1264 class VIEW3D_PT_imagepaint_options(View3DPaintPanel):
1265     bl_label = "Options"
1266
1267     @classmethod
1268     def poll(cls, context):
1269         return (context.image_paint_object and context.tool_settings.image_paint)
1270
1271     def draw(self, context):
1272         layout = self.layout
1273
1274         col = layout.column()
1275         self.unified_paint_settings(col, context)
1276
1277
1278 class VIEW3D_MT_tools_projectpaint_stencil(Menu):
1279     bl_label = "Mask Layer"
1280
1281     def draw(self, context):
1282         layout = self.layout
1283         for i, uv_layer in enumerate(context.active_object.data.uv_layers):
1284             props = layout.operator("wm.context_set_int", text=uv_layer.name, translate=False)
1285             props.data_path = "active_object.data.uv_layer_stencil_index"
1286             props.value = i
1287
1288
1289 # TODO, move to space_view3d.py
1290 class VIEW3D_PT_tools_particlemode(View3DPanel, Panel):
1291     """Default tools for particle mode"""
1292     bl_context = ".particlemode"
1293     bl_label = "Options"
1294
1295     def draw(self, context):
1296         layout = self.layout
1297
1298         pe = context.tool_settings.particle_edit
1299         ob = pe.object
1300
1301         layout.prop(pe, "type", text="")
1302
1303         ptcache = None
1304
1305         if pe.type == 'PARTICLES':
1306             if ob.particle_systems:
1307                 if len(ob.particle_systems) > 1:
1308                     layout.template_list("UI_UL_list", "particle_systems", ob, "particle_systems",
1309                                          ob.particle_systems, "active_index", rows=2, maxrows=3)
1310
1311                 ptcache = ob.particle_systems.active.point_cache
1312         else:
1313             for md in ob.modifiers:
1314                 if md.type == pe.type:
1315                     ptcache = md.point_cache
1316
1317         if ptcache and len(ptcache.point_caches) > 1:
1318             layout.template_list("UI_UL_list", "particles_point_caches", ptcache, "point_caches",
1319                                  ptcache.point_caches, "active_index", rows=2, maxrows=3)
1320
1321         if not pe.is_editable:
1322             layout.label(text="Point cache must be baked")
1323             layout.label(text="in memory to enable editing!")
1324
1325         col = layout.column(align=True)
1326         if pe.is_hair:
1327             col.active = pe.is_editable
1328             col.prop(pe, "use_emitter_deflect", text="Deflect Emitter")
1329             sub = col.row(align=True)
1330             sub.active = pe.use_emitter_deflect
1331             sub.prop(pe, "emitter_distance", text="Distance")
1332
1333         col = layout.column(align=True)
1334         col.active = pe.is_editable
1335         col.label(text="Keep:")
1336         col.prop(pe, "use_preserve_length", text="Lengths")
1337         col.prop(pe, "use_preserve_root", text="Root")
1338         if not pe.is_hair:
1339             col.label(text="Correct:")
1340             col.prop(pe, "use_auto_velocity", text="Velocity")
1341         col.prop(ob.data, "use_mirror_x")
1342
1343         col.prop(pe, "shape_object")
1344         col.operator("particle.shape_cut")
1345
1346         col = layout.column(align=True)
1347         col.active = pe.is_editable
1348         col.label(text="Draw:")
1349         col.prop(pe, "draw_step", text="Path Steps")
1350         if pe.is_hair:
1351             col.prop(pe, "show_particles", text="Children")
1352         else:
1353             if pe.type == 'PARTICLES':
1354                 col.prop(pe, "show_particles", text="Particles")
1355             col.prop(pe, "use_fade_time")
1356             sub = col.row(align=True)
1357             sub.active = pe.use_fade_time
1358             sub.prop(pe, "fade_frames", slider=True)
1359
1360
1361 class VIEW3D_PT_tools_normal(View3DPanel, Panel):
1362     bl_category = ""
1363     bl_context = ".mesh_edit"
1364     bl_label = "Normal Tools"
1365
1366     def draw(self, context):
1367         layout = self.layout
1368         toolsettings = context.tool_settings
1369
1370         col = layout.column(align=True)
1371         col.label(text="Normal Vector")
1372         col.prop(toolsettings, "normal_vector", text="")
1373
1374         layout.separator()
1375         layout.label(text="Face Strength")
1376         layout.prop(toolsettings, "face_strength", text="")
1377
1378         col = layout.column(align=True)
1379
1380
1381 # ********** grease pencil object tool panels ****************
1382
1383 # Grease Pencil drawing brushes
1384 class VIEW3D_PT_tools_grease_pencil_brush(View3DPanel, Panel):
1385     bl_context = ".greasepencil_paint"
1386     bl_label = "Brush"
1387
1388     @classmethod
1389     def poll(cls, context):
1390         is_3d_view = context.space_data.type == 'VIEW_3D'
1391         if is_3d_view:
1392             if context.gpencil_data is None:
1393                 return False
1394
1395             gpd = context.gpencil_data
1396             return bool(gpd.is_stroke_paint_mode)
1397         else:
1398             return True
1399
1400     @staticmethod
1401     def draw(self, context):
1402         layout = self.layout
1403         layout.use_property_split = True
1404         layout.use_property_decorate = False
1405
1406         ts = context.scene.tool_settings
1407         settings = ts.gpencil_paint
1408
1409         row = layout.row()
1410         col = row.column()
1411         col.template_ID_preview(settings, "brush", new="brush.add_gpencil", rows=3, cols=8)
1412
1413         col = row.column()
1414         brush = context.active_gpencil_brush
1415         gp_settings = brush.gpencil_settings
1416
1417         sub = col.column(align=True)
1418         sub.operator("gpencil.brush_presets_create", icon='HELP', text="")
1419
1420         if brush is not None:
1421             # XXX: Items in "sub" currently show up beside the brush selector in a separate column
1422             if gp_settings.gpencil_brush_type == 'ERASE':
1423                 sub.prop(gp_settings, "default_eraser", text="")
1424
1425             # Brush details
1426             if gp_settings.gpencil_brush_type == 'ERASE':
1427                 col = layout.column(align=True)
1428                 col.prop(brush, "size", text="Radius")
1429
1430                 col.separator()
1431                 row = col.row()
1432                 row.prop(gp_settings, "eraser_mode", expand=True)
1433             elif gp_settings.gpencil_brush_type == 'FILL':
1434                 col = layout.column(align=True)
1435                 col.prop(gp_settings, "gpencil_fill_leak", text="Leak Size")
1436                 col.prop(brush, "size", text="Thickness")
1437                 col.prop(gp_settings, "gpencil_fill_simplyfy_level", text="Simplify")
1438
1439                 col = layout.row(align=True)
1440                 col.template_ID(gp_settings, "material")
1441
1442                 row = layout.row(align=True)
1443                 row.prop(gp_settings, "gpencil_fill_draw_mode", text="Boundary Draw Mode")
1444                 row.prop(gp_settings, "gpencil_fill_show_boundary", text="", icon='GRID')
1445
1446                 col = layout.column(align=True)
1447                 col.enabled = gp_settings.gpencil_fill_draw_mode != "STROKE"
1448                 col.prop(gp_settings, "gpencil_fill_hide", text="Hide Transparent Lines")
1449                 sub = col.row(align=True)
1450                 sub.enabled = gp_settings.gpencil_fill_hide
1451                 sub.prop(gp_settings, "gpencil_fill_threshold", text="Threshold")
1452             else:  # bgpsettings.gpencil_brush_type == 'DRAW':
1453                 row = layout.row(align=True)
1454                 row.prop(brush, "size", text="Radius")
1455                 row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
1456                 row = layout.row(align=True)
1457                 row.prop(gp_settings, "pen_strength", slider=True)
1458                 row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
1459
1460                 row = layout.row(align=True)
1461                 row.template_ID(gp_settings, "material")
1462
1463
1464 # Grease Pencil drawing brushes options
1465 class VIEW3D_PT_tools_grease_pencil_brush_option(View3DPanel, Panel):
1466     bl_context = ".greasepencil_paint"
1467     bl_label = "Options"
1468     bl_options = {'DEFAULT_CLOSED'}
1469
1470     def draw_header_preset(self, context):
1471         VIEW3D_PT_gpencil_brush_presets.draw_panel_header(self.layout)
1472
1473     @staticmethod
1474     def draw(self, context):
1475         layout = self.layout
1476         layout.use_property_split = True
1477         layout.use_property_decorate = False
1478
1479         brush = context.active_gpencil_brush
1480         gp_settings = brush.gpencil_settings
1481
1482         if brush is not None:
1483             col = layout.column(align=True)
1484             col.prop(gp_settings, "input_samples")
1485             col.separator()
1486
1487             col.prop(gp_settings, "active_smooth_factor")
1488             col.separator()
1489
1490             col.prop(gp_settings, "angle", slider=True)
1491             col.prop(gp_settings, "angle_factor", text="Factor", slider=True)
1492             col.separator()
1493
1494
1495 class VIEW3D_PT_tools_grease_pencil_brush_stabilizer(View3DPanel, Panel):
1496     bl_context = ".greasepencil_paint"
1497     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1498     bl_label = "Stabilizer"
1499     bl_options = {'DEFAULT_CLOSED'}
1500
1501     @classmethod
1502     def poll(cls, context):
1503         brush = context.active_gpencil_brush
1504         gp_settings = brush.gpencil_settings
1505
1506         return brush is not None and gp_settings.gpencil_brush_type == 'DRAW'
1507
1508     def draw_header(self, context):
1509         brush = context.active_gpencil_brush
1510         gp_settings = brush.gpencil_settings
1511         self.layout.prop(gp_settings, "use_stabilizer", text="")
1512
1513     @staticmethod
1514     def draw(self, context):
1515         layout = self.layout
1516         layout.use_property_split = True
1517         layout.use_property_decorate = False
1518
1519         brush = context.active_gpencil_brush
1520         gp_settings = brush.gpencil_settings
1521         layout.active = gp_settings.use_stabilizer
1522
1523         layout.prop(brush, "smooth_stroke_radius", text="Radius", slider=True)
1524         layout.prop(brush, "smooth_stroke_factor", text="Factor", slider=True)
1525
1526
1527 class VIEW3D_PT_tools_grease_pencil_brush_settings(View3DPanel, Panel):
1528     bl_context = ".greasepencil_paint"
1529     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1530     bl_label = "Post-processing Settings"
1531     bl_options = {'DEFAULT_CLOSED'}
1532
1533     @classmethod
1534     def poll(cls, context):
1535         brush = context.active_gpencil_brush
1536
1537         return brush is not None
1538
1539     def draw_header(self, context):
1540         brush = context.active_gpencil_brush
1541         gp_settings = brush.gpencil_settings
1542         self.layout.prop(gp_settings, "enable_settings", text="")
1543
1544     @staticmethod
1545     def draw(self, context):
1546         layout = self.layout
1547         layout.use_property_split = True
1548         layout.use_property_decorate = False
1549
1550         brush = context.active_gpencil_brush
1551         gp_settings = brush.gpencil_settings
1552         layout.active = gp_settings.enable_settings
1553
1554         col = layout.column(align=True)
1555         col.prop(gp_settings, "pen_smooth_factor")
1556         col.prop(gp_settings, "pen_thick_smooth_factor")
1557
1558         col = layout.column(align=True)
1559         col.prop(gp_settings, "pen_smooth_steps")
1560         col.prop(gp_settings, "pen_thick_smooth_steps")
1561
1562         col = layout.column(align=True)
1563         col.prop(gp_settings, "pen_subdivision_steps")
1564         col.prop(gp_settings, "random_subdiv", text="Randomness", slider=True)
1565
1566
1567 class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
1568     bl_context = ".greasepencil_paint"
1569     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_option'
1570     bl_label = "Random Settings"
1571     bl_options = {'DEFAULT_CLOSED'}
1572
1573     @classmethod
1574     def poll(cls, context):
1575         brush = context.active_gpencil_brush
1576
1577         return brush is not None
1578
1579     def draw_header(self, context):
1580         brush = context.active_gpencil_brush
1581         gp_settings = brush.gpencil_settings
1582         self.layout.prop(gp_settings, "enable_random", text="")
1583
1584     @staticmethod
1585     def draw(self, context):
1586         layout = self.layout
1587         layout.use_property_split = True
1588         layout.use_property_decorate = False
1589
1590         brush = context.active_gpencil_brush
1591         gp_settings = brush.gpencil_settings
1592         layout.active = gp_settings.enable_random
1593
1594         layout.prop(gp_settings, "random_pressure", text="Pressure", slider=True)
1595         layout.prop(gp_settings, "random_strength", text="Strength", slider=True)
1596         layout.prop(gp_settings, "uv_random", text="UV", slider=True)
1597
1598         row = layout.row(align=True)
1599         row.prop(gp_settings, "pen_jitter", slider=True)
1600         row.prop(gp_settings, "use_jitter_pressure", text="", icon='STYLUS_PRESSURE')
1601
1602
1603 # Grease Pencil drawingcurves
1604 class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
1605     bl_context = ".greasepencil_paint"
1606     bl_label = "Curves"
1607     bl_options = {'DEFAULT_CLOSED'}
1608
1609     @staticmethod
1610     def draw(self, context):
1611         layout = self.layout
1612         layout.use_property_split = True
1613
1614         brush = context.active_gpencil_brush
1615         gp_settings = brush.gpencil_settings
1616
1617         # Brush
1618         layout.label(text="Sensitivity")
1619         layout.template_curve_mapping(gp_settings, "curve_sensitivity", brush=True)
1620
1621         layout.label(text="Strength")
1622         layout.template_curve_mapping(gp_settings, "curve_strength", brush=True)
1623
1624         layout.label(text="Jitter")
1625         layout.template_curve_mapping(gp_settings, "curve_jitter", brush=True)
1626
1627
1628 # Grease Pencil create shapes
1629 class VIEW3D_PT_tools_grease_pencil_shapes(View3DPanel, Panel):
1630     bl_space_type = 'VIEW_3D'
1631     bl_region_type = 'HEADER'
1632     bl_label = "Shapes"
1633
1634     @classmethod
1635     def poll(cls, context):
1636         ob = context.active_object
1637         return ob and ob.type == 'GPENCIL'
1638
1639     @staticmethod
1640     def draw(self, context):
1641         layout = self.layout
1642         layout.use_property_split = True
1643
1644         col = layout.column(align=True)
1645         col.operator("gpencil.primitive", text="Line", icon='IPO_CONSTANT').type = 'LINE'
1646         col.operator("gpencil.primitive", text="Rectangle", icon='UV_FACESEL').type = 'BOX'
1647         col.operator("gpencil.primitive", text="Circle", icon='ANTIALIASED').type = 'CIRCLE'
1648
1649         layout.operator("object.gpencil_add", text="Monkey", icon='MONKEY').type = 'MONKEY'
1650
1651
1652 # Grease Pencil stroke editing tools
1653 class VIEW3D_PT_tools_grease_pencil_edit(GreasePencilStrokeEditPanel, Panel):
1654     bl_space_type = 'VIEW_3D'
1655
1656
1657 # Grease Pencil stroke interpolation tools
1658 class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
1659     bl_space_type = 'VIEW_3D'
1660     bl_region_type = 'HEADER'
1661     bl_label = "Interpolate"
1662
1663     @classmethod
1664     def poll(cls, context):
1665         if context.gpencil_data is None:
1666             return False
1667
1668         gpd = context.gpencil_data
1669         return bool(context.editable_gpencil_strokes) and bool(gpd.use_stroke_edit_mode)
1670
1671     @staticmethod
1672     def draw(self, context):
1673         layout = self.layout
1674         settings = context.tool_settings.gpencil_interpolate
1675
1676         col = layout.column(align=True)
1677         col.label(text="Interpolate Strokes")
1678         col.operator("gpencil.interpolate", text="Interpolate")
1679         col.operator("gpencil.interpolate_sequence", text="Sequence")
1680         col.operator("gpencil.interpolate_reverse", text="Remove Breakdowns")
1681
1682         col = layout.column(align=True)
1683         col.label(text="Options:")
1684         col.prop(settings, "interpolate_all_layers")
1685         col.prop(settings, "interpolate_selected_only")
1686
1687         col = layout.column(align=True)
1688         col.label(text="Sequence Options:")
1689         col.prop(settings, "type")
1690         if settings.type == 'CUSTOM':
1691             # TODO: Options for loading/saving curve presets?
1692             col.template_curve_mapping(settings, "interpolation_curve", brush=True)
1693         elif settings.type != 'LINEAR':
1694             col.prop(settings, "easing")
1695
1696             if settings.type == 'BACK':
1697                 layout.prop(settings, "back")
1698             elif setting.type == 'ELASTIC':
1699                 sub = layout.column(align=True)
1700                 sub.prop(settings, "amplitude")
1701                 sub.prop(settings, "period")
1702
1703
1704 # Grease Pencil stroke sculpting tools
1705 class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, View3DPanel, Panel):
1706     bl_context = ".greasepencil_sculpt"
1707     bl_category = "Tools"
1708     bl_label = "Sculpt Strokes"
1709
1710
1711 # Grease Pencil weight painting tools
1712 class VIEW3D_PT_tools_grease_pencil_weight_paint(View3DPanel, Panel):
1713     bl_context = ".greasepencil_weight"
1714     bl_category = "Tools"
1715     bl_label = "Weight Paint"
1716
1717     @staticmethod
1718     def draw(self, context):
1719         layout = self.layout
1720         layout.use_property_split = True
1721         layout.use_property_decorate = False
1722
1723         gpd = context.gpencil_data
1724         settings = context.tool_settings.gpencil_sculpt
1725         tool = settings.tool
1726         brush = settings.brush
1727
1728         layout.template_icon_view(settings, "weight_tool", show_labels=True)
1729
1730         col = layout.column()
1731         col.prop(brush, "size", slider=True)
1732         row = col.row(align=True)
1733         row.prop(brush, "strength", slider=True)
1734         row.prop(brush, "use_pressure_strength", text="")
1735
1736         col.prop(brush, "use_falloff")
1737
1738
1739 # Grease Pencil Brush Appeareance (one for each mode)
1740 class VIEW3D_PT_tools_grease_pencil_paint_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1741     bl_context = ".greasepencil_paint"
1742     bl_label = "Appearance"
1743
1744
1745 class VIEW3D_PT_tools_grease_pencil_sculpt_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1746     bl_context = ".greasepencil_sculpt"
1747     bl_label = "Appearance"
1748
1749
1750 class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilAppearancePanel, View3DPanel, Panel):
1751     bl_context = ".greasepencil_weight"
1752     bl_label = "Appearance"
1753
1754
1755 class VIEW3D_PT_gpencil_brush_presets(PresetMenu):
1756     """Brush settings"""
1757     bl_label = "Brush Presets"
1758     preset_subdir = "gpencil_brush"
1759     preset_operator = "script.execute_preset"
1760     preset_add_operator = "scene.gpencil_brush_preset_add"
1761
1762
1763 classes = (
1764     VIEW3D_PT_tools_meshedit_options,
1765     VIEW3D_PT_tools_curveedit_options_stroke,
1766     VIEW3D_PT_tools_armatureedit_options,
1767     VIEW3D_PT_tools_posemode_options,
1768     VIEW3D_PT_imapaint_tools_missing,
1769     VIEW3D_PT_tools_brush,
1770     TEXTURE_UL_texpaintslots,
1771     VIEW3D_MT_tools_projectpaint_uvlayer,
1772     VIEW3D_PT_slots_projectpaint,
1773     VIEW3D_PT_stencil_projectpaint,
1774     VIEW3D_PT_tools_brush_overlay,
1775     VIEW3D_PT_tools_brush_texture,
1776     VIEW3D_PT_tools_mask_texture,
1777     VIEW3D_PT_tools_brush_stroke,
1778     VIEW3D_PT_tools_brush_curve,
1779     VIEW3D_PT_sculpt_dyntopo,
1780     VIEW3D_PT_sculpt_options,
1781     VIEW3D_PT_sculpt_symmetry,
1782     VIEW3D_PT_tools_brush_appearance,
1783     VIEW3D_PT_tools_weightpaint_symmetry,
1784     VIEW3D_PT_tools_weightpaint_options,
1785     VIEW3D_PT_tools_vertexpaint,
1786     VIEW3D_PT_tools_vertexpaint_symmetry,
1787     VIEW3D_PT_tools_imagepaint_external,
1788     VIEW3D_PT_tools_imagepaint_symmetry,
1789     VIEW3D_PT_tools_projectpaint,
1790     VIEW3D_MT_tools_projectpaint_stencil,
1791     VIEW3D_PT_tools_particlemode,
1792
1793     VIEW3D_PT_gpencil_brush_presets,
1794     VIEW3D_PT_tools_grease_pencil_brush,
1795     VIEW3D_PT_tools_grease_pencil_brush_option,
1796     VIEW3D_PT_tools_grease_pencil_brush_settings,
1797     VIEW3D_PT_tools_grease_pencil_brush_stabilizer,
1798     VIEW3D_PT_tools_grease_pencil_brush_random,
1799     VIEW3D_PT_tools_grease_pencil_brushcurves,
1800     VIEW3D_PT_tools_grease_pencil_shapes,
1801     VIEW3D_PT_tools_grease_pencil_sculpt,
1802     VIEW3D_PT_tools_grease_pencil_weight_paint,
1803     VIEW3D_PT_tools_grease_pencil_paint_appearance,
1804     VIEW3D_PT_tools_grease_pencil_sculpt_appearance,
1805     VIEW3D_PT_tools_grease_pencil_weight_appearance,
1806     VIEW3D_PT_tools_grease_pencil_interpolate,
1807     VIEW3D_PT_tools_normal,
1808 )
1809
1810 if __name__ == "__main__":  # only for live edit.
1811     from bpy.utils import register_class
1812     for cls in classes:
1813         register_class(cls)