[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50483] trunk/blender/source/blender/ editors/interface: fix [#29072] Color pickers don' t close properly when moving the mouse away

Campbell Barton ideasman42 at gmail.com
Sun Sep 9 03:44:57 CEST 2012


Revision: 50483
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50483
Author:   campbellbarton
Date:     2012-09-09 01:44:55 +0000 (Sun, 09 Sep 2012)
Log Message:
-----------
fix [#29072] Color pickers don't close properly when moving the mouse away

instead of checking if the mouse is over another button to exit the popup.
Just check if the mouse is outside the rect-union between the button and the popup.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_handlers.c
    trunk/blender/source/blender/editors/interface/interface_intern.h

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2012-09-09 00:00:21 UTC (rev 50482)
+++ trunk/blender/source/blender/editors/interface/interface.c	2012-09-09 01:44:55 UTC (rev 50483)
@@ -134,7 +134,7 @@
 	*y = (int)(fy + 0.5f);
 }
 
-void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, rctf *graph, rcti *winr)
+void ui_block_to_window_rct(const ARegion *ar, uiBlock *block, const rctf *graph, rcti *winr)
 {
 	rctf tmpr;
 

Modified: trunk/blender/source/blender/editors/interface/interface_handlers.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-09-09 00:00:21 UTC (rev 50482)
+++ trunk/blender/source/blender/editors/interface/interface_handlers.c	2012-09-09 01:44:55 UTC (rev 50483)
@@ -81,6 +81,8 @@
 static void ui_add_smart_controller(bContext *C, uiBut *from, uiBut *to);
 static void ui_add_link(bContext *C, uiBut *from, uiBut *to);
 
+static int ui_mouse_motion_towards_check(uiBlock *block, uiPopupBlockHandle *menu, int mx, int my);
+
 /***************** structs and defines ****************/
 
 #define BUTTON_TOOLTIP_DELAY        0.500
@@ -5798,22 +5800,35 @@
 		switch (event->type) {
 			case MOUSEMOVE:
 			{
-				uiBut *bt;
+				/* if the mouse is over the button, do nothing */
+				if (ui_mouse_inside_button(data->region, but, event->x, event->y)) {
+					break;
+				}
 
+				/* if the mouse is over the menu, also do nothing */
 				if (data->menu && data->menu->region) {
 					if (ui_mouse_inside_region(data->menu->region, event->x, event->y)) {
 						break;
 					}
-				}
+					else {
+						/* make a rectangle between the menu and the button that opened it,
+						 * this avoids any space between them exiting the popup. see [#29072] - campbell */
+						rctf rct_all = but->rect;
+						rctf rct_win;
 
-				bt = ui_but_find_mouse_over(ar, event->x, event->y);
+						ui_block_to_window_fl(ar, block, &rct_all.xmin, &rct_all.ymin);
+						ui_block_to_window_fl(ar, block, &rct_all.xmax, &rct_all.ymax);
 
-				if (bt && bt->active != data) {
-					if (but->type != COL) {  /* exception */
-						data->cancel = 1;
+						BLI_rctf_rcti_copy(&rct_win, &data->menu->region->winrct);
+						BLI_rctf_union(&rct_all, &rct_win);
+
+						if (BLI_rctf_isect_pt(&rct_all, event->x, event->y)) {
+							break;
+						}
 					}
-					button_activate_state(C, but, BUTTON_STATE_EXIT);
 				}
+
+				button_activate_state(C, but, BUTTON_STATE_EXIT);
 				break;
 			}
 		}

Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h	2012-09-09 00:00:21 UTC (rev 50482)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h	2012-09-09 01:44:55 UTC (rev 50483)
@@ -348,7 +348,7 @@
 
 extern void ui_block_to_window_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
 extern void ui_block_to_window(const struct ARegion *ar, uiBlock *block, int *x, int *y);
-extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, rctf *graph, rcti *winr);
+extern void ui_block_to_window_rct(const struct ARegion *ar, uiBlock *block, const rctf *graph, rcti *winr);
 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);




More information about the Bf-blender-cvs mailing list