[Bf-blender-cvs] [86bbadaaee9] master: UI: improve corner splitting feedback by showing custom cursors.

Harley Acheson noreply at git.blender.org
Thu Feb 21 18:03:43 CET 2019


Commit: 86bbadaaee949f39f28436ff65c65ae6b194a3c3
Author: Harley Acheson
Date:   Thu Feb 21 17:22:51 2019 +0100
Branches: master
https://developer.blender.org/rB86bbadaaee949f39f28436ff65c65ae6b194a3c3

UI: improve corner splitting feedback by showing custom cursors.

* Two cursors for horizontal and vertical split.
* Four cursors for each join direction.
* One cursor to indicate when splitting is not possible.

Differential Revision: https://developer.blender.org/D4264

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

M	source/blender/editors/screen/screen_ops.c
M	source/blender/windowmanager/intern/wm_cursors.c
M	source/blender/windowmanager/wm_cursors.h

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

diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index 236c167904f..f28e58fca5f 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -940,12 +940,11 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
 
 			/* Movement in dominant direction. */
 			const int delta_max = max_ii(ABS(delta_x), ABS(delta_y));
-			/* Movement in secondary direction. */
-			const int delta_min = min_ii(ABS(delta_x), ABS(delta_y));
-			/* Movement required in dominant direction. */
-			const int delta_threshold = (0.2 * U.widget_unit);
-			/* Must be over threshold and 2:1 ratio or more. */
-			const int delta_okay = (delta_max > delta_threshold) && (delta_min * 2 <= delta_max);
+
+			/* Movement in dominant direction before action taken. */
+			const int join_threshold  = (0.6 * U.widget_unit);
+			const int split_threshold = (1.2 * U.widget_unit);
+			const int area_threshold  = (0.1 * U.widget_unit);
 
 			/* Calculate gesture cardinal direction. */
 			if (delta_y > ABS(delta_x))
@@ -958,18 +957,41 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event)
 				sad->gesture_dir = 'w';
 
 			if (sad->az->type == AZONE_AREA) {
-				const wmWindow *win = CTX_wm_window(C);
+				wmWindow *win = CTX_wm_window(C);
 				rcti screen_rect;
 
 				WM_window_screen_rect_calc(win, &screen_rect);
-				/* once we drag outside the actionzone, register a gesture
-				 * check we're not on an edge so join finds the other area */
-				is_gesture = (delta_okay && (screen_actionzone_find_xy(sc, &event->x) != sad->az) &&
-				              (screen_geom_area_map_find_active_scredge(
-				                   AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL));
+
+				/* Have we dragged off the zone and are not on an edge? */
+				if ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) &&
+					(screen_geom_area_map_find_active_scredge(
+						AREAMAP_FROM_SCREEN(sc), &screen_rect, event->x, event->y) == NULL)) {
+					/* Are we still in same area? */
+					if (BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y) == sad->sa1) {
+						/* Same area, so possible split. */
+						WM_cursor_set(win, (ELEM(sad->gesture_dir, 'n', 's')) ? BC_V_SPLITCURSOR : BC_H_SPLITCURSOR);
+						is_gesture = (delta_max > split_threshold);
+					}
+					else {
+						/* Different area, so posible join. */
+						if (sad->gesture_dir == 'n')
+							WM_cursor_set(win, BC_N_ARROWCURSOR);
+						else if (sad->gesture_dir == 's')
+							WM_cursor_set(win, BC_S_ARROWCURSOR);
+						else if (sad->gesture_dir == 'e')
+							WM_cursor_set(win, BC_E_ARROWCURSOR);
+						else
+							WM_cursor_set(win, BC_W_ARROWCURSOR);
+						is_gesture = (delta_max > join_threshold);
+					}
+				}
+				else {
+					WM_cursor_set(CTX_wm_window(C), BC_CROSSCURSOR);
+					is_gesture = false;
+				}
 			}
 			else {
-				is_gesture = delta_okay;
+				is_gesture = (delta_max > area_threshold);
 			}
 
 			/* gesture is large enough? */
@@ -1919,7 +1941,7 @@ static void area_split_preview_update_cursor(bContext *C, wmOperator *op)
 {
 	wmWindow *win = CTX_wm_window(C);
 	int dir = RNA_enum_get(op->ptr, "direction");
-	WM_cursor_set(win, (dir == 'v') ? CURSOR_X_MOVE : CURSOR_Y_MOVE);
+	WM_cursor_set(win, (dir == 'n' || dir == 's') ? BC_V_SPLITCURSOR : BC_H_SPLITCURSOR);
 }
 
 /* UI callback, adds new handler */
@@ -3019,7 +3041,6 @@ static int area_join_init(bContext *C, wmOperator *op)
 	sAreaJoinData *jd = NULL;
 	int x1, y1;
 	int x2, y2;
