diff options
author | George Vogiatzis <Gvgeo> | 2019-04-03 15:53:57 +0300 |
---|---|---|
committer | Jacques Lucke <mail@jlucke.com> | 2019-04-03 16:01:05 +0300 |
commit | 822c67364e85f1092c25cdd5ab9d68c515deb09d (patch) | |
tree | 654c29f5c4649bbf6ac83f06a5ecf12873d7fbba /source/blender/editors/screen | |
parent | e2d5ccf5983732fb6aacbef8aa1f06a33dec7ea6 (diff) |
UI: Fix odd behavior in region sizing, simplify code
* When resizing sidebars, don't collapse when the region becomes too big but
instead clamp the region size to the available space.
* Fix clicking the tab to expand sidebars no working if the sidebar is too
wide to fit. Instead make it less wide so it does fit.
* Fix incorrect limit on tool properties region height, for example in the
file browser.
Differential Revision: https://developer.blender.org/D4611
Diffstat (limited to 'source/blender/editors/screen')
-rw-r--r-- | source/blender/editors/screen/area.c | 12 | ||||
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 103 |
2 files changed, 42 insertions, 73 deletions
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 411826d79c1..e599f3b7ed3 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -985,17 +985,7 @@ static void region_azones_add(const bScreen *screen, ScrArea *sa, ARegion *ar, c const bool is_fullscreen = screen->state == SCREENFULL; /* edge code (t b l r) is along which area edge azone will be drawn */ - - if (ar->regiontype == RGN_TYPE_HEADER && ar->winy + 6 > sa->winy) { - /* The logic for this is: when the header takes up the full area, - * disallow hiding it to view the main window. - * - * Without this, you can drag down the file selectors header and hide it - * by accident very easily (highly annoying!), the value 6 is arbitrary - * but accounts for small common rounding problems when scaling the UI, - * must be minimum '4' */ - } - else if (alignment == RGN_ALIGN_TOP) + if (alignment == RGN_ALIGN_TOP) region_azone_edge_initialize(sa, ar, AE_BOTTOM_TO_TOPLEFT, is_fullscreen); else if (alignment == RGN_ALIGN_BOTTOM) region_azone_edge_initialize(sa, ar, AE_TOP_TO_BOTTOMRIGHT, is_fullscreen); diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index 4ce21013924..06eadedd7b6 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -2278,48 +2278,56 @@ typedef struct RegionMoveData { } RegionMoveData; - static int area_max_regionsize(ScrArea *sa, ARegion *scalear, AZEdge edge) { ARegion *ar; int dist; - if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { - dist = BLI_rcti_size_x(&sa->totrct); - } - else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ - dist = BLI_rcti_size_y(&sa->totrct); - } + /* regions in regions. */ + if (scalear->alignment & RGN_SPLIT_PREV) { + const int align = scalear->alignment & RGN_ALIGN_ENUM_MASK; - /* subtractwidth of regions on opposite side - * prevents dragging regions into other opposite regions */ - for (ar = sa->regionbase.first; ar; ar = ar->next) { - if (ar == scalear) - continue; + if (ELEM(align, RGN_ALIGN_TOP, RGN_ALIGN_BOTTOM)) { + ar = scalear->prev; + dist = ar->winy + scalear->winy - U.pixelsize; + } + else if (ELEM(align, RGN_ALIGN_LEFT, RGN_ALIGN_RIGHT)) { + ar = scalear->prev; + dist = ar->winx + scalear->winx - U.pixelsize; + } + } + else { + if (edge == AE_RIGHT_TO_TOPLEFT || edge == AE_LEFT_TO_TOPRIGHT) { + dist = BLI_rcti_size_x(&sa->totrct); + } + else { /* AE_BOTTOM_TO_TOPLEFT, AE_TOP_TO_BOTTOMRIGHT */ + dist = BLI_rcti_size_y(&sa->totrct); + } - if (scalear->alignment == RGN_ALIGN_TOP && ar->alignment == RGN_ALIGN_BOTTOM) - dist -= ar->winy; - else if (scalear->alignment == RGN_ALIGN_BOTTOM && ar->alignment == RGN_ALIGN_TOP) - dist -= ar->winy; - else if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT) - dist -= ar->winx; - else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT) - dist -= ar->winx; + /* subtractwidth of regions on opposite side + * prevents dragging regions into other opposite regions */ + for (ar = sa->regionbase.first; ar; ar = ar->next) { + if (ar == scalear) + continue; - /* case of regions in regions, like operator properties panel */ - /* these can sit on top of other regions such as headers, so account for this */ - else if (edge == AE_BOTTOM_TO_TOPLEFT && scalear->alignment & RGN_ALIGN_TOP && - ar->alignment == RGN_ALIGN_TOP && ar->regiontype == RGN_TYPE_HEADER) - { - dist -= ar->winy; - } - else if (edge == AE_TOP_TO_BOTTOMRIGHT && scalear->alignment & RGN_ALIGN_BOTTOM && - ar->alignment == RGN_ALIGN_BOTTOM && ar->regiontype == RGN_TYPE_HEADER) - { - dist -= ar->winy; + if (scalear->alignment == RGN_ALIGN_LEFT && ar->alignment == RGN_ALIGN_RIGHT) { + dist -= ar->winx; + } + else if (scalear->alignment == RGN_ALIGN_RIGHT && ar->alignment == RGN_ALIGN_LEFT) { + dist -= ar->winx; + } + else if (scalear->alignment == RGN_ALIGN_TOP && + (ar->alignment == RGN_ALIGN_BOTTOM || ar->regiontype == RGN_TYPE_HEADER)) { + dist -= ar->winy; + } + else if (scalear->alignment == RGN_ALIGN_BOTTOM && + (ar->alignment == RGN_ALIGN_TOP || ar->regiontype == RGN_TYPE_HEADER)) { + dist -= ar->winy; + } } } + dist /= UI_DPI_FAC; return dist; } @@ -2337,7 +2345,6 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event if (az->ar) { RegionMoveData *rmd = MEM_callocN(sizeof(RegionMoveData), "RegionMoveData"); - int maxsize; op->customdata = rmd; @@ -2363,13 +2370,7 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event rmd->origval = rmd->ar->sizey; } - /* limit headers to standard height for now */ - if (rmd->ar->regiontype == RGN_TYPE_HEADER) - maxsize = ED_area_headersize(); - else - maxsize = 1000; - - CLAMP(rmd->maxsize, 0, maxsize); + CLAMP(rmd->maxsize, 0, 1000); /* add temp handler */ WM_event_add_modal_handler(C, op); @@ -2380,24 +2381,6 @@ static int region_scale_invoke(bContext *C, wmOperator *op, const wmEvent *event return OPERATOR_FINISHED; } -static int region_scale_get_maxsize(RegionMoveData *rmd) -{ - int maxsize = 0; - - if (rmd->edge == AE_LEFT_TO_TOPRIGHT || rmd->edge == AE_RIGHT_TO_TOPLEFT) { - return (int) ( (rmd->sa->winx / UI_DPI_FAC) - UI_UNIT_X); - } - - if (rmd->ar->regiontype == RGN_TYPE_TOOL_PROPS) { - /* this calculation seems overly verbose - * can someone explain why this method is necessary? - campbell */ - const bool top_header = ED_area_header_alignment(rmd->sa) == RGN_ALIGN_TOP; - maxsize = rmd->maxsize - ((top_header) ? UI_UNIT_Y * 2 : UI_UNIT_Y) - (UI_UNIT_Y / 4); - } - - return maxsize; -} - static void region_scale_validate_size(RegionMoveData *rmd) { if ((rmd->ar->flag & RGN_FLAG_HIDDEN) == 0) { @@ -2409,7 +2392,7 @@ static void region_scale_validate_size(RegionMoveData *rmd) else size = &rmd->ar->sizey; - maxsize = region_scale_get_maxsize(rmd); + maxsize = rmd->maxsize - (UI_UNIT_Y / UI_DPI_FAC); if (*size > maxsize && maxsize > 0) *size = maxsize; @@ -2469,7 +2452,6 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) } } else { - int maxsize = region_scale_get_maxsize(rmd); delta = event->y - rmd->origy; if (rmd->edge == AE_BOTTOM_TO_TOPLEFT) delta = -delta; @@ -2494,9 +2476,6 @@ static int region_scale_modal(bContext *C, wmOperator *op, const wmEvent *event) if (!(rmd->ar->flag & RGN_FLAG_HIDDEN)) region_scale_toggle_hidden(C, rmd); } - else if (maxsize > 0 && (rmd->ar->sizey > maxsize)) { - rmd->ar->sizey = maxsize; - } else if (rmd->ar->flag & RGN_FLAG_HIDDEN) { region_scale_toggle_hidden(C, rmd); } |