From 4dcda1ec12abfa1d918469961ed1f3b2c88c0329 Mon Sep 17 00:00:00 2001 From: Casey Bianco-Davis Date: Thu, 7 Dec 2023 11:42:06 +0100 Subject: [PATCH] GPv3: Overlay: Show edit lines option Adds option to only show edit mode lines overlay, and also adds overlay options panel. Pull Request: https://projects.blender.org/blender/blender/pulls/115739 --- scripts/startup/bl_ui/space_view3d.py | 30 +++++++++++++++++++ .../engines/overlay/overlay_grease_pencil.cc | 14 ++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/scripts/startup/bl_ui/space_view3d.py b/scripts/startup/bl_ui/space_view3d.py index 1d76b84b549..e842d46cfd8 100644 --- a/scripts/startup/bl_ui/space_view3d.py +++ b/scripts/startup/bl_ui/space_view3d.py @@ -1042,6 +1042,8 @@ class VIEW3D_HT_header(Header): sub.popover(panel="VIEW3D_PT_overlay_vertex_paint", text="", icon='VPAINT_HLT') elif obj is not None and obj.type == 'GPENCIL': sub.popover(panel="VIEW3D_PT_overlay_gpencil_options", text="", icon='OUTLINER_DATA_GREASEPENCIL') + elif obj is not None and obj.type == 'GREASEPENCIL': + sub.popover(panel="VIEW3D_PT_overlay_grease_pencil_options", text="", icon='OUTLINER_DATA_GREASEPENCIL') # Separate from `elif` chain because it may coexist with weight-paint. if ( @@ -7788,6 +7790,33 @@ class VIEW3D_PT_overlay_gpencil_options(Panel): row.prop(overlay, "gpencil_vertex_paint_opacity", text="Opacity", slider=True) +class VIEW3D_PT_overlay_grease_pencil_options(Panel): + bl_space_type = 'VIEW_3D' + bl_region_type = 'HEADER' + bl_label = "" + bl_ui_units_x = 13 + + @classmethod + def poll(cls, context): + return context.object and context.object.type == 'GREASEPENCIL' + + def draw(self, context): + layout = self.layout + view = context.space_data + overlay = view.overlay + + layout.label(text={ + 'PAINT_GREASE_PENCIL': iface_("Draw Grease Pencil"), + 'EDIT_GREASE_PENCIL': iface_("Edit Grease Pencil"), + 'OBJECT': iface_("Grease Pencil"), + }[context.mode], translate=False) + + if context.object.mode in {'EDIT'}: + split = layout.split() + col = split.column() + col.prop(overlay, "use_gpencil_edit_lines", text="Edit Lines") + + class VIEW3D_PT_quad_view(Panel): bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @@ -8953,6 +8982,7 @@ classes = ( VIEW3D_PT_gpencil_guide, VIEW3D_PT_transform_orientations, VIEW3D_PT_overlay_gpencil_options, + VIEW3D_PT_overlay_grease_pencil_options, VIEW3D_PT_context_properties, VIEW3D_PT_paint_vertex_context_menu, VIEW3D_PT_paint_texture_context_menu, diff --git a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc index 7334aa5a2ce..e1f1222232f 100644 --- a/source/blender/draw/engines/overlay/overlay_grease_pencil.cc +++ b/source/blender/draw/engines/overlay/overlay_grease_pencil.cc @@ -21,6 +21,7 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata) const DRWContextState *draw_ctx = DRW_context_state_get(); const eAttrDomain selection_domain = ED_grease_pencil_selection_domain_get( draw_ctx->scene->toolsettings); + const View3D *v3d = draw_ctx->v3d; GPUShader *sh; DRWShadingGroup *grp; @@ -29,11 +30,16 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata) DRW_STATE_BLEND_ALPHA; DRW_PASS_CREATE(psl->edit_grease_pencil_ps, (state | pd->clipping_state)); - sh = OVERLAY_shader_edit_particle_strand(); - grp = pd->edit_grease_pencil_wires_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); - DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + const bool show_points = selection_domain == ATTR_DOMAIN_POINT; + const bool show_lines = (v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES) != 0; - if (selection_domain == ATTR_DOMAIN_POINT) { + if (show_lines) { + sh = OVERLAY_shader_edit_particle_strand(); + grp = pd->edit_grease_pencil_wires_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); + DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo); + } + + if (show_points) { sh = OVERLAY_shader_edit_particle_point(); grp = pd->edit_grease_pencil_points_grp = DRW_shgroup_create(sh, psl->edit_grease_pencil_ps); DRW_shgroup_uniform_block(grp, "globalsBlock", G_draw.block_ubo);