[Bf-blender-cvs] [6f45dea6eeb] master: UI: support canceling color ramp drag

Campbell Barton noreply at git.blender.org
Tue Jan 16 01:07:27 CET 2018


Commit: 6f45dea6eeb32b55d422e4dce33ae9b1521871b1
Author: Campbell Barton
Date:   Tue Jan 16 11:14:54 2018 +1100
Branches: master
https://developer.blender.org/rB6f45dea6eeb32b55d422e4dce33ae9b1521871b1

UI: support canceling color ramp drag

D2997 by @oktomus

===================================================================

M	source/blender/editors/interface/interface_handlers.c

===================================================================

diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 85cc05962c8..06cdef0c441 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5983,6 +5983,7 @@ static int ui_do_but_COLORBAND(
 				}
 		
 				data->dragcbd = coba->data + coba->cur;
+				data->dragfstart = data->dragcbd->pos;
 				button_activate_state(C, but, BUTTON_STATE_NUM_EDITING);
 			}
 
@@ -5999,7 +6000,15 @@ static int ui_do_but_COLORBAND(
 		else if (event->type == LEFTMOUSE && event->val != KM_PRESS) {
 			button_activate_state(C, but, BUTTON_STATE_EXIT);
 		}
-		
+		else if (ELEM(event->type, ESCKEY, RIGHTMOUSE)) {
+			if (event->val == KM_PRESS) {
+				data->dragcbd->pos = data->dragfstart;
+				BKE_colorband_update_sort(data->coba);
+				data->cancel = true;
+				data->escapecancel = true;
+				button_activate_state(C, but, BUTTON_STATE_EXIT);
+			}
+		}
 		return WM_UI_HANDLER_BREAK;
 	}



More information about the Bf-blender-cvs mailing list