-	int shared = 0;
 
 	/* required properties, make negative to get return 0 if not set by caller */
 	x1 = RNA_int_get(op->ptr, "min_x");
@@ -3043,16 +3064,6 @@ static int area_join_init(bContext *C, wmOperator *op)
 		return 0;
 	}
 
-	/* do areas share an edge? */
-	if (sa1->v1 == sa2->v1 || sa1->v1 == sa2->v2 || sa1->v1 == sa2->v3 || sa1->v1 == sa2->v4) shared++;
-	if (sa1->v2 == sa2->v1 || sa1->v2 == sa2->v2 || sa1->v2 == sa2->v3 || sa1->v2 == sa2->v4) shared++;
-	if (sa1->v3 == sa2->v1 || sa1->v3 == sa2->v2 || sa1->v3 == sa2->v3 || sa1->v3 == sa2->v4) shared++;
-	if (sa1->v4 == sa2->v1 || sa1->v4 == sa2->v2 || sa1->v4 == sa2->v3 || sa1->v4 == sa2->v4) shared++;
-	if (shared != 2) {
-		printf("areas don't share edge\n");
-		return 0;
-	}
-
 	jd = (sAreaJoinData *)MEM_callocN(sizeof(sAreaJoinData), "op_area_join");
 
 	jd->sa1 = sa1;
