GPv3: Overlay: Show edit lines option #115739

Merged
Falk David merged 4 commits from casey-bianco-davis/blender:GPv3-Edit-Lines-Option into main 2023-12-07 11:42:17 +01:00
3 changed files with 49 additions and 4 deletions
Showing only changes of commit f99e2cf69f - Show all commits

View File

@ -1039,6 +1039,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 (
@ -7790,6 +7792,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_grease_pencil_edit_lines", text="Edit Lines")
class VIEW3D_PT_quad_view(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
@ -8955,6 +8984,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,

View File

@ -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);
View3D *v3d = draw_ctx->v3d;
casey-bianco-davis marked this conversation as resolved Outdated

const View3D *v3d

`const View3D *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;
casey-bianco-davis marked this conversation as resolved Outdated

(v3d->gp_flag & V3D_GP_SHOW_EDIT_LINES) != 0

`(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);

View File

@ -37,6 +37,7 @@
#include "DNA_action_types.h"
#include "DNA_gpencil_legacy_types.h"
#include "DNA_grease_pencil_types.h"
#include "DNA_key_types.h"
#include "DNA_mask_types.h"
#include "DNA_material_types.h"
@ -4907,6 +4908,14 @@ static void rna_def_space_view3d_overlay(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Opacity", "Vertex Paint mix factor");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPencil_update");
# ifdef WITH_GREASE_PENCIL_V3
/* show edit lines */
prop = RNA_def_property(srna, "use_grease_pencil_edit_lines", PROP_BOOLEAN, PROP_NONE);
casey-bianco-davis marked this conversation as resolved Outdated

I don't think we need to duplicate this property. Using use_gpencil_edit_lines is fine.

I don't think we need to duplicate this property. Using `use_gpencil_edit_lines` is fine.
RNA_def_property_boolean_sdna(prop, nullptr, "gp_flag", V3D_GP_SHOW_EDIT_LINES);
RNA_def_property_ui_text(prop, "Show Edit Lines", "Show Edit Lines when editing strokes");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, nullptr);
# endif
/* Developer Debug overlay */
prop = RNA_def_property(srna, "use_debug_freeze_view_culling", PROP_BOOLEAN, PROP_NONE);