[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53008] trunk/blender/source/blender/ editors: use UI_view2d_getscale() to get the scale for image cursor drawing and ED_mask_pixelspace_factor().

Campbell Barton ideasman42 at gmail.com
Fri Dec 14 17:51:02 CET 2012


Revision: 53008
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53008
Author:   campbellbarton
Date:     2012-12-14 16:51:02 +0000 (Fri, 14 Dec 2012)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_view2d.h
    trunk/blender/source/blender/editors/interface/view2d.c
    trunk/blender/source/blender/editors/mask/mask_edit.c
    trunk/blender/source/blender/editors/uvedit/uvedit_draw.c

Modified: trunk/blender/source/blender/editors/include/UI_view2d.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_view2d.h	2012-12-14 16:10:46 UTC (rev 53007)
+++ trunk/blender/source/blender/editors/include/UI_view2d.h	2012-12-14 16:51:02 UTC (rev 53008)
@@ -199,6 +199,7 @@
 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);
 

Modified: trunk/blender/source/blender/editors/interface/view2d.c
===================================================================
--- trunk/blender/source/blender/editors/interface/view2d.c	2012-12-14 16:10:46 UTC (rev 53007)
+++ trunk/blender/source/blender/editors/interface/view2d.c	2012-12-14 16:51:02 UTC (rev 53008)
@@ -2059,6 +2059,12 @@
 	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

Modified: trunk/blender/source/blender/editors/mask/mask_edit.c
===================================================================
--- trunk/blender/source/blender/editors/mask/mask_edit.c	2012-12-14 16:10:46 UTC (rev 53007)
+++ trunk/blender/source/blender/editors/mask/mask_edit.c	2012-12-14 16:51:02 UTC (rev 53008)
@@ -324,15 +324,13 @@
 			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 @@
 			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:

Modified: trunk/blender/source/blender/editors/uvedit/uvedit_draw.c
===================================================================
--- trunk/blender/source/blender/editors/uvedit/uvedit_draw.c	2012-12-14 16:10:46 UTC (rev 53007)
+++ trunk/blender/source/blender/editors/uvedit/uvedit_draw.c	2012-12-14 16:51:02 UTC (rev 53008)
@@ -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);




More information about the Bf-blender-cvs mailing list