diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-05 10:37:33 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-05 10:39:56 +0300 |
commit | caacedd861fea49086d6ec531acbaf79a775c62b (patch) | |
tree | 3fb1c44941122247d65d7f34eef83bc60527a4f6 /source/blender/editors/gpencil/gpencil_select.c | |
parent | b8ef725497e45648ac7214927294e3ab60b71bc2 (diff) |
GP: move select all into a utility function
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_select.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_select.c | 85 |
1 files changed, 1 insertions, 84 deletions
diff --git a/source/blender/editors/gpencil/gpencil_select.c b/source/blender/editors/gpencil/gpencil_select.c index 720e3656b0c..e3d4b42e359 100644 --- a/source/blender/editors/gpencil/gpencil_select.c +++ b/source/blender/editors/gpencil/gpencil_select.c @@ -102,90 +102,7 @@ static int gpencil_select_all_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - /* for "toggle", test for existing selected strokes */ - if (action == SEL_TOGGLE) { - action = SEL_SELECT; - - CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) - { - if (gps->flag & GP_STROKE_SELECT) { - action = SEL_DESELECT; - break; // XXX: this only gets out of the inner loop... - } - } - CTX_DATA_END; - } - - /* if deselecting, we need to deselect strokes across all frames - * - Currently, an exception is only given for deselection - * Selecting and toggling should only affect what's visible, - * while deselecting helps clean up unintended/forgotten - * stuff on other frames - */ - if (action == SEL_DESELECT) { - /* deselect strokes across editable layers - * NOTE: we limit ourselves to editable layers, since once a layer is "locked/hidden - * nothing should be able to touch it - */ - CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) - { - bGPDframe *gpf; - - /* deselect all strokes on all frames */ - for (gpf = gpl->frames.first; gpf; gpf = gpf->next) { - bGPDstroke *gps; - - for (gps = gpf->strokes.first; gps; gps = gps->next) { - bGPDspoint *pt; - int i; - - /* only edit strokes that are valid in this view... */ - if (ED_gpencil_stroke_can_use(C, gps)) { - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - pt->flag &= ~GP_SPOINT_SELECT; - } - - gps->flag &= ~GP_STROKE_SELECT; - } - } - } - } - CTX_DATA_END; - } - else { - /* select or deselect all strokes */ - CTX_DATA_BEGIN(C, bGPDstroke *, gps, editable_gpencil_strokes) - { - bGPDspoint *pt; - int i; - bool selected = false; - - /* Change selection status of all points, then make the stroke match */ - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - switch (action) { - case SEL_SELECT: - pt->flag |= GP_SPOINT_SELECT; - break; - //case SEL_DESELECT: - // pt->flag &= ~GP_SPOINT_SELECT; - // break; - case SEL_INVERT: - pt->flag ^= GP_SPOINT_SELECT; - break; - } - - if (pt->flag & GP_SPOINT_SELECT) - selected = true; - } - - /* Change status of stroke */ - if (selected) - gps->flag |= GP_STROKE_SELECT; - else - gps->flag &= ~GP_STROKE_SELECT; - } - CTX_DATA_END; - } + ED_gpencil_select_toggle_all(C, action); /* updates */ DEG_id_tag_update(&gpd->id, ID_RECALC_GEOMETRY); |