diff options
author | Antonioya <blendergit@gmail.com> | 2018-11-29 23:59:29 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-11-29 23:59:57 +0300 |
commit | 0487089c3146755dd7a19238cd9595744c5fee65 (patch) | |
tree | 7caa96196fe8de6802acd27392c19211f16da31c /source/blender/editors/gpencil/annotate_paint.c | |
parent | 6cfed6d7756801ed2e10a82615da2b6a20f38d3b (diff) |
Enable annotations when GP object is selected.
Now when try to add annotation, if a grease pencil object is selected, first the object is unselected. This solution is not perfect but it's better than cancel the annotation.
Thanks Dalai for his help.
Diffstat (limited to 'source/blender/editors/gpencil/annotate_paint.c')
-rw-r--r-- | source/blender/editors/gpencil/annotate_paint.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c index 3a9b7e7306c..c5dcb51ff6e 100644 --- a/source/blender/editors/gpencil/annotate_paint.c +++ b/source/blender/editors/gpencil/annotate_paint.c @@ -49,6 +49,7 @@ #include "BKE_context.h" #include "BKE_global.h" #include "BKE_gpencil.h" +#include "BKE_layer.h" #include "BKE_main.h" #include "BKE_report.h" #include "BKE_screen.h" @@ -1867,15 +1868,24 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event { Object *ob = CTX_data_active_object(C); ScrArea *sa = CTX_wm_area(C); + Scene *scene = CTX_data_scene(C); tGPsdata *p = NULL; - /* GPXX Need a better solution */ + /* if try to do annotations with a gp object selected, first + * unselect the object to avoid conflicts. + * The solution is not perfect but we can keep running the annotations while + * found a better solution. + */ if (sa && sa->spacetype == SPACE_VIEW3D) { if ((ob != NULL) && (ob->type == OB_GPENCIL)) { - BKE_report(op->reports, RPT_ERROR, "Cannot draw annotation with a Grease Pencil object active"); - return OPERATOR_CANCELLED; + ViewLayer *view_layer = CTX_data_view_layer(C); + BKE_view_layer_base_deselect_all(view_layer); + view_layer->basact = NULL; + DEG_id_tag_update(&scene->id, DEG_TAG_SELECT_UPDATE); + WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene); } } + if (G.debug & G_DEBUG) printf("GPencil - Starting Drawing\n"); |