[Bf-blender-cvs] [f831af0083b] temp-gpencil-fill: GPencil: New button to enable extend lines helper
Antonio Vazquez
noreply at git.blender.org
Wed Feb 3 22:14:54 CET 2021
Commit: f831af0083bd2528cd05f9df3eb4616402f501a1
Author: Antonio Vazquez
Date: Wed Feb 3 22:14:49 2021 +0100
Branches: temp-gpencil-fill
https://developer.blender.org/rBf831af0083bd2528cd05f9df3eb4616402f501a1
GPencil: New button to enable extend lines helper
Now the extend lines are displayed with a different button.
===================================================================
M release/scripts/startup/bl_ui/space_view3d_toolbar.py
M source/blender/blenkernel/intern/brush.c
M source/blender/editors/gpencil/gpencil_fill.c
M source/blender/makesdna/DNA_brush_enums.h
M source/blender/makesrna/intern/rna_brush.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 9dc2f05eed2..20ec26200f6 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -1449,6 +1449,7 @@ class VIEW3D_PT_tools_grease_pencil_brush_advanced(View3DPanel, Panel):
col.separator()
row = col.row(align=True)
row.prop(gp_settings, "extend_stroke_factor")
+ row.prop(gp_settings, "show_fill_extend", text="", icon='GRID')
col.separator()
col.prop(gp_settings, "fill_simplify_level", text="Simplify")
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index ab4e2f404ee..2bd9303f0fb 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -989,6 +989,8 @@ void BKE_gpencil_brush_preset_set(Main *bmain, Brush *brush, const short type)
brush->gpencil_settings->draw_smoothlvl = 1;
brush->gpencil_settings->draw_subdivide = 1;
+ brush->gpencil_settings->flag |= GP_BRUSH_FILL_SHOW_EXTENDLINES;
+
brush->gpencil_settings->icon_id = GP_BRUSH_ICON_FILL;
brush->gpencil_tool = GPAINT_TOOL_FILL;
brush->gpencil_settings->vertex_mode = GPPAINT_MODE_FILL;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 87103ae92c2..d4bee2b8355 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -327,6 +327,31 @@ static void gpencil_update_extend(tGPDfill *tgpf)
WM_event_add_notifier(tgpf->C, NC_GPENCIL | NA_EDITED, NULL);
}
+static bool gpencil_stroke_is_drawable(tGPDfill *tgpf, bGPDstroke *gps)
+{
+ if (tgpf->is_render) {
+ return true;
+ }
+
+ const bool show_help = (tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) != 0;
+ const bool show_extend = (tgpf->flag & GP_BRUSH_FILL_SHOW_EXTENDLINES) != 0;
+ const bool is_extend = (gps->flag & GP_STROKE_NOFILL) && (gps->flag & GP_STROKE_TAG);
+
+ if ((!show_help) && (show_extend)) {
+ if (!is_extend) {
+ return false;
+ }
+ }
+
+ if ((show_help) && (!show_extend)) {
+ if (is_extend) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
/* draw a given stroke using same thickness and color for all points */
static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
bGPDstroke *gps,
@@ -347,6 +372,11 @@ static void gpencil_draw_basic_stroke(tGPDfill *tgpf,
float col[4];
const float extend_col[4] = {0.0f, 1.0f, 1.0f, 1.0f};
const bool is_extend = (gps->flag & GP_STROKE_NOFILL) && (gps->flag & GP_STROKE_TAG);
+
+ if (!gpencil_stroke_is_drawable(tgpf, gps)) {
+ return;
+ }
+
if ((is_extend) && (!tgpf->is_render)) {
copy_v4_v4(col, extend_col);
}
@@ -558,9 +588,9 @@ static void gpencil_draw_datablock(tGPDfill *tgpf, const float ink[4])
tgpw.onion = true;
tgpw.custonion = true;
- /* normal strokes */
+ /* Normal strokes. */
if (ELEM(tgpf->fill_draw_mode, GP_FILL_DMODE_STROKE, GP_FILL_DMODE_BOTH)) {
- if ((gps->flag & GP_STROKE_TAG) == 0) {
+ if (gpencil_stroke_is_drawable(tgpf, gps) && ((gps->flag & GP_STROKE_TAG) == 0)) {
ED_gpencil_draw_fill(&tgpw);
}
}
@@ -1767,7 +1797,11 @@ static int gpencil_fill_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSE
tgpf = op->customdata;
/* Enable custom drawing handlers to show help lines */
- if (tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) {
+ const bool do_extend = (tgpf->fill_extend_fac > 0.0f);
+ const bool help_lines = ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) ||
+ ((tgpf->flag & GP_BRUSH_FILL_SHOW_EXTENDLINES) && (do_extend)));
+
+ if (help_lines) {
tgpf->draw_handle_3d = ED_region_draw_cb_activate(
tgpf->region->type, gpencil_fill_draw_3d, tgpf, REGION_DRAW_POST_VIEW);
}
@@ -1955,9 +1989,10 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
const bool is_inverted = (is_brush_inv && !event->ctrl) || (!is_brush_inv && event->ctrl);
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(tgpf->gpd);
const bool do_extend = (tgpf->fill_extend_fac > 0.0f);
+ const bool help_lines = ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) ||
+ ((tgpf->flag & GP_BRUSH_FILL_SHOW_EXTENDLINES) && (do_extend)));
- int estate = ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) == 0) ? OPERATOR_PASS_THROUGH :
- OPERATOR_RUNNING_MODAL;
+ int estate = (!help_lines) ? OPERATOR_PASS_THROUGH : OPERATOR_RUNNING_MODAL;
switch (event->type) {
case EVT_ESCKEY:
case RIGHTMOUSE:
@@ -1966,7 +2001,7 @@ static int gpencil_fill_modal(bContext *C, wmOperator *op, const wmEvent *event)
case LEFTMOUSE:
tgpf->on_back = RNA_boolean_get(op->ptr, "on_back");
/* first time the event is not enabled to show help lines. */
- if ((tgpf->oldkey != -1) || ((tgpf->flag & GP_BRUSH_FILL_SHOW_HELPLINES) == 0)) {
+ if ((tgpf->oldkey != -1) || (!help_lines)) {
ARegion *region = BKE_area_find_region_xy(
CTX_wm_area(C), RGN_TYPE_ANY, event->x, event->y);
if (region) {
diff --git a/source/blender/makesdna/DNA_brush_enums.h b/source/blender/makesdna/DNA_brush_enums.h
index 236cd65e5f6..093a1a00ece 100644
--- a/source/blender/makesdna/DNA_brush_enums.h
+++ b/source/blender/makesdna/DNA_brush_enums.h
@@ -77,6 +77,8 @@ typedef enum eGPDbrush_Flag {
GP_BRUSH_USE_JITTER_PRESSURE = (1 << 2),
/* Disable automatic zoom for filling. */
GP_BRUSH_FILL_FIT_DISABLE = (1 << 3),
+ /* Show extend fill help lines. */
+ GP_BRUSH_FILL_SHOW_EXTENDLINES = (1 << 4),
/* fill hide transparent */
GP_BRUSH_FILL_HIDE = (1 << 6),
/* show fill help lines */
diff --git a/source/blender/makesrna/intern/rna_brush.c b/source/blender/makesrna/intern/rna_brush.c
index 877b9a2d83d..bd3fe16a437 100644
--- a/source/blender/makesrna/intern/rna_brush.c
+++ b/source/blender/makesrna/intern/rna_brush.c
@@ -1836,6 +1836,12 @@ static void rna_def_gpencil_options(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Show Lines", "Show help lines for filling to see boundaries");
RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ prop = RNA_def_property(srna, "show_fill_extend", PROP_BOOLEAN, PROP_NONE);
+ RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_BRUSH_FILL_SHOW_EXTENDLINES);
+ RNA_def_property_boolean_default(prop, true);
+ RNA_def_property_ui_text(prop, "Show Extend Lines", "Show help lines for stroke extension");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+
prop = RNA_def_property(srna, "show_fill", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_BRUSH_FILL_HIDE);
RNA_def_property_boolean_default(prop, true);
More information about the Bf-blender-cvs
mailing list