Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/mask/mask_add.c
| Show First 20 Lines • Show All 501 Lines • ▼ Show 20 Lines | static int add_vertex_handle_cyclic( | ||||
| if (is_first_point_active) { | if (is_first_point_active) { | ||||
| return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, last_point, co); | return add_vertex_handle_cyclic_at_point(C, mask, spline, active_point, last_point, co); | ||||
| } | } | ||||
| return OPERATOR_PASS_THROUGH; | return OPERATOR_PASS_THROUGH; | ||||
| } | } | ||||
| static int add_vertex_exec(bContext *C, wmOperator *op) | static int add_vertex_exec(bContext *C, wmOperator *op) | ||||
| { | { | ||||
| MaskViewLockState lock_state; | |||||
| ED_mask_view_lock_state_store(C, &lock_state); | |||||
| Mask *mask = CTX_data_edit_mask(C); | Mask *mask = CTX_data_edit_mask(C); | ||||
| if (mask == NULL) { | if (mask == NULL) { | ||||
| /* if there's no active mask, create one */ | /* if there's no active mask, create one */ | ||||
| mask = ED_mask_new(C, NULL); | mask = ED_mask_new(C, NULL); | ||||
| } | } | ||||
| MaskLayer *mask_layer = BKE_mask_layer_active(mask); | MaskLayer *mask_layer = BKE_mask_layer_active(mask); | ||||
| Show All 25 Lines | if (!add_vertex_subdivide(C, mask, co)) { | ||||
| if (!add_vertex_new(C, mask, mask_layer, co)) { | if (!add_vertex_new(C, mask, mask_layer, co)) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY); | ||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) | static int add_vertex_invoke(bContext *C, wmOperator *op, const wmEvent *event) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| ARegion *region = CTX_wm_region(C); | ARegion *region = CTX_wm_region(C); | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | RNA_def_float_vector(ot->srna, | ||||
| 1.0f); | 1.0f); | ||||
| } | } | ||||
| /******************** common primitive functions *********************/ | /******************** common primitive functions *********************/ | ||||
| static int create_primitive_from_points( | static int create_primitive_from_points( | ||||
| bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type) | bContext *C, wmOperator *op, const float (*points)[2], int num_points, char handle_type) | ||||
| { | { | ||||
| MaskViewLockState lock_state; | |||||
| ED_mask_view_lock_state_store(C, &lock_state); | |||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| int size = RNA_float_get(op->ptr, "size"); | int size = RNA_float_get(op->ptr, "size"); | ||||
| int width, height; | int width, height; | ||||
| ED_mask_get_size(area, &width, &height); | ED_mask_get_size(area, &width, &height); | ||||
| float scale = (float)size / max_ii(width, height); | float scale = (float)size / max_ii(width, height); | ||||
| /* Get location in mask space. */ | /* Get location in mask space. */ | ||||
| ▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | static int create_primitive_from_points( | ||||
| if (added_mask) { | if (added_mask) { | ||||
| WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL); | WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL); | ||||
| } | } | ||||
| WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); | WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask); | ||||
| DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY); | DEG_id_tag_update(&mask->id, ID_RECALC_GEOMETRY); | ||||
| ED_mask_view_lock_state_restore_no_jump(C, &lock_state); | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | static int primitive_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | ||||
| { | { | ||||
| ScrArea *area = CTX_wm_area(C); | ScrArea *area = CTX_wm_area(C); | ||||
| float cursor[2]; | float cursor[2]; | ||||
| int width, height; | int width, height; | ||||
| ▲ Show 20 Lines • Show All 89 Lines • Show Last 20 Lines | |||||