diff options
Diffstat (limited to 'source/blender/editors/mask')
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 63 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_select.c | 6 |
3 files changed, 65 insertions, 7 deletions
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 6a5e5c03345..0491b164fec 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -155,8 +155,15 @@ void ED_mask_point_pos(const bContext *C, float x, float y, float *xr, float *yr break; case SPACE_IMAGE: { - //SpaceImage *sima = sa->spacedata.first; - zero_v2(co); /* MASKTODO */ + int width, height; + float frame_size[2]; + SpaceImage *sima = sa->spacedata.first; + ARegion *ar = CTX_wm_region(C); + ED_space_image_get_size(sima, &width, &height); + frame_size[0] = width; + frame_size[1] = height; + ED_image_point_pos(sima, ar, x, y, &co[0], &co[1]); + BKE_mask_coord_from_frame(co, co, frame_size); break; } default: @@ -195,8 +202,21 @@ void ED_mask_point_pos__reverse(const bContext *C, float x, float y, float *xr, zero_v2(co); /* MASKTODO */ break; case SPACE_IMAGE: - zero_v2(co); /* MASKTODO */ + { + int width, height; + float frame_size[2]; + SpaceImage *sima = sa->spacedata.first; + ARegion *ar = CTX_wm_region(C); + ED_space_image_get_size(sima, &width, &height); + frame_size[0] = width; + frame_size[1] = height; + + co[0] = x; + co[1] = y; + BKE_mask_coord_to_frame(co, co, frame_size); + ED_image_point_pos__reverse(sima, ar, co, co); break; + } default: /* possible other spaces from which mask editing is available */ BLI_assert(0); @@ -251,6 +271,41 @@ void ED_mask_size(const bContext *C, int *width, int *height) } } +void ED_mask_zoom(const bContext *C, float *zoomx, float *zoomy) +{ + ScrArea *sa = CTX_wm_area(C); + if (sa && sa->spacedata.first) { + switch (sa->spacetype) { + case SPACE_CLIP: + { + ED_space_clip_get_zoom(C, zoomx, zoomy); + break; + } + case SPACE_SEQ: + { + *zoomx = *zoomy = 1.0f; + break; + } + case SPACE_IMAGE: + { + SpaceImage *sima = sa->spacedata.first; + ARegion *ar = CTX_wm_region(C); + ED_space_image_get_zoom(sima, ar, zoomx, zoomy); + break; + } + default: + /* possible other spaces from which mask editing is available */ + BLI_assert(0); + *zoomx = *zoomy = 1.0f; + break; + } + } + else { + BLI_assert(0); + *zoomx = *zoomy = 1.0f; + } +} + void ED_mask_aspect(const bContext *C, float *aspx, float *aspy) { ScrArea *sa = CTX_wm_area(C); @@ -472,6 +527,8 @@ void ED_keymap_mask(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "MASK_OT_shape_key_insert", IKEY, KM_PRESS, 0, 0); WM_keymap_add_item(keymap, "MASK_OT_shape_key_clear", IKEY, KM_PRESS, KM_ALT, 0); + /* for image editor only */ + WM_keymap_add_item(keymap, "UV_OT_cursor_set", ACTIONMOUSE, KM_PRESS, 0, 0); transform_keymap_for_space(keyconf, keymap, SPACE_CLIP); } diff --git a/source/blender/editors/mask/mask_intern.h b/source/blender/editors/mask/mask_intern.h index 70dafc963ec..b4ff4bc5b31 100644 --- a/source/blender/editors/mask/mask_intern.h +++ b/source/blender/editors/mask/mask_intern.h @@ -105,6 +105,9 @@ void ED_mask_mouse_pos(const struct bContext *C, struct wmEvent *event, float co void ED_mask_point_pos(const struct bContext *C, float x, float y, float *xr, float *yr); void ED_mask_point_pos__reverse(const struct bContext *C, float x, float y, float *xr, float *yr); +void ED_mask_get_zoom(const bContext *C, float *zoomx, float *zoomy); +void ED_mask_get_size(const bContext *C, float *zoomx, float *zoomy); + /* mask_shapekey.c */ void MASK_OT_shape_key_insert(struct wmOperatorType *ot); void MASK_OT_shape_key_clear(struct wmOperatorType *ot); diff --git a/source/blender/editors/mask/mask_select.c b/source/blender/editors/mask/mask_select.c index c7f917548ce..565beaf34ef 100644 --- a/source/blender/editors/mask/mask_select.c +++ b/source/blender/editors/mask/mask_select.c @@ -592,10 +592,9 @@ static int circle_select_exec(bContext *C, wmOperator *op) mode = RNA_int_get(op->ptr, "gesture_mode"); - /* TODO - make generic! - this is SpaceClip only! */ /* compute ellipse and position in unified coordinates */ - ED_space_clip_get_size(C, &width, &height); - ED_space_clip_get_zoom(C, &zoomx, &zoomy); + ED_mask_size(C, &width, &height); + ED_mask_zoom(C, &zoomx, &zoomy); width = height = MAX2(width, height); ellipse[0] = width * zoomx / radius; @@ -639,7 +638,6 @@ static int circle_select_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } -/* MASKTODO - image space */ void MASK_OT_select_circle(wmOperatorType *ot) { /* identifiers */ |