UI: Fix view reset when toggling subpanel expansion

The view should only reset for the ctrl-click mode that collapses
all other panels.
This commit is contained in:
Hans Goudey 2020-06-21 10:47:37 -04:00
parent 3fc5826f7c
commit 0de14fbe78
1 changed files with 4 additions and 4 deletions

View File

@ -2051,10 +2051,13 @@ static void ui_handle_panel_header(
/* Collapse and expand panels. */
if (ctrl) {
/* Only collapse all for parent panels. */
/* For parent panels, collapse all other panels or toggle children. */
if (block->panel->type != NULL && block->panel->type->parent == NULL) {
if (block->panel->flag & PNL_CLOSED || BLI_listbase_is_empty(&block->panel->children)) {
panels_collapse_all(C, area, region, block->panel);
/* Reset the view - we don't want to display a view without content. */
UI_view2d_offset(&region->v2d, 0.0f, 1.0f);
}
else {
const int closed_flag = (align == BUT_HORIZONTAL) ? PNL_CLOSEDX : PNL_CLOSEDY;
@ -2066,9 +2069,6 @@ static void ui_handle_panel_header(
block->panel, closed_flag, (first_child->flag & PNL_CLOSED) == 0);
block->panel->flag |= closed_flag;
}
/* reset the view - we don't want to display a view without content */
UI_view2d_offset(&region->v2d, 0.0f, 1.0f);
}
}