[Bf-blender-cvs] [596f10a0cf1] soc-2020-greasepencil-curve: GPencil: Curve mode: Set stroke select flag
Falk David
noreply at git.blender.org
Thu Jul 9 17:55:56 CEST 2020
Commit: 596f10a0cf14741679a4b3228662e12a0ae591ff
Author: Falk David
Date: Thu Jul 9 16:24:04 2020 +0200
Branches: soc-2020-greasepencil-curve
https://developer.blender.org/rB596f10a0cf14741679a4b3228662e12a0ae591ff
GPencil: Curve mode: Set stroke select flag
Set/unset the selection flag for a stroke, when its curve is selected.
This change is needed so that operators like "change end caps"
work as expected in curve edit mode.
===================================================================
M source/blender/blenkernel/BKE_gpencil.h
M source/blender/blenkernel/intern/gpencil.c
M source/blender/editors/gpencil/gpencil_select.c
M source/blender/editors/gpencil/gpencil_utils.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index ffc16dbbaaf..9259729695d 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -104,7 +104,7 @@ void BKE_gpencil_batch_cache_dirty_tag(struct bGPdata *gpd);
void BKE_gpencil_batch_cache_free(struct bGPdata *gpd);
void BKE_gpencil_stroke_sync_selection(struct bGPDstroke *gps);
-void BKE_gpencil_curve_sync_selection(struct bGPDcurve *gpc);
+void BKE_gpencil_curve_sync_selection(struct bGPDstroke *gps);
struct bGPDframe *BKE_gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe);
struct bGPDframe *BKE_gpencil_frame_addcopy(struct bGPDlayer *gpl, int cframe);
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 1b734e2e792..4d3b820304a 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -934,13 +934,16 @@ void BKE_gpencil_stroke_sync_selection(bGPDstroke *gps)
}
}
-void BKE_gpencil_curve_sync_selection(bGPDcurve *gpc)
+void BKE_gpencil_curve_sync_selection(bGPDstroke *gps)
{
+ bGPDcurve *gpc = gps->editcurve;
if (gpc == NULL) {
return;
}
+ gps->flag &= ~GP_STROKE_SELECT;
gpc->flag &= ~GP_CURVE_SELECT;
+
bool is_selected = false;
for (int i = 0; i < gpc->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
@@ -960,6 +963,7 @@ void BKE_gpencil_curve_sync_selection(bGPDcurve *gpc)
if (is_selected) {
gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
}
}
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c
index 6dc7228b70a..0a231bee5cc 100644
--- a/source/blender/editors/gpencil/gpencil_select.c
+++ b/source/blender/editors/gpencil/gpencil_select.c
@@ -1612,6 +1612,7 @@ static void deselect_all_selected(bContext *C)
}
gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
}
}
CTX_DATA_END;
@@ -1620,6 +1621,7 @@ static void deselect_all_selected(bContext *C)
static void gpencil_select_curve_point(bContext *C,
const int mval[2],
const int radius_squared,
+ bGPDstroke **r_gps,
bGPDcurve **r_gpc,
bGPDcurve_point **r_pt,
char *handle)
@@ -1658,6 +1660,7 @@ static void gpencil_select_curve_point(bContext *C,
const int pt_distance = len_manhattan_v2v2_int(mval, screen_co);
if (pt_distance <= radius_squared && pt_distance < hit_distance) {
+ *r_gps = gps;
*r_gpc = gpc;
*r_pt = gpc_pt;
*handle = j;
@@ -1726,10 +1729,10 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
if (is_curve_edit) {
gpencil_select_curve_point(
- C, mval, radius_squared, &hit_curve, &hit_curve_point, &hit_curve_handle);
+ C, mval, radius_squared, &hit_stroke, &hit_curve, &hit_curve_point, &hit_curve_handle);
}
- if (hit_curve_point == NULL) {
+ if (hit_curve == NULL) {
/* init space conversion stuff */
gpencil_point_conversion_init(C, &gsc);
@@ -1831,9 +1834,11 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
if (deselect == false) {
hit_curve->flag |= GP_CURVE_SELECT;
+ hit_stroke->flag |= GP_STROKE_SELECT;
}
else {
hit_curve->flag &= ~GP_CURVE_SELECT;
+ hit_stroke->flag &= ~GP_STROKE_SELECT;
}
}
else {
@@ -1866,6 +1871,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
hit_curve_point->flag |= GP_CURVE_POINT_SELECT;
BEZT_SEL_IDX(&hit_curve_point->bezt, hit_curve_handle);
hit_curve->flag |= GP_CURVE_SELECT;
+ hit_stroke->flag |= GP_STROKE_SELECT;
}
else {
/* we're adding selection, so selection must be true */
@@ -1898,7 +1904,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
if (!BEZT_ISSEL_ANY(&hit_curve_point->bezt)) {
hit_curve_point->flag &= ~GP_CURVE_POINT_SELECT;
}
- BKE_gpencil_curve_sync_selection(hit_curve);
+ BKE_gpencil_curve_sync_selection(hit_stroke);
}
else {
/* deselect point */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 82287b81171..7a98284889a 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -2635,10 +2635,11 @@ void ED_gpencil_select_curve_toggle_all(bContext *C, int action)
for (int i = 0; i < gpc->tot_curve_points; i++) {
bGPDcurve_point *gpc_pt = &gpc->curve_points[i];
BezTriple *bezt = &gpc_pt->bezt;
- gpc_pt->flag |= GP_CURVE_POINT_SELECT;
+ gpc_pt->flag &= ~GP_CURVE_POINT_SELECT;
BEZT_DESEL_ALL(bezt);
}
gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
}
GP_EDITABLE_CURVES_END(gps_iter);
}
@@ -2680,9 +2681,11 @@ void ED_gpencil_select_curve_toggle_all(bContext *C, int action)
if (selected) {
gpc->flag |= GP_CURVE_SELECT;
+ gps->flag |= GP_STROKE_SELECT;
}
else {
gpc->flag &= ~GP_CURVE_SELECT;
+ gps->flag &= ~GP_STROKE_SELECT;
}
}
CTX_DATA_END;
More information about the Bf-blender-cvs
mailing list