Fix #19482: setting cursor position in uv editor was not correct
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 28 Sep 2009 08:52:02 +0000 (08:52 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Mon, 28 Sep 2009 08:52:02 +0000 (08:52 +0000)
zoomed in, needed to make view2d offset for pixel rounding dependent
on zoom level.

source/blender/editors/interface/view2d.c
source/blender/editors/space_image/space_image.c

index be58a78ca859908082b25af9418ccdf86e2e8b51..2da491e488db68138c2d105468567d67f0f9f979 100644 (file)
@@ -973,8 +973,8 @@ void UI_view2d_view_ortho(const bContext *C, View2D *v2d)
 
        /* XXX brecht: instead of zero at least use a tiny offset, otherwise
         * pixel rounding is effectively random due to float inaccuracy */
-       xofs= 0.001f;
-       yofs= 0.001f;
+       xofs= 0.001f*(v2d->cur.xmax - v2d->cur.xmin)/(v2d->mask.xmax - v2d->mask.xmin);
+       yofs= 0.001f*(v2d->cur.ymax - v2d->cur.ymin)/(v2d->mask.ymax - v2d->mask.ymin);
        
        /* apply mask-based adjustments to cur rect (due to scrollers), to eliminate scaling artifacts */
        view2d_map_cur_using_mask(v2d, &curmasked);
index f041cb00ee4de6bef15072980d27da711edb22de..55b910cf6b4c1b4942d3a4483272487c8267aff8 100644 (file)
@@ -374,8 +374,8 @@ static void image_main_area_set_view2d(SpaceImage *sima, ARegion *ar, Scene *sce
        ar->v2d.mask.ymax= winy;
 
        /* which part of the image space do we see? */
-       x1= ar->winrct.xmin+(winx-sima->zoom*w)/2;
-       y1= ar->winrct.ymin+(winy-sima->zoom*h)/2;
+       x1= ar->winrct.xmin+(winx-sima->zoom*w)/2.0f;
+       y1= ar->winrct.ymin+(winy-sima->zoom*h)/2.0f;
 
        x1-= sima->zoom*sima->xof;
        y1-= sima->zoom*sima->yof;
@@ -440,11 +440,13 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
 
        /* and uvs in 0.0-1.0 space */
        UI_view2d_view_ortho(C, v2d);
-               draw_uvedit_main(sima, ar, scene, obedit);
-               ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
+       draw_uvedit_main(sima, ar, scene, obedit);
+
+       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
                
-               /* Grease Pencil too (in addition to UV's) */
-               draw_image_grease_pencil((bContext *)C, 1); 
+       /* Grease Pencil too (in addition to UV's) */
+       draw_image_grease_pencil((bContext *)C, 1); 
+
        UI_view2d_view_restore(C);
        
        /* draw Grease Pencil - screen space only */