GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions
authorAntonio Vazquez <blendergit@gmail.com>
Mon, 9 Mar 2020 15:27:24 +0000 (16:27 +0100)
committerAntonio Vazquez <blendergit@gmail.com>
Mon, 9 Mar 2020 15:27:24 +0000 (16:27 +0100)
This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes.

Also, a huge code cleanup has been done at all levels.

Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development.

Differential Revision: https://developer.blender.org/D6293

252 files changed:
release/datafiles/userdef/userdef_default.c
release/scripts/modules/bl_keymap_utils/keymap_from_toolbar.py
release/scripts/modules/bl_keymap_utils/keymap_hierarchy.py
release/scripts/presets/gpencil_material/fill_only.py
release/scripts/presets/gpencil_material/stroke_and_fill.py
release/scripts/presets/gpencil_material/stroke_only.py
release/scripts/presets/keyconfig/keymap_data/blender_default.py
release/scripts/presets/keyconfig/keymap_data/industry_compatible_data.py
release/scripts/startup/bl_operators/presets.py
release/scripts/startup/bl_ui/properties_data_gpencil.py
release/scripts/startup/bl_ui/properties_data_modifier.py
release/scripts/startup/bl_ui/properties_data_shaderfx.py
release/scripts/startup/bl_ui/properties_grease_pencil_common.py
release/scripts/startup/bl_ui/properties_material_gpencil.py
release/scripts/startup/bl_ui/properties_object.py
release/scripts/startup/bl_ui/properties_paint_common.py
release/scripts/startup/bl_ui/space_dopesheet.py
release/scripts/startup/bl_ui/space_image.py
release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
release/scripts/startup/bl_ui/space_topbar.py
release/scripts/startup/bl_ui/space_userpref.py
release/scripts/startup/bl_ui/space_view3d.py
release/scripts/startup/bl_ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_blender_version.h
source/blender/blenkernel/BKE_brush.h
source/blender/blenkernel/BKE_context.h
source/blender/blenkernel/BKE_gpencil.h
source/blender/blenkernel/BKE_gpencil_modifier.h
source/blender/blenkernel/BKE_paint.h
source/blender/blenkernel/intern/brush.c
source/blender/blenkernel/intern/context.c
source/blender/blenkernel/intern/gpencil.c
source/blender/blenkernel/intern/gpencil_modifier.c
source/blender/blenkernel/intern/lib_query.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/object.c
source/blender/blenkernel/intern/object_update.c
source/blender/blenkernel/intern/paint.c
source/blender/blenkernel/intern/paint_toolslots.c
source/blender/blenkernel/intern/scene.c
source/blender/blenlib/intern/BLI_memblock.c
source/blender/blenloader/intern/readfile.c
source/blender/blenloader/intern/versioning_270.c
source/blender/blenloader/intern/versioning_280.c
source/blender/blenloader/intern/versioning_defaults.c
source/blender/blenloader/intern/writefile.c
source/blender/depsgraph/intern/builder/deg_builder_nodes.cc
source/blender/depsgraph/intern/builder/deg_builder_relations.cc
source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc
source/blender/draw/CMakeLists.txt
source/blender/draw/DRW_engine.h
source/blender/draw/engines/gpencil/gpencil_antialiasing.c [new file with mode: 0644]
source/blender/draw/engines/gpencil/gpencil_cache_utils.c
source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c [deleted file]
source/blender/draw/engines/gpencil/gpencil_draw_data.c [new file with mode: 0644]
source/blender/draw/engines/gpencil/gpencil_draw_utils.c [deleted file]
source/blender/draw/engines/gpencil/gpencil_engine.c
source/blender/draw/engines/gpencil/gpencil_engine.h
source/blender/draw/engines/gpencil/gpencil_render.c
source/blender/draw/engines/gpencil/gpencil_shader.c [new file with mode: 0644]
source/blender/draw/engines/gpencil/gpencil_shader_fx.c
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_blur_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_colorize_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_flip_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_glow_prepare_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_glow_resolve_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_light_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_pixel_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_prepare_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_rim_resolve_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_shadow_prepare_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_shadow_resolve_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_swirl_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/fx/gpencil_fx_wave_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_antialiasing_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_background_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_blend_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_depth_merge_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_geom.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_edit_point_vert.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_fill_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_fill_vert.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_layer_blend_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_mask_invert_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_paper_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_point_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_point_geom.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_point_vert.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_simple_mix_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_stroke_frag.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_stroke_geom.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_stroke_vert.glsl [deleted file]
source/blender/draw/engines/gpencil/shaders/gpencil_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_vfx_frag.glsl [new file with mode: 0644]
source/blender/draw/engines/gpencil/shaders/gpencil_zdepth_mix_frag.glsl [deleted file]
source/blender/draw/engines/overlay/overlay_engine.c
source/blender/draw/engines/overlay/overlay_extra.c
source/blender/draw/engines/overlay/overlay_gpencil.c [new file with mode: 0644]
source/blender/draw/engines/overlay/overlay_motion_path.c
source/blender/draw/engines/overlay/overlay_outline.c
source/blender/draw/engines/overlay/overlay_private.h
source/blender/draw/engines/overlay/overlay_shader.c
source/blender/draw/engines/overlay/overlay_wireframe.c
source/blender/draw/engines/overlay/shaders/edit_gpencil_canvas_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/overlay/shaders/edit_gpencil_guide_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/overlay/shaders/edit_gpencil_vert.glsl [new file with mode: 0644]
source/blender/draw/engines/overlay/shaders/outline_prepass_frag.glsl
source/blender/draw/engines/overlay/shaders/outline_prepass_vert.glsl
source/blender/draw/engines/overlay/shaders/wireframe_vert.glsl
source/blender/draw/engines/workbench/workbench_render.c
source/blender/draw/intern/DRW_render.h
source/blender/draw/intern/draw_cache.c
source/blender/draw/intern/draw_cache.h
source/blender/draw/intern/draw_cache_impl_gpencil.c [new file with mode: 0644]
source/blender/draw/intern/draw_common.c
source/blender/draw/intern/draw_common.h
source/blender/draw/intern/draw_manager.c
source/blender/draw/intern/draw_manager.h
source/blender/draw/intern/draw_manager_data.c
source/blender/draw/intern/draw_manager_exec.c
source/blender/draw/intern/shaders/common_globals_lib.glsl
source/blender/draw/intern/shaders/common_smaa_lib.glsl
source/blender/draw/intern/shaders/common_view_lib.glsl
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/animation/anim_channels_edit.c
source/blender/editors/armature/armature_naming.c
source/blender/editors/gpencil/CMakeLists.txt
source/blender/editors/gpencil/annotate_draw.c
source/blender/editors/gpencil/annotate_paint.c
source/blender/editors/gpencil/drawgpencil.c
source/blender/editors/gpencil/editaction_gpencil.c
source/blender/editors/gpencil/gpencil_add_monkey.c
source/blender/editors/gpencil/gpencil_add_stroke.c
source/blender/editors/gpencil/gpencil_armature.c
source/blender/editors/gpencil/gpencil_convert.c
source/blender/editors/gpencil/gpencil_data.c
source/blender/editors/gpencil/gpencil_edit.c
source/blender/editors/gpencil/gpencil_fill.c
source/blender/editors/gpencil/gpencil_intern.h
source/blender/editors/gpencil/gpencil_interpolate.c
source/blender/editors/gpencil/gpencil_merge.c
source/blender/editors/gpencil/gpencil_ops.c
source/blender/editors/gpencil/gpencil_ops_versioning.c
source/blender/editors/gpencil/gpencil_paint.c
source/blender/editors/gpencil/gpencil_primitive.c
source/blender/editors/gpencil/gpencil_sculpt_paint.c [moved from source/blender/editors/gpencil/gpencil_brush.c with 76% similarity]
source/blender/editors/gpencil/gpencil_select.c
source/blender/editors/gpencil/gpencil_undo.c
source/blender/editors/gpencil/gpencil_utils.c
source/blender/editors/gpencil/gpencil_uv.c [new file with mode: 0644]
source/blender/editors/gpencil/gpencil_vertex_ops.c [new file with mode: 0644]
source/blender/editors/gpencil/gpencil_vertex_paint.c [new file with mode: 0644]
source/blender/editors/gpencil/gpencil_weight_paint.c [new file with mode: 0644]
source/blender/editors/include/ED_gpencil.h
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_eyedropper_gpencil_color.c
source/blender/editors/interface/interface_handlers.c
source/blender/editors/interface/interface_icons.c
source/blender/editors/interface/interface_layout.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/object/object_add.c
source/blender/editors/object/object_edit.c
source/blender/editors/object/object_gpencil_modifier.c
source/blender/editors/object/object_modes.c
source/blender/editors/object/object_transform.c
source/blender/editors/screen/area.c
source/blender/editors/screen/screen_context.c
source/blender/editors/sculpt_paint/paint_ops.c
source/blender/editors/space_action/action_edit.c
source/blender/editors/space_action/action_select.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_view3d/space_view3d.c
source/blender/editors/space_view3d/view3d_gizmo_ruler.c
source/blender/editors/space_view3d/view3d_select.c
source/blender/editors/transform/transform_convert.c
source/blender/editors/transform/transform_convert_gpencil.c
source/blender/editors/transform/transform_generics.c
source/blender/editors/transform/transform_gizmo_3d.c
source/blender/editors/undo/ed_undo.c
source/blender/gpencil_modifiers/CMakeLists.txt
source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
source/blender/gpencil_modifiers/intern/MOD_gpencil_util.h
source/blender/gpencil_modifiers/intern/MOD_gpencilarmature.c
source/blender/gpencil_modifiers/intern/MOD_gpencilarray.c
source/blender/gpencil_modifiers/intern/MOD_gpencilbuild.c
source/blender/gpencil_modifiers/intern/MOD_gpencilcolor.c
source/blender/gpencil_modifiers/intern/MOD_gpencilhook.c
source/blender/gpencil_modifiers/intern/MOD_gpencillattice.c
source/blender/gpencil_modifiers/intern/MOD_gpencilmirror.c
source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
source/blender/gpencil_modifiers/intern/MOD_gpencilnoise.c
source/blender/gpencil_modifiers/intern/MOD_gpenciloffset.c
source/blender/gpencil_modifiers/intern/MOD_gpencilopacity.c
source/blender/gpencil_modifiers/intern/MOD_gpencilsimplify.c
source/blender/gpencil_modifiers/intern/MOD_gpencilsmooth.c
source/blender/gpencil_modifiers/intern/MOD_gpencilsubdiv.c
source/blender/gpencil_modifiers/intern/MOD_gpencilthick.c
source/blender/gpencil_modifiers/intern/MOD_gpenciltint.c
source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c [new file with mode: 0644]
source/blender/gpu/GPU_framebuffer.h
source/blender/gpu/GPU_shader_interface.h
source/blender/gpu/GPU_texture.h
source/blender/gpu/GPU_vertex_format.h
source/blender/gpu/intern/gpu_framebuffer.c
source/blender/gpu/intern/gpu_shader_interface.c
source/blender/gpu/intern/gpu_vertex_format.c
source/blender/imbuf/IMB_imbuf.h
source/blender/imbuf/intern/imageprocess.c
source/blender/makesdna/DNA_brush_types.h
source/blender/makesdna/DNA_gpencil_modifier_types.h
source/blender/makesdna/DNA_gpencil_types.h
source/blender/makesdna/DNA_material_types.h
source/blender/makesdna/DNA_object_enums.h
source/blender/makesdna/DNA_object_types.h
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_shader_fx_types.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesdna/intern/dna_rename_defs.h
source/blender/makesrna/RNA_access.h
source/blender/makesrna/RNA_enum_types.h
source/blender/makesrna/intern/rna_brush.c
source/blender/makesrna/intern/rna_context.c
source/blender/makesrna/intern/rna_gpencil.c
source/blender/makesrna/intern/rna_gpencil_modifier.c
source/blender/makesrna/intern/rna_material.c
source/blender/makesrna/intern/rna_object.c
source/blender/makesrna/intern/rna_scene.c
source/blender/makesrna/intern/rna_sculpt_paint.c
source/blender/makesrna/intern/rna_shader_fx.c
source/blender/makesrna/intern/rna_space.c
source/blender/makesrna/intern/rna_ui_api.c
source/blender/makesrna/intern/rna_userdef.c
source/blender/shader_fx/CMakeLists.txt
source/blender/shader_fx/FX_shader_types.h
source/blender/shader_fx/intern/FX_shader_blur.c
source/blender/shader_fx/intern/FX_shader_flip.c
source/blender/shader_fx/intern/FX_shader_glow.c
source/blender/shader_fx/intern/FX_shader_pixel.c
source/blender/shader_fx/intern/FX_shader_rim.c
source/blender/shader_fx/intern/FX_shader_shadow.c
source/blender/shader_fx/intern/FX_shader_util.c
source/blender/shader_fx/intern/FX_shader_wave.c
source/blender/windowmanager/intern/wm_keymap_utils.c
source/blender/windowmanager/intern/wm_toolsystem.c

index 576cff5bd0eb95f495fffb75a189067ca8f5b268..18750c12d5569a03f128e5dff5adc266e200b846 100644 (file)
@@ -187,7 +187,6 @@ const UserDef U_default = {
     .pie_menu_radius = 100,
     .pie_menu_threshold = 12,
     .opensubdiv_compute_type = 0,
-    .gpencil_multisamples = 4,
     .factor_display_type = USER_FACTOR_AS_FACTOR,
     .render_display_type = USER_RENDER_DISPLAY_WINDOW,
     .filebrowser_display_type = USER_TEMP_SPACE_DISPLAY_WINDOW,
index da4a47783ad827f7df2b910a50c2b840223f95ff..505223872fe31d88df4deddff2e5b9d2f91b230d 100644 (file)
@@ -199,6 +199,9 @@ def generate(context, space_type, use_fallback_keys=True, use_reset=True):
                         'WEIGHT_PAINT': "weight_tool",
                         'TEXTURE_PAINT': "image_tool",
                         'PAINT_GPENCIL': "gpencil_tool",
+                        'VERTEX_GPENCIL': "gpencil_vertex_tool",
+                        'SCULPT_GPENCIL': "gpencil_sculpt_tool",
+                        'WEIGHT_GPENCIL': "gpencil_weight_tool",
                     }.get(mode, None)
                     if attr is not None:
                         setattr(kmi_hack_brush_select_properties, attr, item.data_block)
index 35b5f2172473dde647de7a5abdabc6b9580b08e2..3b829de405ae15c77fcbcd42a3a26bb337d99eef 100644 (file)
@@ -194,9 +194,26 @@ _km_hierarchy = [
         ('Grease Pencil Stroke Paint (Draw brush)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint (Fill)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint (Erase)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Paint (Tint)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Paint Mode', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Sculpt Mode', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Smooth)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Thickness)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Strength)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Grab)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Push)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Twist)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Pinch)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Randomize)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Sculpt (Clone)', 'EMPTY', 'WINDOW', []),
         ('Grease Pencil Stroke Weight Mode', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Weight (Draw)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex Mode', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex (Draw)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex (Blur)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex (Average)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex (Smear)', 'EMPTY', 'WINDOW', []),
+        ('Grease Pencil Stroke Vertex (Replace)', 'EMPTY', 'WINDOW', []),
     ]),
     ('Mask Editing', 'EMPTY', 'WINDOW', []),
     ('Frames', 'EMPTY', 'WINDOW', []),    # frame navigation (per region)
index c60811d25bc2e0b918899653623a39051b6c565c..57d5dc3b8600042410eb6ea0a121ce878cb0cfd7 100644 (file)
@@ -7,8 +7,6 @@ gpcolor.stroke_style = 'SOLID'
 gpcolor.color = (0.0, 0.0, 0.0, 0.0)
 gpcolor.stroke_image = None
 gpcolor.pixel_size = 100.0
-gpcolor.use_stroke_pattern = False
-gpcolor.use_stroke_texture_mix = False
 gpcolor.mix_stroke_factor = 0.0
 gpcolor.alignment_mode = 'PATH'
 gpcolor.fill_style = 'SOLID'
@@ -18,18 +16,11 @@ gpcolor.gradient_type = 'LINEAR'
 gpcolor.mix_color = (1.0, 1.0, 1.0, 0.2)
 gpcolor.mix_factor = 0.0
 gpcolor.flip = False
-gpcolor.pattern_shift = (0.0, 0.0)
-gpcolor.pattern_scale = (1.0, 1.0)
-gpcolor.pattern_radius = 0.5
-gpcolor.pattern_angle = 0.0
-gpcolor.pattern_gridsize = 0.1
-gpcolor.use_fill_pattern = False
 gpcolor.texture_offset = (0.0, 0.0)
 gpcolor.texture_scale = (1.0, 1.0)
 gpcolor.texture_angle = 0.0
 gpcolor.texture_opacity = 1.0
 gpcolor.texture_clamp = False
-gpcolor.use_fill_texture_mix = False
 gpcolor.mix_factor = 0.0
 gpcolor.show_stroke = False
 gpcolor.show_fill = True
index ee18eeb01143dcba5ddac8333832fb81d3fc8721..eff728a7857e07295647954c18fce10c8a425344 100644 (file)
@@ -7,8 +7,6 @@ gpcolor.stroke_style = 'SOLID'
 gpcolor.color = (0.0, 0.0, 0.0, 1.0)
 gpcolor.stroke_image = None
 gpcolor.pixel_size = 100.0
-gpcolor.use_stroke_pattern = False
-gpcolor.use_stroke_texture_mix = False
 gpcolor.mix_stroke_factor = 0.0
 gpcolor.alignment_mode = 'PATH'
 gpcolor.fill_style = 'SOLID'
@@ -18,18 +16,11 @@ gpcolor.gradient_type = 'LINEAR'
 gpcolor.mix_color = (1.0, 1.0, 1.0, 0.2)
 gpcolor.mix_factor = 0.0
 gpcolor.flip = False
-gpcolor.pattern_shift = (0.0, 0.0)
-gpcolor.pattern_scale = (1.0, 1.0)
-gpcolor.pattern_radius = 0.5
-gpcolor.pattern_angle = 0.0
-gpcolor.pattern_gridsize = 0.1
-gpcolor.use_fill_pattern = False
 gpcolor.texture_offset = (0.0, 0.0)
 gpcolor.texture_scale = (1.0, 1.0)
 gpcolor.texture_angle = 0.0
 gpcolor.texture_opacity = 1.0
 gpcolor.texture_clamp = False
-gpcolor.use_fill_texture_mix = False
 gpcolor.mix_factor = 0.0
 gpcolor.show_stroke = True
 gpcolor.show_fill = True
index 3ca05c6a073e675dc72051b616e3df4dd302028d..1724a62bffc3a0c8d341b6d5b38fc84338bb74d2 100644 (file)
@@ -7,8 +7,6 @@ gpcolor.stroke_style = 'SOLID'
 gpcolor.color = (0.0, 0.0, 0.0, 1.0)
 gpcolor.stroke_image = None
 gpcolor.pixel_size = 100.0
-gpcolor.use_stroke_pattern = False
-gpcolor.use_stroke_texture_mix = False
 gpcolor.mix_stroke_factor = 0.0
 gpcolor.alignment_mode = 'PATH'
 gpcolor.fill_style = 'SOLID'
@@ -18,18 +16,11 @@ gpcolor.gradient_type = 'LINEAR'
 gpcolor.mix_color = (1.0, 1.0, 1.0, 0.2)
 gpcolor.mix_factor = 0.0
 gpcolor.flip = False
-gpcolor.pattern_shift = (0.0, 0.0)
-gpcolor.pattern_scale = (1.0, 1.0)
-gpcolor.pattern_radius = 0.5
-gpcolor.pattern_angle = 0.0
-gpcolor.pattern_gridsize = 0.1
-gpcolor.use_fill_pattern = False
 gpcolor.texture_offset = (0.0, 0.0)
 gpcolor.texture_scale = (1.0, 1.0)
 gpcolor.texture_angle = 0.0
 gpcolor.texture_opacity = 1.0
 gpcolor.texture_clamp = False
-gpcolor.use_fill_texture_mix = False
 gpcolor.mix_factor = 0.0
 gpcolor.show_stroke = True
 gpcolor.show_fill = False
index 5aff2a75e03fc25734539084e980fe2860020581..bf1ff0604ad44ac1daaab52cf1d5747463ef4445 100644 (file)
@@ -3168,6 +3168,10 @@ def km_grease_pencil_stroke_edit_mode(params):
          {"properties": [("mode", 1)]}),
         ("gpencil.selectmode_toggle", {"type": 'THREE', "value": 'PRESS'},
          {"properties": [("mode", 2)]}),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
         # Context menu
         *_template_items_context_menu("VIEW3D_MT_gpencil_edit_context_menu", params.context_menu_event),
     ])
@@ -3211,6 +3215,10 @@ def km_grease_pencil_stroke_paint_mode(params):
          {"properties": [("unselected", False)]}),
         ("gpencil.hide", {"type": 'H', "value": 'PRESS', "shift": True},
          {"properties": [("unselected", True)]}),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
         # Draw context menu
         *_template_items_context_panel("VIEW3D_PT_gpencil_draw_context_menu", params.context_menu_event),
     ])
@@ -3322,6 +3330,25 @@ def km_grease_pencil_stroke_paint_fill(params):
     return keymap
 
 
