diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-22 17:59:06 +0300 |
---|---|---|
committer | Alexander Gavrilov <angavrilov@gmail.com> | 2019-05-22 17:59:22 +0300 |
commit | 5397d8d268244c34ecab94f89885e64925acc50e (patch) | |
tree | e032eec7627c852d64705bb69caf150cacceb34c | |
parent | 8f2538f4fba84c965b5b85e12eb441a97cfa5e58 (diff) |
UI: allow shrinking panel height to zero when open.
Currently if a panel becomes empty (draw simply returns), it stays
at the last non-empty height. This seems to be caused by some legacy
checks that may be completely obsolete, but the safest fix is to at
least allow resetting height when the panel is open.
-rw-r--r-- | source/blender/editors/include/UI_interface.h | 2 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_panel.c | 18 | ||||
-rw-r--r-- | source/blender/editors/screen/area.c | 2 |
3 files changed, 11 insertions, 11 deletions
diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 5efe5a7e07c..979e13915d4 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -1630,7 +1630,7 @@ struct Panel *UI_panel_begin(struct ScrArea *sa, struct PanelType *pt, struct Panel *pa, bool *r_open); -void UI_panel_end(uiBlock *block, int width, int height); +void UI_panel_end(uiBlock *block, int width, int height, bool open); void UI_panels_scale(struct ARegion *ar, float new_width); void UI_panel_label_offset(struct uiBlock *block, int *r_x, int *r_y); int UI_panel_size_y(const struct Panel *pa); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index aa7ff015bad..14e880c927a 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -367,7 +367,7 @@ Panel *UI_panel_begin( return pa; } -void UI_panel_end(uiBlock *block, int width, int height) +void UI_panel_end(uiBlock *block, int width, int height, bool open) { Panel *pa = block->panel; @@ -390,21 +390,21 @@ void UI_panel_end(uiBlock *block, int width, int height) pa->sizey = height; } else { - /* check if we need to do an animation */ - if (!ELEM(width, 0, pa->sizex) || !ELEM(height, 0, pa->sizey)) { - pa->runtime_flag |= PNL_ANIM_ALIGN; - if (height != 0) { - pa->ofsy += pa->sizey - height; - } - } + int old_sizex = pa->sizex, old_sizey = pa->sizey; /* update width/height if non-zero */ if (width != 0) { pa->sizex = width; } - if (height != 0) { + if (height != 0 || open) { pa->sizey = height; } + + /* check if we need to do an animation */ + if (pa->sizex != old_sizex || pa->sizey != old_sizey) { + pa->runtime_flag |= PNL_ANIM_ALIGN; + pa->ofsy += old_sizey - pa->sizey; + } } } diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index c2f9beb5d78..9b35c809d5a 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -2292,7 +2292,7 @@ static void ed_panel_draw(const bContext *C, } } - UI_panel_end(block, w, h); + UI_panel_end(block, w, h, open); } /** |