Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_ops.c
| Show First 20 Lines • Show All 425 Lines • ▼ Show 20 Lines | static void *slide_point_customdata(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| MaskSplinePoint *point, *cv_point, *feather_point; | MaskSplinePoint *point, *cv_point, *feather_point; | ||||
| MaskSplinePointUW *uw = NULL; | MaskSplinePointUW *uw = NULL; | ||||
| int width, height, action = SLIDE_ACTION_NONE; | int width, height, action = SLIDE_ACTION_NONE; | ||||
| const bool slide_feather = RNA_boolean_get(op->ptr, "slide_feather"); | const bool slide_feather = RNA_boolean_get(op->ptr, "slide_feather"); | ||||
| float co[2], cv_score, feather_score; | float co[2], cv_score, feather_score; | ||||
| const float threshold = 19; | const float threshold = 19; | ||||
| eMaskWhichHandle which_handle; | eMaskWhichHandle which_handle; | ||||
| MaskViewLockState lock_state; | |||||
| ED_mask_view_lock_state_store(C, &lock_state); | |||||
| ED_mask_mouse_pos(area, region, event->mval, co); | ED_mask_mouse_pos(area, region, event->mval, co); | ||||
| ED_mask_get_size(area, &width, &height); | ED_mask_get_size(area, &width, &height); | ||||
| cv_point = ED_mask_point_find_nearest( | cv_point = ED_mask_point_find_nearest( | ||||
| C, mask, co, threshold, &cv_mask_layer, &cv_spline, &which_handle, &cv_score); | C, mask, co, threshold, &cv_mask_layer, &cv_spline, &which_handle, &cv_score); | ||||
| if (ED_mask_feather_find_nearest(C, | if (ED_mask_feather_find_nearest(C, | ||||
| mask, | mask, | ||||
| ▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | if (customdata->action != SLIDE_ACTION_SPLINE) { | ||||
| copy_m3_m3(customdata->vec, point->bezt.vec); | copy_m3_m3(customdata->vec, point->bezt.vec); | ||||
| if (which_handle != MASK_WHICH_HANDLE_NONE) { | if (which_handle != MASK_WHICH_HANDLE_NONE) { | ||||
| BKE_mask_point_handle(point, which_handle, customdata->orig_handle_coord); | BKE_mask_point_handle(point, which_handle, customdata->orig_handle_coord); | ||||
| copy_v2_v2(customdata->prev_handle_coord, customdata->orig_handle_coord); | copy_v2_v2(customdata->prev_handle_coord, customdata->orig_handle_coord); | ||||
| } | } | ||||
| } | } | ||||
| customdata->which_handle = which_handle; | customdata->which_handle = which_handle; | ||||
| { | |||||
| WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); | |||||
| DEG_id_tag_update(&mask->id, 0); | |||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| } | |||||
| ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord); | ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord); | ||||
| } | } | ||||
| return customdata; | return customdata; | ||||
| } | } | ||||
| static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int slide_point_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| if (data->orig_spline) { | if (data->orig_spline) { | ||||
| BKE_mask_spline_free(data->orig_spline); | BKE_mask_spline_free(data->orig_spline); | ||||
| } | } | ||||
| MEM_freeN(data); | MEM_freeN(data); | ||||
| } | } | ||||
| /* XXX: For evaluation purposes only, final solution would require some smarter way to avoid mouse | |||||
| * coordinate jump on lock-to-selected. */ | |||||
| void movieclip_main_area_set_view2d(const bContext *C, ARegion *region); | |||||
| static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) | static int slide_point_modal(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| SlidePointData *data = (SlidePointData *)op->customdata; | SlidePointData *data = (SlidePointData *)op->customdata; | ||||
| BezTriple *bezt = &data->point->bezt; | BezTriple *bezt = &data->point->bezt; | ||||
| float co[2]; | float co[2]; | ||||
| switch (event->type) { | switch (event->type) { | ||||
| case EVT_LEFTALTKEY: | case EVT_LEFTALTKEY: | ||||
| ▲ Show 20 Lines • Show All 185 Lines • ▼ Show 20 Lines | case MOUSEMOVE: { | ||||
| add_v2_v2(point->bezt.vec[1], delta); | add_v2_v2(point->bezt.vec[1], delta); | ||||
| add_v2_v2(point->bezt.vec[2], delta); | add_v2_v2(point->bezt.vec[2], delta); | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask); | WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask); | ||||
| DEG_id_tag_update(&data->mask->id, 0); | DEG_id_tag_update(&data->mask->id, 0); | ||||
| if (true) { | |||||
| SpaceClip *space_clip = CTX_wm_space_clip(C); | |||||
| if (space_clip != NULL && space_clip->flag & SC_LOCK_SELECTION) { | |||||
| struct Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C); | |||||
| (void)depsgraph; | |||||
| if (ED_clip_view_selection(C, region, 0)) { | |||||
| space_clip->xof += space_clip->xlockof; | |||||
| space_clip->yof += space_clip->ylockof; | |||||
| movieclip_main_area_set_view2d(C, region); | |||||
| ED_mask_mouse_pos(area, region, event->mval, co); | |||||
| copy_v2_v2(data->prev_mouse_coord, co); | |||||
| } | |||||
| } | |||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| case LEFTMOUSE: | case LEFTMOUSE: | ||||
| case RIGHTMOUSE: | case RIGHTMOUSE: | ||||
| if (event->type == data->event_invoke_type && event->val == KM_RELEASE) { | if (event->type == data->event_invoke_type && event->val == KM_RELEASE) { | ||||
| Scene *scene = CTX_data_scene(C); | Scene *scene = CTX_data_scene(C); | ||||
| Show All 12 Lines | case RIGHTMOUSE: | ||||
| bezt->h2 = HD_VECT; | bezt->h2 = HD_VECT; | ||||
| } | } | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask); | WM_event_add_notifier(C, NC_MASK | NA_EDITED, data->mask); | ||||
| DEG_id_tag_update(&data->mask->id, 0); | DEG_id_tag_update(&data->mask->id, 0); | ||||
| free_slide_point_data(op->customdata); /* keep this last! */ | free_slide_point_data(op->customdata); /* keep this last! */ | ||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| else if (event->type != data->event_invoke_type && event->val == KM_PRESS) { | else if (event->type != data->event_invoke_type && event->val == KM_PRESS) { | ||||
| /* pass to ESCKEY */ | /* pass to ESCKEY */ | ||||
| } | } | ||||
| else { | else { | ||||
| break; | break; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | static SlideSplineCurvatureData *slide_spline_curvature_customdata(bContext *C, | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| SlideSplineCurvatureData *slide_data; | SlideSplineCurvatureData *slide_data; | ||||
| MaskLayer *mask_layer; | MaskLayer *mask_layer; | ||||
| MaskSpline *spline; | MaskSpline *spline; | ||||
| MaskSplinePoint *point; | MaskSplinePoint *point; | ||||
| float u, co[2]; | float u, co[2]; | ||||
| BezTriple *next_bezt; | BezTriple *next_bezt; | ||||
| MaskViewLockState lock_state; | |||||
| ED_mask_view_lock_state_store(C, &lock_state); | |||||
| ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, co); | ED_mask_mouse_pos(CTX_wm_area(C), CTX_wm_region(C), event->mval, co); | ||||
| if (!ED_mask_find_nearest_diff_point(C, | if (!ED_mask_find_nearest_diff_point(C, | ||||
| mask, | mask, | ||||
| co, | co, | ||||
| threshold, | threshold, | ||||
| false, | false, | ||||
| NULL, | NULL, | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | static SlideSplineCurvatureData *slide_spline_curvature_customdata(bContext *C, | ||||
| else { | else { | ||||
| slide_data->adjust_bezt->f1 |= SELECT; | slide_data->adjust_bezt->f1 |= SELECT; | ||||
| slide_data->other_bezt->f3 |= SELECT; | slide_data->other_bezt->f3 |= SELECT; | ||||
| } | } | ||||
| mask_layer->act_spline = spline; | mask_layer->act_spline = spline; | ||||
| mask_layer->act_point = point; | mask_layer->act_point = point; | ||||
| ED_mask_select_flush_all(mask); | ED_mask_select_flush_all(mask); | ||||
| DEG_id_tag_update(&mask->id, 0); | |||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| return slide_data; | return slide_data; | ||||
| } | } | ||||
| static int slide_spline_curvature_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int slide_spline_curvature_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| SlideSplineCurvatureData *slide_data; | SlideSplineCurvatureData *slide_data; | ||||
| ▲ Show 20 Lines • Show All 1,042 Lines • Show Last 20 Lines | |||||