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 86 Lines • ▼ Show 20 Lines | if (customdata->action != SLIDE_ACTION_SPLINE) { | ||||
| 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; | ||||
| ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord); | ED_mask_mouse_pos(area, region, event->mval, customdata->prev_mouse_coord); | ||||
| } | } | ||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| 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) | ||||
| { | { | ||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| SlidePointData *slidedata; | SlidePointData *slidedata; | ||||
| ▲ Show 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| 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]; | ||||
| MaskViewLockState lock_state; | |||||
| ED_mask_view_lock_state_store(C, &lock_state); | |||||
| switch (event->type) { | switch (event->type) { | ||||
| case EVT_LEFTALTKEY: | case EVT_LEFTALTKEY: | ||||
| case EVT_RIGHTALTKEY: | case EVT_RIGHTALTKEY: | ||||
| case EVT_LEFTSHIFTKEY: | case EVT_LEFTSHIFTKEY: | ||||
| case EVT_RIGHTSHIFTKEY: | case EVT_RIGHTSHIFTKEY: | ||||
| if (ELEM(event->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { | if (ELEM(event->type, EVT_LEFTALTKEY, EVT_RIGHTALTKEY)) { | ||||
| if (data->action == SLIDE_ACTION_FEATHER) { | if (data->action == SLIDE_ACTION_FEATHER) { | ||||
| data->is_overall_feather = (event->val == KM_PRESS); | data->is_overall_feather = (event->val == KM_PRESS); | ||||
| ▲ Show 20 Lines • Show All 179 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); | ||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| 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! */ | ||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| 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 1,237 Lines • Show Last 20 Lines | |||||