+def km_grease_pencil_stroke_paint_tint(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Paint (Tint)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
 def km_grease_pencil_stroke_sculpt_mode(params):
     items = []
     keymap = (
@@ -3336,14 +3363,22 @@ def km_grease_pencil_stroke_sculpt_mode(params):
 
         # Brush strength
         ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength')]}),
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt_paint.brush.strength')]}),
         # Brush size
         ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size')]}),
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt_paint.brush.size')]}),
         # Copy
         ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
         # Display
         *_grease_pencil_display(),
+         # Keyframe menu
+        ("gpencil.blank_frame_add", {"type": 'I', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
         # Context menu
         *_template_items_context_panel("VIEW3D_PT_gpencil_sculpt_context_menu", params.context_menu_event),
     ])
@@ -3351,28 +3386,385 @@ def km_grease_pencil_stroke_sculpt_mode(params):
     return keymap
 
 
-def km_grease_pencil_stroke_weight_mode(_params):
+def km_grease_pencil_stroke_sculpt_smooth(_params):
     items = []
     keymap = (
-        "Grease Pencil Stroke Weight Mode",
+        "Grease Pencil Stroke Sculpt (Smooth)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_thickness(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Thickness)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_strength(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Strength)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_grab(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Grab)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_push(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Push)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_twist(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Twist)",
         {"space_type": 'EMPTY', "region_type": 'WINDOW'},
         {"items": items},
     )
 
     items.extend([
-        # Painting
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
         ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
          {"properties": [("wait_for_input", False)]}),
         ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
          {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_pinch(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Pinch)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_randomize(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Randomize)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_clone(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Clone)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_weight_mode(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Weight Mode",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
         # Brush strength
         ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.weight_brush.strength')]}),
-        # Brush sze
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_weight_paint.brush.strength')]}),
+        # Brush size
         ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.weight_brush.size')]}),
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_weight_paint.brush.size')]}),
         # Display
         *_grease_pencil_display(),
+         # Keyframe menu
+        ("gpencil.blank_frame_add", {"type": 'I', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
+        # Context menu
+        *_template_items_context_panel("VIEW3D_PT_gpencil_weight_context_menu", params.context_menu_event),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_weight_draw(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Weight (Draw)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+         # Draw
+        ("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_mode(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex Mode",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Selection
+        *_grease_pencil_selection(params),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+        # Display
+        *_grease_pencil_display(),
+        # Tools
+        op_tool("builtin_brush.Draw", {"type": 'D', "value": 'PRESS'}),
+        op_tool("builtin_brush.Blur", {"type": 'F', "value": 'PRESS'}),
+        op_tool("builtin_brush.Average", {"type": 'E', "value": 'PRESS'}),
+        op_tool("builtin.brush.Smear", {"type": 'K', "value": 'PRESS'}),
+         # Keyframe menu
+        ("gpencil.blank_frame_add", {"type": 'I', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'X', "value": 'PRESS', "shift": True}, None),
+        ("gpencil.active_frames_delete_all", {"type": 'DEL', "value": 'PRESS', "shift": True}, None),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'Y', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
+        # Vertex Paint context menu
+        op_panel("VIEW3D_PT_gpencil_vertex_context_menu", params.context_menu_event),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_draw(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Draw)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_blur(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Blur)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_average(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Average)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_smear(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Smear)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_replace(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Replace)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
     ])
 
     return keymap
@@ -6053,18 +6445,13 @@ def km_3d_view_tool_edit_gpencil_to_sphere(params):
     )
 
 
-# Also used for weight paint.
-def km_3d_view_tool_sculpt_gpencil_paint(_params):
+def km_3d_view_tool_edit_gpencil_transform_fill(params):
     return (
-        "3D View Tool: Sculpt Gpencil, Paint",
+        "3D View Tool: Edit Gpencil, Transform Fill",
         {"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
         {"items": [
-            ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
-             {"properties": [("wait_for_input", False)]}),
-            ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
-             {"properties": [("wait_for_input", False)]}),
-            ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
-             {"properties": [("wait_for_input", False)]}),
+            ("gpencil.transform_fill", {"type": params.tool_tweak, "value": 'ANY'},
+             {"properties": [("release_confirm", True)]}),
         ]},
     )
 
@@ -6201,8 +6588,25 @@ def generate_keymaps(params=None):
         km_grease_pencil_stroke_paint_draw_brush(params),
         km_grease_pencil_stroke_paint_erase(params),
         km_grease_pencil_stroke_paint_fill(params),
+        km_grease_pencil_stroke_paint_tint(params),
         km_grease_pencil_stroke_sculpt_mode(params),
+        km_grease_pencil_stroke_sculpt_smooth(params),
+        km_grease_pencil_stroke_sculpt_thickness(params),
+        km_grease_pencil_stroke_sculpt_strength(params),
+        km_grease_pencil_stroke_sculpt_grab(params),
+        km_grease_pencil_stroke_sculpt_push(params),
+        km_grease_pencil_stroke_sculpt_twist(params),
+        km_grease_pencil_stroke_sculpt_pinch(params),
+        km_grease_pencil_stroke_sculpt_randomize(params),
+        km_grease_pencil_stroke_sculpt_clone(params),
         km_grease_pencil_stroke_weight_mode(params),
+        km_grease_pencil_stroke_weight_draw(params),
+        km_grease_pencil_stroke_vertex_mode(params),
+        km_grease_pencil_stroke_vertex_draw(params),
+        km_grease_pencil_stroke_vertex_blur(params),
+        km_grease_pencil_stroke_vertex_average(params),
+        km_grease_pencil_stroke_vertex_smear(params),
+        km_grease_pencil_stroke_vertex_replace(params),
         km_face_mask(params),
         km_weight_paint_vertex_selection(params),
         km_pose(params),
@@ -6345,7 +6749,7 @@ def generate_keymaps(params=None):
         km_3d_view_tool_edit_gpencil_bend(params),
         km_3d_view_tool_edit_gpencil_shear(params),
         km_3d_view_tool_edit_gpencil_to_sphere(params),
-        km_3d_view_tool_sculpt_gpencil_paint(params),
+        km_3d_view_tool_edit_gpencil_transform_fill(params),
         km_3d_view_tool_sculpt_gpencil_select(params),
         km_3d_view_tool_sculpt_gpencil_select_box(params),
         km_3d_view_tool_sculpt_gpencil_select_circle(params),
index b0b7c542df315b8a5fcc728d4263f520be2ea73a..18acbb54b3443807f93e3fbb7efd0183b1155f3f 100644 (file)
@@ -2364,6 +2364,10 @@ def km_grease_pencil_stroke_paint_mode(params):
         op_tool_cycle("builtin_brush.Erase", {"type": 'E', "value": 'PRESS'}),
         op_tool_cycle("builtin.cutter", {"type": 'K', "value": 'PRESS'}),
         op_tool_cycle("builtin.cursor", {"type": 'C', "value": 'PRESS'}),
+        # Active layer
+        op_menu("GPENCIL_MT_layer_active", {"type": 'M', "value": 'PRESS'}),
+        # Keyframe menu
+        op_menu("VIEW3D_MT_gpencil_animation", {"type": 'I', "value": 'PRESS'}),
     ])
 
     return keymap
@@ -2470,6 +2474,25 @@ def km_grease_pencil_stroke_paint_fill(params):
     return keymap
 
 
+def km_grease_pencil_stroke_paint_tint(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Paint (Tint)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
 def km_grease_pencil_stroke_sculpt_mode(params):
     items = []
     keymap = (
@@ -2481,30 +2504,246 @@ def km_grease_pencil_stroke_sculpt_mode(params):
     items.extend([
         # Selection
         *_grease_pencil_selection(params),
-        # Painting
+
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt_paint.brush.strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt_paint.brush.size')]}),
+        # Copy
+        ("gpencil.copy", {"type": 'C', "value": 'PRESS', "ctrl": True}, None),
+        # Display
+        *_grease_pencil_display(),
+        # Context menu
+        op_panel("VIEW3D_PT_gpencil_sculpt_context_menu", params.context_menu_event),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_smooth(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Smooth)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
         ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
          {"properties": [("wait_for_input", False)]}),
         ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
          {"properties": [("wait_for_input", False)]}),
         ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
          {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_thickness(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Thickness)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_strength(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Strength)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_grab(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Grab)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_push(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Push)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_twist(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Twist)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_pinch(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Pinch)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_randomize(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Randomize)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_sculpt_clone(_params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Sculpt (Clone)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_weight_mode(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Weight Mode",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
         # Brush strength
-        ("wm.radial_control", {"type": 'U', "value": 'PRESS'},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.strength')]}),
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_weight_paint.brush.strength')]}),
         # Brush size
         ("wm.radial_control", {"type": 'S', "value": 'PRESS'},
          {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.brush.size')]}),
         # Context menu
-        *_template_items_context_panel("VIEW3D_PT_gpencil_sculpt_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
+        *_template_items_context_panel("VIEW3D_PT_gpencil_weight_context_menu", {"type": 'RIGHTMOUSE', "value": 'PRESS'}),
     ])
 
     return keymap
 
 
-def km_grease_pencil_stroke_weight_mode(params):
+def km_grease_pencil_stroke_weight_draw(_params):
     items = []
     keymap = (
-        "Grease Pencil Stroke Weight Mode",
+        "Grease Pencil Stroke Weight (Draw)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        ("gpencil.weight_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_mode(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex Mode",
         {"space_type": 'EMPTY', "region_type": 'WINDOW'},
         {"items": items},
     )
@@ -2512,22 +2751,141 @@ def km_grease_pencil_stroke_weight_mode(params):
     items.extend([
         # Selection
         *_grease_pencil_selection(params),
-        # Painting
-        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+        # Display
+        *_grease_pencil_display(),
+        # Tools
+        op_tool("builtin_brush.Draw", {"type": 'D', "value": 'PRESS'}),
+        op_tool("builtin_brush.Blur", {"type": 'F', "value": 'PRESS'}),
+        op_tool("builtin_brush.Average", {"type": 'E', "value": 'PRESS'}),
+        op_tool("builtin.brush.Smear", {"type": 'K', "value": 'PRESS'}),
+        op_tool("builtin.brush.Replace", {"type": 'R', "value": 'PRESS'}),
+        # Vertex Paint context menu
+        op_panel("VIEW3D_PT_gpencil_vertex_context_menu", params.context_menu_event),
+    ])
+
+    return keymap
+
+def km_grease_pencil_stroke_vertex_draw(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Draw)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
          {"properties": [("wait_for_input", False)]}),
-        ("gpencil.sculpt_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "shift": True},
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_blur(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Blur)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_average(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Average)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS', "ctrl": True},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush strength
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS', "shift": True},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
+
+def km_grease_pencil_stroke_vertex_smear(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Smear)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
          {"properties": [("wait_for_input", False)]}),
         # Brush strength
         ("wm.radial_control", {"type": 'U', "value": 'PRESS', "shift": True},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.weight_brush.strength')]}),
-        # Brush size.
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.gpencil_settings.pen_strength')]}),
+        # Brush size
         ("wm.radial_control", {"type": 'S', "value": 'PRESS'},
-         {"properties": [("data_path_primary", 'tool_settings.gpencil_sculpt.weight_brush.size')]}),
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
     ])
 
     return keymap
 
 
+def km_grease_pencil_stroke_vertex_replace(params):
+    items = []
+    keymap = (
+        "Grease Pencil Stroke Vertex (Replace)",
+        {"space_type": 'EMPTY', "region_type": 'WINDOW'},
+        {"items": items},
+    )
+
+    items.extend([
+        # Tint
+        ("gpencil.vertex_paint", {"type": 'LEFTMOUSE', "value": 'PRESS'},
+         {"properties": [("wait_for_input", False)]}),
+        # Brush size
+        ("wm.radial_control", {"type": 'F', "value": 'PRESS'},
+         {"properties": [("data_path_primary", 'tool_settings.gpencil_vertex_paint.brush.size')]}),
+    ])
+
+    return keymap
+
 def km_face_mask(params):
     items = []
     keymap = (
@@ -3679,8 +4037,25 @@ def generate_keymaps_impl(params=None):
         km_grease_pencil_stroke_paint_draw_brush(params),
         km_grease_pencil_stroke_paint_erase(params),
         km_grease_pencil_stroke_paint_fill(params),
+        km_grease_pencil_stroke_paint_tint(params),
         km_grease_pencil_stroke_sculpt_mode(params),
+        km_grease_pencil_stroke_sculpt_smooth(params),
+        km_grease_pencil_stroke_sculpt_thickness(params),
+        km_grease_pencil_stroke_sculpt_strength(params),
+        km_grease_pencil_stroke_sculpt_grab(params),
+        km_grease_pencil_stroke_sculpt_push(params),
+        km_grease_pencil_stroke_sculpt_twist(params),
+        km_grease_pencil_stroke_sculpt_pinch(params),
+        km_grease_pencil_stroke_sculpt_randomize(params),
+        km_grease_pencil_stroke_sculpt_clone(params),
         km_grease_pencil_stroke_weight_mode(params),
+        km_grease_pencil_stroke_weight_draw(params),
+        km_grease_pencil_stroke_vertex_mode(params),
+        km_grease_pencil_stroke_vertex_draw(params),
+        km_grease_pencil_stroke_vertex_blur(params),
+        km_grease_pencil_stroke_vertex_average(params),
+        km_grease_pencil_stroke_vertex_smear(params),
+        km_grease_pencil_stroke_vertex_replace(params),
         km_face_mask(params),
         km_weight_paint_vertex_selection(params),
         km_pose(params),
index b94edc23f4edd60d05cf211bca9c93c810a3971b..c83d0b9f4d815f0961dcd40e0a55bf9c1c682544 100644 (file)
@@ -642,10 +642,7 @@ class AddPresetGpencilBrush(AddPresetBase, Operator):
         "brush.smooth_stroke_factor",
         "settings.pen_smooth_factor",
         "settings.pen_smooth_steps",
-        "settings.pen_thick_smooth_factor",
-        "settings.pen_thick_smooth_steps",
         "settings.pen_subdivision_steps",
-        "settings.random_subdiv",
         "settings.use_settings_random",
         "settings.random_pressure",
         "settings.random_strength",
@@ -675,8 +672,6 @@ class AddPresetGpencilMaterial(AddPresetBase, Operator):
         "gpcolor.color",
         "gpcolor.stroke_image",
         "gpcolor.pixel_size",
-        "gpcolor.use_stroke_pattern",
-        "gpcolor.use_stroke_texture_mix",
         "gpcolor.mix_stroke_factor",
         "gpcolor.alignment_mode",
         "gpcolor.fill_style",
@@ -686,18 +681,11 @@ class AddPresetGpencilMaterial(AddPresetBase, Operator):
         "gpcolor.mix_color",
         "gpcolor.mix_factor",
         "gpcolor.flip",
-        "gpcolor.pattern_shift",
-        "gpcolor.pattern_scale",
-        "gpcolor.pattern_radius",
-        "gpcolor.pattern_angle",
-        "gpcolor.pattern_gridsize",
-        "gpcolor.use_fill_pattern",
         "gpcolor.texture_offset",
         "gpcolor.texture_scale",
         "gpcolor.texture_angle",
         "gpcolor.texture_opacity",
         "gpcolor.texture_clamp",
-        "gpcolor.use_fill_texture_mix",
         "gpcolor.mix_factor",
         "gpcolor.show_stroke",
         "gpcolor.show_fill",
index 883673ffd7a9519855f88e43149141aab7643053..4ed5264549f9c22ab27ecaa0d27d8004f8e4a8a9 100644 (file)
@@ -22,6 +22,7 @@ from bpy.types import Menu, Panel, UIList
 from rna_prop_ui import PropertyPanel
 
 from bl_ui.properties_grease_pencil_common import (
+    GreasePencilLayerMasksPanel,
     GreasePencilLayerAdjustmentsPanel,
     GreasePencilLayerRelationsPanel,
     GreasePencilLayerDisplayPanel,
@@ -116,7 +117,7 @@ class DATA_PT_gpencil_layers(DataButtonsPanel, Panel):
 
     def draw(self, context):
         layout = self.layout
-        #layout.use_property_split = True
+        # layout.use_property_split = True
         layout.use_property_decorate = False
 
         gpd = context.gpencil
@@ -166,7 +167,6 @@ class DATA_PT_gpencil_layers(DataButtonsPanel, Panel):
         col = layout.column(align=True)
 
         if gpl:
-
             layout = self.layout
             layout.use_property_split = True
             layout.use_property_decorate = True
@@ -178,6 +178,15 @@ class DATA_PT_gpencil_layers(DataButtonsPanel, Panel):
             col = layout.row(align=True)
             col.prop(gpl, "opacity", text="Opacity", slider=True)
 
+            col = layout.row(align=True)
+            col.prop(gpl, "use_lights")
+
+
+class DATA_PT_gpencil_layer_masks(LayerDataButtonsPanel, GreasePencilLayerMasksPanel, Panel):
+    bl_label = "Masks"
+    bl_parent_id = 'DATA_PT_gpencil_layers'
+    bl_options = {'DEFAULT_CLOSED'}
+
 
 class DATA_PT_gpencil_layer_adjustments(LayerDataButtonsPanel, GreasePencilLayerAdjustmentsPanel, Panel):
     bl_label = "Adjustments"
@@ -264,7 +273,7 @@ class DATA_PT_gpencil_onion_skinning_display(DataButtonsPanel, Panel):
         col.prop(gpd, "use_onion_fade", text="Fade")
         sub = layout.column()
         sub.active = gpd.onion_mode in {'RELATIVE', 'SELECTED'}
-        sub.prop(gpd, "use_onion_loop", text="Loop")
+        sub.prop(gpd, "use_onion_loop", text="Show Start Frame")
 
 
 class GPENCIL_MT_gpencil_vertex_group(Menu):
@@ -364,9 +373,6 @@ class DATA_PT_gpencil_strokes(DataButtonsPanel, Panel):
         sub.active = gpd.stroke_thickness_space == 'WORLDSPACE'
         sub.prop(gpd, "pixel_factor", text="Thickness Scale")
 
-        layout.prop(gpd, "use_force_fill_recalc", text="Force Fill Update")
-        layout.prop(gpd, "use_adaptive_uv", text="Adaptive UVs")
-
 
 class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
     bl_label = "Viewport Display"
@@ -381,8 +387,6 @@ class DATA_PT_gpencil_display(DataButtonsPanel, Panel):
         gpl = gpd.layers.active
 
         layout.prop(gpd, "edit_line_color", text="Edit Line Color")
-        if gpl:
-            layout.prop(gpd, "show_stroke_direction", text="Show Stroke Directions")
 
 
 class DATA_PT_gpencil_canvas(DataButtonsPanel, Panel):
@@ -411,6 +415,7 @@ class DATA_PT_custom_props_gpencil(DataButtonsPanel, PropertyPanel, Panel):
     _context_path = "object.data"
     _property_type = bpy.types.GreasePencil
 
+
 ###############################
 
 
@@ -420,6 +425,7 @@ classes = (
     DATA_PT_gpencil_onion_skinning,
     DATA_PT_gpencil_onion_skinning_custom_colors,
     DATA_PT_gpencil_onion_skinning_display,
+    DATA_PT_gpencil_layer_masks,
     DATA_PT_gpencil_layer_adjustments,
     DATA_PT_gpencil_layer_relations,
     DATA_PT_gpencil_layer_display,
@@ -437,5 +443,6 @@ classes = (
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
+
     for cls in classes:
         register_class(cls)
index 603c873c29034b4a1e78b8fe0519482edb62ddb8..9070aa5faee14eb029c42c92802f5be861892a7a 100644 (file)
@@ -1746,132 +1746,102 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
     # ...to avoid lengthy if statements
     # so each type must have a function here.
 
-    def GP_NOISE(self, layout, ob, md):
+    def gpencil_masking(self, layout, ob, md, use_vertex, use_curve=False):
         gpd = ob.data
-        split = layout.split()
-
-        col = split.column()
-        row = col.row(align=True)
-        row.prop(md, "factor")
-        row.prop(md, "random", text="", icon='TIME', toggle=True)
-        row = col.row()
-        row.enabled = md.random
-        row.prop(md, "step")
-        row = col.row()
-        row.enabled = md.random
-        row.prop(md, "seed")
-        col.prop(md, "full_stroke")
-        col.prop(md, "move_extreme")
-
-        row = layout.row(align=True)
-        row.label(text="Affect:")
-        row = layout.row(align=True)
-        row.prop(md, "use_edit_position", text="Position", icon='MESH_DATA', toggle=True)
-        row.prop(md, "use_edit_strength", text="Strength", icon='COLOR', toggle=True)
-        row.prop(md, "use_edit_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
-        row.prop(md, "use_edit_uv", text="UV", icon='MOD_UVPROJECT', toggle=True)
+        layout.separator()
+        layout.label(text="Influence Filters:")
 
-        col = layout.column()
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
+        split = layout.split(factor=0.25)
 
-        col = layout.column()
-        col.separator()
+        col1 = split.column()
 
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        col1.label(text="Layer:")
+        col1.label(text="Material:")
+        if use_vertex:
+            col1.label(text="Vertex Group:")
 
-        col = layout.column()
-        col.separator()
+        col2 = split.column()
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
+        split = col2.split(factor=0.6)
+        row = split.row(align=True)
         row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
         row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
+
+        row = split.row(align=True)
         row.prop(md, "layer_pass", text="Pass")
         row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
 
-    def GP_SMOOTH(self, layout, ob, md):
-        gpd = ob.data
-        col = layout.column()
-        col.prop(md, "factor")
-        col.prop(md, "step")
+        split = col2.split(factor=0.6)
 
-        col.label(text="Affect:")
-        row = col.row(align=True)
-        row.prop(md, "use_edit_position", text="Position", icon='MESH_DATA', toggle=True)
-        row.prop(md, "use_edit_strength", text="Strength", icon='COLOR', toggle=True)
-        row.prop(md, "use_edit_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
-        row.prop(md, "use_edit_uv", text="UV", icon='MOD_UVPROJECT', toggle=True)
-
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
+        row = split.row(align=True)
         row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
         row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
+
+        row = split.row(align=True)
         row.prop(md, "pass_index", text="Pass")
         row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
 
-        col = layout.column()
-        col.separator()
+        if use_vertex:
+            row = col2.row(align=True)
+            row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+            row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        if use_curve:
+            col = layout.column()
+            col.separator()
+            col.prop(md, "use_custom_curve")
+            if md.use_custom_curve:
+                col.template_curve_mapping(md, "curve")
 
-    def GP_SUBDIV(self, layout, ob, md):
-        gpd = ob.data
+    def GP_NOISE(self, layout, ob, md):
         split = layout.split()
 
         col = split.column()
         row = col.row(align=True)
-        row.prop(md, "level")
-        row.prop(md, "simple", text="", icon='PARTICLE_POINT')
+        row.prop(md, "factor", text="Position")
+        row = col.row(align=True)
+        row.prop(md, "factor_strength", text="Strength")
+        row = col.row(align=True)
+        row.prop(md, "factor_thickness", text="Thickness")
+        row = col.row(align=True)
+        row.prop(md, "factor_uvs", text="UV")
 
-        col = layout.column()
         col.separator()
-
-        col.label(text="Material:")
         row = col.row(align=True)
+        row.prop(md, "random", text="", icon='TIME', toggle=True)
 
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        subrow = row.row(align=True)
+        subrow.enabled = md.random
+        subrow.prop(md, "step")
+        subrow.prop(md, "seed")
 
-        col = layout.column()
         col.separator()
+        col.prop(md, "noise_scale")
 
-        col.label(text="Layer:")
+        self.gpencil_masking(layout, ob, md, True, True)
+
+    def GP_SMOOTH(self, layout, ob, md):
+        col = layout.column()
+        col.prop(md, "factor")
+        col.prop(md, "step", text="Repeat")
+
+        col.label(text="Affect:")
         row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        row.prop(md, "use_edit_position", text="Position", toggle=True)
+        row.prop(md, "use_edit_strength", text="Strength", toggle=True)
+        row.prop(md, "use_edit_thickness", text="Thickness", toggle=True)
+        row.prop(md, "use_edit_uv", text="UV", toggle=True)
+
+        self.gpencil_masking(layout, ob, md, True, True)
+
+    def GP_SUBDIV(self, layout, ob, md):
+        layout.row().prop(md, "subdivision_type", expand=True)
+        split = layout.split()
+        col = split.column()
+        row = col.row(align=True)
+        row.prop(md, "level", text="Subdivisions")
+
+        self.gpencil_masking(layout, ob, md, False)
 
     def GP_SIMPLIFY(self, layout, ob, md):
         gpd = ob.data
@@ -1893,77 +1863,21 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         elif md.mode == 'MERGE':
             col.prop(md, "distance")
 
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, False)
 
     def GP_THICK(self, layout, ob, md):
-        gpd = ob.data
-        split = layout.split()
-
-        col = split.column()
-        row = col.row(align=True)
-        row.prop(md, "thickness", text="Thickness Factor")
-
-        col.prop(md, "normalize_thickness")
-
-        if not md.normalize_thickness:
-            split = layout.split()
-            col = split.column()
-            col.prop(md, "use_custom_curve")
-
-            if md.use_custom_curve:
-                col.template_curve_mapping(md, "curve")
-
-        col = layout.column()
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
         col = layout.column()
-        col.separator()
 
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        col.prop(md, "normalize_thickness")
 
-        col = layout.column()
-        col.separator()
+        if md.normalize_thickness:
+            col.prop(md, "thickness")
+        else:
+            col.prop(md, "thickness_factor")
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, True, True)
 
     def GP_TINT(self, layout, ob, md):
-        gpd = ob.data
         split = layout.split()
 
         col = split.column()
@@ -1971,30 +1885,9 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "factor")
 
         row = layout.row()
-        row.prop(md, "create_materials")
         row.prop(md, "modify_color")
 
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, False, True)
 
     def GP_TIME(self, layout, ob, md):
         gpd = ob.data
@@ -2040,7 +1933,6 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
 
     def GP_COLOR(self, layout, ob, md):
-        gpd = ob.data
         split = layout.split()
 
         col = split.column()
@@ -2050,134 +1942,66 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         col.prop(md, "value", text="V", slider=True)
 
         row = layout.row()
-        row.prop(md, "create_materials")
         row.prop(md, "modify_color")
 
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, False, True)
 
     def GP_OPACITY(self, layout, ob, md):
-        gpd = ob.data
         split = layout.split()
 
         col = split.column()
-        col.label(text="Opacity:")
-        col.prop(md, "factor")
-
-        row = layout.row()
-        row.prop(md, "opacity_mode", text="Mode")
-
-        if md.opacity_mode == 'MATERIAL':
-            row = layout.row()
-            row.prop(md, "create_materials")
-            row.prop(md, "modify_color", text="Change")
+        col.prop(md, "normalize_opacity")
+        if md.normalize_opacity is True:
+            text="Strength"
         else:
-            col = layout.column()
-            col.separator()
-            col.label(text="Vertex Group:")
-            row = col.row(align=True)
-            row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-            row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+            text="Opacity Factor"
 
-        col = layout.column()
-        col.separator()
+        col.prop(md, "factor", text=text)
+        col.prop(md, "modify_color")
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, True, True)
 
     def GP_ARRAY(self, layout, ob, md):
-        gpd = ob.data
-
         col = layout.column()
         col.prop(md, "count")
 
         split = layout.split()
         col = split.column()
-        col.label(text="Offset:")
-        col.prop(md, "offset", text="")
-        col.prop(md, "offset_object", text="Object")
+        col.prop(md, "use_constant_offset", text="Constant Offset")
+        subcol = col.column()
+        subcol.enabled = md.use_constant_offset
+        subcol.prop(md, "constant_offset", text="")
+
+        col.prop(md, "use_object_offset")
+        subcol = col.column()
+        subcol.enabled = md.use_object_offset
+        subcol.prop(md, "offset_object", text="")
 
         col = split.column()
-        col.label(text="Shift:")
-        col.prop(md, "shift", text="")
+        col.prop(md, "use_relative_offset", text="Relative Offset")
+        subcol = col.column()
+        subcol.enabled = md.use_relative_offset
+        subcol.prop(md, "relative_offset", text="")
 
         split = layout.split()
         col = split.column()
-        col.label(text="Rotation:")
-        col.prop(md, "rotation", text="")
-        col.separator()
-        row = col.row(align=True)
-        row.prop(md, "random_rot", text="", icon='TIME', toggle=True)
-        row.prop(md, "rot_factor", text="")
+        col.label(text="Random Offset:")
+        col.prop(md, "random_offset", text="")
 
         col = split.column()
-        col.label(text="Scale:")
-        col.prop(md, "scale", text="")
-        col.separator()
-        row = col.row(align=True)
-        row.prop(md, "random_scale", text="", icon='TIME', toggle=True)
-        row.prop(md, "scale_factor", text="")
+        col.label(text="Random Rotation:")
+        col.prop(md, "random_rotation", text="")
 
-        col = layout.column()
-        col.prop(md, "replace_material", text="Material")
-        col.prop(md, "keep_on_top", text="Keep original stroke on top")
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        col = split.column()
+        col.label(text="Random Scale:")
+        col.prop(md, "random_scale", text="")
 
         col = layout.column()
+        col.prop(md, "seed")
         col.separator()
+        col.prop(md, "replace_material", text="Material Override")
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, False)
 
     def GP_BUILD(self, layout, ob, md):
         gpd = ob.data
@@ -2215,7 +2039,6 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
 
     def GP_LATTICE(self, layout, ob, md):
-        gpd = ob.data
         split = layout.split()
 
         col = split.column()
@@ -2224,70 +2047,20 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
 
         layout.prop(md, "strength", slider=True)
 
-        col = layout.column()
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, True)
 
     def GP_MIRROR(self, layout, ob, md):
-        gpd = ob.data
-
         row = layout.row(align=True)
         row.prop(md, "x_axis")
         row.prop(md, "y_axis")
         row.prop(md, "z_axis")
 
-        layout.label(text="Object:")
+        layout.label(text="Mirror Object:")
         layout.prop(md, "object", text="")
 
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, False)
 
     def GP_HOOK(self, layout, ob, md):
-        gpd = ob.data
         split = layout.split()
 
         col = split.column()
@@ -2317,71 +2090,16 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         col = split.column()
         col.prop(md, "use_falloff_uniform")
 
-        col = layout.column()
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, True)
 
     def GP_OFFSET(self, layout, ob, md):
-        gpd = ob.data
-        col = layout.column()
-
-        col.prop(md, "location")
-        col.prop(md, "scale")
-        col.prop(md, "rotation")
-
-        col = layout.column()
-        col.separator()
-        col.label(text="Vertex Group:")
-        row = col.row(align=True)
-        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
-        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
-
-        col = layout.column()
-        col.separator()
-
-        col.label(text="Material:")
-        row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        split = layout.split()
 
-        col = layout.column()
-        col.separator()
+        split.column().prop(md, "location")
+        split.column().prop(md, "rotation")
+        split.column().prop(md, "scale")
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        self.gpencil_masking(layout, ob, md, True)
 
     def GP_ARMATURE(self, layout, ob, md):
         split = layout.split()
@@ -2407,50 +2125,42 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
 
     def GP_MULTIPLY(self, layout, ob, md):
-        gpd = ob.data
         col = layout.column()
 
-        col.prop(md, "duplications")
+        col.prop(md, "duplicates")
         subcol = col.column()
-        subcol.enabled = md.duplications > 0
+        subcol.enabled = md.duplicates > 0
         subcol.prop(md, "distance")
         subcol.prop(md, "offset", slider=True)
 
         subcol.separator()
 
-        subcol.prop(md, "enable_fading")
-        if md.enable_fading:
+        subcol.prop(md, "use_fade")
+        if md.use_fade:
             subcol.prop(md, "fading_center")
             subcol.prop(md, "fading_thickness", slider=True)
             subcol.prop(md, "fading_opacity", slider=True)
 
-        subcol.separator()
-
-        col.prop(md, "enable_angle_splitting")
-        if md.enable_angle_splitting:
-            col.prop(md, "split_angle")
+        self.gpencil_masking(layout, ob, md, False)
 
+    def GP_VERTEXCOLOR(self, layout, ob, md):
         col = layout.column()
-        col.separator()
+        col.label(text="Object:")
+        col.prop(md, "object", text="")
 
-        col.label(text="Material:")
+        col.separator()
         row = col.row(align=True)
-        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
-        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "pass_index", text="Pass")
-        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+        row.prop(md, "radius")
+        row.prop(md, "factor", text="Strength", slider=True)
 
-        col = layout.column()
         col.separator()
+        col.label(text="Colors:")
+        col.template_color_ramp(md, "colors")
 
-        col.label(text="Layer:")
-        row = col.row(align=True)
-        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
-        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
-        row = layout.row(align=True)
-        row.prop(md, "layer_pass", text="Pass")
-        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+        col.separator()
+        col.prop(md, "vertex_mode")
+
+        self.gpencil_masking(layout, ob, md, True, True)
 
 
 classes = (
@@ -2460,5 +2170,6 @@ classes = (
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
+
     for cls in classes:
         register_class(cls)
index fce86446dfc5b76ee60c7a88494991e20fca884f..48a851e8befc99427a53b37866376c45a12831cf 100644 (file)
@@ -56,27 +56,30 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
 
     def FX_BLUR(self, layout, fx):
 
-        layout.prop(fx, "factor", text="Factor")
+        layout.prop(fx, "use_dof_mode", text="Use as Depth Of Field")
+        layout.separator()
+
+        col = layout.column()
+        col.enabled = not fx.use_dof_mode
+        col.prop(fx, "size", text="Size")
+        col.separator()
+        col.prop(fx, "rotation")
+
         layout.prop(fx, "samples", text="Samples")
 
-        layout.separator()
-        layout.prop(fx, "use_dof_mode")
-        if fx.use_dof_mode:
-            layout.prop(fx, "coc")
 
     def FX_COLORIZE(self, layout, fx):
         layout.prop(fx, "mode", text="Mode")
 
-        if fx.mode == 'BITONE':
+        if fx.mode == 'DUOTONE':
             layout.prop(fx, "low_color", text="Low Color")
         if fx.mode == 'CUSTOM':
             layout.prop(fx, "low_color", text="Color")
 
-        if fx.mode == 'BITONE':
+        if fx.mode == 'DUOTONE':
             layout.prop(fx, "high_color", text="High Color")
 
-        if fx.mode in {'BITONE', 'CUSTOM', 'TRANSPARENT'}:
-            layout.prop(fx, "factor")
+        layout.prop(fx, "factor")
 
     def FX_WAVE(self, layout, fx):
         row = layout.row(align=True)
@@ -127,16 +130,21 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
 
     def FX_GLOW(self, layout, fx):
         layout.prop(fx, "mode")
-        layout.prop(fx, "glow_color")
         if fx.mode == 'LUMINANCE':
             layout.prop(fx, "threshold")
         else:
             layout.prop(fx, "select_color")
 
+        layout.prop(fx, "glow_color")
         layout.separator()
-        layout.prop(fx, "radius")
+        layout.prop(fx, "blend_mode", text="Blend")
+        layout.prop(fx, "opacity")
+
+        layout.prop(fx, "size")
+        layout.prop(fx, "rotation")
         layout.prop(fx, "samples")
-        layout.prop(fx, "use_alpha_mode", text="Use Alpha Mode")
+
+        layout.prop(fx, "use_glow_under", text="Glow Under")
 
     def FX_SWIRL(self, layout, fx):
         layout.prop(fx, "object", text="Object")
@@ -144,18 +152,10 @@ class DATA_PT_shader_fx(ShaderFxButtonsPanel, Panel):
         layout.prop(fx, "radius")
         layout.prop(fx, "angle")
 
-        layout.prop(fx, "use_transparent")
-
     def FX_FLIP(self, layout, fx):
         layout.prop(fx, "flip_horizontal")
         layout.prop(fx, "flip_vertical")
 
-    def FX_LIGHT(self, layout, fx):
-        layout.prop(fx, "object", text="Object")
-
-        layout.prop(fx, "energy")
-        layout.prop(fx, "ambient")
-
 
 classes = (
     DATA_PT_shader_fx,
index 2001f46820fcaeed56d58c59752ef5d6d95abb5e..fced848641e08400ca6a4e95a9561fb8395d42d9 100644 (file)
@@ -19,7 +19,7 @@
 # <pep8 compliant>
 
 import bpy
-from bpy.types import Menu, UIList
+from bpy.types import Menu, UIList, Operator
 from bpy.app.translations import pgettext_iface as iface_
 
 
@@ -108,11 +108,6 @@ class AnnotationDrawingToolsPanel:
         sub.operator("gpencil.blank_frame_add", icon='FILE_NEW')
         sub.operator("gpencil.active_frames_delete_all", icon='X', text="Delete Frame(s)")
 
-        #sub = col.column(align=True)
-        #sub.prop(context.tool_settings, "use_gpencil_draw_additive", text="Additive Drawing")
-        #sub.prop(context.tool_settings, "use_gpencil_continuous_drawing", text="Continuous Drawing")
-        #sub.prop(context.tool_settings, "use_gpencil_draw_onback", text="Draw on Back")
-
         col.separator()
         col.separator()
 
@@ -125,9 +120,6 @@ class AnnotationDrawingToolsPanel:
             elif is_clip_editor:
                 row.prop(context.space_data, "grease_pencil_source", expand=True)
 
-        # col.separator()
-        # col.separator()
-
         gpencil_stroke_placement_settings(context, col)
 
 
@@ -136,29 +128,33 @@ class GreasePencilSculptOptionsPanel:
 
     @classmethod
     def poll(cls, context):
-        settings = context.tool_settings.gpencil_sculpt
-        tool = settings.sculpt_tool
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_sculpt_paint
+        brush = settings.brush
+        tool = brush.gpencil_sculpt_tool
 
-        return bool(tool in {'SMOOTH', 'RANDOMIZE', 'SMOOTH'})
+        return bool(tool in {'SMOOTH', 'RANDOMIZE'})
 
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        settings = context.tool_settings.gpencil_sculpt
-        tool = settings.sculpt_tool
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_sculpt_paint
         brush = settings.brush
+        gp_settings = brush.gpencil_settings
+        tool = brush.gpencil_sculpt_tool
 
         if tool in {'SMOOTH', 'RANDOMIZE'}:
-            layout.prop(settings, "use_edit_position", text="Affect Position")
-            layout.prop(settings, "use_edit_strength", text="Affect Strength")
-            layout.prop(settings, "use_edit_thickness", text="Affect Thickness")
+            layout.prop(gp_settings, "use_edit_position", text="Affect Position")
+            layout.prop(gp_settings, "use_edit_strength", text="Affect Strength")
+            layout.prop(gp_settings, "use_edit_thickness", text="Affect Thickness")
 
             if tool == 'SMOOTH':
-                layout.prop(brush, "use_edit_pressure")
+                layout.prop(gp_settings, "use_edit_pressure")
 
-            layout.prop(settings, "use_edit_uv", text="Affect UV")
+            layout.prop(gp_settings, "use_edit_uv", text="Affect UV")
 
 
 # GP Object Tool Settings
@@ -174,7 +170,7 @@ class GreasePencilDisplayPanel:
             if context.mode == 'PAINT_GPENCIL':
                 return brush.gpencil_tool != 'ERASE'
             else:
-                # GP Sculpt and Weight Paint always have Brush Tip panel.
+                # GP Sculpt, Vertex and Weight Paint always have Brush Tip panel.
                 return True
         return False
 
@@ -182,16 +178,18 @@ class GreasePencilDisplayPanel:
         if self.is_popover:
             return
 
+        tool_settings = context.tool_settings
         if context.mode == 'PAINT_GPENCIL':
-            brush = context.tool_settings.gpencil_paint.brush
-            gp_settings = brush.gpencil_settings
-
-            self.layout.prop(gp_settings, "use_cursor", text="")
-        elif context.mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
-            settings = context.tool_settings.gpencil_sculpt
-            brush = settings.brush
-
-            self.layout.prop(brush, "use_cursor", text="")
+            settings = tool_settings.gpencil_paint
+        elif context.mode == 'SCULPT_GPENCIL':
+            settings = tool_settings.gpencil_sculpt_paint
+        elif context.mode == 'WEIGHT_GPENCIL':
+            settings = tool_settings.gpencil_weight_paint
+        elif context.mode == 'VERTEX_GPENCIL':
+            settings = tool_settings.gpencil_vertex_paint
+        brush = settings.brush
+        if brush:
+            self.layout.prop(settings, "show_brush", text="")
 
     def draw(self, context):
         layout = self.layout
@@ -199,279 +197,101 @@ class GreasePencilDisplayPanel:
         layout.use_property_decorate = False
 
         tool_settings = context.tool_settings
-        ob = context.active_object
+        if context.mode == 'PAINT_GPENCIL':
+            settings = tool_settings.gpencil_paint
+        elif context.mode == 'SCULPT_GPENCIL':
+            settings = tool_settings.gpencil_sculpt_paint
+        elif context.mode == 'WEIGHT_GPENCIL':
+            settings = tool_settings.gpencil_weight_paint
+        elif context.mode == 'VERTEX_GPENCIL':
+            settings = tool_settings.gpencil_vertex_paint
+        brush = settings.brush
+        gp_settings = brush.gpencil_settings
 
+        ob = context.active_object
         if ob.mode == 'PAINT_GPENCIL':
-            brush = tool_settings.gpencil_paint.brush
-            gp_settings = brush.gpencil_settings
 
             if self.is_popover:
                 row = layout.row(align=True)
-                row.prop(gp_settings, "use_cursor", text="")
+                row.prop(settings, "show_brush", text="")
                 row.label(text="Display Cursor")
 
             col = layout.column(align=True)
-            col.active = gp_settings.use_cursor
+            col.active = settings.show_brush
 
             if brush.gpencil_tool == 'DRAW':
                 col.prop(gp_settings, "show_lasso", text="Show Fill Color While Drawing")
 
-            if brush.gpencil_tool == 'FILL':
-                col.prop(brush, "cursor_color_add", text="Cursor Color")
-
-        elif ob.mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
-            settings = tool_settings.gpencil_sculpt
-            brush = settings.brush
-            tool = settings.sculpt_tool
-
-            if self.is_popover:
-                row = layout.row(align=True)
-                row.prop(brush, "use_cursor", text="")
-                row.label(text="Display Cursor")
-
+        elif ob.mode == 'SCULPT_GPENCIL':
             col = layout.column(align=True)
-            col.active = brush.use_cursor
+            col.active = settings.show_brush
 
             col.prop(brush, "cursor_color_add", text="Cursor Color")
-            if tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
-                col.prop(brush, "cursor_color_sub", text="Inverse Cursor Color")
-
-
-class GPENCIL_MT_pie_tool_palette(Menu):
-    """A pie menu for quick access to Grease Pencil tools"""
-    bl_label = "Grease Pencil Tools"
-
-    def draw(self, context):
-        layout = self.layout
-
-        pie = layout.menu_pie()
-        gpd = context.gpencil_data
-
-        # W - Drawing Types
-        col = pie.column()
-        col.operator("gpencil.draw", text="Draw", icon='GREASEPENCIL').mode = 'DRAW'
-        col.operator("gpencil.draw", text="Straight Lines", icon='LINE_DATA').mode = 'DRAW_STRAIGHT'
-        col.operator("gpencil.draw", text="Poly", icon='MESH_DATA').mode = 'DRAW_POLY'
-
-        # E - Eraser
-        # XXX: needs a dedicated icon...
-        col = pie.column()
-        col.operator("gpencil.draw", text="Eraser", icon='FORCE_CURVE').mode = 'ERASER'
-
-        # E - "Settings" Palette is included here too, since it needs to be in a stable position...
-        if gpd and gpd.layers.active:
-            col.separator()
-            col.operator(
-                "wm.call_menu_pie",
-                text="Settings...",
-                icon='SCRIPTWIN').name = "GPENCIL_MT_pie_settings_palette"
-
-        # Editing tools
-        if gpd:
-            if gpd.use_stroke_edit_mode and context.editable_gpencil_strokes:
-                # S - Exit Edit Mode
-                pie.operator("gpencil.editmode_toggle", text="Exit Edit Mode", icon='EDIT')
-
-                # N - Transforms
-                col = pie.column()
-                row = col.row(align=True)
-                row.operator("transform.translate", icon='MAN_TRANS')
-                row.operator("transform.rotate", icon='MAN_ROT')
-                row.operator("transform.resize", text="Scale", icon='MAN_SCALE')
-                row = col.row(align=True)
-                row.label(text="Proportional Edit:")
-                row.prop(context.tool_settings, "use_proportional_edit", text="", icon_only=True)
-                row.prop(context.tool_settings, "proportional_edit_falloff", text="", icon_only=True)
-
-                # NW - Select (Non-Modal)
-                col = pie.column()
-                col.operator("gpencil.select_all", text="Select All", icon='PARTICLE_POINT')
-                col.operator("gpencil.select_all", text="Select Inverse", icon='BLANK1')
-                col.operator("gpencil.select_linked", text="Select Linked", icon='LINKED')
-                col.operator("gpencil.palettecolor_select", text="Select Color", icon='COLOR')
-
-                # NE - Select (Modal)
-                col = pie.column()
-                col.operator("gpencil.select_box", text="Box Select", icon='BORDER_RECT')
-                col.operator("gpencil.select_circle", text="Circle Select", icon='META_EMPTY')
-                col.operator("gpencil.select_lasso", text="Lasso Select", icon='BORDER_LASSO')
-                col.operator("gpencil.select_alternate", text="Alternate Select", icon='BORDER_LASSO')
-
-                # SW - Edit Tools
-                col = pie.column()
-                col.operator("gpencil.duplicate_move", icon='PARTICLE_PATH', text="Duplicate")
-                col.operator("gpencil.delete", icon='X', text="Delete...")
-
-                # SE - More Tools
-                pie.operator("wm.call_menu_pie", text="More...").name = "GPENCIL_MT_pie_tools_more"
-            else:
-                # Toggle Edit Mode
-                pie.operator("gpencil.editmode_toggle", text="Enable Stroke Editing", icon='EDIT')
+            if brush.gpencil_sculpt_tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
+                col.prop(brush, "cursor_color_subtract", text="Inverse Cursor Color")
 
+        elif ob.mode == 'WEIGHT_GPENCIL':
+            col = layout.column(align=True)
+            col.active = settings.show_brush
 
-class GPENCIL_MT_pie_settings_palette(Menu):
-    """A pie menu for quick access to Grease Pencil settings"""
-    bl_label = "Grease Pencil Settings"
+            col.prop(brush, "cursor_color_add", text="Cursor Color")
 
-    @classmethod
-    def poll(cls, context):
-        return bool(context.gpencil_data and context.active_gpencil_layer)
+        elif ob.mode == 'VERTEX_GPENCIL':
+            row = layout.row(align=True)
+            row.prop(settings, "show_brush", text="")
+            row.label(text="Display Cursor")
 
-    def draw(self, context):
-        layout = self.layout
 
-        pie = layout.menu_pie()
-        gpd = context.gpencil_data
-        gpl = context.active_gpencil_layer
-        palcolor = None  # context.active_gpencil_palettecolor
-
-        is_editmode = bool(gpd and gpd.use_stroke_edit_mode and context.editable_gpencil_strokes)
-
-        # W - Stroke draw settings
-        col = pie.column(align=True)
-        if palcolor is not None:
-            col.enabled = not palcolor.lock
-            col.label(text="Stroke")
-            col.prop(palcolor, "color", text="")
-            col.prop(palcolor, "alpha", text="", slider=True)
-
-        # E - Fill draw settings
-        col = pie.column(align=True)
-        if palcolor is not None:
-            col.enabled = not palcolor.lock
-            col.label(text="Fill")
-            col.prop(palcolor, "fill_color", text="")
-            col.prop(palcolor, "fill_alpha", text="", slider=True)
-
-        # S Brush settings
-        gpencil_active_brush_settings_simple(context, pie)
-
-        # N - Active Layer
-        col = pie.column()
-        col.label(text="Active Layer:      ")
-
-        row = col.row()
-        row.operator_context = 'EXEC_REGION_WIN'
-        row.operator_menu_enum("gpencil.layer_change", "layer", text="", icon='GREASEPENCIL')
-        row.prop(gpl, "info", text="")
-        row.operator("gpencil.layer_remove", text="", icon='X')
-
-        row = col.row()
-        row.prop(gpl, "lock")
-        row.prop(gpl, "hide")
-        col.prop(gpl, "use_onion_skinning")
-
-        # NW/NE/SW/SE - These operators are only available in editmode
-        # as they require strokes to be selected to work
-        if is_editmode:
-            # NW - Move stroke Down
-            col = pie.column(align=True)
-            col.label(text="Arrange Strokes")
-            col.operator("gpencil.stroke_arrange", text="Send to Back").direction = 'BOTTOM'
-            col.operator("gpencil.stroke_arrange", text="Send Backward").direction = 'DOWN'
-
-            # NE - Move stroke Up
-            col = pie.column(align=True)
-            col.label(text="Arrange Strokes")
-            col.operator("gpencil.stroke_arrange", text="Bring to Front").direction = 'TOP'
-            col.operator("gpencil.stroke_arrange", text="Bring Forward").direction = 'UP'
-
-            # SW - Move stroke to color
-            col = pie.column(align=True)
-            col.operator("gpencil.stroke_change_color", text="Move to Color")
-
-            # SE - Join strokes
-            col = pie.column(align=True)
-            col.label(text="Join Strokes")
-            row = col.row()
-            row.operator("gpencil.stroke_join", text="Join").type = 'JOIN'
-            row.operator("gpencil.stroke_join", text="Join & Copy").type = 'JOINCOPY'
-            col.operator("gpencil.stroke_flip", text="Flip Direction")
-
-            col.prop(gpd, "show_stroke_direction", text="Show Drawing Direction")
-
-
-class GPENCIL_MT_pie_tools_more(Menu):
-    """A pie menu for accessing more Grease Pencil tools"""
-    bl_label = "More Grease Pencil Tools"
+class GreasePencilBrushFalloff:
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
 
     @classmethod
     def poll(cls, context):
-        gpd = context.gpencil_data
-        return bool(gpd and gpd.use_stroke_edit_mode and context.editable_gpencil_strokes)
-
-    def draw(self, _context):
-        layout = self.layout
-
-        pie = layout.menu_pie()
-        # gpd = context.gpencil_data
-
-        col = pie.column(align=True)
-        col.operator("gpencil.copy", text="Copy", icon='COPYDOWN')
-        col.operator("gpencil.paste", text="Paste", icon='PASTEDOWN').type = 'ACTIVE'
-        col.operator("gpencil.paste", text="Paste by Layer").type = 'LAYER'
-
-        col = pie.column(align=True)
-        col.operator("gpencil.select_more", icon='ADD')
-        col.operator("gpencil.select_less", icon='REMOVE')
-
-        pie.operator("transform.mirror", icon='MOD_MIRROR')
-        pie.operator("transform.bend", icon='MOD_SIMPLEDEFORM')
-        pie.operator("transform.shear", icon='MOD_TRIANGULATE')
-        pie.operator("transform.tosphere", icon='MOD_MULTIRES')
-
-        pie.operator("gpencil.convert", icon='OUTLINER_OB_CURVE', text="Convert...")
-        pie.operator("wm.call_menu_pie", text="Back to Main Palette...").name = "GPENCIL_MT_pie_tool_palette"
-
-
-class GPENCIL_MT_pie_sculpt(Menu):
-    """A pie menu for accessing Grease Pencil stroke sculpt settings"""
-    bl_label = "Grease Pencil Sculpt"
+        ts = context.tool_settings
+        settings = None
+        if context.mode == 'PAINT_GPENCIL':
+            settings = ts.gpencil_paint
+        if context.mode == 'SCULPT_GPENCIL':
+            settings = ts.gpencil_sculpt_paint
+        elif context.mode == 'WEIGHT_GPENCIL':
+            settings = ts.gpencil_weight_paint
+        elif context.mode == 'VERTEX_GPENCIL':
+            settings = ts.gpencil_vertex_paint
 
-    @classmethod
-    def poll(cls, context):
-        gpd = context.gpencil_data
-        return bool(gpd and gpd.use_stroke_edit_mode and context.editable_gpencil_strokes)
+        return (settings and settings.brush and settings.brush.curve)
 
     def draw(self, context):
         layout = self.layout
+        ts = context.tool_settings
+        settings = None
+        if context.mode == 'PAINT_GPENCIL':
+            settings = ts.gpencil_paint
+        if context.mode == 'SCULPT_GPENCIL':
+            settings = ts.gpencil_sculpt_paint
+        elif context.mode == 'WEIGHT_GPENCIL':
+            settings = ts.gpencil_weight_paint
+        elif context.mode == 'VERTEX_GPENCIL':
+            settings = ts.gpencil_vertex_paint
+
+        if settings:
+            brush = settings.brush
 
-        pie = layout.menu_pie()
-
-        settings = context.tool_settings.gpencil_sculpt
-        brush = settings.brush
-
-        # W - Launch Sculpt Mode
-        col = pie.column()
-        # col.label(text="Tool:")
-        col.prop(settings, "sculpt_tool", text="")
-        col.operator("gpencil.sculpt_paint", text="Sculpt", icon='SCULPTMODE_HLT')
-
-        # E - Common Settings
-        col = pie.column(align=True)
-        col.prop(brush, "size", slider=True)
-        row = col.row(align=True)
-        row.prop(brush, "strength", slider=True)
-        # row.prop(brush, "use_pressure_strength", text="", icon_only=True)
-        col.prop(brush, "use_falloff")
-        if settings.sculpt_tool in {'SMOOTH', 'RANDOMIZE'}:
+            col = layout.column(align=True)
             row = col.row(align=True)
-            row.prop(settings, "use_edit_position", text="Position", icon='MESH_DATA', toggle=True)
-            row.prop(settings, "use_edit_strength", text="Strength", icon='COLOR', toggle=True)
-            row.prop(settings, "use_edit_thickness", text="Thickness", icon='LINE_DATA', toggle=True)
+            row.prop(brush, "curve_preset", text="")
 
-        # S - Change Brush Type Shortcuts
-        row = pie.row()
-        row.prop_enum(settings, "tool", value='GRAB')
-        row.prop_enum(settings, "tool", value='PUSH')
-        row.prop_enum(settings, "tool", value='CLONE')
+            if brush.curve_preset == 'CUSTOM':
+                layout.template_curve_mapping(brush, "curve", brush=True)
 
-        # N - Change Brush Type Shortcuts
-        row = pie.row()
-        row.prop_enum(settings, "tool", value='SMOOTH')
-        row.prop_enum(settings, "tool", value='THICKNESS')
-        row.prop_enum(settings, "tool", value='STRENGTH')
-        row.prop_enum(settings, "tool", value='RANDOMIZE')
+                col = layout.column(align=True)
+                row = col.row(align=True)
+                row.operator("brush.curve_preset", icon='SMOOTHCURVE', text="").shape = 'SMOOTH'
+                row.operator("brush.curve_preset", icon='SPHERECURVE', text="").shape = 'ROUND'
+                row.operator("brush.curve_preset", icon='ROOTCURVE', text="").shape = 'ROOT'
+                row.operator("brush.curve_preset", icon='SHARPCURVE', text="").shape = 'SHARP'
+                row.operator("brush.curve_preset", icon='LINCURVE', text="").shape = 'LINE'
+                row.operator("brush.curve_preset", icon='NOCURVE', text="").shape = 'MAX'
 
 
 class GPENCIL_MT_snap(Menu):
@@ -515,6 +335,32 @@ class GPENCIL_MT_move_to_layer(Menu):
         layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
 
 
+class GPENCIL_MT_layer_active(Menu):
+    bl_label = "Change Active Layer"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.operator_context = 'INVOKE_REGION_WIN'
+
+        gpd = context.gpencil_data
+        if gpd:
+            gpl_active = context.active_gpencil_layer
+            tot_layers = len(gpd.layers)
+            i = tot_layers - 1
+            while i >= 0:
+                gpl = gpd.layers[i]
+                if gpl.info == gpl_active.info:
+                    icon = 'GREASEPENCIL'
+                else:
+                    icon = 'NONE'
+                layout.operator("gpencil.layer_active", text=gpl.info, icon=icon).layer = i
+                i -= 1
+
+            layout.separator()
+
+        layout.operator("gpencil.layer_add", text="New Layer", icon='ADD')
+
+
 class GPENCIL_MT_gpencil_draw_delete(Menu):
     bl_label = "Delete"
 
@@ -800,11 +646,7 @@ class GreasePencilMaterialsPanel:
 
             if ma is not None and ma.grease_pencil is not None:
                 gpcolor = ma.grease_pencil
-                if (
-                        gpcolor.stroke_style == 'SOLID' or
-                        gpcolor.use_stroke_pattern or
-                        gpcolor.use_stroke_texture_mix
-                ):
+                if gpcolor.stroke_style == 'SOLID':
                     row = layout.row()
                     row.prop(gpcolor, "color", text="Stroke Color")
 
@@ -813,6 +655,48 @@ class GreasePencilMaterialsPanel:
             row.template_ID(space, "pin_id")
 
 
+class GreasePencilVertexcolorPanel:
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        ts = context.scene.tool_settings
+        is_vertex = context.mode == 'VERTEX_GPENCIL'
+        gpencil_paint = ts.gpencil_vertex_paint if is_vertex else ts.gpencil_paint
+        brush = gpencil_paint.brush
+        gp_settings = brush.gpencil_settings
+        tool = brush.gpencil_vertex_tool if is_vertex else brush.gpencil_tool
+
+        ob = context.object
+
+        if ob:
+            col = layout.column()
+            col.template_color_picker(brush, "color", value_slider=True)
+
+            sub_row = layout.row(align=True)
+            sub_row.prop(brush, "color", text="")
+            sub_row.prop(brush, "secondary_color", text="")
+
+            sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
+
+            row = layout.row(align=True)
+            row.template_ID(gpencil_paint, "palette", new="palette.new")
+            if gpencil_paint.palette:
+                layout.template_palette(gpencil_paint, "palette", color=True)
+
+            if tool in {'DRAW', 'FILL'} and is_vertex is False:
+                row = layout.row(align=True)
+                row.prop(gp_settings, "vertex_mode", text="Mode")
+                row = layout.row(align=True)
+                row.prop(gp_settings, "vertex_color_factor", slider=True, text="Mix Factor")
+
+            if tool == 'TINT' or is_vertex is True:
+                row = layout.row(align=True)
+                row.prop(gp_settings, "vertex_mode", text="Mode")
+
+
 class GPENCIL_UL_layer(UIList):
     def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
         # assert(isinstance(item, bpy.types.GPencilLayer)
@@ -830,9 +714,10 @@ class GPENCIL_UL_layer(UIList):
             row.prop(gpl, "info", text="", emboss=False)
 
             row = layout.row(align=True)
-            row.prop(gpl, "mask_layer", text="",
-                     icon='MOD_MASK' if gpl.mask_layer else 'LAYER_ACTIVE',
-                     emboss=False)
+
+            icon_mask = 'MOD_MASK' if gpl.use_mask_layer else 'LAYER_ACTIVE'
+
+            row.prop(gpl, "use_mask_layer", text="", icon=icon_mask, emboss=False)
 
             subrow = row.row(align=True)
             subrow.prop(
@@ -868,16 +753,12 @@ class GreasePencilSimplifyPanel:
         layout.active = rd.simplify_gpencil
 
         col = layout.column()
-        col.prop(rd, "simplify_gpencil_onplay", text="Playback Only")
-        col.prop(rd, "simplify_gpencil_view_modifier", text="Modifiers")
-        col.prop(rd, "simplify_gpencil_shader_fx", text="ShaderFX")
-        col.prop(rd, "simplify_gpencil_blend", text="Layers Blending")
-        col.prop(rd, "simplify_gpencil_tint", text="Layers Tinting")
-
+        col.prop(rd, "simplify_gpencil_onplay")
         col.prop(rd, "simplify_gpencil_view_fill")
-        sub = col.column()
-        sub.active = rd.simplify_gpencil_view_fill
-        sub.prop(rd, "simplify_gpencil_remove_lines", text="Lines")
+        col.prop(rd, "simplify_gpencil_modifier")
+        col.prop(rd, "simplify_gpencil_shader_fx")
+        col.prop(rd, "simplify_gpencil_tint")
+        col.prop(rd, "simplify_gpencil_antialiasing")
 
 
 class GreasePencilLayerAdjustmentsPanel:
@@ -913,6 +794,65 @@ class GreasePencilLayerAdjustmentsPanel:
         col.prop(gpl, "lock_material")
 
 
+class GPENCIL_UL_masks(UIList):
+    def draw_item(self, _context, layout, _data, item, icon, _active_data, _active_propname, _index):
+        mask = item
+        if self.layout_type in {'DEFAULT', 'COMPACT'}:
+            row = layout.row(align=True)
+            row.prop(mask, "name", text="", emboss=False, icon_value=icon)
+            row.prop(mask, "invert", text="", emboss=False)
+            row.prop(mask, "hide", text="", emboss=False)
+        elif self.layout_type == 'GRID':
+            layout.alignment = 'CENTER'
+            layout.prop(mask, "name", text="", emboss=False, icon_value=icon)
+
+
+class GPENCIL_MT_layer_mask_menu(Menu):
+    bl_label = "Layer Specials"
+
+    def draw(self, context):
+        layout = self.layout
+        ob = context.object
+        gpd = ob.data
+        gpl_active = gpd.layers.active
+        done = False
+        for gpl in gpd.layers:
+            if gpl != gpl_active and gpl.info not in gpl_active.mask_layers:
+                done = True
+                layout.operator("gpencil.layer_mask_add", text=gpl.info).name=gpl.info
+
+        if done is False:
+            layout.label(text="No layers to add")
+
+
+class GreasePencilLayerMasksPanel:
+    def draw_header(self, context):
+        ob = context.active_object
+        gpd = ob.data
+        gpl = gpd.layers.active
+
+        self.layout.prop(gpl, "use_mask_layer", text="")
+
+    def draw(self, context):
+        ob = context.active_object
+        gpd = ob.data
+        gpl = gpd.layers.active
+
+        layout = self.layout
+        layout.enabled = gpl.use_mask_layer
+
+        if gpl:
+            rows = 4
+            row = layout.row()
+            col = row.column()
+            col.template_list("GPENCIL_UL_masks", "", gpl, "mask_layers", gpl.mask_layers,
+                            "active_mask_index", rows=rows, sort_lock=True)
+
+            col2 = row.column(align=True)
+            col2.menu("GPENCIL_MT_layer_mask_menu", icon='ADD', text="")
+            col2.operator("gpencil.layer_mask_remove", icon='REMOVE', text="")
+
+
 class GreasePencilLayerRelationsPanel:
 
     def draw(self, context):
@@ -952,20 +892,58 @@ class GreasePencilLayerDisplayPanel:
         col.prop(gpl, "use_solo_mode", text="Show Only On Keyframed")
 
 
-classes = (
-    GPENCIL_MT_pie_tool_palette,
-    GPENCIL_MT_pie_settings_palette,
-    GPENCIL_MT_pie_tools_more,
-    GPENCIL_MT_pie_sculpt,
+class GreasePencilFlipTintColors(Operator):
+    bl_label = "Flip Colors"
+    bl_idname = "gpencil.tint_flip"
+    bl_description = "Switch Tint colors"
+
+    def execute(self, context):
+        try:
+            ts = context.tool_settings
+            settings = None
+            if context.mode == 'PAINT_GPENCIL':
+                settings = ts.gpencil_paint
+            if context.mode == 'SCULPT_GPENCIL':
+                settings = ts.gpencil_sculpt_paint
+            elif context.mode == 'WEIGHT_GPENCIL':
+                settings = ts.gpencil_weight_paint
+            elif context.mode == 'VERTEX_GPENCIL':
+                settings = ts.gpencil_vertex_paint
 
+            brush = settings.brush
+            if brush is not None:
+                color = brush.color
+                secondary_color = brush.secondary_color
+
+                orig_prim = color.hsv
+                orig_sec = secondary_color.hsv
+
+                color.hsv = orig_sec
+                secondary_color.hsv = orig_prim
+
+            return {'FINISHED'}
+
+        except Exception as e:
+            utils_core.error_handlers(self, "gpencil.tint_flip", e,
+                                      "Flip Colors could not be completed")
+
+            return {'CANCELLED'}
+
+
+classes = (
     GPENCIL_MT_snap,
     GPENCIL_MT_cleanup,
     GPENCIL_MT_move_to_layer,
+    GPENCIL_MT_layer_active,
 
     GPENCIL_MT_gpencil_draw_delete,
+    GPENCIL_MT_layer_mask_menu,
 
     GPENCIL_UL_annotation_layer,
     GPENCIL_UL_layer,
+    GPENCIL_UL_masks,
+
+    GreasePencilFlipTintColors,
 )
 
 if __name__ == "__main__":  # only for live edit.
index 4f419ec1f18ab5f9fd68e5e458cd0fd111555812..56201b29e7f524a47b51f84b217d9e67d4c78f15 100644 (file)
@@ -47,6 +47,11 @@ class GPENCIL_MT_color_context_menu(Menu):
         layout.separator()
 
         layout.operator("object.material_slot_remove_unused")
+        layout.operator("gpencil.stroke_merge_material", text="Merge Similar")
+
+        layout.separator()
+        layout.operator("gpencil.material_to_vertex_color", text="Convert Materials to Vertex Color")
+        layout.operator("gpencil.extract_palette_vertex", text="Extract Palette from Vertex Color")
 
 
 class GPENCIL_UL_matslots(UIList):
@@ -142,27 +147,25 @@ class MATERIAL_PT_gpencil_strokecolor(GPMaterialButtonsPanel, Panel):
 
             col.prop(gpcolor, "stroke_style", text="Style")
 
+            row = col.row()
+            row.prop(gpcolor, "color", text="Base Color")
+
             if gpcolor.stroke_style == 'TEXTURE':
                 row = col.row()
                 row.enabled = not gpcolor.lock
                 col = row.column(align=True)
                 col.template_ID(gpcolor, "stroke_image", open="image.open")
+
+            if gpcolor.stroke_style == 'TEXTURE':
+                row = col.row()
+                row.prop(gpcolor, "mix_stroke_factor", text="Blend", slider=True)
                 if gpcolor.mode == 'LINE':
                     col.prop(gpcolor, "pixel_size", text="UV Factor")
 
-                col.prop(gpcolor, "use_stroke_pattern", text="Use As Stencil Mask")
-                if gpcolor.use_stroke_pattern is False:
-                    col.prop(gpcolor, "use_stroke_texture_mix", text="Mix Color")
-                    if gpcolor.use_stroke_texture_mix is True:
-                        col.prop(gpcolor, "mix_stroke_factor", text="Factor")
-
-            if (gpcolor.stroke_style == 'SOLID' or gpcolor.use_stroke_pattern or gpcolor.use_stroke_texture_mix):
-                col.prop(gpcolor, "color", text="Color")
-
             if gpcolor.mode in {'DOTS', 'BOX'}:
                 col.prop(gpcolor, "alignment_mode")
 
-            if gpcolor.mode == 'LINE' and gpcolor.stroke_style != 'TEXTURE':
+            if gpcolor.mode == 'LINE':
                 col.prop(gpcolor, "use_overlap_strokes")
 
 
@@ -188,55 +191,35 @@ class MATERIAL_PT_gpencil_fillcolor(GPMaterialButtonsPanel, Panel):
         col.enabled = not gpcolor.lock
         col.prop(gpcolor, "fill_style", text="Style")
 
-        if gpcolor.fill_style == 'GRADIENT':
-            col.prop(gpcolor, "gradient_type")
 
-        if gpcolor.fill_style != 'TEXTURE':
-            col.prop(gpcolor, "fill_color", text="Color")
+        if gpcolor.fill_style == 'SOLID':
+            col.prop(gpcolor, "fill_color", text="Base Color")
 
-            if gpcolor.fill_style in {'GRADIENT', 'CHECKER'}:
-                col.prop(gpcolor, "mix_color", text="Secondary Color")
-
-            if gpcolor.fill_style == 'GRADIENT':
-                col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
-
-            if gpcolor.fill_style in {'GRADIENT', 'CHECKER'}:
-                col.prop(gpcolor, "flip", text="Flip Colors")
-
-                col.prop(gpcolor, "pattern_shift", text="Location")
-                col.prop(gpcolor, "pattern_scale", text="Scale")
+        elif gpcolor.fill_style == 'GRADIENT':
+            col.prop(gpcolor, "gradient_type")
 
-            if gpcolor.gradient_type == 'RADIAL' and gpcolor.fill_style not in {'SOLID', 'CHECKER'}:
-                col.prop(gpcolor, "pattern_radius", text="Radius")
-            else:
-                if gpcolor.fill_style != 'SOLID':
-                    col.prop(gpcolor, "pattern_angle", text="Angle")
+            col.prop(gpcolor, "fill_color", text="Base Color")
+            col.prop(gpcolor, "mix_color", text="Secondary Color")
+            col.prop(gpcolor, "mix_factor", text="Blend in Fill Gradient", slider=True)
+            col.prop(gpcolor, "flip", text="Flip Colors")
 
-            if gpcolor.fill_style == 'CHECKER':
-                col.prop(gpcolor, "pattern_gridsize", text="Box Size")
+            col.prop(gpcolor, "texture_offset", text="Location")
+            col.prop(gpcolor, "texture_scale", text="Scale")
+            if gpcolor.gradient_type == 'LINEAR':
+                col.prop(gpcolor, "texture_angle", text="Rotation")
 
-        # Texture
-        if gpcolor.fill_style == 'TEXTURE' or (gpcolor.use_fill_texture_mix is True and gpcolor.fill_style == 'SOLID'):
+        elif gpcolor.fill_style == 'TEXTURE':
             col.template_ID(gpcolor, "fill_image", open="image.open")
 
-            if gpcolor.fill_style == 'TEXTURE':
-                col.prop(gpcolor, "use_fill_pattern", text="Use as Stencil Mask")
-                if gpcolor.use_fill_pattern is True:
-                    col.prop(gpcolor, "fill_color", text="Color")
+            col.prop(gpcolor, "fill_color", text="Base Color")
+            col.prop(gpcolor, "texture_opacity", slider=True)
+            col.prop(gpcolor, "mix_factor", text="Blend in Fill Texture", slider=True)
 
-            col.prop(gpcolor, "texture_offset", text="Offset")
+            col.prop(gpcolor, "texture_offset", text="Location")
+            col.prop(gpcolor, "texture_angle", text="Rotation")
             col.prop(gpcolor, "texture_scale", text="Scale")
-            col.prop(gpcolor, "texture_angle")
-            col.prop(gpcolor, "texture_opacity")
             col.prop(gpcolor, "texture_clamp", text="Clip Image")
 
-            if gpcolor.use_fill_pattern is False:
-                col.prop(gpcolor, "use_fill_texture_mix", text="Mix with Color")
-
-                if gpcolor.use_fill_texture_mix is True:
-                    col.prop(gpcolor, "fill_color", text="Mix Color")
-                    col.prop(gpcolor, "mix_factor", text="Mix Factor", slider=True)
-
 
 class MATERIAL_PT_gpencil_preview(GPMaterialButtonsPanel, Panel):
     bl_label = "Preview"
@@ -291,5 +274,6 @@ classes = (
 
 if __name__ == "__main__":  # only for live edit.
     from bpy.utils import register_class
+
     for cls in classes:
         register_class(cls)
index bb020084b03bfa5ec79aaf79b2084ce8e0c41b73..33ba981e235836cc4491087d0ed6d2bf1da27418 100644 (file)
@@ -397,6 +397,27 @@ class OBJECT_PT_visibility(ObjectButtonsPanel, Panel):
         col.prop(ob, "hide_select", text="Selectable", toggle=False, invert_checkbox=True)
 
 
+class OBJECT_PT_greasepencil_light(ObjectButtonsPanel, Panel):
+    bl_label = "Grease Pencil"
+    bl_options = {'DEFAULT_CLOSED'}
+    COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
+
+    @classmethod
+    def poll(cls, context):
+        return (context.object) and (context.engine in cls.COMPAT_ENGINES) and (context.object.type == 'GPENCIL')
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+
+        flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
+        layout = self.layout
+        ob = context.object
+
+        col = flow.column()
+        col.prop(ob, "use_grease_pencil_lights", toggle=False)
+
+
 class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
     COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
     _context_path = "object"
@@ -417,6 +438,7 @@ classes = (
     OBJECT_PT_display,
     OBJECT_PT_display_bounds,
     OBJECT_PT_visibility,
+    OBJECT_PT_greasepencil_light,
     OBJECT_PT_custom_props,
 )
 
index f1f6e9898b123e85ecf6a357c9b10496703d663a..df3dc930f9708f77a31c77a6299a446954de3fb9 100644 (file)
@@ -89,8 +89,12 @@ class UnifiedPaintPanel:
         # Grease Pencil settings
         elif mode == 'PAINT_GPENCIL':
             return tool_settings.gpencil_paint
-        elif mode in {'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
-            return tool_settings.gpencil_sculpt
+        elif mode == 'SCULPT_GPENCIL':
+            return tool_settings.gpencil_sculpt_paint
+        elif mode == 'WEIGHT_GPENCIL':
+            return tool_settings.gpencil_weight_paint
+        elif mode == 'VERTEX_GPENCIL':
+            return tool_settings.gpencil_vertex_paint
         return None
 
     @staticmethod
@@ -1019,6 +1023,8 @@ def brush_basic_texpaint_settings(layout, context, brush, *, compact=False):
 
 
 def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False):
+    tool_settings = context.tool_settings
+    settings = tool_settings.gpencil_paint
     gp_settings = brush.gpencil_settings
     tool = context.workspace.tools.from_space_view3d_mode(context.mode, create=False)
     if gp_settings is None:
@@ -1043,7 +1049,7 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
             row.prop(gp_settings, "eraser_thickness_factor")
 
         row = layout.row(align=True)
-        row.prop(gp_settings, "use_cursor", text="Display Cursor")
+        row.prop(settings, "show_brush", text="Display Cursor")
 
     # FIXME: tools must use their own UI drawing!
     elif brush.gpencil_tool == 'FILL':
@@ -1091,52 +1097,63 @@ def brush_basic_gpencil_paint_settings(layout, context, brush, *, compact=False)
 
 
 def brush_basic_gpencil_sculpt_settings(layout, context, brush, *, compact=False):
-    tool_settings = context.tool_settings
-    settings = tool_settings.gpencil_sculpt
-    tool = settings.sculpt_tool
+    gp_settings = brush.gpencil_settings
+    tool = brush.gpencil_sculpt_tool
 
     row = layout.row(align=True)
     row.prop(brush, "size", slider=True)
     sub = row.row(align=True)
     sub.enabled = tool not in {'GRAB', 'CLONE'}
-    sub.prop(brush, "use_pressure_radius", text="")
+    sub.prop(gp_settings, "use_pressure", text="")
 
     row = layout.row(align=True)
     row.prop(brush, "strength", slider=True)
     row.prop(brush, "use_pressure_strength", text="")
 
-    layout.prop(brush, "use_falloff")
-
     if compact:
         if tool in {'THICKNESS', 'STRENGTH', 'PINCH', 'TWIST'}:
             row.separator()
-            row.prop(brush, "direction", expand=True, text="")
+            row.prop(gp_settings, "direction", expand=True, text="")
     else:
         use_property_split_prev = layout.use_property_split
         layout.use_property_split = False
         if tool in {'THICKNESS', 'STRENGTH'}:
-            layout.row().prop(brush, "direction", expand=True)
+            layout.row().prop(gp_settings, "direction", expand=True)
         elif tool == 'PINCH':
             row = layout.row(align=True)
-            row.prop_enum(brush, "direction", value='ADD', text="Pinch")
-            row.prop_enum(brush, "direction", value='SUBTRACT', text="Inflate")
+            row.prop_enum(gp_settings, "direction", value='ADD', text="Pinch")
+            row.prop_enum(gp_settings, "direction", value='SUBTRACT', text="Inflate")
         elif tool == 'TWIST':
             row = layout.row(align=True)
-            row.prop_enum(brush, "direction", value='ADD', text="CCW")
-            row.prop_enum(brush, "direction", value='SUBTRACT', text="CW")
+            row.prop_enum(gp_settings, "direction", value='ADD', text="CCW")
+            row.prop_enum(gp_settings, "direction", value='SUBTRACT', text="CW")
         layout.use_property_split = use_property_split_prev
 
 
 def brush_basic_gpencil_weight_settings(layout, _context, brush, *, compact=False):
+    gp_settings = brush.gpencil_settings
     layout.prop(brush, "size", slider=True)
 
     row = layout.row(align=True)
     row.prop(brush, "strength", slider=True)
     row.prop(brush, "use_pressure_strength", text="")
+
     layout.prop(brush, "weight", slider=True)
-    layout.prop(brush, "use_falloff")
 
 
+def brush_basic_gpencil_vertex_settings(layout, _context, brush, *, compact=False):
+    gp_settings = brush.gpencil_settings
+
+    # Brush details
+    row = layout.row(align=True)
+    row.prop(brush, "size", text="Radius")
+    row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
+
+    if brush.gpencil_vertex_tool in {'DRAW', 'BLUR', 'SMEAR'}:
+        row = layout.row(align=True)
+        row.prop(gp_settings, "pen_strength", slider=True)
+        row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
+
 classes = (
     VIEW3D_MT_tools_projectpaint_clone,
 )
index a09e263fd87d053db9424520c5c9d4a709f501ba..41adea0b922916323746f747b45e841bc431d7b3 100644 (file)
@@ -26,6 +26,7 @@ from bpy.types import (
 )
 
 from bl_ui.properties_grease_pencil_common import (
+    GreasePencilLayerMasksPanel,
     GreasePencilLayerAdjustmentsPanel,
     GreasePencilLayerRelationsPanel,
     GreasePencilLayerDisplayPanel,
@@ -699,6 +700,15 @@ class DOPESHEET_PT_gpencil_mode(LayersDopeSheetPanel, Panel):
             row = layout.row(align=True)
             row.prop(gpl, "opacity", text="Opacity", slider=True)
 
+            row = layout.row(align=True)
+            row.prop(gpl, "use_lights")
+
+
+class DOPESHEET_PT_gpencil_layer_masks(LayersDopeSheetPanel, GreasePencilLayerMasksPanel, Panel):
+    bl_label = "Masks"
+    bl_parent_id = 'DOPESHEET_PT_gpencil_mode'
+    bl_options = {'DEFAULT_CLOSED'}
+
 
 class DOPESHEET_PT_gpencil_layer_adjustments(LayersDopeSheetPanel, GreasePencilLayerAdjustmentsPanel, Panel):
     bl_label = "Adjustments"
@@ -736,6 +746,7 @@ classes = (
     DOPESHEET_MT_snap_pie,
     DOPESHEET_PT_filters,
     DOPESHEET_PT_gpencil_mode,
+    DOPESHEET_PT_gpencil_layer_masks,
     DOPESHEET_PT_gpencil_layer_adjustments,
     DOPESHEET_PT_gpencil_layer_relations,
     DOPESHEET_PT_gpencil_layer_display,
index c6f490f9d267708305369987b774eff946328a29..980f89eaaa4658982f6ea8298aedba3fc53a4f5e 100644 (file)
@@ -238,6 +238,11 @@ class IMAGE_MT_image(Menu):
                 layout.separator()
                 layout.operator("image.pack", text="Pack")
 
+        if ima:
+            layout.separator()
+            layout.operator("palette.extract_from_image", text="Extract Palette")
+            layout.operator("gpencil.image_to_grease_pencil", text="Generate Grease Pencil")
+
 
 class IMAGE_MT_image_invert(Menu):
     bl_label = "Invert"
index 63fb72a71bdb746d168da2a1352880aa2b63a8de..583d8ea44cfe0cb500dd8d82a366cc58959cf381 100644 (file)
@@ -1455,6 +1455,11 @@ class _defs_gpencil_paint:
 
     @ToolDef.from_fn
     def eyedropper():
+        def draw_settings(context, layout, tool):
+            props = tool.operator_properties("ui.eyedropper_gpencil_color")
+            row = layout.row()
+            row.use_property_split = False
+            row.prop(props, "mode", expand=True)
         return dict(
             idname="builtin.eyedropper",
             label="Eyedropper",
@@ -1462,6 +1467,7 @@ class _defs_gpencil_paint:
             cursor='EYEDROPPER',
             widget=None,
             keymap=(),
+            draw_settings=draw_settings,
         )
 
 
@@ -1594,6 +1600,23 @@ class _defs_gpencil_edit:
             draw_settings=_template_widget.VIEW3D_GGT_xform_extrude.draw_settings,
         )
 
+    @ToolDef.from_fn
+    def transform_fill():
+        def draw_settings(context, layout, tool):
+                props = tool.operator_properties("gpencil.transform_fill")
+                row = layout.row()
+                row.use_property_split = False
+                row.prop(props, "mode", expand=True)
+
+        return dict(
+            idname="builtin.transform_fill",
+            label="Transform Fill",
+            icon="ops.gpencil.transform_fill",
+            cursor='DEFAULT',
+            widget=None,
+            keymap=(),
+            draw_settings=draw_settings,
+        )
 
 class _defs_gpencil_sculpt:
 
@@ -1613,11 +1636,10 @@ class _defs_gpencil_sculpt:
             context,
             idname_prefix="builtin_brush.",
             icon_prefix="ops.gpencil.sculpt_",
-            type=bpy.types.GPencilSculptSettings,
-            attr="sculpt_tool",
+            type=bpy.types.Brush,
+            attr="gpencil_sculpt_tool",
             tooldef_keywords=dict(
                 operator="gpencil.sculpt_paint",
-                keymap="3D View Tool: Sculpt Gpencil, Paint",
             ),
         )
 
@@ -1630,11 +1652,37 @@ class _defs_gpencil_weight:
             context,
             idname_prefix="builtin_brush.",
             icon_prefix="ops.gpencil.sculpt_",
-            type=bpy.types.GPencilSculptSettings,
-            attr="weight_tool",
+            type=bpy.types.Brush,
+            attr="gpencil_weight_tool",
             tooldef_keywords=dict(
-                operator="gpencil.sculpt_paint",
-                keymap="3D View Tool: Sculpt Gpencil, Paint",
+                operator="gpencil.weight_paint",
+            ),
+        )
+
+
+class _defs_gpencil_vertex:
+
+    @staticmethod
+    def poll_select_mask(context):
+        if context is None:
+            return True
+        ob = context.active_object
+        ts = context.scene.tool_settings
+        return ob and ob.type == 'GPENCIL' and (ts.use_gpencil_vertex_select_mask_point or
+                                                ts.use_gpencil_vertex_select_mask_stroke or
+                                                ts.use_gpencil_vertex_select_mask_segment)
+
+    @staticmethod
+    def generate_from_brushes(context):
+        return generate_from_enum_ex(
+            context,
+            idname_prefix="builtin_brush.",
+            icon_prefix="brush.paint_vertex.",
+            type=bpy.types.Brush,
+            attr="gpencil_vertex_tool",
+            cursor='DOT',
+            tooldef_keywords=dict(
+                operator="gpencil.vertex_paint",
             ),
         )
 
@@ -2202,6 +2250,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
                 _defs_gpencil_edit.tosphere,
             ),
             None,
+            _defs_gpencil_edit.transform_fill,
+            None,
             *_tools_annotate,
         ],
         'SCULPT_GPENCIL': [
@@ -2219,6 +2269,17 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
             None,
             *_tools_annotate,
         ],
+        'VERTEX_GPENCIL': [
+            _defs_gpencil_vertex.generate_from_brushes,
+            None,
+            *_tools_annotate,
+            None,
+            lambda context: (
+                VIEW3D_PT_tools_active._tools_gpencil_select
+                if _defs_gpencil_vertex.poll_select_mask(context)
+                else ()
+            ),
+        ],
     }
 class SEQUENCER_PT_tools_active(ToolSelectPanelHelper, Panel):
     bl_space_type = 'SEQUENCE_EDITOR'
index 192b239ac0330f760bc68328b2ab6c3584db95b1..1f52323f5404511f01f57b9172c98fd72de1278c 100644 (file)
@@ -165,11 +165,11 @@ class TOPBAR_PT_gpencil_layers(Panel):
 
             srow = col.row(align=True)
             srow.prop(gpl, "opacity", text="Opacity", slider=True)
-            srow.prop(gpl, "mask_layer", text="",
-                      icon='MOD_MASK' if gpl.mask_layer else 'LAYER_ACTIVE')
+            srow.prop(gpl, "use_mask_layer", text="",
+                      icon='MOD_MASK' if gpl.use_mask_layer else 'LAYER_ACTIVE')
 
             srow = col.row(align=True)
-            srow.prop(gpl, "use_solo_mode", text="Show Only On Keyframed")
+            srow.prop(gpl, "use_lights")
 
         col = row.column()
 
index c3c99ebb82600b669cc123af1da6eb6399a833a9..b8051a1d98a42d8efbd969060d46c0a67eb5f5c2 100644 (file)
@@ -668,7 +668,6 @@ class USERPREF_PT_viewport_quality(ViewportPanel, CenterAlignMixIn, Panel):
         flow = layout.grid_flow(row_major=False, columns=0, even_columns=True, even_rows=False, align=False)
 
         flow.prop(system, "viewport_aa")
-        flow.prop(system, "gpencil_multi_sample", text="Grease Pencil Multisampling")
         flow.prop(system, "use_overlay_smooth_wire")
         flow.prop(system, "use_edit_mode_smooth_wire")
 
index 078ad96778979b6935fce84b1f35a72cef9af26a..447386b8f9d990a6ce061fd00b92ee28990fcbd0 100644 (file)
@@ -31,6 +31,7 @@ from bl_ui.properties_grease_pencil_common import (
     AnnotationDataPanel,
     AnnotationOnionSkin,
     GreasePencilMaterialsPanel,
+    GreasePencilVertexcolorPanel,
 )
 from bl_ui.space_toolsystem_common import (
     ToolActivePanelHelper,
@@ -119,21 +120,27 @@ class VIEW3D_HT_tool_header(Header):
             if is_valid_context:
                 brush = context.tool_settings.gpencil_paint.brush
                 if brush.gpencil_tool != 'ERASE':
-                    layout.popover("VIEW3D_PT_tools_grease_pencil_brush_advanced")
+                    if brush.gpencil_tool != 'TINT':
+                        layout.popover("VIEW3D_PT_tools_grease_pencil_brush_advanced")
 
-                    if brush.gpencil_tool != 'FILL':
+                    if brush.gpencil_tool not in {'FILL', 'TINT'}:
                         layout.popover("VIEW3D_PT_tools_grease_pencil_brush_stroke")
                         layout.popover("VIEW3D_PT_tools_grease_pencil_brushcurves")
 
                     layout.popover("VIEW3D_PT_tools_grease_pencil_paint_appearance")
         elif tool_mode == 'SCULPT_GPENCIL':
-            settings = context.tool_settings.gpencil_sculpt
-            tool = settings.sculpt_tool
-            if tool in {'SMOOTH', 'RANDOMIZE', 'SMOOTH'}:
-                layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options")
-            layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance")
+            if is_valid_context:
+                brush = context.tool_settings.gpencil_sculpt_paint.brush
+                tool = brush.gpencil_tool
+                if tool in ('SMOOTH', 'RANDOMIZE'):
+                    layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_options")
+                layout.popover("VIEW3D_PT_tools_grease_pencil_sculpt_appearance")
         elif tool_mode == 'WEIGHT_GPENCIL':
-            layout.popover("VIEW3D_PT_tools_grease_pencil_weight_appearance")
+            if is_valid_context:
+                layout.popover("VIEW3D_PT_tools_grease_pencil_weight_appearance")
+        elif tool_mode == 'VERTEX_GPENCIL':
+            if is_valid_context:
+                layout.popover("VIEW3D_PT_tools_grease_pencil_vertex_appearance")
 
     def draw_mode_settings(self, context):
         layout = self.layout
@@ -425,6 +432,15 @@ class _draw_tool_settings_context_mode:
 
             row.prop(gp_settings, "use_material_pin", text="")
 
+            if brush.gpencil_tool in {'DRAW', 'FILL'} and ma:
+                row.separator(factor=1.0)
+                subrow = row.row(align=True)
+                row.prop_enum(settings, "color_mode", 'MATERIAL', text="", icon='MATERIAL')
+                row.prop_enum(settings, "color_mode", 'VERTEXCOLOR', text="", icon='VPAINT_HLT')
+                sub_row = row.row(align=True)
+                sub_row.enabled = settings.color_mode == 'VERTEXCOLOR'
+                sub_row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
+
         row = layout.row(align=True)
         tool_settings = context.scene.tool_settings
         settings = tool_settings.gpencil_paint
@@ -433,6 +449,10 @@ class _draw_tool_settings_context_mode:
         if context.object and brush.gpencil_tool in {'FILL', 'DRAW'}:
             draw_color_selector()
 
+        if context.object and brush.gpencil_tool == 'TINT':
+            row.separator(factor=0.4)
+            row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
+
         from bl_ui.properties_paint_common import (
             brush_basic_gpencil_paint_settings,
         )
@@ -444,9 +464,8 @@ class _draw_tool_settings_context_mode:
     def SCULPT_GPENCIL(context, layout, tool):
         if (tool is None) or (not tool.has_datablock):
             return False
-        tool_settings = context.tool_settings
-        settings = tool_settings.gpencil_sculpt
-        brush = settings.brush
+        paint = context.tool_settings.gpencil_sculpt_paint
+        brush = paint.brush
 
         from bl_ui.properties_paint_common import (
             brush_basic_gpencil_sculpt_settings,
@@ -459,9 +478,8 @@ class _draw_tool_settings_context_mode:
     def WEIGHT_GPENCIL(context, layout, tool):
         if (tool is None) or (not tool.has_datablock):
             return False
-        tool_settings = context.tool_settings
-        settings = tool_settings.gpencil_sculpt
-        brush = settings.brush
+        paint = context.tool_settings.gpencil_weight_paint
+        brush = paint.brush
 
         from bl_ui.properties_paint_common import (
             brush_basic_gpencil_weight_settings,
@@ -470,6 +488,31 @@ class _draw_tool_settings_context_mode:
 
         return True
 
+    @staticmethod
+    def VERTEX_GPENCIL(context, layout, tool):
+        if (tool is None) or (not tool.has_datablock):
+            return False
+
+        paint = context.tool_settings.gpencil_vertex_paint
+        brush = paint.brush
+
+        row = layout.row(align=True)
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_vertex_paint
+        row.template_ID_preview(settings, "brush", rows=3, cols=8, hide_buttons=True)
+
+        if brush.gpencil_vertex_tool not in {'BLUR', 'AVERAGE', 'SMEAR'}:
+            row.separator(factor=0.4)
+            row.prop_with_popover(brush, "color", text="", panel="TOPBAR_PT_gpencil_vertexcolor")
+
+        from bl_ui.properties_paint_common import (
+            brush_basic_gpencil_vertex_settings,
+        )
+
+        brush_basic_gpencil_vertex_settings(layout, context, brush, compact=True)
+
+        return True
+
     @staticmethod
     def PARTICLE(context, layout, tool):
         if (tool is None) or (not tool.has_datablock):
@@ -550,7 +593,7 @@ class VIEW3D_HT_header(Header):
         else:
             if (object_mode not in {
                     'SCULPT', 'VERTEX_PAINT', 'WEIGHT_PAINT', 'TEXTURE_PAINT',
-                    'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'
+                    'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'
             }) or has_pose_mode:
                 show_snap = True
             else:
@@ -687,7 +730,14 @@ class VIEW3D_HT_header(Header):
                 row.prop(tool_settings, "use_gpencil_select_mask_stroke", text="")
                 row.prop(tool_settings, "use_gpencil_select_mask_segment", text="")
 
-            if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode:
+            # Select mode for Vertex Paint
+            if gpd.is_stroke_vertex_mode:
+                row = layout.row(align=True)
+                row.prop(tool_settings, "use_gpencil_vertex_select_mask_point", text="")
+                row.prop(tool_settings, "use_gpencil_vertex_select_mask_stroke", text="")
+                row.prop(tool_settings, "use_gpencil_vertex_select_mask_segment", text="")
+
+            if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode or gpd.is_stroke_weight_mode or gpd.is_stroke_vertex_mode:
                 row = layout.row(align=True)
                 row.prop(gpd, "use_multiedit", text="", icon='GP_MULTIFRAME_EDITING')
 
@@ -812,7 +862,8 @@ class VIEW3D_MT_editor_menus(Menu):
         obj = context.active_object
         mode_string = context.mode
         edit_object = context.edit_object
-        gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}
+        gp_edit = obj and obj.mode in {'EDIT_GPENCIL', 'PAINT_GPENCIL', 'SCULPT_GPENCIL',
+                                       'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}
         ts = context.scene.tool_settings
 
         layout.menu("VIEW3D_MT_view")
@@ -827,6 +878,8 @@ class VIEW3D_MT_editor_menus(Menu):
                     layout.menu("VIEW3D_MT_select_gpencil")
                 elif mode_string == 'EDIT_GPENCIL':
                     layout.menu("VIEW3D_MT_select_gpencil")
+                elif mode_string == 'VERTEX_GPENCIL':
+                    layout.menu("VIEW3D_MT_select_gpencil")
         elif mode_string in {'PAINT_WEIGHT', 'PAINT_VERTEX', 'PAINT_TEXTURE'}:
             mesh = obj.data
             if mesh.use_paint_mask:
@@ -4650,6 +4703,10 @@ class VIEW3D_MT_paint_gpencil(Menu):
 
         layout = self.layout
 
+        layout.menu("GPENCIL_MT_layer_active", text="Active Layer")
+
+        layout.separator()
+
         layout.menu("VIEW3D_MT_gpencil_animation")
         layout.menu("VIEW3D_MT_edit_gpencil_interpolate")
 
@@ -4708,6 +4765,10 @@ class VIEW3D_MT_edit_gpencil(Menu):
 
         layout.separator()
 
+        layout.menu("GPENCIL_MT_layer_active", text="Active Layer")
+
+        layout.separator()
+
         layout.menu("VIEW3D_MT_gpencil_animation")
         layout.menu("VIEW3D_MT_edit_gpencil_interpolate")
 
@@ -4742,6 +4803,7 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu):
 
     def draw(self, _context):
         layout = self.layout
+        settings = _context.tool_settings.gpencil_sculpt
 
         layout.operator("gpencil.stroke_subdivide", text="Subdivide").only_selected = False
         layout.menu("VIEW3D_MT_gpencil_simplify")
@@ -4767,6 +4829,10 @@ class VIEW3D_MT_edit_gpencil_stroke(Menu):
         layout.operator("gpencil.stroke_cyclical_set", text="Toggle Cyclic").type = 'TOGGLE'
         layout.operator_menu_enum("gpencil.stroke_caps_set", text="Toggle Caps", property="type")
         layout.operator("gpencil.stroke_flip", text="Switch Direction")
+        layout.prop(settings, "use_scale_thickness")
+
+        layout.separator()
+        layout.operator("gpencil.reset_transform_fill", text="Reset Fill Transform")
 
 
 class VIEW3D_MT_edit_gpencil_point(Menu):
@@ -4811,6 +4877,22 @@ class VIEW3D_MT_weight_gpencil(Menu):
         layout.menu("VIEW3D_MT_gpencil_autoweights")
 
 
+class VIEW3D_MT_vertex_gpencil(Menu):
+    bl_label = "Paint"
+
+    def draw(self, _context):
+        layout = self.layout
+        layout.operator("gpencil.vertex_color_set", text="Set Vertex Colors")
+        layout.separator()
+        layout.operator("gpencil.vertex_color_invert", text="Invert")
+        layout.operator("gpencil.vertex_color_levels", text="Levels")
+        layout.operator("gpencil.vertex_color_hsv", text="Hue Saturation Value")
+        layout.operator("gpencil.vertex_color_brightness_contrast", text="Bright/Contrast")
+
+        layout.separator()
+        layout.menu("VIEW3D_MT_join_palette")
+
+
 class VIEW3D_MT_gpencil_animation(Menu):
     bl_label = "Animation"
 
@@ -6473,6 +6555,7 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
             'EDIT_GPENCIL': "Edit Grease Pencil",
             'SCULPT_GPENCIL': "Sculpt Grease Pencil",
             'WEIGHT_GPENCIL': "Weight Grease Pencil",
+            'VERTEX_GPENCIL': "Vertex Grease Pencil",
             'OBJECT': "Grease Pencil",
         }[context.mode])
 
@@ -6497,17 +6580,32 @@ class VIEW3D_PT_overlay_gpencil_options(Panel):
         sub.prop(overlay, "gpencil_fade_layer", text="Fade Layers", slider=True)
 
         row = col.row()
-        row.prop(overlay, "use_gpencil_paper", text="")
+        row.prop(overlay, "use_gpencil_fade_objects", text="")
         sub = row.row(align=True)
-        sub.active = overlay.use_gpencil_paper
-        sub.prop(overlay, "gpencil_paper_opacity", text="Fade Objects", slider=True)
-        sub.prop(overlay, "use_gpencil_fade_objects", text="", icon='OUTLINER_OB_GREASEPENCIL')
+        sub.active = overlay.use_gpencil_fade_objects
+        sub.prop(overlay, "gpencil_fade_objects", text="Fade Objects", slider=True)
+        sub.prop(overlay, "use_gpencil_fade_gp_objects", text="", icon='OUTLINER_OB_GREASEPENCIL')
+
+        if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL', 'VERTEX_GPENCIL'}:
+            split = layout.split()
+            col = split.column()
+            col.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines")
+            col = split.column()
+            col.prop(overlay, "use_gpencil_multiedit_line_only", text="Only in Multiframe")
+
+            if context.object.mode == 'EDIT_GPENCIL':
+                split = layout.split()
+                col = split.column()
+                col.prop(overlay, "use_gpencil_show_directions")
+                col = split.column()
+                col.prop(overlay, "use_gpencil_show_material_name",  text="Material Name")
 
-        if context.object.mode in {'EDIT_GPENCIL', 'SCULPT_GPENCIL', 'WEIGHT_GPENCIL'}:
-            layout.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines")
-            layout.prop(overlay, "use_gpencil_multiedit_line_only", text="Show Edit Lines only in multiframe")
             layout.prop(overlay, "vertex_opacity", text="Vertex Opacity", slider=True)
 
+        if context.object.mode in {'PAINT_GPENCIL', 'VERTEX_GPENCIL'}:
+            layout.label(text="Vertex Paint")
+            layout.prop(overlay, "gpencil_vertex_paint_opacity", text="Opacity", slider=True)
+
 
 class VIEW3D_PT_quad_view(Panel):
     bl_space_type = 'VIEW_3D'
@@ -6783,77 +6881,127 @@ class VIEW3D_MT_gpencil_edit_context_menu(Menu):
             col.operator("gpencil.reproject", text="Reproject Strokes")
 
 
+def draw_gpencil_layer_active(context, layout):
+        gpl = context.active_gpencil_layer
+        if gpl:
+            layout.label(text="Active Layer")
+            row = layout.row(align=True)
+            row.operator_context = 'EXEC_REGION_WIN'
+            row.operator_menu_enum("gpencil.layer_change", "layer", text="", icon='GREASEPENCIL')
+            row.prop(gpl, "info", text="")
+            row.operator("gpencil.layer_remove", text="", icon='X')
+
+
 class VIEW3D_PT_gpencil_sculpt_context_menu(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'WINDOW'
     bl_label = "Sculpt Context Menu"
+    bl_ui_units_x = 12
 
     def draw(self, context):
-        brush = context.tool_settings.gpencil_sculpt.brush
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
 
         layout = self.layout
 
-        if context.mode == 'WEIGHT_GPENCIL':
-            layout.prop(brush, "weight")
         layout.prop(brush, "size", slider=True)
         layout.prop(brush, "strength")
 
-        layout.separator()
-
-        # Frames
-        layout.label(text="Frames:")
+        # Layers
+        draw_gpencil_layer_active(context, layout)
 
-        layout.operator_context = 'INVOKE_REGION_WIN'
 
-        layout.operator("gpencil.blank_frame_add", text="Insert Blank in Active Layer", icon='ADD')
-        layout.operator("gpencil.blank_frame_add", text="Insert Blank in All Layers", icon='ADD').all_layers = True
+class VIEW3D_PT_gpencil_weight_context_menu(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'WINDOW'
+    bl_label = "Weight Paint Context Menu"
+    bl_ui_units_x = 12
 
-        layout.separator()
+    def draw(self, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
 
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Layer", icon='DUPLICATE')
-        layout.operator("gpencil.frame_duplicate", text="Duplicate All Layers", icon='DUPLICATE').mode = 'ALL'
+        layout = self.layout
 
-        layout.separator()
+        layout.prop(brush, "size", slider=True)
+        layout.prop(brush, "strength")
+        layout.prop(brush, "weight")
 
-        layout.operator("gpencil.delete", text="Delete Active Layer", icon='REMOVE').type = 'FRAME'
-        layout.operator("gpencil.active_frames_delete_all", text="Delete All Layers", icon='REMOVE')
+        # Layers
+        draw_gpencil_layer_active(context, layout)
 
 
 class VIEW3D_PT_gpencil_draw_context_menu(Panel):
     bl_space_type = 'VIEW_3D'
     bl_region_type = 'WINDOW'
     bl_label = "Draw Context Menu"
+    bl_ui_units_x = 12
 
     def draw(self, context):
-        brush = context.tool_settings.gpencil_paint.brush
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
         gp_settings = brush.gpencil_settings
 
         layout = self.layout
 
+        if brush.gpencil_tool not in {'ERASE', 'CUTTER', 'EYEDROPPER'} and settings.color_mode == 'VERTEXCOLOR':
+            split = layout.split(factor=0.1)
+            split.prop(brush, "color", text="")
+            split.template_color_picker(brush, "color", value_slider=True)
+
+            col = layout.column()
+            col.separator()
+            col.prop_menu_enum(gp_settings, "vertex_mode", text="Mode")
+            col.separator()
+
         if brush.gpencil_tool not in {'FILL', 'CUTTER'}:
             layout.prop(brush, "size", slider=True)
         if brush.gpencil_tool not in {'ERASE', 'FILL', 'CUTTER'}:
             layout.prop(gp_settings, "pen_strength")
 
-        layout.separator()
+        # Layers
+        draw_gpencil_layer_active(context, layout)
 
-        # Frames
-        layout.label(text="Frames:")
 
-        layout.operator_context = 'INVOKE_REGION_WIN'
+class VIEW3D_PT_gpencil_vertex_context_menu(Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'WINDOW'
+    bl_label = "Vertex Paint Context Menu"
+    bl_ui_units_x = 12
 
-        layout.operator("gpencil.blank_frame_add", text="Insert Blank in Active Layer", icon='ADD')
-        layout.operator("gpencil.blank_frame_add", text="Insert Blank in All Layers", icon='ADD').all_layers = True
+    def draw(self, context):
+        layout = self.layout
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+        gp_settings = brush.gpencil_settings
 
-        layout.separator()
+        col = layout.column()
 
-        layout.operator("gpencil.frame_duplicate", text="Duplicate Active Layer", icon='DUPLICATE')
-        layout.operator("gpencil.frame_duplicate", text="Duplicate All Layers", icon='DUPLICATE').mode = 'ALL'
+        if brush.gpencil_vertex_tool in {'DRAW', 'REPLACE'}:
+            split = layout.split(factor=0.1)
+            split.prop(brush, "color", text="")
+            split.template_color_picker(brush, "color", value_slider=True)
 
-        layout.separator()
+            col = layout.column()
+            col.separator()
+            col.prop_menu_enum(gp_settings, "vertex_mode", text="Mode")
+            col.separator()
+
+        row = col.row(align=True)
+        row.prop(brush, "size", text="Radius")
+        row.prop(gp_settings, "use_pressure", text="", icon='STYLUS_PRESSURE')
 
-        layout.operator("gpencil.delete", text="Delete Active Layer", icon='REMOVE').type = 'FRAME'
-        layout.operator("gpencil.active_frames_delete_all", text="Delete All Layers", icon='REMOVE')
+        if brush.gpencil_vertex_tool in {'DRAW', 'BLUR', 'SMEAR'}:
+            row = layout.row(align=True)
+            row.prop(gp_settings, "pen_strength", slider=True)
+            row.prop(gp_settings, "use_strength_pressure", text="", icon='STYLUS_PRESSURE')
+
+        # Layers
+        draw_gpencil_layer_active(context, layout)
 
 
 class VIEW3D_PT_paint_vertex_context_menu(Panel):
@@ -7037,6 +7185,17 @@ class TOPBAR_PT_gpencil_materials(GreasePencilMaterialsPanel, Panel):
         return ob and ob.type == 'GPENCIL'
 
 
+class TOPBAR_PT_gpencil_vertexcolor(GreasePencilVertexcolorPanel, Panel):
+    bl_space_type = 'VIEW_3D'
+    bl_region_type = 'HEADER'
+    bl_label = "Vertex Color"
+    bl_ui_units_x = 10
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        return ob and ob.type == 'GPENCIL'
+
 classes = (
     VIEW3D_HT_header,
     VIEW3D_HT_tool_header,
@@ -7163,6 +7322,7 @@ classes = (
     VIEW3D_MT_edit_gpencil_delete,
     VIEW3D_MT_edit_gpencil_showhide,
     VIEW3D_MT_weight_gpencil,
+    VIEW3D_MT_vertex_gpencil,
     VIEW3D_MT_gpencil_animation,
     VIEW3D_MT_gpencil_simplify,
     VIEW3D_MT_gpencil_copy_layer,
@@ -7249,10 +7409,13 @@ classes = (
     VIEW3D_PT_paint_vertex_context_menu,
     VIEW3D_PT_paint_texture_context_menu,
     VIEW3D_PT_paint_weight_context_menu,
+    VIEW3D_PT_gpencil_vertex_context_menu,
     VIEW3D_PT_gpencil_sculpt_context_menu,
+    VIEW3D_PT_gpencil_weight_context_menu,
     VIEW3D_PT_gpencil_draw_context_menu,
     VIEW3D_PT_sculpt_context_menu,
     TOPBAR_PT_gpencil_materials,
+    TOPBAR_PT_gpencil_vertexcolor,
     TOPBAR_PT_annotation_layers,
 )
 
index 1990e9a7260c4a7b9404189c8f0001ee26392509..9ad339b418c666258414051fc4fba24b77c37cdc 100644 (file)
@@ -21,6 +21,7 @@ from bpy.types import Menu, Panel, UIList
 from bl_ui.properties_grease_pencil_common import (
     GreasePencilSculptOptionsPanel,
     GreasePencilDisplayPanel,
+    GreasePencilBrushFalloff,
 )
 from bl_ui.properties_paint_common import (
     UnifiedPaintPanel,
@@ -71,6 +72,33 @@ class VIEW3D_MT_brush_context_menu(Menu):
             layout.operator("brush.reset")
 
 
+class VIEW3D_MT_brush_gpencil_context_menu(Menu):
+    bl_label = "Brush Specials"
+
+    def draw(self, context):
+        layout = self.layout
+        ts = context.tool_settings
+
+        settings = None
+        if context.mode == 'PAINT_GPENCIL':
+            settings = ts.gpencil_paint
+        if context.mode == 'SCULPT_GPENCIL':
+            settings = ts.gpencil_sculpt_paint
+        elif context.mode == 'WEIGHT_GPENCIL':
+            settings = ts.gpencil_weight_paint
+        elif context.mode == 'VERTEX_GPENCIL':
+            settings = ts.gpencil_vertex_paint
+
+        brush = getattr(settings, "brush", None)
+        # skip if no active brush
+        if not brush:
+            layout.label(text="No Brushes currently available", icon='INFO')
+            return
+
+        layout.operator("gpencil.brush_reset")
+        layout.operator("gpencil.brush_reset_all")
+
+
 class VIEW3D_MT_brush_context_menu_paint_modes(Menu):
     bl_label = "Enabled Modes"
 
@@ -1339,7 +1367,7 @@ class VIEW3D_PT_tools_particlemode_options_display(View3DPanel, Panel):
 # Grease Pencil drawing brushes
 
 
-class GreasePencilPanel:
+class GreasePencilPaintPanel:
     bl_context = ".greasepencil_paint"
     bl_category = "Tool"
 
@@ -1355,7 +1383,7 @@ class GreasePencilPanel:
             return True
 
 
-class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePencilPanel):
+class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePencilPaintPanel):
     bl_label = "Brushes"
 
     def draw(self, context):
@@ -1370,7 +1398,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePenci
         row.column().template_ID_preview(gpencil_paint, "brush", new="brush.add_gpencil", rows=3, cols=8)
 
         col = row.column()
-        col.operator("gpencil.brush_presets_create", icon='PRESET_NEW', text="")
+        col.menu("VIEW3D_MT_brush_gpencil_context_menu", icon='DOWNARROW_HLT', text="")
 
         if context.mode == 'PAINT_GPENCIL':
             brush = tool_settings.gpencil_paint.brush
@@ -1383,7 +1411,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_select(Panel, View3DPanel, GreasePenci
                     layout.row().prop(brush, "icon_filepath", text="")
 
 
-class VIEW3D_PT_tools_grease_pencil_brush_settings(Panel, View3DPanel, GreasePencilPanel):
+class VIEW3D_PT_tools_grease_pencil_brush_settings(Panel, View3DPanel, GreasePencilPaintPanel):
     bl_label = "Brush Settings"
 
     # What is the point of brush presets? Seems to serve the exact same purpose as brushes themselves??
@@ -1431,7 +1459,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
     @classmethod
     def poll(cls, context):
         brush = context.tool_settings.gpencil_paint.brush
-        return brush is not None and brush.gpencil_tool != 'ERASE'
+        return brush is not None and brush.gpencil_tool not in {'ERASE', 'TINT'}
 
     def draw(self, context):
         layout = self.layout
@@ -1463,11 +1491,11 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
                     ma = brush.gpencil_settings.material
 
                 col.separator()
+                col.prop(gp_settings, "hardeness", slider=True)
                 subcol = col.column(align=True)
                 if ma and ma.grease_pencil.mode == 'LINE':
                     subcol.enabled = False
-                subcol.prop(gp_settings, "gradient_factor", slider=True)
-                subcol.prop(gp_settings, "gradient_shape")
+                subcol.prop(gp_settings, "aspect")
 
             elif brush.gpencil_tool == 'FILL':
                 row = col.row(align=True)
@@ -1479,6 +1507,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
                     col.prop(gp_settings, "show_fill", text="Ignore Transparent Strokes")
                     col.prop(gp_settings, "fill_threshold", text="Threshold")
 
+
 class VIEW3D_PT_tools_grease_pencil_brush_stroke(Panel, View3DPanel):
     bl_context = ".greasepencil_paint"
     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_settings'
@@ -1545,7 +1574,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_post_processing(View3DPanel, Panel):
     @classmethod
     def poll(cls, context):
         brush = context.tool_settings.gpencil_paint.brush
-        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL'}
+        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL', 'TINT'}
 
     def draw_header(self, context):
         if self.is_popover:
@@ -1575,13 +1604,8 @@ class VIEW3D_PT_tools_grease_pencil_brush_post_processing(View3DPanel, Panel):
         col1.prop(gp_settings, "pen_smooth_factor")
         col1.prop(gp_settings, "pen_smooth_steps")
 
-        col1 = col.column(align=True)
-        col1.prop(gp_settings, "pen_thick_smooth_factor")
-        col1.prop(gp_settings, "pen_thick_smooth_steps", text="Iterations")
-
         col1 = col.column(align=True)
         col1.prop(gp_settings, "pen_subdivision_steps")
-        col1.prop(gp_settings, "random_subdiv", text="Randomness", slider=True)
 
         col1 = col.column(align=True)
         col1.prop(gp_settings, "simplify_factor")
@@ -1600,7 +1624,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_random(View3DPanel, Panel):
     @classmethod
     def poll(cls, context):
         brush = context.tool_settings.gpencil_paint.brush
-        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL'}
+        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL', 'TINT'}
 
     def draw_header(self, context):
         if self.is_popover:
@@ -1646,7 +1670,7 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves(View3DPanel, Panel):
     @classmethod
     def poll(cls, context):
         brush = context.tool_settings.gpencil_paint.brush
-        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL'}
+        return brush is not None and brush.gpencil_tool not in {'ERASE', 'FILL', 'TINT'}
 
     def draw(self, context):
         pass
@@ -1703,6 +1727,24 @@ class VIEW3D_PT_tools_grease_pencil_brushcurves_jitter(View3DPanel, Panel):
                                       use_negative_slope=True)
 
 
+class VIEW3D_PT_tools_grease_pencil_brush_paint_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
+    bl_context = ".greasepencil_paint"
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
+        if brush is None:
+            return False
+
+        tool = brush.gpencil_tool
+
+        return (settings and settings.brush and settings.brush.curve and tool == 'TINT')
+
+
 # Grease Pencil stroke interpolation tools
 class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
     bl_space_type = 'VIEW_3D'
@@ -1751,25 +1793,49 @@ class VIEW3D_PT_tools_grease_pencil_interpolate(Panel):
 
 
 # Grease Pencil stroke sculpting tools
-
-class VIEW3D_PT_tools_grease_pencil_sculpt_select(Panel, View3DPanel):
+class GreasePencilSculptPanel:
     bl_context = ".greasepencil_sculpt"
-    bl_label = "Brushes"
     bl_category = "Tool"
 
+    @classmethod
+    def poll(cls, context):
+        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
+            if context.gpencil_data is None:
+                return False
+
+            gpd = context.gpencil_data
+            return bool(gpd.is_stroke_sculpt_mode)
+        else:
+            return True
+
+
+class VIEW3D_PT_tools_grease_pencil_sculpt_select(Panel, View3DPanel, GreasePencilSculptPanel):
+    bl_label = "Brushes"
+
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        settings = context.tool_settings.gpencil_sculpt
+        tool_settings = context.scene.tool_settings
+        gpencil_paint = tool_settings.gpencil_sculpt_paint
 
-        layout.template_icon_view(settings, "sculpt_tool", show_labels=True)
+        row = layout.row()
+        row.column().template_ID_preview(gpencil_paint, "brush", new="brush.add_gpencil", rows=3, cols=8)
 
+        col = row.column()
+        col.menu("VIEW3D_MT_brush_gpencil_context_menu", icon='DOWNARROW_HLT', text="")
 
-class VIEW3D_PT_tools_grease_pencil_sculpt_settings(Panel, View3DPanel):
-    bl_context = ".greasepencil_sculpt"
-    bl_category = "Tool"
+        if context.mode == 'SCULPT_GPENCIL':
+            brush = tool_settings.gpencil_sculpt_paint.brush
+            if brush is not None:
+                col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")
+
+                if(brush.use_custom_icon):
+                    layout.row().prop(brush, "icon_filepath", text="")
+
+
+class VIEW3D_PT_tools_grease_pencil_sculpt_settings(Panel, View3DPanel, GreasePencilSculptPanel):
     bl_label = "Brush Settings"
 
     def draw(self, context):
@@ -1777,7 +1843,8 @@ class VIEW3D_PT_tools_grease_pencil_sculpt_settings(Panel, View3DPanel):
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        settings = context.tool_settings.gpencil_sculpt
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_sculpt_paint
         brush = settings.brush
 
         if not self.is_popover:
@@ -1786,27 +1853,63 @@ class VIEW3D_PT_tools_grease_pencil_sculpt_settings(Panel, View3DPanel):
             )
             brush_basic_gpencil_sculpt_settings(layout, context, brush)
 
-# Grease Pencil weight painting tools
 
+class VIEW3D_PT_tools_grease_pencil_brush_sculpt_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
+    bl_context = ".greasepencil_sculpt"
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_sculpt_paint
+        return (settings and settings.brush and settings.brush.curve)
 
-class VIEW3D_PT_tools_grease_pencil_weight_paint_select(View3DPanel, Panel):
+
+# Grease Pencil weight painting tools
+class GreasePencilWeightPanel:
     bl_context = ".greasepencil_weight"
-    bl_label = "Brushes"
     bl_category = "Tool"
 
+    @classmethod
+    def poll(cls, context):
+        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
+            if context.gpencil_data is None:
+                return False
+
+            gpd = context.gpencil_data
+            return bool(gpd.is_stroke_weight_mode)
+        else:
+            return True
+
+
+class VIEW3D_PT_tools_grease_pencil_weight_paint_select(View3DPanel, Panel, GreasePencilWeightPanel):
+    bl_label = "Brushes"
+
     def draw(self, context):
         layout = self.layout
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        settings = context.tool_settings.gpencil_sculpt
+        tool_settings = context.scene.tool_settings
+        gpencil_paint = tool_settings.gpencil_weight_paint
 
-        layout.template_icon_view(settings, "weight_tool", show_labels=True)
+        row = layout.row()
+        row.column().template_ID_preview(gpencil_paint, "brush", new="brush.add_gpencil", rows=3, cols=8)
 
+        col = row.column()
+        col.menu("VIEW3D_MT_brush_gpencil_context_menu", icon='DOWNARROW_HLT', text="")
 
-class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel):
-    bl_context = ".greasepencil_weight"
-    bl_category = "Tool"
+        if context.mode == 'WEIGHT_GPENCIL':
+            brush = tool_settings.gpencil_weight_paint.brush
+            if brush is not None:
+                col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")
+
+                if(brush.use_custom_icon):
+                    layout.row().prop(brush, "icon_filepath", text="")
+
+
+class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel, GreasePencilWeightPanel):
     bl_label = "Brush Settings"
 
     def draw(self, context):
@@ -1814,7 +1917,8 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel):
         layout.use_property_split = True
         layout.use_property_decorate = False
 
-        settings = context.tool_settings.gpencil_sculpt
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_weight_paint
         brush = settings.brush
 
         if not self.is_popover:
@@ -1824,6 +1928,272 @@ class VIEW3D_PT_tools_grease_pencil_weight_paint_settings(Panel, View3DPanel):
             brush_basic_gpencil_weight_settings(layout, context, brush)
 
 
+class VIEW3D_PT_tools_grease_pencil_brush_weight_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
+    bl_context = ".greasepencil_weight"
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_weight_paint
+        brush = settings.brush
+        return (settings and settings.brush and settings.brush.curve)
+
+
+# Grease Pencil vertex painting tools
+class GreasePencilVertexPanel:
+    bl_context = ".greasepencil_vertex"
+    bl_category = "Tool"
+
+    @classmethod
+    def poll(cls, context):
+        if context.space_data.type in ('VIEW_3D', 'PROPERTIES'):
+            if context.gpencil_data is None:
+                return False
+
+            gpd = context.gpencil_data
+            return bool(gpd.is_stroke_vertex_mode)
+        else:
+            return True
+
+
+class VIEW3D_PT_tools_grease_pencil_vertex_paint_select(View3DPanel, Panel, GreasePencilVertexPanel):
+    bl_label = "Brushes"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        tool_settings = context.scene.tool_settings
+        gpencil_paint = tool_settings.gpencil_vertex_paint
+
+        row = layout.row()
+        row.column().template_ID_preview(gpencil_paint, "brush", new="brush.add_gpencil", rows=3, cols=8)
+
+        col = row.column()
+        col.menu("VIEW3D_MT_brush_gpencil_context_menu", icon='DOWNARROW_HLT', text="")
+
+        if context.mode == 'VERTEX_GPENCIL':
+            brush = tool_settings.gpencil_vertex_paint.brush
+            if brush is not None:
+                col.prop(brush, "use_custom_icon", toggle=True, icon='FILE_IMAGE', text="")
+
+                if(brush.use_custom_icon):
+                    layout.row().prop(brush, "icon_filepath", text="")
+
+
+class VIEW3D_PT_tools_grease_pencil_vertex_paint_settings(Panel, View3DPanel, GreasePencilVertexPanel):
+    bl_label = "Brush Settings"
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+
+        tool_settings = context.scene.tool_settings
+        settings = tool_settings.gpencil_vertex_paint
+        brush = settings.brush
+
+        if not self.is_popover:
+            from bl_ui.properties_paint_common import (
+                brush_basic_gpencil_vertex_settings,
+            )
+            brush_basic_gpencil_vertex_settings(layout, context, brush)
+
+
+class VIEW3D_PT_tools_grease_pencil_brush_vertex_color(View3DPanel, Panel):
+    bl_context = ".greasepencil_vertex"
+    bl_label = "Color"
+    bl_category = "Tool"
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+
+        if ob is None or brush is None:
+            return False
+
+        if context.region.type == 'TOOL_HEADER' or brush.gpencil_vertex_tool in {'BLUR', 'AVERAGE', 'SMEAR'}:
+            return False
+
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+        gp_settings = brush.gpencil_settings
+
+        col = layout.column()
+
+        col.template_color_picker(brush, "color", value_slider=True)
+
+        sub_row = col.row(align=True)
+        sub_row.prop(brush, "color", text="")
+        sub_row.prop(brush, "secondary_color", text="")
+
+        sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
+
+        col.prop(gp_settings, "vertex_mode", text="Mode")
+
+
+class VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff(GreasePencilBrushFalloff, Panel, View3DPaintPanel):
+    bl_context = ".greasepencil_vertex"
+    bl_label = "Falloff"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        return (settings and settings.brush and settings.brush.curve)
+
+
+class VIEW3D_PT_tools_grease_pencil_brush_vertex_palette(View3DPanel, Panel):
+    bl_context = ".greasepencil_vertex"
+    bl_label = "Palette"
+    bl_category = "Tool"
+    bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_vertex_color'
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+        brush = settings.brush
+
+        if ob is None or brush is None:
+            return False
+
+        if brush.gpencil_vertex_tool in {'BLUR', 'AVERAGE', 'SMEAR'}:
+            return False
+
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        ts = context.tool_settings
+        settings = ts.gpencil_vertex_paint
+
+        col = layout.column()
+
+        row = col.row(align=True)
+        row.template_ID(settings, "palette", new="palette.new")
+        if settings.palette:
+            col.template_palette(settings, "palette", color=True)
+
+
+class VIEW3D_PT_tools_grease_pencil_brush_mixcolor(View3DPanel, Panel):
+    bl_context = ".greasepencil_paint"
+    bl_label = "Color"
+    bl_category = "Tool"
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
+
+        if ob is None or brush is None:
+            return False
+
+        if context.region.type == 'TOOL_HEADER':
+            return False
+
+        if brush.gpencil_tool == 'TINT':
+            return True
+
+        if brush.gpencil_tool not in {'DRAW', 'FILL'}:
+            return False
+
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
+        gp_settings = brush.gpencil_settings
+
+        if brush.gpencil_tool != 'TINT':
+            row = layout.row()
+            row.prop(settings, "color_mode", expand=True)
+
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        col = layout.column()
+        col.enabled = settings.color_mode == 'VERTEXCOLOR' or brush.gpencil_tool == 'TINT'
+
+        col.template_color_picker(brush, "color", value_slider=True)
+
+        sub_row = col.row(align=True)
+        sub_row.prop(brush, "color", text="")
+        sub_row.prop(brush, "secondary_color", text="")
+
+        sub_row.operator("gpencil.tint_flip", icon='FILE_REFRESH', text="")
+
+        if brush.gpencil_tool in {'DRAW', 'FILL'}:
+            col.prop(gp_settings, "vertex_mode", text="Mode")
+            col.prop(gp_settings, "vertex_color_factor", slider=True, text="Mix Factor")
+
+        if brush.gpencil_tool == 'TINT':
+            col.prop(gp_settings, "vertex_mode", text="Mode")
+
+
+class VIEW3D_PT_tools_grease_pencil_brush_mix_palette(View3DPanel, Panel):
+    bl_context = ".greasepencil_paint"
+    bl_label = "Palette"
+    bl_category = "Tool"
+    bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_brush_mixcolor'
+    bl_options = {'DEFAULT_CLOSED'}
+
+    @classmethod
+    def poll(cls, context):
+        ob = context.object
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
+
+        if ob is None or brush is None:
+            return False
+
+        if brush.gpencil_tool == 'TINT':
+            return True
+
+        if brush.gpencil_tool not in {'DRAW', 'FILL'}:
+            return False
+
+        return True
+
+    def draw(self, context):
+        layout = self.layout
+        layout.use_property_split = True
+        layout.use_property_decorate = False
+        ts = context.tool_settings
+        settings = ts.gpencil_paint
+        brush = settings.brush
+
+        col = layout.column()
+        col.enabled = settings.color_mode == 'VERTEXCOLOR' or brush.gpencil_tool == 'TINT'
+
+        row = col.row(align=True)
+        row.template_ID(settings, "palette", new="palette.new")
+        if settings.palette:
+            col.template_palette(settings, "palette", color=True)
+
+
 class VIEW3D_PT_tools_grease_pencil_sculpt_options(GreasePencilSculptOptionsPanel, Panel, View3DPanel):
     bl_context = ".greasepencil_sculpt"
     bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_sculpt_settings'
@@ -1852,6 +2222,11 @@ class VIEW3D_PT_tools_grease_pencil_weight_appearance(GreasePencilDisplayPanel,
     bl_category = "Tool"
     bl_label = "Cursor"
 
+class VIEW3D_PT_tools_grease_pencil_vertex_appearance(GreasePencilDisplayPanel, Panel, View3DPanel):
+    bl_context = ".greasepencil_vertex"
+    bl_parent_id = 'VIEW3D_PT_tools_grease_pencil_vertex_paint_settings'
+    bl_category = "Tool"
+    bl_label = "Cursor"
 
 class VIEW3D_PT_gpencil_brush_presets(Panel, PresetPanel):
     """Brush settings"""
@@ -1863,6 +2238,7 @@ class VIEW3D_PT_gpencil_brush_presets(Panel, PresetPanel):
 
 classes = (
     VIEW3D_MT_brush_context_menu,
+    VIEW3D_MT_brush_gpencil_context_menu,
     VIEW3D_MT_brush_context_menu_paint_modes,
     VIEW3D_PT_tools_object_options,
     VIEW3D_PT_tools_object_options_transform,
@@ -1940,7 +2316,19 @@ classes = (
     VIEW3D_PT_tools_grease_pencil_weight_paint_select,
     VIEW3D_PT_tools_grease_pencil_weight_paint_settings,
     VIEW3D_PT_tools_grease_pencil_weight_appearance,
+    VIEW3D_PT_tools_grease_pencil_vertex_paint_select,
+    VIEW3D_PT_tools_grease_pencil_vertex_paint_settings,
+    VIEW3D_PT_tools_grease_pencil_vertex_appearance,
     VIEW3D_PT_tools_grease_pencil_interpolate,
+    VIEW3D_PT_tools_grease_pencil_brush_mixcolor,
+    VIEW3D_PT_tools_grease_pencil_brush_mix_palette,
+
+    VIEW3D_PT_tools_grease_pencil_brush_paint_falloff,
+    VIEW3D_PT_tools_grease_pencil_brush_sculpt_falloff,
+    VIEW3D_PT_tools_grease_pencil_brush_weight_falloff,
+    VIEW3D_PT_tools_grease_pencil_brush_vertex_color,
+    VIEW3D_PT_tools_grease_pencil_brush_vertex_palette,
+    VIEW3D_PT_tools_grease_pencil_brush_vertex_falloff,
 )
 
 if __name__ == "__main__":  # only for live edit.
index 9e4453d21fe30af59cf5302ccf13b91adaf28b3a..233c385c24798532b3c7693d9c6e6a2d58f06e15 100644 (file)
@@ -27,7 +27,7 @@
  * \note Use #STRINGIFY() rather than defining with quotes.
  */
 #define BLENDER_VERSION 283
-#define BLENDER_SUBVERSION 6
+#define BLENDER_SUBVERSION 7
 /** Several breakages with 280, e.g. collections vs layers. */
 #define BLENDER_MINVERSION 280
 #define BLENDER_MINSUBVERSION 0
index 6644a3f0231c8e5217cd0ff3642540acbd66cc01..a97263a6523cf710d59397358ff40cdfb6772df0 100644 (file)
@@ -46,13 +46,22 @@ void BKE_brush_system_exit(void);
 
 /* datablock functions */
 struct Brush *BKE_brush_add(struct Main *bmain, const char *name, const eObjectMode ob_mode);
-struct Brush *BKE_brush_add_gpencil(struct Main *bmain, struct ToolSettings *ts, const char *name);
+struct Brush *BKE_brush_add_gpencil(struct Main *bmain,
+                                    struct ToolSettings *ts,
+                                    const char *name,
+                                    eObjectMode mode);
+bool BKE_brush_delete(struct Main *bmain, struct Brush *brush);
 void BKE_brush_init_gpencil_settings(struct Brush *brush);
 struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode);
 struct Brush *BKE_brush_copy(struct Main *bmain, const struct Brush *brush);
 
 void BKE_brush_sculpt_reset(struct Brush *brush);
-void BKE_brush_gpencil_presets(struct Main *bmain, struct ToolSettings *ts);
+
+void BKE_brush_gpencil_paint_presets(struct Main *bmain, struct ToolSettings *ts);
+void BKE_brush_gpencil_vertex_presets(struct Main *bmain, struct ToolSettings *ts);
+void BKE_brush_gpencil_sculpt_presets(struct Main *bmain, struct ToolSettings *ts);
+void BKE_brush_gpencil_weight_presets(struct Main *bmain, struct ToolSettings *ts);
+void BKE_gpencil_brush_preset_set(struct Main *bmain, struct Brush *brush, const short type);
 
 /* image icon function */
 struct ImBuf *get_brush_icon(struct Brush *brush);
index 88a27b6796335d6ee33f4a3f3b24960236db80d3..9e2a124491ce5013b41bcb78fae4f5ee070b30ba 100644 (file)
@@ -115,8 +115,9 @@ typedef enum eContextObjectMode {
   CTX_MODE_EDIT_GPENCIL,
   CTX_MODE_SCULPT_GPENCIL,
   CTX_MODE_WEIGHT_GPENCIL,
+  CTX_MODE_VERTEX_GPENCIL,
 } eContextObjectMode;
-#define CTX_MODE_NUM (CTX_MODE_WEIGHT_GPENCIL + 1)
+#define CTX_MODE_NUM (CTX_MODE_VERTEX_GPENCIL + 1)
 
 /* Context */
 
index 1a186d2d6829a38d6b381d98057af9a84e079c8c..9d382775df79f545d217446122062c0ce7d44492 100644 (file)
@@ -32,19 +32,22 @@ struct BoundBox;
 struct Brush;
 struct CurveMapping;
 struct Depsgraph;
+struct GHash;
 struct ListBase;
 struct Main;
 struct Material;
 struct Object;
 struct Scene;
+struct SpaceImage;
 struct ToolSettings;
 struct bDeformGroup;
 struct bGPDframe;
 struct bGPDlayer;
+struct bGPDlayer_Mask;
 struct bGPDspoint;
 struct bGPDstroke;
 struct bGPdata;
-
+struct MaterialGPencilStyle;
 struct MDeformVert;
 
 #define GPENCIL_SIMPLIFY(scene) ((scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_ENABLE))
@@ -54,18 +57,33 @@ struct MDeformVert;
 #define GPENCIL_SIMPLIFY_FILL(scene, playing) \
   ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
     (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FILL)))
-#define GPENCIL_SIMPLIFY_MODIF(scene, playing) \
-  ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
-    (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_MODIFIER)))
+#define GPENCIL_SIMPLIFY_MODIF(scene) \
+  ((GPENCIL_SIMPLIFY(scene) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_MODIFIER)))
 #define GPENCIL_SIMPLIFY_FX(scene, playing) \
   ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
     (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_FX)))