@@ -3159,6 +3170,7 @@ static void area_join_cancel(bContext *C, wmOperator *op)
 static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
 {
 	bScreen *sc = CTX_wm_screen(C);
+	wmWindow *win = CTX_wm_window(C);
 	sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
 
 	/* execute the events */
@@ -3167,7 +3179,7 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
 		case MOUSEMOVE:
 		{
 			ScrArea *sa = BKE_screen_find_area_xy(sc, SPACE_TYPE_ANY, event->x, event->y);
-			int dir;
+			int dir = -1;
 
 			if (sa) {
 				if (jd->sa1 != sa) {
@@ -3211,6 +3223,18 @@ static int area_join_modal(bContext *C, wmOperator *op, const wmEvent *event)
 					WM_event_add_notifier(C, NC_WINDOW, NULL);
 				}
 			}
+
+			if (dir == 1)
+				WM_cursor_set(win, BC_N_ARROWCURSOR);
+			else if (dir == 3)
+				WM_cursor_set(win, BC_S_ARROWCURSOR);
+			else if (dir == 2)
+				WM_cursor_set(win, BC_E_ARROWCURSOR);
+			else if (dir == 0)
+				WM_cursor_set(win, BC_W_ARROWCURSOR);
+			else
+				WM_cursor_set(win, BC_STOPCURSOR);
+
 			break;
 		}
 		case LEFTMOUSE:
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index 10f6a55c4ab..b0d74458bb7 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -1094,6 +1094,512 @@ BEGIN_CURSOR_BLOCK
 	BlenderCursor[BC_SWAPAREA_CURSOR] = &SwapCursor;
 
 END_CURSOR_BLOCK
+
+/********************** Horizontal Split Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+	static char hsplit_sbm[] = {
+		0x00,  0x00,  0x80,  0x00,  0x80,  0x00,  0x80,  0x00,
+		0x80,  0x00,  0x88,  0x08,  0x8C,  0x18,  0x8E,  0x38,
+		0x8C,  0x18,  0x88,  0x08,  0x80,  0x00,  0x80,  0x00,
+		0x80,  0x00,  0x80,  0x00,  0x00,  0x00,  0x00,  0x00
+	};
+
+	static char hsplit_smsk[] = {
+		0xC0,  0x01,  0xC0,  0x01,  0xC0,  0x01,  0xD0,  0x05,
+		0xD8,  0x0D,  0xDC,  0x1D,  0xDE,  0x3D,  0xDF,  0x7D,
+		0xDE,  0x3D,  0xDC,  0x1D,  0xD8,  0x0D,  0xD0,  0x05,
+		0xC0,  0x01,  0xC0,  0x01,  0xC0,  0x01,  0x00,  0x00
+	};
+
+	static char hsplit_lbm[] = {
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x84,  0x21,  0x00,  0x00,  0x86,  0x61,  0x00,
+		0x00,  0x87,  0xE1,  0x00,  0x80,  0x87,  0xE1,  0x01,
+		0xC0,  0x87,  0xE1,  0x03,  0xE0,  0x87,  0xE1,  0x07,
+		0xF0,  0x87,  0xE1,  0x0F,  0xF8,  0x87,  0xE1,  0x1F,
+		0xF0,  0x87,  0xE1,  0x0F,  0xE0,  0x87,  0xE1,  0x07,
+		0xC0,  0x87,  0xE1,  0x03,  0x80,  0x87,  0xE1,  0x01,
+		0x00,  0x87,  0xE1,  0x00,  0x00,  0x86,  0x61,  0x00,
+		0x00,  0x84,  0x21,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x80,  0x01,  0x00,  0x00,  0x80,  0x01,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00
+	};
+
+	static char hsplit_lmsk[] = {
+		0x00,  0xC0,  0x03,  0x00,  0x00,  0xC0,  0x03,  0x00,
+		0x00,  0xC0,  0x03,  0x00,  0x00,  0xC0,  0x03,  0x00,
+		0x00,  0xC0,  0x03,  0x00,  0x00,  0xC8,  0x13,  0x00,
+		0x00,  0xCC,  0x33,  0x00,  0x00,  0xCE,  0x73,  0x00,
+		0x00,  0xCF,  0xF3,  0x00,  0x80,  0xCF,  0xF3,  0x01,
+		0xC0,  0xCF,  0xF3,  0x03,  0xE0,  0xCF,  0xF3,  0x07,
+		0xF0,  0xCF,  0xF3,  0x0F,  0xF8,  0xCF,  0xF3,  0x1F,
+		0xFC,  0xCF,  0xF3,  0x3F,  0xFE,  0xCF,  0xF3,  0x7F,
+		0xFC,  0xCF,  0xF3,  0x3F,  0xF8,  0xCF,  0xF3,  0x1F,
+		0xF0,  0xCF,  0xF3,  0x0F,  0xE0,  0xCF,  0xF3,  0x07,
+		0xC0,  0xCF,  0xF3,  0x03,  0x80,  0xCF,  0xF3,  0x01,
+		0x00,  0xCF,  0xF3,  0x00,  0x00,  0xCE,  0x73,  0x00,
+		0x00,  0xCC,  0x33,  0x00,  0x00,  0xC8,  0x13,  0x00,
+		0x00,  0xC8,  0x03,  0x00,  0x00,  0xC0,  0x03,  0x00,
+		0x00,  0xC0,  0x03,  0x00,  0x00,  0xC0,  0x03,  0x00,
+		0x00,  0xC0,  0x03,  0x00,  0x00,  0x00,  0x00,  0x00
+	};
+
+	static BCursor HSplitCursor = {
+		/*small*/
+		hsplit_sbm, hsplit_smsk,
+		16, 16,
+		7,  7,
+		/*big*/
+		hsplit_lbm, hsplit_lmsk,
+		32, 32,
+		15, 15,
+		/*color*/
+		BC_BLACK, BC_WHITE
+	};
+
+	BlenderCursor[BC_H_SPLITCURSOR] = &HSplitCursor;
+
+END_CURSOR_BLOCK
+
+/********************** Vertical Split Cursor ***********************/
+BEGIN_CURSOR_BLOCK
+
+	static char vsplit_sbm[] = {
+		0x00,  0x00,  0x80,  0x00,  0xC0,  0x01,  0xE0,  0x03,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0xFE,  0x3F,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0xE0,  0x03,
+		0xC0,  0x01,  0x80,  0x00,  0x00,  0x00,  0x00,  0x00
+	};
+
+	static char vsplit_smsk[] = {
+		0x80,  0x00,  0xC0,  0x01,  0xE0,  0x03,  0xF0,  0x07,
+		0xF8,  0x0F,  0x00,  0x00,  0xFF,  0x7F,  0xFF,  0x7F,
+		0xFF,  0x7F,  0x00,  0x00,  0xF8,  0x0F,  0xF0,  0x07,
+		0xE0,  0x03,  0xC0,  0x01,  0x80,  0x00,  0x00,  0x00
+	};
+
+	static char vsplit_lbm[] = {
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x80,  0x00,  0x00,
+		0x00,  0xC0,  0x01,  0x00,  0x00,  0xE0,  0x03,  0x00,
+		0x00,  0xF0,  0x07,  0x00,  0x00,  0xF8,  0x0F,  0x00,
+		0x00,  0xFC,  0x1F,  0x00,  0x00,  0xFE,  0x3F,  0x00,
+		0x00,  0xFF,  0x7F,  0x00,  0x00,  0x00,  0x00,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0xFE,  0xFF,  0xFF,  0x3F,
+		0xFE,  0xFF,  0xFF,  0x3F,  0x00,  0x00,  0x00,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0x00,
+		0x00,  0x00,  0x00,  0x00,  0x00,  0xFF,  0x7F,  0x00,
+		0x00,  0xFE,  0x3F,  0x00,  0x00,  0xFC,  0x1F,  0x00,
+		0x00,  0xF8,  0x0F,  0x00,  0x00,  0xF0,  0x07,  0x00,
+		0x00,  0xE0,  0x03,  0x00,  0x00,  0xC0, 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list