diff options
author | Antonioya <blendergit@gmail.com> | 2018-09-25 19:17:34 +0300 |
---|---|---|
committer | Antonioya <blendergit@gmail.com> | 2018-09-25 19:17:48 +0300 |
commit | df5cb4d66ffa5fbd4af553c433f7742406665686 (patch) | |
tree | abceeaff4706eacb9227648b4fc00f5a09eb7e2f /source/blender/editors/gpencil/gpencil_data.c | |
parent | 89b535690c35a8d9968faa6054a4ce5572bce7c9 (diff) |
GP: Add multiframe support to select by color
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_data.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_data.c | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c index 6202720883c..3f159c87b3c 100644 --- a/source/blender/editors/gpencil/gpencil_data.c +++ b/source/blender/editors/gpencil/gpencil_data.c @@ -2581,37 +2581,52 @@ static int gpencil_color_select_exec(bContext *C, wmOperator *UNUSED(op)) bGPdata *gpd = ED_gpencil_data_get_active(C); Object *ob = CTX_data_active_object(C); MaterialGPencilStyle *gp_style = BKE_material_gpencil_settings_get(ob, ob->actcol); + bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd); /* sanity checks */ if (ELEM(NULL, gpd, gp_style)) return OPERATOR_CANCELLED; /* read all strokes and select*/ - for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) { - /* only editable and visible layers are considered */ - if (gpencil_layer_is_editable(gpl) && (gpl->actframe != NULL)) { - /* verify something to do */ - for (bGPDstroke *gps = gpl->actframe->strokes.first; gps; gps = gps->next) { - /* skip strokes that are invalid for current view */ - if (ED_gpencil_stroke_can_use(C, gps) == false) - continue; - /* check if the color is editable */ - if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) - continue; + CTX_DATA_BEGIN(C, bGPDlayer *, gpl, editable_gpencil_layers) + { + bGPDframe *init_gpf = gpl->actframe; + if (is_multiedit) { + init_gpf = gpl->frames.first; + } + for (bGPDframe *gpf = init_gpf; gpf; gpf = gpf->next) { + if ((gpf == gpl->actframe) || ((gpf->flag & GP_FRAME_SELECT) && (is_multiedit))) { + + /* verify something to do */ + for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) { + /* skip strokes that are invalid for current view */ + if (ED_gpencil_stroke_can_use(C, gps) == false) + continue; + /* check if the color is editable */ + if (ED_gpencil_stroke_color_use(ob, gpl, gps) == false) + continue; - /* select */ - if (ob->actcol == gps->mat_nr + 1) { - bGPDspoint *pt; - int i; + /* select */ + if (ob->actcol == gps->mat_nr + 1) { + bGPDspoint *pt; + int i; - gps->flag |= GP_STROKE_SELECT; - for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { - pt->flag |= GP_SPOINT_SELECT; + gps->flag |= GP_STROKE_SELECT; + for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) { + pt->flag |= GP_SPOINT_SELECT; + } } } } + /* if not multiedit, exit loop*/ + if (!is_multiedit) { + break; + } + } } + CTX_DATA_END; + /* copy on write tag is needed, or else no refresh happens */ DEG_id_tag_update(&gpd->id, DEG_TAG_COPY_ON_WRITE); |