-#define GPENCIL_SIMPLIFY_BLEND(scene, playing) \
-  ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
-    (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_BLEND)))
-#define GPENCIL_SIMPLIFY_TINT(scene, playing) \
-  ((GPENCIL_SIMPLIFY_ONPLAY(playing) && (GPENCIL_SIMPLIFY(scene)) && \
-    (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT)))
+#define GPENCIL_SIMPLIFY_TINT(scene) \
+  ((GPENCIL_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_TINT))
+#define GPENCIL_SIMPLIFY_AA(scene) \
+  ((GPENCIL_SIMPLIFY(scene)) && (scene->r.simplify_gpencil & SIMPLIFY_GPENCIL_AA))
+
+/* Vertex Color macros. */
+#define GPENCIL_USE_VERTEX_COLOR(toolsettings) \
+  ((toolsettings->gp_paint->mode == GPPAINT_FLAG_USE_VERTEXCOLOR))
+#define GPENCIL_USE_VERTEX_COLOR_STROKE(toolsettings, brush) \
+  ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \
+    ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \
+     (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))))
+#define GPENCIL_USE_VERTEX_COLOR_FILL(toolsettings, brush) \
+  ((GPENCIL_USE_VERTEX_COLOR(toolsettings) && \
+    ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \
+     (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))))
+#define GPENCIL_TINT_VERTEX_COLOR_STROKE(brush) \
+  ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_STROKE) || \
+   (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))
+#define GPENCIL_TINT_VERTEX_COLOR_FILL(brush) \
+  ((brush->gpencil_settings->vertex_mode == GPPAINT_MODE_FILL) || \
+   (brush->gpencil_settings->vertex_mode == GPPAINT_MODE_BOTH))
 
 /* ------------ Grease-Pencil API ------------------ */
 
