[Bf-blender-cvs] [5397d8d2682] master: UI: allow shrinking panel height to zero when open.

Alexander Gavrilov noreply at git.blender.org
Wed May 22 17:11:38 CEST 2019


Commit: 5397d8d268244c34ecab94f89885e64925acc50e
Author: Alexander Gavrilov
Date:   Wed May 22 17:59:06 2019 +0300
Branches: master
https://developer.blender.org/rB5397d8d268244c34ecab94f89885e64925acc50e

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.

===================================================================

M	source/blender/editors/include/UI_interface.h
M	source/blender/editors/interface/interface_panel.c
M	source/blender/editors/screen/area.c

===================================================================

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);
 }
 
 /**



More information about the Bf-blender-cvs mailing list