Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Jolly <mistajolly@gmail.com>2018-11-29 13:50:21 +0300
committerCharlie Jolly <mistajolly@gmail.com>2018-11-29 18:44:20 +0300
commit1f5216c57ae2f7896c9392668fae5019e481c723 (patch)
tree70e6485b94d80f1d2fb79613b12d656d3e440c14 /source/blender/editors/gpencil/gpencil_primitive.c
parent1c0bc19e3f55eff4bc2df4c2affb64272c5f5cb7 (diff)
GP: Add option to draw primatives from center
This allows primatives to be drawn from the center using the ALT key. Also fixes SHIFT constraint not working correctly in all directions. Both options can be used together. Differential Revision: https://developer.blender.org/D4009
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_primitive.c')
-rw-r--r--source/blender/editors/gpencil/gpencil_primitive.c37
1 files changed, 31 insertions, 6 deletions
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 9d9410d0885..ee2cf7fad48 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -210,13 +210,13 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi
char msg_str[UI_MAX_DRAW_STR];
if (tgpi->type == GP_STROKE_BOX) {
- BLI_strncpy(msg_str, IFACE_("Rectangle: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Rectangle: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Shift to square, Alt to center"), UI_MAX_DRAW_STR);
}
else if (tgpi->type == GP_STROKE_LINE) {
- BLI_strncpy(msg_str, IFACE_("Line: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Line: ESC/RMB to cancel, LMB set origin, Enter/LMB to confirm, Alt to center"), UI_MAX_DRAW_STR);
}
else {
- BLI_strncpy(msg_str, IFACE_("Circle: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL to adjust edge number, Shift to square"), UI_MAX_DRAW_STR);
+ BLI_strncpy(msg_str, IFACE_("Circle: ESC/RMB to cancel, Enter/LMB to confirm, WHEEL to adjust edge number, Shift to square, Alt to center"), UI_MAX_DRAW_STR);
}
if (tgpi->type == GP_STROKE_CIRCLE) {
@@ -408,6 +408,9 @@ static void gpencil_primitive_update(bContext *C, wmOperator *op, tGPDprimitive
static void gpencil_primitive_interaction_begin(tGPDprimitive *tgpi, const wmEvent *event)
{
+ tgpi->origin[0] = event->mval[0];
+ tgpi->origin[1] = event->mval[1];
+
tgpi->top[0] = event->mval[0];
tgpi->top[1] = event->mval[1];
@@ -671,13 +674,35 @@ static int gpencil_primitive_modal(bContext *C, wmOperator *op, const wmEvent *e
/* update position of mouse */
tgpi->bottom[0] = event->mval[0];
tgpi->bottom[1] = event->mval[1];
+ tgpi->top[0] = tgpi->origin[0];
+ tgpi->top[1] = tgpi->origin[1];
if (tgpi->flag == IDLE) {
- tgpi->top[0] = event->mval[0];
- tgpi->top[1] = event->mval[1];
+ tgpi->origin[0] = event->mval[0];
+ tgpi->origin[1] = event->mval[1];
}
/* Keep square if shift key */
if (event->shift) {
- tgpi->bottom[1] = tgpi->top[1] - (tgpi->bottom[0] - tgpi->top[0]);
+ int x = tgpi->bottom[0] - tgpi->origin[0];
+ int y = tgpi->bottom[1] - tgpi->origin[1];
+ int w = abs(x);
+ int h = abs(y);
+ if ((x > 0 && y > 0) || (x < 0 && y < 0)) {
+ if (w > h)
+ tgpi->bottom[1] = tgpi->origin[1] + x;
+ else
+ tgpi->bottom[0] = tgpi->origin[0] + y;
+ }
+ else {
+ if (w > h)
+ tgpi->bottom[1] = tgpi->origin[1] - x;
+ else
+ tgpi->bottom[0] = tgpi->origin[0] - y;
+ }
+ }
+ /* Center primitive if alt key */
+ if (event->alt) {
+ tgpi->top[0] = tgpi->origin[0] - (tgpi->bottom[0] - tgpi->origin[0]);
+ tgpi->top[1] = tgpi->origin[1] - (tgpi->bottom[1] - tgpi->origin[1]);
}
/* update screen */
gpencil_primitive_update(C, op, tgpi);