@@ -75,8 +93,9 @@ void BKE_gpencil_free_stroke(struct bGPDstroke *gps);
 bool BKE_gpencil_free_strokes(struct bGPDframe *gpf);
 void BKE_gpencil_free_frames(struct bGPDlayer *gpl);
 void BKE_gpencil_free_layers(struct ListBase *list);
-bool BKE_gpencil_free_frame_runtime_data(struct bGPDframe *gpf_eval);
 void BKE_gpencil_free(struct bGPdata *gpd, bool free_all);
+void BKE_gpencil_eval_delete(struct bGPdata *gpd_eval);
+void BKE_gpencil_free_layer_masks(struct bGPDlayer *gpl);
 
 void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
 void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
@@ -91,10 +110,11 @@ struct bGPdata *BKE_gpencil_data_addnew(struct Main *bmain, const char name[]);
 struct bGPDframe *BKE_gpencil_frame_duplicate(const struct bGPDframe *gpf_src);
 struct bGPDlayer *BKE_gpencil_layer_duplicate(const struct bGPDlayer *gpl_src);
 void BKE_gpencil_frame_copy_strokes(struct bGPDframe *gpf_src, struct bGPDframe *gpf_dst);
-struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src);
+struct bGPDstroke *BKE_gpencil_stroke_duplicate(struct bGPDstroke *gps_src, const bool dup_points);
 
 void BKE_gpencil_copy_data(struct bGPdata *gpd_dst, const struct bGPdata *gpd_src, const int flag);
 struct bGPdata *BKE_gpencil_copy(struct Main *bmain, const struct bGPdata *gpd);
