Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarley Acheson <harley>2019-02-21 19:22:51 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-02-21 20:03:34 +0300
commit86bbadaaee949f39f28436ff65c65ae6b194a3c3 (patch)
tree53599ee21d7619d693a0ffa8dbd720ff589959bc /source/blender/editors/screen
parenta1e531ebbdc55d25be3f995e15ecb10571fd85d7 (diff)
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
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r--source/blender/editors/screen/screen_ops.c76
1 files changed, 50 insertions, 26 deletions
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: