Grease Pencil: Fix hardcoded DKEY for continous drawing
authorDalai Felinto <dfelinto@gmail.com>
Fri, 23 Jun 2017 08:32:03 +0000 (10:32 +0200)
committerDalai Felinto <dfelinto@gmail.com>
Fri, 23 Jun 2017 08:46:30 +0000 (10:46 +0200)
source/blender/editors/gpencil/gpencil_paint.c

index 5eacbf6f80758d1d38017e1ead721add9ac10d9c..eb49060b629cce0fe6b1f627d97dfa54211e1f65 100644 (file)
@@ -162,6 +162,8 @@ typedef struct tGPsdata {
        bGPDbrush *brush; /* current drawing brush */
        short straight[2];   /* 1: line horizontal, 2: line vertical, other: not defined, second element position */
        int lock_axis;       /* lock drawing to one axis */
+
+       short keymodifier;   /* key used for invoking the operator */
 } tGPsdata;
 
 /* ------ */
@@ -1940,7 +1942,7 @@ static void gpencil_draw_cancel(bContext *C, wmOperator *op)
 /* ------------------------------- */
 
 
-static int gpencil_draw_init(bContext *C, wmOperator *op)
+static int gpencil_draw_init(bContext *C, wmOperator *op, const wmEvent *event)
 {
        tGPsdata *p;
        eGPencil_PaintModes paintmode = RNA_enum_get(op->ptr, "mode");
@@ -1959,6 +1961,13 @@ static int gpencil_draw_init(bContext *C, wmOperator *op)
                gpencil_draw_exit(C, op);
                return 0;
        }
+
+       if (event != NULL) {
+               p->keymodifier = event->keymodifier;
+       }
+       else {
+               p->keymodifier = -1;
+       }
        
        /* everything is now setup ok */
        return 1;
@@ -2200,7 +2209,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
        /* printf("GPencil - Starting Re-Drawing\n"); */
        
        /* try to initialize context data needed while drawing */
-       if (!gpencil_draw_init(C, op)) {
+       if (!gpencil_draw_init(C, op, NULL)) {
                if (op->customdata) MEM_freeN(op->customdata);
                /* printf("\tGP - no valid data\n"); */
                return OPERATOR_CANCELLED;
@@ -2275,7 +2284,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
                printf("GPencil - Starting Drawing\n");
        
        /* try to initialize context data needed while drawing */
-       if (!gpencil_draw_init(C, op)) {
+       if (!gpencil_draw_init(C, op, event)) {
                if (op->customdata)
                        MEM_freeN(op->customdata);
                if (G.debug & G_DEBUG)
@@ -2438,7 +2447,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, const wmEvent *event)
                         *   is essential for ensuring that they can quickly return to that view
                         */
                }
-               else if ((ELEM(event->type, DKEY)) && (event->val == KM_RELEASE)) {
+               else if ((ELEM(event->type, p->keymodifier)) && (event->val == KM_RELEASE)) {
                        /* enable continuous if release D key in mid drawing */
                        p->scene->toolsettings->gpencil_flags |= GP_TOOL_FLAG_PAINTSESSIONS_ON;
                }