+
 struct bGPdata *BKE_gpencil_data_duplicate(struct Main *bmain,
                                            const struct bGPdata *gpd,
                                            bool internal_copy);
@@ -109,6 +129,11 @@ bool BKE_gpencil_material_index_used(struct bGPdata *gpd, int index);
 void BKE_gpencil_material_remap(struct bGPdata *gpd,
                                 const unsigned int *remap,
                                 unsigned int remap_len);
+bool BKE_gpencil_merge_materials_table_get(struct Object *ob,
+                                           const float hue_threshold,
+                                           const float sat_threshold,
+                                           const float val_threshold,
+                                           struct GHash *r_mat_table);
 
 /* statistics functions */
 void BKE_gpencil_stats_update(struct bGPdata *gpd);
@@ -124,12 +149,11 @@ void BKE_gpencil_stroke_add_points(struct bGPDstroke *gps,
                                    const int totpoints,
                                    const float mat[4][4]);
 
-struct bGPDstroke *BKE_gpencil_add_stroke(struct bGPDframe *gpf,
-                                          int mat_idx,
-                                          int totpoints,
-                                          short thickness);
+struct bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness);
+struct bGPDstroke *BKE_gpencil_stroke_add(
+    struct bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head);
 
-struct bGPDstroke *BKE_gpencil_add_stroke_existing_style(struct bGPDframe *gpf,
+struct bGPDstroke *BKE_gpencil_stroke_add_existing_style(struct bGPDframe *gpf,
                                                          struct bGPDstroke *existing,
                                                          int mat_idx,
                                                          int totpoints,
@@ -139,7 +163,7 @@ struct bGPDstroke *BKE_gpencil_add_stroke_existing_style(struct bGPDframe *gpf,
 #define GPENCIL_ALPHA_OPACITY_THRESH 0.001f
 #define GPENCIL_STRENGTH_MIN 0.003f
 
-bool gpencil_layer_is_editable(const struct bGPDlayer *gpl);
+bool BKE_gpencil_layer_is_editable(const struct bGPDlayer *gpl);
 
 /* How gpencil_layer_getframe() should behave when there
  * is no existing GP-Frame on the frame requested.
@@ -154,17 +178,25 @@ typedef enum eGP_GetFrame_Mode {
   GP_GETFRAME_ADD_COPY = 2,
 } eGP_GetFrame_Mode;
 
-struct bGPDframe *BKE_gpencil_layer_getframe(struct bGPDlayer *gpl,
-                                             int cframe,
-                                             eGP_GetFrame_Mode addnew);
-struct bGPDframe *BKE_gpencil_layer_find_frame(struct bGPDlayer *gpl, int cframe);
-bool BKE_gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
+struct bGPDframe *BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl,
+                                              int cframe,
+                                              eGP_GetFrame_Mode addnew);
+struct bGPDframe *BKE_gpencil_layer_frame_find(struct bGPDlayer *gpl, int cframe);
+bool BKE_gpencil_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf);
 
-struct bGPDlayer *BKE_gpencil_layer_getactive(struct bGPdata *gpd);
-void BKE_gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
+struct bGPDlayer *BKE_gpencil_layer_named_get(struct bGPdata *gpd, const char *name);
+struct bGPDlayer *BKE_gpencil_layer_active_get(struct bGPdata *gpd);
+void BKE_gpencil_layer_active_set(struct bGPdata *gpd, struct bGPDlayer *active);
 void BKE_gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
 void BKE_gpencil_layer_autolock_set(struct bGPdata *gpd, const bool unlock);
 
+struct bGPDlayer_Mask *BKE_gpencil_layer_mask_add(struct bGPDlayer *gpl, const char *name);
+void BKE_gpencil_layer_mask_remove(struct bGPDlayer *gpl, struct bGPDlayer_Mask *mask);
+void BKE_gpencil_layer_mask_remove_ref(struct bGPdata *gpd, const char *name);
+struct bGPDlayer_Mask *BKE_gpencil_layer_mask_named_get(struct bGPDlayer *gpl, const char *name);
+void BKE_gpencil_layer_mask_sort(struct bGPdata *gpd, struct bGPDlayer *gpl);
+void BKE_gpencil_layer_mask_sort_all(struct bGPdata *gpd);
+
 /* Brush */
 struct Material *BKE_gpencil_brush_material_get(struct Brush *brush);
 void BKE_gpencil_brush_material_set(struct Brush *brush, struct Material *material);
@@ -183,9 +215,9 @@ struct Material *BKE_gpencil_object_material_new(struct Main *bmain,
                                                  const char *name,
                                                  int *r_index);
 
-int BKE_gpencil_object_material_get_index(struct Object *ob, struct Material *ma);
+int BKE_gpencil_object_material_index_get(struct Object *ob, struct Material *ma);
 
-struct Material *BKE_gpencil_object_material_get_from_brush(struct Object *ob,
+struct Material *BKE_gpencil_object_material_from_brush_get(struct Object *ob,
                                                             struct Brush *brush);
 int BKE_gpencil_object_material_get_index_from_brush(struct Object *ob, struct Brush *brush);
 
@@ -206,22 +238,23 @@ bool BKE_gpencil_stroke_select_check(const struct bGPDstroke *gps);
 
 struct BoundBox *BKE_gpencil_boundbox_get(struct Object *ob);
 void BKE_gpencil_centroid_3d(struct bGPdata *gpd, float r_centroid[3]);
+void BKE_gpencil_stroke_boundingbox_calc(struct bGPDstroke *gps);
 
 /* vertex groups */
 void BKE_gpencil_dvert_ensure(struct bGPDstroke *gps);
 void BKE_gpencil_vgroup_remove(struct Object *ob, struct bDeformGroup *defgroup);
 void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst);
 
-/* GPencil geometry evaluation */
-void BKE_gpencil_eval_geometry(struct Depsgraph *depsgraph, struct bGPdata *gpd);
+/* Set active frame by layer. */
+void BKE_gpencil_frame_active_set(struct Depsgraph *depsgraph, struct bGPdata *gpd);
 
 /* stroke geometry utilities */
 void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
-void BKE_gpencil_simplify_stroke(struct bGPDstroke *gps, float factor);
-void BKE_gpencil_simplify_fixed(struct bGPDstroke *gps);
-void BKE_gpencil_subdivide(struct bGPDstroke *gps, int level, int flag);
-bool BKE_gpencil_trim_stroke(struct bGPDstroke *gps);
-void BKE_gpencil_merge_distance_stroke(struct bGPDframe *gpf,
+void BKE_gpencil_stroke_simplify_adaptive(struct bGPDstroke *gps, float factor);
+void BKE_gpencil_stroke_simplify_fixed(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_subdivide(struct bGPDstroke *gps, int level, int type);
+bool BKE_gpencil_stroke_trim(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_merge_distance(struct bGPDframe *gpf,
                                        struct bGPDstroke *gps,
                                        const float threshold,
                                        const bool use_unselected);
@@ -237,31 +270,33 @@ void BKE_gpencil_stroke_2d_flat_ref(const struct bGPDspoint *ref_points,
                                     float (*points2d)[2],
                                     const float scale,
                                     int *r_direction);
-void BKE_gpencil_triangulate_stroke_fill(struct bGPdata *gpd, struct bGPDstroke *gps);
+void BKE_gpencil_stroke_fill_triangulate(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_geometry_update(struct bGPDstroke *gps);
+void BKE_gpencil_stroke_uv_update(struct bGPDstroke *gps);
 
 void BKE_gpencil_transform(struct bGPdata *gpd, float mat[4][4]);
 
-bool BKE_gpencil_sample_stroke(struct bGPDstroke *gps, const float dist, const bool select);
-bool BKE_gpencil_smooth_stroke(struct bGPDstroke *gps, int i, float inf);
-bool BKE_gpencil_smooth_stroke_strength(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_smooth_stroke_thickness(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_smooth_stroke_uv(struct bGPDstroke *gps, int point_index, float influence);
-bool BKE_gpencil_close_stroke(struct bGPDstroke *gps);
+bool BKE_gpencil_stroke_sample(struct bGPDstroke *gps, const float dist, const bool select);
+bool BKE_gpencil_stroke_smooth(struct bGPDstroke *gps, int i, float inf);
+bool BKE_gpencil_stroke_smooth_strength(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_smooth_thickness(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_smooth_uv(struct bGPDstroke *gps, int point_index, float influence);
+bool BKE_gpencil_stroke_close(struct bGPDstroke *gps);
 void BKE_gpencil_dissolve_points(struct bGPDframe *gpf, struct bGPDstroke *gps, const short tag);
 
-bool BKE_gpencil_stretch_stroke(struct bGPDstroke *gps, const float dist, const float tip_length);
-bool BKE_gpencil_trim_stroke_points(struct bGPDstroke *gps,
+bool BKE_gpencil_stroke_stretch(struct bGPDstroke *gps, const float dist, const float tip_length);
+bool BKE_gpencil_stroke_trim_points(struct bGPDstroke *gps,
                                     const int index_from,
                                     const int index_to);
-bool BKE_gpencil_split_stroke(struct bGPDframe *gpf,
+bool BKE_gpencil_stroke_split(struct bGPDframe *gpf,
                               struct bGPDstroke *gps,
                               const int before_index,
                               struct bGPDstroke **remaining_gps);
-bool BKE_gpencil_shrink_stroke(struct bGPDstroke *gps, const float dist);
+bool BKE_gpencil_stroke_shrink(struct bGPDstroke *gps, const float dist);
 
 float BKE_gpencil_stroke_length(const struct bGPDstroke *gps, bool use_3d);
 
-void BKE_gpencil_get_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe);
+void BKE_gpencil_frame_range_selected(struct bGPDlayer *gpl, int *r_initframe, int *r_endframe);
 float BKE_gpencil_multiframe_falloff_calc(
     struct bGPDframe *gpf, int actnum, int f_init, int f_end, struct CurveMapping *cur_falloff);
 
@@ -273,9 +308,41 @@ void BKE_gpencil_convert_curve(struct Main *bmain,
                                const bool use_collections,
                                const bool only_stroke);
 
+void BKE_gpencil_palette_ensure(struct Main *bmain, struct Scene *scene);
+
+bool BKE_gpencil_from_image(struct SpaceImage *sima,
+                            struct bGPDframe *gpf,
+                            const float size,
+                            const bool mask);
+
+/* Iterator */
+/* frame & stroke are NULL if it is a layer callback. */
+typedef void (*gpIterCb)(struct bGPDlayer *layer,
+                         struct bGPDframe *frame,
+                         struct bGPDstroke *stroke,
+                         void *thunk);
+
+void BKE_gpencil_visible_stroke_iter(struct Object *ob,
+                                     gpIterCb layer_cb,
+                                     gpIterCb stroke_cb,
+                                     void *thunk,
+                                     bool do_onion,
+                                     int cfra);
+
 extern void (*BKE_gpencil_batch_cache_dirty_tag_cb)(struct bGPdata *gpd);
 extern void (*BKE_gpencil_batch_cache_free_cb)(struct bGPdata *gpd);
 
+void BKE_gpencil_frame_original_pointers_update(const struct bGPDframe *gpf_orig,
+                                                const struct bGPDframe *gpf_eval);
+void BKE_gpencil_update_orig_pointers(const struct Object *ob_orig, const struct Object *ob_eval);
+
+void BKE_gpencil_parent_matrix_get(const struct Depsgraph *depsgraph,
+                                   struct Object *obact,
+                                   struct bGPDlayer *gpl,
+                                   float diff_mat[4][4]);
+
+void BKE_gpencil_update_layer_parent(const struct Depsgraph *depsgraph, struct Object *ob);
+
 #ifdef __cplusplus
 }
 #endif
index 3a1e729e4deec56465a68fc31935a1b487b42bee..b48a62845678574d5025b1d899b4b74febf9c3c5 100644 (file)
@@ -141,20 +141,10 @@ typedef struct GpencilModifierTypeInfo {
   /**
    * Callback for GP "geometry" modifiers that create extra geometry
    * in the frame (e.g. Array)
-   *
-   * The gpf parameter contains the GP frame/strokes to operate on. This is
-   * usually a copy of the original (unmodified and saved to files) stroke data.
-   * Modifiers should only add any generated strokes to this frame (and not one accessed
-   * via the gpl parameter).
-   *
-   * The modifier_index parameter indicates where the modifier is
-   * in the modifier stack in relation to other modifiers.
    */
   void (*generateStrokes)(struct GpencilModifierData *md,
                           struct Depsgraph *depsgraph,
-                          struct Object *ob,
-                          struct bGPDlayer *gpl,
-                          struct bGPDframe *gpf);
+                          struct Object *ob);
 
   /**
    * Bake-down GP modifier's effects into the GP data-block.
@@ -297,24 +287,6 @@ bool BKE_gpencil_has_geometry_modifiers(struct Object *ob);
 bool BKE_gpencil_has_time_modifiers(struct Object *ob);
 bool BKE_gpencil_has_transform_modifiers(struct Object *ob);
 
-void BKE_gpencil_stroke_modifiers(struct Depsgraph *depsgraph,
-                                  struct Object *ob,
-                                  struct bGPDlayer *gpl,
-                                  struct bGPDframe *gpf,
-                                  struct bGPDstroke *gps,
-                                  bool is_render);
-void BKE_gpencil_geometry_modifiers(struct Depsgraph *depsgraph,
-                                    struct Object *ob,
-                                    struct bGPDlayer *gpl,
-                                    struct bGPDframe *gpf,
-                                    bool is_render);
-int BKE_gpencil_time_modifier(struct Depsgraph *depsgraph,
-                              struct Scene *scene,
-                              struct Object *ob,
-                              struct bGPDlayer *gpl,
-                              int cfra,
-                              bool is_render);
-
 void BKE_gpencil_lattice_init(struct Object *ob);
 void BKE_gpencil_lattice_clear(struct Object *ob);
 
@@ -322,6 +294,15 @@ void BKE_gpencil_modifiers_calc(struct Depsgraph *depsgraph,
                                 struct Scene *scene,
                                 struct Object *ob);
 
+void BKE_gpencil_prepare_eval_data(struct Depsgraph *depsgraph,
+                                   struct Scene *scene,
+                                   struct Object *ob);
+
+struct bGPDframe *BKE_gpencil_frame_retime_get(struct Depsgraph *depsgraph,
+                                               struct Scene *scene,
+                                               struct Object *ob,
+                                               struct bGPDlayer *gpl);
+
 #ifdef __cplusplus
 }
 #endif
index 5283672bdde689a5b4ef5fb1c68ccf751554e9ff..46fb254a387a652538589ab9d7292e4953b44a63 100644 (file)
@@ -34,6 +34,7 @@ struct Brush;
 struct CurveMapping;
 struct Depsgraph;
 struct EnumPropertyItem;
+struct GHash;
 struct GridPaintMask;
 struct ImagePool;
 struct MLoop;
@@ -55,6 +56,7 @@ struct SubdivCCG;
 struct SubdivCCG;
 struct Tex;
 struct ToolSettings;
+struct tPaletteColorHSV;
 struct UnifiedPaintSettings;
 struct View3D;
 struct ViewLayer;
@@ -82,9 +84,13 @@ typedef enum ePaintMode {
   PAINT_MODE_TEXTURE_2D = 4,
   PAINT_MODE_SCULPT_UV = 5,
   PAINT_MODE_GPENCIL = 6,
+  /* Grease Pencil Vertex Paint */
+  PAINT_MODE_VERTEX_GPENCIL = 7,
+  PAINT_MODE_SCULPT_GPENCIL = 8,
+  PAINT_MODE_WEIGHT_GPENCIL = 9,
 
   /** Keep last. */
-  PAINT_MODE_INVALID = 7,
+  PAINT_MODE_INVALID = 10,
 } ePaintMode;
 
 #define PAINT_MODE_HAS_BRUSH(mode) !ELEM(mode, PAINT_MODE_SCULPT_UV)
@@ -143,6 +149,15 @@ bool BKE_palette_is_empty(const struct Palette *palette);
 void BKE_palette_color_remove(struct Palette *palette, struct PaletteColor *color);
 void BKE_palette_clear(struct Palette *palette);
 
+void BKE_palette_sort_hsv(struct tPaletteColorHSV *color_array, const int totcol);
+void BKE_palette_sort_svh(struct tPaletteColorHSV *color_array, const int totcol);
+void BKE_palette_sort_vhs(struct tPaletteColorHSV *color_array, const int totcol);
+void BKE_palette_sort_luminance(struct tPaletteColorHSV *color_array, const int totcol);
+bool BKE_palette_from_hash(struct Main *bmain,
+                           struct GHash *color_table,
+                           const char *name,
+                           const bool linear);
+
 /* paint curves */
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
 struct PaintCurve *BKE_paint_curve_copy(struct Main *bmain, const struct PaintCurve *pc);
index 4a92f439d7483053ea8d9699bc34ceba7a57216b..1716439c3fd9d2af647a7b72d9d6317ddf047856 100644 (file)
@@ -271,12 +271,10 @@ void BKE_brush_init_gpencil_settings(Brush *brush)
   brush->gpencil_settings->draw_smoothlvl = 1;
   brush->gpencil_settings->flag = 0;
   brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
   brush->gpencil_settings->draw_strength = 1.0f;
   brush->gpencil_settings->draw_jitter = 0.0f;
   brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
   brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN;
-  brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR;
 
   /* curves */
   brush->gpencil_settings->curve_sensitivity = BKE_curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
@@ -285,11 +283,32 @@ void BKE_brush_init_gpencil_settings(Brush *brush)
 }
 
 /* add a new gp-brush */
-Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name)
+Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name, eObjectMode mode)
 {
+  Paint *paint = NULL;
   Brush *brush;
-  Paint *paint = &ts->gp_paint->paint;
-  brush = BKE_brush_add(bmain, name, OB_MODE_PAINT_GPENCIL);
+  switch (mode) {
+    case OB_MODE_PAINT_GPENCIL: {
+      paint = &ts->gp_paint->paint;
+      break;
+    }
+    case OB_MODE_SCULPT_GPENCIL: {
+      paint = &ts->gp_sculptpaint->paint;
+      break;
+    }
+    case OB_MODE_WEIGHT_GPENCIL: {
+      paint = &ts->gp_weightpaint->paint;
+      break;
+    }
+    case OB_MODE_VERTEX_GPENCIL: {
+      paint = &ts->gp_vertexpaint->paint;
+      break;
+    }
+    default:
+      paint = &ts->gp_paint->paint;
+  }
+
+  brush = BKE_brush_add(bmain, name, mode);
 
   BKE_paint_brush_set(paint, brush);
   id_us_min(&brush->id);
@@ -303,6 +322,22 @@ Brush *BKE_brush_add_gpencil(Main *bmain, ToolSettings *ts, const char *name)
   return brush;
 }
 
+/* Delete a Brush. */
+bool BKE_brush_delete(Main *bmain, Brush *brush)
+{
+  if (brush->id.tag & LIB_TAG_INDIRECT) {
+    return false;
+  }
+  else if (BKE_library_ID_is_indirectly_used(bmain, brush) && ID_REAL_USERS(brush) <= 1 &&
+           ID_EXTRA_USERS(brush) == 0) {
+    return false;
+  }
+
+  BKE_id_delete(bmain, brush);
+
+  return true;
+}
+
 /* grease pencil cumapping->preset */
 typedef enum eGPCurveMappingPreset {
   GPCURVE_PRESET_PENCIL = 0,
@@ -363,442 +398,760 @@ static void brush_gpencil_curvemap_reset(CurveMap *cuma, int tot, int preset)
   }
 }
 
-/* create a set of grease pencil presets. */
-void BKE_brush_gpencil_presets(Main *bmain, ToolSettings *ts)
+void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
 {
 #define SMOOTH_STROKE_RADIUS 40
 #define SMOOTH_STROKE_FACTOR 0.9f
+#define ACTIVE_SMOOTH 0.35f
 
-  Paint *paint = &ts->gp_paint->paint;
+  CurveMapping *custom_curve = NULL;
 
-  Brush *brush, *deft;
-  CurveMapping *custom_curve;
+  /* Set general defaults at brush level. */
+  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
+  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
 
-  /* Airbrush brush. */
-  brush = BLI_findstring(&bmain->brushes, "Airbrush", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Airbrush");
+  brush->rgb[0] = 0.498f;
+  brush->rgb[1] = 1.0f;
+  brush->rgb[2] = 0.498f;
+
+  brush->secondary_rgb[0] = 1.0f;
+  brush->secondary_rgb[1] = 1.0f;
+  brush->secondary_rgb[2] = 1.0f;
+
+  brush->curve_preset = BRUSH_CURVE_SMOOTH;
+
+  if (brush->gpencil_settings == NULL) {
+    return;
   }
 
-  brush->size = 300.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+  /* Set preset type. */
+  brush->gpencil_settings->preset_type = type;
 
-  brush->gpencil_settings->draw_strength = 0.4f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+  /* Set vertex mix factor. */
+  brush->gpencil_settings->vertex_mode = GPPAINT_MODE_STROKE;
+  brush->gpencil_settings->vertex_factor = 1.0f;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.98f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 0.211f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+  switch (type) {
+    case GP_BRUSH_PRESET_AIRBRUSH: {
+      brush->size = 300.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.4f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_AIRBRUSH;
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 0.211f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_AIRBRUSH;
 
-  /* Create and link Black Dots material to brush.
-   * This material is required because the brush uses the material to define how the stroke is
-   * drawn. */
-  Material *ma = BLI_findstring(&bmain->materials, "Black Dots", offsetof(ID, name) + 2);
-  if (ma == NULL) {
-    ma = BKE_gpencil_material_add(bmain, "Black Dots");
-  }
-  brush->gpencil_settings->material = ma;
-  /* Pin the matterial to the brush. */
-  brush->gpencil_settings->flag |= GP_BRUSH_MATERIAL_PINNED;
+      /* Create and link Black Dots material to brush.
+       * This material is required because the brush uses the material to define how the stroke is
+       * drawn. */
+      Material *ma = BLI_findstring(&bmain->materials, "Dots Stroke", offsetof(ID, name) + 2);
+      if (ma == NULL) {
+        ma = BKE_gpencil_material_add(bmain, "Dots Stroke");
+      }
+      brush->gpencil_settings->material = ma;
+      /* Pin the matterial to the brush. */
+      brush->gpencil_settings->flag |= GP_BRUSH_MATERIAL_PINNED;
 
-  /* Ink Pen brush. */
-  brush = BLI_findstring(&bmain->brushes, "Ink Pen", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Ink Pen");
-  }
-  brush->size = 60.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_INK_PEN: {
 
-  brush->gpencil_settings->draw_strength = 1.0f;
+      brush->size = 60.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.7f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+      brush->gpencil_settings->draw_strength = 1.0f;
 
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.1f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.002f;
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
 
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.1f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.002f;
 
-  /* Curve. */
-  custom_curve = brush->gpencil_settings->curve_sensitivity;
-  BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
-  BKE_curvemapping_initialize(custom_curve);
-  brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK);
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INK;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      /* Curve. */
+      custom_curve = brush->gpencil_settings->curve_sensitivity;
+      BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
+      BKE_curvemapping_initialize(custom_curve);
+      brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INK);
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INK;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
 
-  /* Ink Pen Rough brush. */
-  brush = BLI_findstring(&bmain->brushes, "Ink Pen Rough", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Ink Pen Rough");
-  }
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_INK_PEN_ROUGH: {
+      brush->size = 60.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 1.0f;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.0f;
+      brush->gpencil_settings->draw_smoothlvl = 2;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.000f;
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_RANDOM;
+      brush->gpencil_settings->draw_random_press = 1.0f;
+      brush->gpencil_settings->draw_random_strength = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      /* Curve. */
+      custom_curve = brush->gpencil_settings->curve_sensitivity;
+      BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
+      BKE_curvemapping_initialize(custom_curve);
+      brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE);
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_MARKER_BOLD: {
+      brush->size = 150.0f;
+      brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 0.3f;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.1f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.002f;
+
+      brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM;
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_random_strength = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      /* Curve. */
+      custom_curve = brush->gpencil_settings->curve_sensitivity;
+      BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
+      BKE_curvemapping_initialize(custom_curve);
+      brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER);
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_MARKER_CHISEL: {
+      brush->size = 80.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 1.0f;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = DEG2RAD(20.0f);
+      brush->gpencil_settings->draw_angle_factor = 1.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.0f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.002f;
+
+      brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM;
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_PEN: {
+      brush->size = 30.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.0f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 1;
+      brush->gpencil_settings->simplify_f = 0.002f;
+
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_random_strength = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_PENCIL_SOFT: {
+      brush->size = 80.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 0.4f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 0.8f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.0f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.000f;
+
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_random_strength = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_PENCIL: {
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 0.6f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+
+      brush->gpencil_settings->input_samples = 10;
+      brush->gpencil_settings->active_smooth = ACTIVE_SMOOTH;
+      brush->gpencil_settings->draw_angle = 0.0f;
+      brush->gpencil_settings->draw_angle_factor = 0.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+
+      brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
+      brush->gpencil_settings->draw_smoothfac = 0.0f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 0;
+      brush->gpencil_settings->simplify_f = 0.002f;
+
+      brush->gpencil_settings->draw_random_press = 0.0f;
+      brush->gpencil_settings->draw_jitter = 0.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL;
+      brush->gpencil_tool = GPAINT_TOOL_DRAW;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_FILL_AREA: {
+      brush->size = 20.0f;
+
+      brush->gpencil_settings->fill_leak = 3;
+      brush->gpencil_settings->fill_threshold = 0.1f;
+      brush->gpencil_settings->fill_simplylvl = 1;
+      brush->gpencil_settings->fill_factor = 1;
+
+      brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->hardeness = 1.0f;
+      copy_v2_fl(brush->gpencil_settings->aspect_ratio, 1.0f);
+      brush->gpencil_settings->draw_smoothfac = 0.1f;
+      brush->gpencil_settings->draw_smoothlvl = 1;
+      brush->gpencil_settings->draw_subdivide = 1;
+
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL;
+      brush->gpencil_tool = GPAINT_TOOL_FILL;
+      brush->gpencil_settings->vertex_mode = GPPAINT_MODE_FILL;
+
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_ERASER_SOFT: {
+      brush->size = 30.0f;
+      brush->gpencil_settings->draw_strength = 0.5f;
+      brush->gpencil_settings->flag |= GP_BRUSH_DEFAULT_ERASER;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT;
+      brush->gpencil_tool = GPAINT_TOOL_ERASE;
+      brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
+      brush->gpencil_settings->era_strength_f = 100.0f;
+      brush->gpencil_settings->era_thickness_f = 10.0f;
 
-  brush->size = 60.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      break;
+    }
+    case GP_BRUSH_PRESET_ERASER_HARD: {
+      brush->size = 30.0f;
+      brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
+      brush->gpencil_settings->era_strength_f = 100.0f;
+      brush->gpencil_settings->era_thickness_f = 50.0f;
 
-  brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD;
+      brush->gpencil_tool = GPAINT_TOOL_ERASE;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.5f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
-
-  brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.0f;
-  brush->gpencil_settings->draw_smoothlvl = 2;
-  brush->gpencil_settings->thick_smoothfac = 0.0f;
-  brush->gpencil_settings->thick_smoothlvl = 2;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.000f;
-
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_RANDOM;
-  brush->gpencil_settings->draw_random_press = 1.0f;
-  brush->gpencil_settings->draw_random_strength = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      break;
+    }
+    case GP_BRUSH_PRESET_ERASER_POINT: {
+      brush->size = 30.0f;
+      brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_HARD;
 
-  /* Curve. */
-  custom_curve = brush->gpencil_settings->curve_sensitivity;
-  BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
-  BKE_curvemapping_initialize(custom_curve);
-  brush_gpencil_curvemap_reset(custom_curve->cm, 3, GPCURVE_PRESET_INKNOISE);
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD;
+      brush->gpencil_tool = GPAINT_TOOL_ERASE;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_INKNOISE;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      break;
+    }
+    case GP_BRUSH_PRESET_ERASER_STROKE: {
+      brush->size = 30.0f;
+      brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_STROKE;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_STROKE;
+      brush->gpencil_tool = GPAINT_TOOL_ERASE;
 
-  /* Marker Bold brush. */
-  brush = BLI_findstring(&bmain->brushes, "Marker Bold", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Marker Bold");
-  }
-  brush->size = 150.0f;
-  brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
+      break;
+    }
+    case GP_BRUSH_PRESET_TINT: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_TINT;
+      brush->gpencil_tool = GPAINT_TOOL_TINT;
 
-  brush->gpencil_settings->draw_strength = 0.3f;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.6f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.1f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.002f;
-
-  brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM;
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_random_strength = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_VERTEX_DRAW: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_DRAW;
+      brush->gpencil_vertex_tool = GPVERTEX_TOOL_DRAW;
 
-  /* Curve. */
-  custom_curve = brush->gpencil_settings->curve_sensitivity;
-  BKE_curvemapping_set_defaults(custom_curve, 0, 0.0f, 0.0f, 1.0f, 1.0f);
-  BKE_curvemapping_initialize(custom_curve);
-  brush_gpencil_curvemap_reset(custom_curve->cm, 4, GPCURVE_PRESET_MARKER);
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_MARKER;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_VERTEX_BLUR: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_BLUR;
+      brush->gpencil_vertex_tool = GPVERTEX_TOOL_BLUR;
 
-  /* Marker Chisel brush. */
-  brush = BLI_findstring(&bmain->brushes, "Marker Chisel", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Marker Chisel");
-  }
-  brush->size = 80.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.5f;
-  brush->gpencil_settings->draw_angle = DEG2RAD(20.0f);
-  brush->gpencil_settings->draw_angle_factor = 1.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_VERTEX_AVERAGE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_AVERAGE;
+      brush->gpencil_vertex_tool = GPVERTEX_TOOL_AVERAGE;
 
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.0f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0;
-  brush->gpencil_settings->simplify_f = 0.002f;
-
-  brush->gpencil_settings->flag &= ~GP_BRUSH_GROUP_RANDOM;
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_CHISEL;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_VERTEX_SMEAR: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_SMEAR;
+      brush->gpencil_vertex_tool = GPVERTEX_TOOL_SMEAR;
 
-  /* Pen brush. */
-  brush = BLI_findstring(&bmain->brushes, "Pen", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Pen");
-  }
-  brush->size = 30.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->draw_strength = 1.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
-
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.3f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
-
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.0f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 1;
-  brush->gpencil_settings->draw_subdivide = 1;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.002f;
-
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_random_strength = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PEN;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_VERTEX_REPLACE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_VERTEX_REPLACE;
+      brush->gpencil_vertex_tool = GPVERTEX_TOOL_REPLACE;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  /* Pencil Soft brush. */
-  brush = BLI_findstring(&bmain->brushes, "Pencil Soft", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Pencil Soft");
-  }
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
 
-  brush->size = 80.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      zero_v3(brush->secondary_rgb);
+      break;
+    }
+    case GP_BRUSH_PRESET_SMOOTH_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_SMOOTH;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_SMOOTH;
 
-  brush->gpencil_settings->draw_strength = 0.4f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.64f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 0.8f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.3f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_flag = GP_SCULPT_FLAG_SMOOTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.0f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.000f;
-
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_random_strength = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      break;
+    }
+    case GP_BRUSH_PRESET_STRENGTH_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_STRENGTH;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_STRENGTH;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->gpencil_settings->draw_strength = 0.3f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_flag = GP_SCULPT_FLAG_SMOOTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  /* Pencil brush. */
-  brush = BLI_findstring(&bmain->brushes, "Pencil", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Pencil");
-  }
-  deft = brush; /* save default brush. */
+      break;
+    }
+    case GP_BRUSH_PRESET_THICKNESS_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_THICKNESS;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_THICKNESS;
 
-  brush->size = 25.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_USE_PRESSURE | GP_BRUSH_ENABLE_CURSOR);
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->draw_strength = 0.6f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->draw_strength = 0.5f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  brush->gpencil_settings->input_samples = 10;
-  brush->gpencil_settings->active_smooth = 0.55f;
-  brush->gpencil_settings->draw_angle = 0.0f;
-  brush->gpencil_settings->draw_angle_factor = 0.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
+      break;
+    }
+    case GP_BRUSH_PRESET_GRAB_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_GRAB;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_GRAB;
+      brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->flag |= GP_BRUSH_GROUP_SETTINGS;
-  brush->gpencil_settings->draw_smoothfac = 0.0f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 0;
-  brush->gpencil_settings->draw_random_sub = 0.0f;
-  brush->gpencil_settings->simplify_f = 0.002f;
+      brush->size = 25.0f;
 
-  brush->gpencil_settings->draw_random_press = 0.0f;
-  brush->gpencil_settings->draw_jitter = 0.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_JITTER_PRESSURE;
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.3f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_PENCIL;
-  brush->gpencil_tool = GPAINT_TOOL_DRAW;
+      break;
+    }
+    case GP_BRUSH_PRESET_PUSH_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_PUSH;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_PUSH;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  /* Fill brush. */
-  brush = BLI_findstring(&bmain->brushes, "Fill Area", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Fill Area");
-  }
-  brush->size = 20.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR;
+      brush->gpencil_settings->draw_strength = 0.3f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  brush->gpencil_settings->fill_leak = 3;
-  brush->gpencil_settings->fill_threshold = 0.1f;
-  brush->gpencil_settings->fill_simplylvl = 1;
-  brush->gpencil_settings->fill_factor = 1;
+      break;
+    }
+    case GP_BRUSH_PRESET_TWIST_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_TWIST;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_TWIST;
 
-  brush->gpencil_settings->draw_strength = 1.0f;
-  brush->gpencil_settings->gradient_f = 1.0f;
-  brush->gpencil_settings->gradient_s[0] = 1.0f;
-  brush->gpencil_settings->gradient_s[1] = 1.0f;
-  brush->gpencil_settings->draw_smoothfac = 0.1f;
-  brush->gpencil_settings->draw_smoothlvl = 1;
-  brush->gpencil_settings->thick_smoothfac = 1.0f;
-  brush->gpencil_settings->thick_smoothlvl = 3;
-  brush->gpencil_settings->draw_subdivide = 1;
+      brush->size = 50.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  brush->gpencil_settings->draw_sensitivity = 1.0f;
+      brush->gpencil_settings->draw_strength = 0.3f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL;
-  brush->gpencil_tool = GPAINT_TOOL_FILL;
+      break;
+    }
+    case GP_BRUSH_PRESET_PINCH_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_PINCH;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_PINCH;
 
-  brush->smooth_stroke_radius = SMOOTH_STROKE_RADIUS;
-  brush->smooth_stroke_factor = SMOOTH_STROKE_FACTOR;
+      brush->size = 50.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
 
-  /* Soft Eraser brush. */
-  brush = BLI_findstring(&bmain->brushes, "Eraser Soft", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Soft");
+      brush->gpencil_settings->draw_strength = 0.5f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
+
+      break;
+    }
+    case GP_BRUSH_PRESET_RANDOMIZE_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_RANDOMIZE;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_RANDOMIZE;
+
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 0.5f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
+
+      break;
+    }
+    case GP_BRUSH_PRESET_CLONE_STROKE: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_CLONE;
+      brush->gpencil_sculpt_tool = GPSCULPT_TOOL_CLONE;
+      brush->gpencil_settings->flag &= ~GP_BRUSH_USE_PRESSURE;
+
+      brush->size = 25.0f;
+
+      brush->gpencil_settings->draw_strength = 1.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
+
+      break;
+    }
+    case GP_BRUSH_PRESET_DRAW_WEIGHT: {
+      brush->gpencil_settings->icon_id = GP_BRUSH_ICON_GPBRUSH_WEIGHT;
+      brush->gpencil_weight_tool = GPWEIGHT_TOOL_DRAW;
+
+      brush->size = 25.0f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
+
+      brush->gpencil_settings->draw_strength = 0.8f;
+      brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
+      brush->gpencil_settings->sculpt_mode_flag |= GP_SCULPT_FLAGMODE_APPLY_POSITION;
+
+      break;
+    }
+    default:
+      break;
   }
-  brush->size = 30.0f;
-  brush->gpencil_settings->draw_strength = 0.5f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_ENABLE_CURSOR | GP_BRUSH_DEFAULT_ERASER);
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_PRESSURE;
-  brush->gpencil_settings->flag |= GP_BRUSH_USE_STENGTH_PRESSURE;
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_SOFT;
-  brush->gpencil_tool = GPAINT_TOOL_ERASE;
-  brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
-  brush->gpencil_settings->era_strength_f = 100.0f;
-  brush->gpencil_settings->era_thickness_f = 10.0f;
+}
 
-  /* Hard Eraser brush. */
-  brush = BLI_findstring(&bmain->brushes, "Eraser Hard", offsetof(ID, name) + 2);
+static Brush *gpencil_brush_ensure(Main *bmain,
+                                   ToolSettings *ts,
+                                   const char *brush_name,
+                                   eObjectMode mode)
+{
+  Brush *brush = BLI_findstring(&bmain->brushes, brush_name, offsetof(ID, name) + 2);
   if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Hard");
+    brush = BKE_brush_add_gpencil(bmain, ts, brush_name, mode);
   }
-  brush->size = 30.0f;
-  brush->gpencil_settings->draw_strength = 1.0f;
-  brush->gpencil_settings->flag |= (GP_BRUSH_ENABLE_CURSOR | GP_BRUSH_DEFAULT_ERASER);
-  brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_SOFT;
-  brush->gpencil_settings->era_strength_f = 100.0f;
-  brush->gpencil_settings->era_thickness_f = 50.0f;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD;
-  brush->gpencil_tool = GPAINT_TOOL_ERASE;
-
-  /* Point Eraser brush. */
-  brush = BLI_findstring(&bmain->brushes, "Eraser Point", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Point");
+  if (brush->gpencil_settings == NULL) {
+    BKE_brush_init_gpencil_settings(brush);
   }
-  brush->size = 30.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR;
-  brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_HARD;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_HARD;
-  brush->gpencil_tool = GPAINT_TOOL_ERASE;
+  return brush;
+}
+
+/* Create a set of grease pencil Drawing presets. */
+void BKE_brush_gpencil_paint_presets(Main *bmain, ToolSettings *ts)
+{
+
+  Paint *paint = &ts->gp_paint->paint;
+
+  Brush *brush, *deft_draw;
+  /* Airbrush brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Airbrush", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_AIRBRUSH);
+
+  /* Ink Pen brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Ink Pen", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_INK_PEN);
+
+  /* Ink Pen Rough brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Ink Pen Rough", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_INK_PEN_ROUGH);
+
+  /* Marker Bold brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Marker Bold", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_MARKER_BOLD);
+
+  /* Marker Chisel brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Marker Chisel", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_MARKER_CHISEL);
+
+  /* Pen brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Pen", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PEN);
+
+  /* Pencil Soft brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Pencil Soft", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PENCIL_SOFT);
+
+  /* Pencil brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Pencil", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PENCIL);
+  deft_draw = brush; /* save default brush. */
+
+  /* Fill brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Fill Area", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_FILL_AREA);
+
+  /* Soft Eraser brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Eraser Soft", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_SOFT);
+
+  /* Hard Eraser brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Eraser Hard", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_HARD);
+
+  /* Point Eraser brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Eraser Point", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_POINT);
 
   /* Stroke Eraser brush. */
-  brush = BLI_findstring(&bmain->brushes, "Eraser Stroke", offsetof(ID, name) + 2);
-  if (brush == NULL) {
-    brush = BKE_brush_add_gpencil(bmain, ts, "Eraser Stroke");
-  }
-  brush->size = 30.0f;
-  brush->gpencil_settings->flag |= GP_BRUSH_ENABLE_CURSOR;
-  brush->gpencil_settings->eraser_mode = GP_BRUSH_ERASER_STROKE;
+  brush = gpencil_brush_ensure(bmain, ts, "Eraser Stroke", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_ERASER_STROKE);
+
+  /* Tint brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Tint", OB_MODE_PAINT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TINT);
+
+  /* Set default Draw brush. */
+  BKE_paint_brush_set(paint, deft_draw);
+}
+
+/* Create a set of grease pencil Vertex Paint presets. */
+void BKE_brush_gpencil_vertex_presets(Main *bmain, ToolSettings *ts)
+{
+  Paint *vertexpaint = &ts->gp_vertexpaint->paint;
+
+  Brush *brush, *deft_vertex;
+  /* Vertex Draw brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Vertex Draw", OB_MODE_VERTEX_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_DRAW);
+  deft_vertex = brush; /* save default brush. */
+
+  /* Vertex Blur brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Vertex Blur", OB_MODE_VERTEX_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_BLUR);
+
+  /* Vertex Average brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Vertex Average", OB_MODE_VERTEX_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_AVERAGE);
+
+  /* Vertex Smear brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Vertex Smear", OB_MODE_VERTEX_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_SMEAR);
+
+  /* Vertex Replace brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Vertex Replace", OB_MODE_VERTEX_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_VERTEX_REPLACE);
+
+  /* Set default Vertex brush. */
+  BKE_paint_brush_set(vertexpaint, deft_vertex);
+}
+
+/* Create a set of grease pencil Sculpt Paint presets. */
+void BKE_brush_gpencil_sculpt_presets(Main *bmain, ToolSettings *ts)
+{
+  Paint *sculptpaint = &ts->gp_sculptpaint->paint;
+  Brush *brush, *deft_sculpt;
+
+  /* Smooth brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Smooth Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_SMOOTH_STROKE);
+  deft_sculpt = brush;
+
+  /* Strength brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Strength Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_STRENGTH_STROKE);
+
+  /* Thickness brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Thickness Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_THICKNESS_STROKE);
+
+  /* Grab brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Grab Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_GRAB_STROKE);
+
+  /* Push brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Push Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PUSH_STROKE);
+
+  /* Twist brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Twist Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_TWIST_STROKE);
+
+  /* Pinch brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Pinch Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_PINCH_STROKE);
+
+  /* Randomize brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Randomize Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_RANDOMIZE_STROKE);
+
+  /* Clone brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Clone Stroke", OB_MODE_SCULPT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_CLONE_STROKE);
+
+  /* Set default brush. */
+  BKE_paint_brush_set(sculptpaint, deft_sculpt);
+}
+
+/* Create a set of grease pencil Weight Paint presets. */
+void BKE_brush_gpencil_weight_presets(Main *bmain, ToolSettings *ts)
+{
+  Paint *weightpaint = &ts->gp_weightpaint->paint;
 
-  brush->gpencil_settings->icon_id = GP_BRUSH_ICON_ERASE_STROKE;
-  brush->gpencil_tool = GPAINT_TOOL_ERASE;
+  Brush *brush, *deft_weight;
+  /* Vertex Draw brush. */
+  brush = gpencil_brush_ensure(bmain, ts, "Draw Weight", OB_MODE_WEIGHT_GPENCIL);
+  BKE_gpencil_brush_preset_set(bmain, brush, GP_BRUSH_PRESET_DRAW_WEIGHT);
+  deft_weight = brush; /* save default brush. */
 
-  /* set default brush. */
-  BKE_paint_brush_set(paint, deft);
+  /* Set default brush. */
+  BKE_paint_brush_set(weightpaint, deft_weight);
 }
 
 struct Brush *BKE_brush_first_search(struct Main *bmain, const eObjectMode ob_mode)
index 48985932d87f3ab993d691071c8b1524d201e62e..b2c551a1752027913ec3881c3c8bd2faed45a19f 100644 (file)
@@ -1124,6 +1124,9 @@ enum eContextObjectMode CTX_data_mode_enum_ex(const Object *obedit,
       else if (object_mode & OB_MODE_WEIGHT_GPENCIL) {
         return CTX_MODE_WEIGHT_GPENCIL;
       }
+      else if (object_mode & OB_MODE_VERTEX_GPENCIL) {
+        return CTX_MODE_VERTEX_GPENCIL;
+      }
     }
   }
 
