static int mask_select_linked_exec(bContext *C, wmOperator *UNUSED(op)) { Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; bool changed = false; /* do actual selection */ for (masklay = mask->masklayers.first; masklay; masklay = masklay->next) { MaskSpline *spline; if (masklay->restrictflag & (MASK_RESTRICT_VIEW | MASK_RESTRICT_SELECT)) { continue; } for (spline = masklay->splines.first; spline; spline = spline->next) { if (ED_mask_spline_select_check(spline)) { ED_mask_spline_select_set(spline, true); changed = true; } } } if (changed) { ED_mask_select_flush_all(mask); WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask); return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; }
void ED_mask_layer_select_set(MaskLayer *masklay, const bool do_select) { MaskSpline *spline; if (masklay->restrictflag & MASK_RESTRICT_SELECT) { if (do_select == true) { return; } } for (spline = masklay->splines.first; spline; spline = spline->next) { ED_mask_spline_select_set(spline, do_select); } }
static int mask_select_linked_pick_invoke(bContext *C, wmOperator *op, wmEvent *event) { ScrArea *sa = CTX_wm_area(C); ARegion *ar = CTX_wm_region(C); Mask *mask = CTX_data_edit_mask(C); MaskLayer *masklay; MaskSpline *spline; MaskSplinePoint *point = NULL; float co[2]; int do_select = !RNA_boolean_get(op->ptr, "deselect"); int is_handle = 0; const float threshold = 19; int change = FALSE; ED_mask_mouse_pos(sa, ar, event->mval, co); point = ED_mask_point_find_nearest(C, mask, co, threshold, &masklay, &spline, &is_handle, NULL); if (point) { ED_mask_spline_select_set(spline, do_select); masklay->act_spline = spline; masklay->act_point = point; change = TRUE; } if (change) { ED_mask_select_flush_all(mask); WM_event_add_notifier(C, NC_MASK | ND_SELECT, mask); return OPERATOR_FINISHED; } return OPERATOR_CANCELLED; }