diff options
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/include/UI_view2d.h | 1 | ||||
-rw-r--r-- | source/blender/editors/interface/view2d.c | 6 | ||||
-rw-r--r-- | source/blender/editors/mask/mask_edit.c | 20 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_draw.c | 12 |
4 files changed, 21 insertions, 18 deletions
diff --git a/source/blender/editors/include/UI_view2d.h b/source/blender/editors/include/UI_view2d.h index d050df5839a..3ae1e93dc3d 100644 --- a/source/blender/editors/include/UI_view2d.h +++ b/source/blender/editors/include/UI_view2d.h @@ -199,6 +199,7 @@ struct View2D *UI_view2d_fromcontext(const struct bContext *C); struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C); void UI_view2d_getscale(struct View2D *v2d, float *x, float *y); +void UI_view2d_getscale_inverse(struct View2D *v2d, float *x, float *y); short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, int x, int y); diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index e2a20e5296a..a5f9995df88 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -2059,6 +2059,12 @@ void UI_view2d_getscale(View2D *v2d, float *x, float *y) if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur); if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur); } +/* Same as UI_view2d_getscale() - 1.0f / x, y */ +void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y) +{ + if (x) *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask); + if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask); +} /* Check if mouse is within scrollers * - Returns appropriate code for match diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c index 18384ad9de4..cd2995be439 100644 --- a/source/blender/editors/mask/mask_edit.c +++ b/source/blender/editors/mask/mask_edit.c @@ -324,15 +324,13 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s case SPACE_CLIP: { SpaceClip *sc = sa->spacedata.first; - int width, height; - float zoomx, zoomy, aspx, aspy; + float aspx, aspy; - ED_space_clip_get_size(sc, &width, &height); - ED_space_clip_get_zoom(sc, ar, &zoomx, &zoomy); + UI_view2d_getscale(&ar->v2d, scalex, scaley); ED_space_clip_get_aspect(sc, &aspx, &aspy); - *scalex = ((float)width * aspx) * zoomx; - *scaley = ((float)height * aspy) * zoomy; + *scalex *= aspx; + *scaley *= aspy; break; } case SPACE_SEQ: @@ -343,15 +341,13 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s case SPACE_IMAGE: { SpaceImage *sima = sa->spacedata.first; - int width, height; - float zoomx, zoomy, aspx, aspy; + float aspx, aspy; - ED_space_image_get_size(sima, &width, &height); - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + UI_view2d_getscale(&ar->v2d, scalex, scaley); ED_space_image_get_aspect(sima, &aspx, &aspy); - *scalex = ((float)width * aspx) * zoomx; - *scaley = ((float)height * aspy) * zoomy; + *scalex *= aspx; + *scaley *= aspy; break; } default: diff --git a/source/blender/editors/uvedit/uvedit_draw.c b/source/blender/editors/uvedit/uvedit_draw.c index c6b251b04ae..607640090aa 100644 --- a/source/blender/editors/uvedit/uvedit_draw.c +++ b/source/blender/editors/uvedit/uvedit_draw.c @@ -61,19 +61,19 @@ #include "UI_resources.h" #include "UI_interface.h" +#include "UI_view2d.h" #include "uvedit_intern.h" void draw_image_cursor(SpaceImage *sima, ARegion *ar) { - float zoomx, zoomy, x_fac, y_fac; - int width, height; + float zoom[2], x_fac, y_fac; - ED_space_image_get_size(sima, &width, &height); - ED_space_image_get_zoom(sima, ar, &zoomx, &zoomy); + UI_view2d_getscale_inverse(&ar->v2d, &zoom[0], &zoom[1]); - x_fac = (1.0f / (zoomx * width / 256.0f)) * UI_DPI_FAC; - y_fac = (1.0f / (zoomy * height / 256.0f)) * UI_DPI_FAC; + mul_v2_fl(zoom, 256.0f * UI_DPI_FAC); + x_fac = zoom[0]; + y_fac = zoom[1]; cpack(0xFFFFFF); glTranslatef(sima->cursor[0], sima->cursor[1], 0.0); |