@@ -1140,25 +1143,11 @@ enum eContextObjectMode CTX_data_mode_enum(const bContext *C)
 /* would prefer if we can use the enum version below over this one - Campbell */
 /* must be aligned with above enum  */
 static const char *data_mode_strings[] = {
-    "mesh_edit",
-    "curve_edit",
-    "surface_edit",
-    "text_edit",
-    "armature_edit",
-    "mball_edit",
-    "lattice_edit",
-    "posemode",
-    "sculpt_mode",
-    "weightpaint",
-    "vertexpaint",
-    "imagepaint",
-    "particlemode",
-    "objectmode",
-    "greasepencil_paint",
-    "greasepencil_edit",
-    "greasepencil_sculpt",
-    "greasepencil_weight",
-    NULL,
+    "mesh_edit",           "curve_edit",          "surface_edit",        "text_edit",
+    "armature_edit",       "mball_edit",          "lattice_edit",        "posemode",
+    "sculpt_mode",         "weightpaint",         "vertexpaint",         "imagepaint",
+    "particlemode",        "objectmode",          "greasepencil_paint",  "greasepencil_edit",
+    "greasepencil_sculpt", "greasepencil_weight", "greasepencil_vertex", NULL,
 };
 BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings) == CTX_MODE_NUM + 1,
                   "Must have a string for each context mode")
