diff options
Diffstat (limited to 'source/blender/editors/gpencil/annotate_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 56 |
1 files changed, 47 insertions, 9 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index ab3b1525e9e..a9f9625db7a 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -1432,6 +1432,41 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p) return 1; } +/* Enable the annotations in the current space. */ +static void annotation_visible_on_space(tGPsdata *p) +{ + ScrArea *area = p->area; + switch (area->spacetype) { + case SPACE_VIEW3D: { + View3D *v3d = (View3D *)area->spacedata.first; + v3d->flag2 |= V3D_SHOW_ANNOTATION; + break; + } + case SPACE_SEQ: { + SpaceSeq *sseq = (SpaceSeq *)area->spacedata.first; + sseq->flag |= SEQ_SHOW_GPENCIL; + break; + } + case SPACE_IMAGE: { + SpaceImage *sima = (SpaceImage *)area->spacedata.first; + sima->flag |= SI_SHOW_GPENCIL; + break; + } + case SPACE_NODE: { + SpaceNode *snode = (SpaceNode *)area->spacedata.first; + snode->flag |= SNODE_SHOW_GPENCIL; + break; + } + case SPACE_CLIP: { + SpaceClip *sclip = (SpaceClip *)area->spacedata.first; + sclip->flag |= SC_SHOW_ANNOTATION; + break; + } + default: + break; + } +} + /* init new painting session */ static tGPsdata *annotation_session_initpaint(bContext *C) { @@ -1458,6 +1493,9 @@ static tGPsdata *annotation_session_initpaint(bContext *C) */ p->radius = U.gp_eraser; + /* Annotations must be always visible when use it. */ + annotation_visible_on_space(p); + /* return context data for running paint operator */ return p; } @@ -2003,7 +2041,7 @@ static void annotation_draw_apply(wmOperator *op, tGPsdata *p, Depsgraph *depsgr short ok = annotation_stroke_addpoint(p, p->mval, p->pressure, p->curtime); /* handle errors while adding point */ - if ((ok == GP_STROKEADD_FULL) || (ok == GP_STROKEADD_OVERFLOW)) { + if (ELEM(ok, GP_STROKEADD_FULL, GP_STROKEADD_OVERFLOW)) { /* finish off old stroke */ annotation_paint_strokeend(p); /* And start a new one!!! Else, projection errors! */ @@ -2089,8 +2127,8 @@ static void annotation_draw_apply_event( } else { p->straight[0] = 0; - /* We were using shift while having permanent stabilization actived, - so activate the temp flag back again. */ + /* We were using shift while having permanent stabilization active, + * so activate the temp flag back again. */ if (p->flags & GP_PAINTFLAG_USE_STABILIZER) { if ((p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) == 0) { annotation_draw_toggle_stabilizer_cursor(p, true); @@ -2098,8 +2136,8 @@ static void annotation_draw_apply_event( } } /* We are using the temporal stabilizer flag atm, - but shift is not pressed as well as the permanent flag is not used, - so we don't need the cursor anymore. */ + * but shift is not pressed as well as the permanent flag is not used, + * so we don't need the cursor anymore. */ else if (p->flags & GP_PAINTFLAG_USE_STABILIZER_TEMP) { /* Reset temporal stabilizer flag and remove cursor. */ p->flags &= ~GP_PAINTFLAG_USE_STABILIZER_TEMP; @@ -2353,7 +2391,7 @@ static tGPsdata *annotation_stroke_begin(bContext *C, wmOperator *op) tGPsdata *p = op->customdata; /* we must check that we're still within the area that we're set up to work from - * otherwise we could crash (see bug #20586) + * otherwise we could crash (see bug T20586) */ if (CTX_wm_area(C) != p->area) { printf("\t\t\tGP - wrong area execution abort!\n"); @@ -2467,8 +2505,8 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve EVT_UPARROWKEY, EVT_ZKEY)) { /* allow some keys: - * - for frame changing [#33412] - * - for undo (during sketching sessions) + * - For frame changing T33412. + * - For undo (during sketching sessions). */ } else if (ELEM(event->type, @@ -2520,7 +2558,7 @@ static int annotation_draw_modal(bContext *C, wmOperator *op, const wmEvent *eve * - LEFTMOUSE = standard drawing (all) / straight line drawing (all) / polyline (toolbox * only) * - RIGHTMOUSE = polyline (hotkey) / eraser (all) - * (Disabling RIGHTMOUSE case here results in bugs like [#32647]) + * (Disabling RIGHTMOUSE case here results in bugs like T32647) * also making sure we have a valid event value, to not exit too early */ if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE) && (ELEM(event->val, KM_PRESS, KM_RELEASE))) { |