diff options
author | Charlie Jolly <mistajolly@gmail.com> | 2018-12-19 13:17:14 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2018-12-19 15:18:45 +0300 |
commit | ac8cde69f50ec5e8b3af7e8538006dc011b1c541 (patch) | |
tree | 1bebff30dc5a1c3ed6b206b683822816ab28774e | |
parent | 76d04f95141cd1e5f5db7523dbfa8349a01a1a62 (diff) |
GP: Primitive: Add RMB behaviour to Grab/Move
-rw-r--r-- | source/blender/editors/gpencil/gpencil_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_primitive.c | 24 |
2 files changed, 21 insertions, 4 deletions
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index e2cbeda2733..7d386c18c64 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -162,6 +162,7 @@ typedef struct tGPDprimitive { int point_count; /* number of edges allocated */ int tot_stored_edges; /* stored number of polygon edges */ int tot_edges; /* number of polygon edges */ + float move[2]; /* move distance */ float origin[2]; /* initial box corner */ float start[2]; /* first box corner */ float end[2]; /* last box corner */ diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c index f13235926f1..d856c1859bb 100644 --- a/source/blender/editors/gpencil/gpencil_primitive.c +++ b/source/blender/editors/gpencil/gpencil_primitive.c @@ -1302,10 +1302,19 @@ static void gpencil_primitive_edit_event_handling(bContext *C, wmOperator *op, w } /* move */ -static void gpencil_primitive_move(tGPDprimitive *tgpi) +static void gpencil_primitive_move(tGPDprimitive *tgpi, bool reset) { float move[2]; - sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo); + zero_v2(move); + + if (reset) { + sub_v2_v2(move, tgpi->move); + zero_v2(tgpi->move); + } + else { + sub_v2_v2v2(move, tgpi->mval, tgpi->mvalo); + add_v2_v2(tgpi->move, move); + } bGPDstroke *gps = tgpi->gpf->strokes.first; tGPspoint *points2D = tgpi->points; @@ -1335,14 +1344,21 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e switch (event->type) { case MOUSEMOVE: - gpencil_primitive_move(tgpi); + gpencil_primitive_move(tgpi, false); gpencil_primitive_update(C, op, tgpi); break; case ESCKEY: - case RIGHTMOUSE: case LEFTMOUSE: + zero_v2(tgpi->move); tgpi->flag = IN_CURVE_EDIT; break; + case RIGHTMOUSE: + if (event->val == KM_RELEASE) { + tgpi->flag = IN_CURVE_EDIT; + gpencil_primitive_move(tgpi, true); + gpencil_primitive_update(C, op, tgpi); + } + break; } copy_v2_v2(tgpi->mvalo, tgpi->mval); return OPERATOR_RUNNING_MODAL; |