index 747ffb92ad5d4353f17a050cdefb975b2a1dc2bd..0b33eaccb6f764d26a8d6a88ca73cc3b7ad10276 100644 (file)
 
 #include "BLT_translation.h"
 
+#include "IMB_imbuf_types.h"
+#include "IMB_imbuf.h"
+
 #include "DNA_anim_types.h"
 #include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_scene_types.h"
+#include "DNA_space_types.h"
 #include "DNA_object_types.h"
 
 #include "BKE_action.h"
 #include "BKE_deform.h"
 #include "BKE_gpencil.h"
 #include "BKE_icons.h"
+#include "BKE_image.h"
 #include "BKE_lib_id.h"
 #include "BKE_main.h"
 #include "BKE_material.h"
 #include "BKE_object.h"
+#include "BKE_paint.h"
 
 #include "BLI_math_color.h"
 
 #include "DEG_depsgraph.h"
+#include "DEG_depsgraph_query.h"
 
 static CLG_LogRef LOG = {"bke.gpencil"};
 
@@ -139,12 +146,10 @@ void BKE_gpencil_free_stroke(bGPDstroke *gps)
 /* Free strokes belonging to a gp-frame */
 bool BKE_gpencil_free_strokes(bGPDframe *gpf)
 {
-  bGPDstroke *gps_next;
   bool changed = (BLI_listbase_is_empty(&gpf->strokes) == false);
 
   /* free strokes */
-  for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps_next) {
-    gps_next = gps->next;
+  LISTBASE_FOREACH_MUTABLE (bGPDstroke *, gps, &gpf->strokes) {
     BKE_gpencil_free_stroke(gps);
   }
   BLI_listbase_clear(&gpf->strokes);
@@ -152,24 +157,6 @@ bool BKE_gpencil_free_strokes(bGPDframe *gpf)
   return changed;
 }
 
