diff options
author | Antonioya <blendergit@gmail.com> | 2018-11-28 22:14:48 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-11-28 22:15:02 +0300 |
commit | 7ced3da6ac25b95ad94541770f63905449ec37e8 (patch) | |
tree | c831544d249b10164f85853cdabc3f71cfd7e553 /source/blender/editors/gpencil/gpencil_select.c | |
parent | 0f4cc474c9b4b42fb20b2af6ab9b1e4c0a3ae2a8 (diff) |
GP: Cleanup duplicated code moving to function
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 57 |
1 files changed, 24 insertions, 33 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index bf90a13b584..ad943a38a64 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -1299,6 +1299,28 @@ void GPENCIL_OT_select_lasso(wmOperatorType *ot) /** \name Mouse Pick Select Operator * \{ */ +/* helper to deselect all selected strokes/points */ +static void deselect_all_selected(bContext *C) +{ + CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) + { + /* deselect stroke and its points if selected */ + if (gps->flag & GP_STROKE_SELECT) { + bGPDspoint *pt; + int i; + + /* deselect points */ + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + pt->flag &= ~GP_SPOINT_SELECT; + } + + /* deselect stroke itself too */ + gps->flag &= ~GP_STROKE_SELECT; + } + } + CTX_DATA_END; +} + static int gpencil_select_exec(bContext *C, wmOperator *op) { ScrArea *sa = CTX_wm_area(C); @@ -1376,23 +1398,8 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) if (ELEM(NULL, hit_stroke, hit_point)) { /* since left mouse select change, deselect all if click outside any hit */ - CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) - { - /* deselect stroke and its points if selected */ - if (gps->flag & GP_STROKE_SELECT) { - bGPDspoint *pt; - int i; + deselect_all_selected(C); - /* deselect points */ - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - pt->flag &= ~GP_SPOINT_SELECT; - } - - /* deselect stroke itself too */ - gps->flag &= ~GP_STROKE_SELECT; - } - } - CTX_DATA_END; /* copy on write tag is needed, or else no refresh happens */ DEG_id_tag_update(&gpd->id, OB_RECALC_DATA); DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE); @@ -1408,23 +1415,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op) /* If not extending selection, deselect everything else */ if (extend == false) { - CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) - { - /* deselect stroke and its points if selected */ - if (gps->flag & GP_STROKE_SELECT) { - bGPDspoint *pt; - int i; - - /* deselect points */ - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - pt->flag &= ~GP_SPOINT_SELECT; - } - - /* deselect stroke itself too */ - gps->flag &= ~GP_STROKE_SELECT; - } - } - CTX_DATA_END; + deselect_all_selected(C); } /* Perform selection operations... */ |