diff options
author | Harley Acheson <harley> | 2019-01-23 16:44:40 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2019-01-23 17:23:06 +0300 |
commit | 93d226952b4eb70a5e5ed4525128ca559b03d349 (patch) | |
tree | 7757127aa853d083b04b1795e0bb9fc8ba9bb4da /source/blender/editors/screen | |
parent | ac5278b682cfb090aafe93082e95349cb7d993d3 (diff) |
UI: make editor corner splitting / joining more reliable.
* Add threshold for minimum amount of mouse movement for dragging to
get activated.
* Limit angles at which dragging is considered an action, do nothing if
mouse does not clearly move up/down/left/right.
* Increase action zone size vertically.
Differential Revision: https://developer.blender.org/D4227
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 16 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_intern.h | 3 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 22 |
3 files changed, 25 insertions, 16 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 76c907a964a..7525e83458d 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -760,21 +760,21 @@ static void area_azone_initialize(wmWindow *win, const bScreen *screen, ScrArea /* Bottom-left. */ {sa->totrct.xmin, sa->totrct.ymin, - sa->totrct.xmin + (AZONESPOT - 1), - sa->totrct.ymin + (AZONESPOT - 1)}, + sa->totrct.xmin + AZONESPOTW, + sa->totrct.ymin + AZONESPOTH}, /* Bottom-right. */ - {sa->totrct.xmax - (AZONESPOT - 1), + {sa->totrct.xmax - AZONESPOTW, sa->totrct.ymin, sa->totrct.xmax, - sa->totrct.ymin + (AZONESPOT - 1)}, + sa->totrct.ymin + AZONESPOTH}, /* Top-left. */ {sa->totrct.xmin, - sa->totrct.ymax - (AZONESPOT - 1), - sa->totrct.xmin + (AZONESPOT - 1), + sa->totrct.ymax - AZONESPOTH, + sa->totrct.xmin + AZONESPOTW, sa->totrct.ymax}, /* Top-right. */ - {sa->totrct.xmax - (AZONESPOT - 1), - sa->totrct.ymax - (AZONESPOT - 1), + {sa->totrct.xmax - AZONESPOTW, + sa->totrct.ymax - AZONESPOTH, sa->totrct.xmax, sa->totrct.ymax}}; diff --git a/source/blender/editors/screen/screen_intern.h b/source/blender/editors/screen/screen_intern.h index 5f36f4a06ab..4c7d859e4ee 100644 --- a/source/blender/editors/screen/screen_intern.h +++ b/source/blender/editors/screen/screen_intern.h @@ -37,7 +37,8 @@ struct Main; /* internal exports only */ -#define AZONESPOT (0.4f * U.widget_unit) +#define AZONESPOTW UI_HEADER_OFFSET /* width of corner azone - max */ +#define AZONESPOTH (0.6f * U.widget_unit) /* height of corner azone */ #define AZONEFADEIN (5.0f * U.widget_unit) /* when azone is totally visible */ #define AZONEFADEOUT (6.5f * U.widget_unit) /* when we start seeing the azone */ diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 7e0116ea64d..6d332f8e427 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -709,7 +709,7 @@ static AZone *area_actionzone_refresh_xy(ScrArea *sa, const int xy[2], const boo } else { const int mouse_sq = SQUARE(xy[0] - az->x2) + SQUARE(xy[1] - az->y2); - const int spot_sq = SQUARE(AZONESPOT); + const int spot_sq = SQUARE(AZONESPOTW); const int fadein_sq = SQUARE(AZONEFADEIN); const int fadeout_sq = SQUARE(AZONEFADEOUT); @@ -916,10 +916,19 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) const int delta_x = (event->x - sad->x); const int delta_y = (event->y - sad->y); - /* calculate gesture direction */ + /* 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); + + /* Calculate gesture cardinal direction. */ if (delta_y > ABS(delta_x)) sad->gesture_dir = 'n'; - else if (delta_x > ABS(delta_y)) + else if (delta_x >= ABS(delta_y)) sad->gesture_dir = 'e'; else if (delta_y < -ABS(delta_x)) sad->gesture_dir = 's'; @@ -933,13 +942,12 @@ static int actionzone_modal(bContext *C, wmOperator *op, const wmEvent *event) 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 = ((ED_area_actionzone_find_xy(sad->sa1, &event->x) != sad->az) && + is_gesture = (delta_okay && (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)); } else { - const int delta_min = 1; - is_gesture = (ABS(delta_x) > delta_min || ABS(delta_y) > delta_min); + is_gesture = delta_okay; } /* gesture is large enough? */ @@ -1272,7 +1280,7 @@ static void area_move_set_limits( int size_min = ED_area_global_min_size_y(area) - 1; int size_max = ED_area_global_max_size_y(area) - 1; - size_min = MAX2(size_min, 0); + size_min = max_ii(size_min, 0); BLI_assert(size_min < size_max); /* logic here is only tested for lower edge :) */ |