diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-07-26 00:39:49 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-07-26 00:39:49 +0400 |
commit | 2b133b14ab1b37f80f94a7a411ee116e095c9b8d (patch) | |
tree | f5651e0b9d13fe68946e0362a69083bd14f3f5f4 /source/blender/editors | |
parent | 8ad3e7396597ffcf56f3ad74c00dfc6fdcd504df (diff) |
mask/image viewer now works with non 1:1 image aspect, editing masks in the image viewer should be generally usable now though still some TODO's left.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/ED_image.h | 2 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 9 | ||||
-rw-r--r-- | source/blender/editors/space_image/image_edit.c | 16 |
3 files changed, 26 insertions, 1 deletions
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h index b31d52a6644..393a400b7bd 100644 --- a/source/blender/editors/include/ED_image.h +++ b/source/blender/editors/include/ED_image.h @@ -39,6 +39,7 @@ struct ToolSettings; struct uiBlock; struct wmWindowManager; struct ARegion; +struct wmEvent; /* image_edit.c, exported for transform */ struct Image *ED_space_image(struct SpaceImage *sima); @@ -61,6 +62,7 @@ void ED_space_image_uv_sculpt_update(struct wmWindowManager *wm, struct ToolSett void ED_image_get_size(struct Image *ima, int *width, int *height); void ED_image_get_aspect(struct Image *ima, float *aspx, float *aspy); void ED_image_get_uv_aspect(struct Image *ima, float *aspx, float *aspy); +void ED_image_mouse_pos(struct SpaceImage *sima, struct ARegion *ar, struct wmEvent *event, float co[2]); int ED_space_image_show_render(struct SpaceImage *sima); int ED_space_image_show_paint(struct SpaceImage *sima); diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 6667b9b69a5..6a5e5c03345 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -110,8 +110,15 @@ void ED_mask_mouse_pos(const bContext *C, wmEvent *event, float co[2]) } case SPACE_IMAGE: { + int width, height; + float frame_size[2]; + SpaceImage *sima = sa->spacedata.first; ARegion *ar = CTX_wm_region(C); - UI_view2d_region_to_view(&ar->v2d, event->mval[0], event->mval[1], &co[0], &co[1]); + ED_space_image_get_size(sima, &width, &height); + frame_size[0] = width; + frame_size[1] = height; + ED_image_mouse_pos(sima, ar, event, co); + BKE_mask_coord_from_frame(co, co, frame_size); break; } default: diff --git a/source/blender/editors/space_image/image_edit.c b/source/blender/editors/space_image/image_edit.c index 8ae2b76cd4e..f80210fe4d7 100644 --- a/source/blender/editors/space_image/image_edit.c +++ b/source/blender/editors/space_image/image_edit.c @@ -47,6 +47,8 @@ #include "ED_screen.h" #include "ED_uvedit.h" +#include "UI_view2d.h" + #include "WM_api.h" #include "WM_types.h" @@ -250,6 +252,20 @@ void ED_image_get_uv_aspect(Image *ima, float *aspx, float *aspy) *aspy *= (float)h; } +void ED_image_mouse_pos(SpaceImage *sima, ARegion *ar, wmEvent *event, float co[2]) +{ + int sx, sy, width, height; + float zoomx, zoomy; + + ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + ED_space_image_get_size(sima, &width, &height); + + UI_view2d_to_region_no_clip(&ar->v2d, 0.0f, 0.0f, &sx, &sy); + + co[0] = ((event->mval[0] - sx) / zoomx) / width; + co[1] = ((event->mval[1] - sy) / zoomy) / height; +} + int ED_space_image_show_render(SpaceImage *sima) { return (sima->image && ELEM(sima->image->type, IMA_TYPE_R_RESULT, IMA_TYPE_COMPOSITE)); |