[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13824] trunk/blender/source/blender: Nodes to be created at the location in which the mouse cursor was initially

Juho Vepsalainen bebraw at gmail.com
Sat Feb 23 11:33:43 CET 2008


Revision: 13824
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13824
Author:   bebraw
Date:     2008-02-23 11:33:36 +0100 (Sat, 23 Feb 2008)

Log Message:
-----------
Nodes to be created at the location in which the mouse cursor was initially
This commit changes the way new nodes are created. Previously nodes were created
at the last location of the mouse cursor before creating a new node. After this
commit the nodes are created at the initial location in which the cursor was
before the menu used to add the node was opened.

This makes it possible for the user to predict where the new node appears without
having to move it to desired location like before. There is no option for this as
this behaviour is clearly superior to previous.

Codewise it uses static variables. This is something to fix during 2.50 rewrite.

Thanks to paprmh for contribution!

Modified Paths:
--------------
    trunk/blender/source/blender/include/BIF_toolbox.h
    trunk/blender/source/blender/src/header_node.c
    trunk/blender/source/blender/src/toolbox.c

Modified: trunk/blender/source/blender/include/BIF_toolbox.h
===================================================================
--- trunk/blender/source/blender/include/BIF_toolbox.h	2008-02-23 04:09:34 UTC (rev 13823)
+++ trunk/blender/source/blender/include/BIF_toolbox.h	2008-02-23 10:33:36 UTC (rev 13824)
@@ -73,4 +73,6 @@
 } TBitem;
 void toolbox_generic( struct TBitem *generic_menu ); /* for external toolbox - python only for now */
 
+void toolbox_mousepos( short *mpos, int save ); /* saves/restores mouse position when entering/exiting menus */
+
 #endif

Modified: trunk/blender/source/blender/src/header_node.c
===================================================================
--- trunk/blender/source/blender/src/header_node.c	2008-02-23 04:09:34 UTC (rev 13823)
+++ trunk/blender/source/blender/src/header_node.c	2008-02-23 10:33:36 UTC (rev 13824)
@@ -216,7 +216,7 @@
 		else node->flag &= ~NODE_TEST;
 	}
 	
-	getmouseco_areawin(mval);
+	toolbox_mousepos(mval, 0 ); /* get initial mouse position */
 	areamouseco_to_ipoco(G.v2d, mval, &locx, &locy);
 	node= node_add_node(snode, event, locx, locy);
 	

Modified: trunk/blender/source/blender/src/toolbox.c
===================================================================
--- trunk/blender/source/blender/src/toolbox.c	2008-02-23 04:09:34 UTC (rev 13823)
+++ trunk/blender/source/blender/src/toolbox.c	2008-02-23 10:33:36 UTC (rev 13824)
@@ -1977,6 +1977,9 @@
 		}
 	}
 	
+	/* save present mouse position */
+	toolbox_mousepos(mval, 1);
+
 	mywinset(G.curscreen->mainwin); // we go to screenspace
 	
 	block= uiNewBlock(&tb_listb, "toolbox", UI_EMBOSSP, UI_HELV, G.curscreen->mainwin);
@@ -2307,3 +2310,25 @@
 	
 	mywinset(curarea->win);
 }
+
+/* save or restore mouse position when entering/exiting menus */
+void toolbox_mousepos( short *mpos, int save )
+{
+	static short initpos[2];
+	static int tog;
+	
+	if (save) {
+		getmouseco_areawin(mpos);
+		initpos[0]= mpos[0];
+		initpos[1]= mpos[1];
+		tog=1;
+	} else {
+		if (tog) {
+			mpos[0]= initpos[0];
+			mpos[1]= initpos[1];
+		} else {
+			getmouseco_areawin(mpos);
+		}
+		tog= 0;
+	}
+}





More information about the Bf-blender-cvs mailing list