[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [23904] trunk/blender: - wrapping failed with the cursor at the screen edge,

Campbell Barton ideasman42 at gmail.com
Sat Oct 17 16:54:14 CEST 2009


Revision: 23904
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=23904
Author:   campbellbarton
Date:     2009-10-17 16:54:13 +0200 (Sat, 17 Oct 2009)

Log Message:
-----------
- wrapping failed with the cursor at the screen edge,
- changed numbuts behavior with continuous grab so dragging back after passing the button limit immediately adjusts the value

Modified Paths:
--------------
    trunk/blender/intern/ghost/GHOST_Rect.h
    trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
    trunk/blender/source/blender/editors/interface/interface_handlers.c

Modified: trunk/blender/intern/ghost/GHOST_Rect.h
===================================================================
--- trunk/blender/intern/ghost/GHOST_Rect.h	2009-10-17 14:45:49 UTC (rev 23903)
+++ trunk/blender/intern/ghost/GHOST_Rect.h	2009-10-17 14:54:13 UTC (rev 23904)
@@ -228,20 +228,19 @@
 	if (y < m_t) m_t = y;
 	if (y > m_b) m_b = y;
 }
-
+#include <stdio.h>
 inline void GHOST_Rect::wrapPoint(GHOST_TInt32 &x, GHOST_TInt32 &y, GHOST_TInt32 ofs)
 {
 	GHOST_TInt32 w= getWidth();
 	GHOST_TInt32 h= getHeight();
 
 	/* highly unlikely but avoid eternal loop */
-	if(w-ofs <= 0 || h-ofs <= 0)
+	if(w-ofs*2 <= 0 || h-ofs*2 <= 0)
 		return;
-
-	while(x-ofs < m_l)		x+= w;
-	while(y-ofs < m_t)		y+= h;
-	while(x+ofs > m_r)		x-= w;
-	while(y+ofs > m_b)		y-= h;
+	while(x-ofs < m_l)		x+= w-(ofs*2);
+	while(y-ofs < m_t)		y+= h-(ofs*2);
+	while(x+ofs > m_r)		x-= w-(ofs*2);
+	while(y+ofs > m_b)		y-= h-(ofs*2);
 }
 
 inline bool GHOST_Rect::isInside(GHOST_TInt32 x, GHOST_TInt32 y) const

Modified: trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp
===================================================================
--- trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2009-10-17 14:45:49 UTC (rev 23903)
+++ trunk/blender/intern/ghost/intern/GHOST_SystemX11.cpp	2009-10-17 14:54:13 UTC (rev 23904)
@@ -399,9 +399,7 @@
 
 				/* could also clamp to screen bounds
 				 * wrap with a window outside the view will fail atm  */
-
-				bounds.wrapPoint(x_new, y_new, 1); /* offset of one incase blender is at screen bounds */
-
+				bounds.wrapPoint(x_new, y_new, 2); /* offset of one incase blender is at screen bounds */
 				window->getCursorGrabAccum(x_accum, y_accum);
 
 				if(x_new != xme.x_root || y_new != xme.y_root) {

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2009-10-17 14:45:49 UTC (rev 23903)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2009-10-17 14:54:13 UTC (rev 23904)
@@ -2056,9 +2056,21 @@
 		/* Mouse location isn't screen clamped to the screen so use a linear mapping
 		 * 2px == 1-int, or 1px == 1-ClickStep */
 		if(ui_is_but_float(but)) {
-			tempf = data->startvalue + ((mx - data->dragstartx) * fac * 0.01*but->a1);
+			fac *= 0.01*but->a1;
+			tempf = data->startvalue + ((mx - data->dragstartx) * fac);
 			tempf= ui_numedit_apply_snapf(tempf, softmin, softmax, softrange, snap);
+
+#if 1		/* fake moving the click start, nicer for dragging back after passing the limit */
+			if(tempf < softmin) {
+				data->dragstartx -= (softmin-tempf) / fac;
+				tempf= softmin;
+			} else if (tempf > softmax) {
+				data->dragstartx += (tempf-softmax) / fac;
+				tempf= softmax;
+			}
+#else
 			CLAMP(tempf, softmin, softmax);
+#endif
 
 			if(tempf != data->value) {
 				data->dragchange= 1;
@@ -2067,9 +2079,22 @@
 			}
 		}
 		else {
-			temp= data->startvalue + (mx - data->dragstartx)/2; /* simple 2px == 1 */
+			fac = 0.5; /* simple 2px == 1 */
+
+			temp= data->startvalue + ((mx - data->dragstartx) * fac);
 			temp= ui_numedit_apply_snap(temp, softmin, softmax, snap);
+
+#if 1		/* fake moving the click start, nicer for dragging back after passing the limit */
+			if(temp < softmin) {
+				data->dragstartx -= (softmin-temp) / fac;
+				temp= softmin;
+			} else if (temp > softmax) {
+				data->dragstartx += (temp-softmax) / fac;
+				temp= softmax;
+			}
+#else
 			CLAMP(temp, softmin, softmax);
+#endif
 
 			if(temp != data->value) {
 				data->dragchange= 1;
@@ -2077,6 +2102,8 @@
 				changed= 1;
 			}
 		}
+
+		data->draglastx= mx;
 	}
 	else {
 		/* Use a non-linear mapping of the mouse drag especially for large floats (normal behavior) */





More information about the Bf-blender-cvs mailing list