forked from bartvdbraak/blender
use UI_view2d_getscale() to get the scale for image cursor drawing and ED_mask_pixelspace_factor(). - was getting the image width/height when its not needed before.
This commit is contained in:
parent
bb26d80ad8
commit
da7ce6a3cc
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user