-/* Free strokes and colors belonging to a gp-frame */
-bool BKE_gpencil_free_frame_runtime_data(bGPDframe *gpf_eval)
-{
-  bGPDstroke *gps_next;
-  if (!gpf_eval) {
-    return false;
-  }
-
-  /* free strokes */
-  for (bGPDstroke *gps = gpf_eval->strokes.first; gps; gps = gps_next) {
-    gps_next = gps->next;
-    BKE_gpencil_free_stroke(gps);
-  }
-  BLI_listbase_clear(&gpf_eval->strokes);
-
-  return true;
-}
-
 /* Free all of a gp-layer's frames */
 void BKE_gpencil_free_frames(bGPDlayer *gpl)
 {
@@ -191,6 +178,15 @@ void BKE_gpencil_free_frames(bGPDlayer *gpl)
   gpl->actframe = NULL;
 }
 
+void BKE_gpencil_free_layer_masks(bGPDlayer *gpl)
+{
+  /* Free masks.*/
+  bGPDlayer_Mask *mask_next = NULL;
+  for (bGPDlayer_Mask *mask = gpl->mask_layers.first; mask; mask = mask_next) {
+    mask_next = mask->next;
+    BLI_freelinkN(&gpl->mask_layers, mask);
+  }
+}
 /* Free all of the gp-layers for a viewport (list should be &gpd->layers or so) */
 void BKE_gpencil_free_layers(ListBase *list)
 {
@@ -207,6 +203,10 @@ void BKE_gpencil_free_layers(ListBase *list)
 
     /* free layers and their data */
     BKE_gpencil_free_frames(gpl);
+
+    /* Free masks.*/
+    BKE_gpencil_free_layer_masks(gpl);
+
     BLI_freelinkN(list, gpl);
   }
 }
@@ -230,6 +230,13 @@ void BKE_gpencil_free(bGPdata *gpd, bool free_all)
   }
 }
 
+void BKE_gpencil_eval_delete(bGPdata *gpd_eval)
+{
+  BKE_gpencil_free(gpd_eval, true);
+  BKE_libblock_free_data(&gpd_eval->id, false);
+  MEM_freeN(gpd_eval);
+}
+
 /* ************************************************** */
 /* Container Creation */
 
@@ -307,7 +314,7 @@ bGPDframe *BKE_gpencil_frame_addcopy(bGPDlayer *gpl, int cframe)
   new_frame = BKE_gpencil_frame_duplicate(gpl->actframe);
 
   /* Find frame to insert it before */
-  for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+  LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) {
     if (gpf->framenum > cframe) {
       /* Add it here */
       BLI_insertlinkbefore(&gpl->frames, gpf, new_frame);
@@ -356,7 +363,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
   /* allocate memory for frame and add to end of list */
   gpl = MEM_callocN(sizeof(bGPDlayer), "bGPDlayer");
 
-  gpl_active = BKE_gpencil_layer_getactive(gpd);
+  gpl_active = BKE_gpencil_layer_active_get(gpd);
 
   /* add to datablock */
   if (gpl_active == NULL) {
@@ -386,6 +393,8 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
     gpl->opacity = 1.0f;
     /* default channel color */
     ARRAY_SET_ITEMS(gpl->color, 0.2f, 0.2f, 0.2f);
+    /* Default vertex mix. */
+    gpl->vertex_paint_opacity = 1.0f;
   }
 
   /* auto-name */
@@ -397,9 +406,11 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
                  offsetof(bGPDlayer, info),
                  sizeof(gpl->info));
 
+  /* Enable always affected by scene lights. */
+  gpl->flag |= GP_LAYER_USE_LIGHTS;
   /* make this one the active one */
   if (setactive) {
-    BKE_gpencil_layer_setactive(gpd, gpl);
+    BKE_gpencil_layer_active_set(gpd, gpl);
   }
 
   /* return layer */
@@ -419,7 +430,6 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
 
   /* general flags */
   gpd->flag |= GP_DATA_VIEWALIGN;
-  gpd->flag |= GP_DATA_STROKE_FORCE_RECALC;
   /* always enable object onion skin switch */
   gpd->flag |= GP_DATA_SHOW_ONIONSKINS;
   /* GP object specific settings */
@@ -427,6 +437,8 @@ bGPdata *BKE_gpencil_data_addnew(Main *bmain, const char name[])
 
   gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
 
+  gpd->zdepth_offset = 0.150f;
+
   /* grid settings */
   ARRAY_SET_ITEMS(gpd->grid.color, 0.5f, 0.5f, 0.5f); /* Color */
   ARRAY_SET_ITEMS(gpd->grid.scale, 1.0f, 1.0f);       /* Scale */
@@ -474,43 +486,59 @@ void BKE_gpencil_stroke_add_points(bGPDstroke *gps,
   }
 }
 
-/* Create a new stroke, with pre-allocated data buffers */
-bGPDstroke *BKE_gpencil_add_stroke(bGPDframe *gpf, int mat_idx, int totpoints, short thickness)
+/* Create a new stroke, with pre-allocated data buffers. */
+bGPDstroke *BKE_gpencil_stroke_new(int mat_idx, int totpoints, short thickness)
 {
   /* allocate memory for a new stroke */
   bGPDstroke *gps = MEM_callocN(sizeof(bGPDstroke), "gp_stroke");
 
   gps->thickness = thickness;
-  gps->gradient_f = 1.0f;
-  gps->gradient_s[0] = 1.0f;
-  gps->gradient_s[1] = 1.0f;
+  gps->fill_opacity_fac = 1.0f;
+  gps->hardeness = 1.0f;
+  copy_v2_fl(gps->aspect_ratio, 1.0f);
+
+  gps->uv_scale = 1.0f;
 
   gps->inittime = 0;
 
-  /* enable recalculation flag by default */
-  gps->flag = GP_STROKE_RECALC_GEOMETRY | GP_STROKE_3DSPACE;
+  gps->flag = GP_STROKE_3DSPACE;
 
   gps->totpoints = totpoints;
   gps->points = MEM_callocN(sizeof(bGPDspoint) * gps->totpoints, "gp_stroke_points");
 
   /* initialize triangle memory to dummy data */
   gps->triangles = NULL;
-  gps->flag |= GP_STROKE_RECALC_GEOMETRY;
   gps->tot_triangles = 0;
 
   gps->mat_nr = mat_idx;
 
-  /* add to frame */
-  BLI_addtail(&gpf->strokes, gps);
+  return gps;
+}
+
+/* Create a new stroke and add to frame. */
+bGPDstroke *BKE_gpencil_stroke_add(
+    bGPDframe *gpf, int mat_idx, int totpoints, short thickness, const bool insert_at_head)
+{
+  bGPDstroke *gps = BKE_gpencil_stroke_new(mat_idx, totpoints, thickness);
+
+  /* Add to frame. */
+  if ((gps != NULL) && (gpf != NULL)) {
+    if (!insert_at_head) {
+      BLI_addtail(&gpf->strokes, gps);
+    }
+    else {
+      BLI_addhead(&gpf->strokes, gps);
+    }
+  }
 
   return gps;
 }
 
 /* Add a stroke and copy the temporary drawing color value from one of the existing stroke */
-bGPDstroke *BKE_gpencil_add_stroke_existing_style(
+bGPDstroke *BKE_gpencil_stroke_add_existing_style(
     bGPDframe *gpf, bGPDstroke *existing, int mat_idx, int totpoints, short thickness)
 {
-  bGPDstroke *gps = BKE_gpencil_add_stroke(gpf, mat_idx, totpoints, thickness);
+  bGPDstroke *gps = BKE_gpencil_stroke_add(gpf, mat_idx, totpoints, thickness, false);
   /* Copy run-time color data so that strokes added in the modifier has the style.
    * There are depsgraph reference pointers inside,
    * change the copy function if interfere with future drawing implementation. */
@@ -533,30 +561,26 @@ void BKE_gpencil_stroke_weights_duplicate(bGPDstroke *gps_src, bGPDstroke *gps_d
 }
 
 /* make a copy of a given gpencil stroke */
-bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src)
+bGPDstroke *BKE_gpencil_stroke_duplicate(bGPDstroke *gps_src, const bool dup_points)
 {
   bGPDstroke *gps_dst = NULL;
 
   gps_dst = MEM_dupallocN(gps_src);
   gps_dst->prev = gps_dst->next = NULL;
+  gps_dst->triangles = MEM_dupallocN(gps_src->triangles);
 
-  gps_dst->points = MEM_dupallocN(gps_src->points);
+  if (dup_points) {
+    gps_dst->points = MEM_dupallocN(gps_src->points);
 
-  if (gps_src->dvert != NULL) {
-    gps_dst->dvert = MEM_dupallocN(gps_src->dvert);
-    BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
-  }
-  else {
-    gps_dst->dvert = NULL;
+    if (gps_src->dvert != NULL) {
+      gps_dst->dvert = MEM_dupallocN(gps_src->dvert);
+      BKE_gpencil_stroke_weights_duplicate(gps_src, gps_dst);
+    }
+    else {
+      gps_dst->dvert = NULL;
+    }
   }
 
-  /* Don't clear triangles, so that modifier evaluation can just use
-   * this without extra work first. Most places that need to force
-   * this data to get recalculated will destroy the data anyway though.
-   */
-  gps_dst->triangles = MEM_dupallocN(gps_dst->triangles);
-  /* gps_dst->flag |= GP_STROKE_RECALC_GEOMETRY; */
-
   /* return new stroke */
   return gps_dst;
 }
@@ -580,7 +604,7 @@ bGPDframe *BKE_gpencil_frame_duplicate(const bGPDframe *gpf_src)
   BLI_listbase_clear(&gpf_dst->strokes);
   for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
     /* make copy of source stroke */
-    gps_dst = BKE_gpencil_stroke_duplicate(gps_src);
+    gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
     BLI_addtail(&gpf_dst->strokes, gps_dst);
   }
 
@@ -601,7 +625,7 @@ void BKE_gpencil_frame_copy_strokes(bGPDframe *gpf_src, struct bGPDframe *gpf_ds
   BLI_listbase_clear(&gpf_dst->strokes);
   for (bGPDstroke *gps_src = gpf_src->strokes.first; gps_src; gps_src = gps_src->next) {
     /* make copy of source stroke */
-    gps_dst = BKE_gpencil_stroke_duplicate(gps_src);
+    gps_dst = BKE_gpencil_stroke_duplicate(gps_src, true);
     BLI_addtail(&gpf_dst->strokes, gps_dst);
   }
 }
@@ -622,6 +646,14 @@ bGPDlayer *BKE_gpencil_layer_duplicate(const bGPDlayer *gpl_src)
   gpl_dst = MEM_dupallocN(gpl_src);
   gpl_dst->prev = gpl_dst->next = NULL;
 
+  /* Copy masks. */
+  BLI_listbase_clear(&gpl_dst->mask_layers);
+  LISTBASE_FOREACH (bGPDlayer_Mask *, mask_src, &gpl_src->mask_layers) {
+    bGPDlayer_Mask *mask_dst = MEM_dupallocN(mask_src);
+    mask_dst->prev = mask_dst->next = NULL;
+    BLI_addtail(&gpl_dst->mask_layers, mask_dst);
+  }
+
   /* copy frames */
   BLI_listbase_clear(&gpl_dst->frames);
   for (gpf_src = gpl_src->frames.first; gpf_src; gpf_src = gpf_src->next) {
@@ -658,7 +690,7 @@ void BKE_gpencil_copy_data(bGPdata *gpd_dst, const bGPdata *gpd_src, const int U
 
   /* copy layers */
   BLI_listbase_clear(&gpd_dst->layers);
-  for (const bGPDlayer *gpl_src = gpd_src->layers.first; gpl_src; gpl_src = gpl_src->next) {
+  LISTBASE_FOREACH (bGPDlayer *, gpl_src, &gpd_src->layers) {
     /* make a copy of source layer and its data */
 
     /* TODO here too could add unused flags... */
@@ -766,8 +798,8 @@ void BKE_gpencil_frame_delete_laststroke(bGPDlayer *gpl, bGPDframe *gpf)
 
   /* if frame has no strokes after this, delete it */
   if (BLI_listbase_is_empty(&gpf->strokes)) {
-    BKE_gpencil_layer_delframe(gpl, gpf);
-    BKE_gpencil_layer_getframe(gpl, cfra, GP_GETFRAME_USE_PREV);
+    BKE_gpencil_layer_frame_delete(gpl, gpf);
+    BKE_gpencil_layer_frame_get(gpl, cfra, GP_GETFRAME_USE_PREV);
   }
 }
 
@@ -775,7 +807,7 @@ void BKE_gpencil_frame_delete_laststroke(bGPDlayer