[Bf-blender-cvs] [a9dfad831b8] master: Fix T77694: Start panel animation when expansion data changes

Hans Goudey noreply at git.blender.org
Wed Jun 10 17:17:02 CEST 2020


Commit: a9dfad831b8b616c7f7c6b17c2764f8610926ddb
Author: Hans Goudey
Date:   Wed Jun 10 11:16:55 2020 -0400
Branches: master
https://developer.blender.org/rBa9dfad831b8b616c7f7c6b17c2764f8610926ddb

Fix T77694: Start panel animation when expansion data changes

During normal drawing there is a rather complicated method to check
whether the panels should be animating. It's not set up to deal with
the panel expansion changing from outside the UI, which is now possible
with the panel expansion connected to the modifier's show_expanded
property.

The solution is to activate panel animation if setting the expansion
property has changed.

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

M	source/blender/editors/interface/interface_panel.c

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

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index 33f600f30a1..a83f1cc44db 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -486,10 +486,13 @@ static void reorder_instanced_panel_list(bContext *C, ARegion *region, Panel *dr
 
 /**
  * Recursive implementation for #UI_panel_set_expand_from_list_data.
+ *
+ * \return Whether the closed flag for the panel or any subpanels changed.
  */
-static void panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
+static bool panel_set_expand_from_list_data_recursive(Panel *panel, short flag, short *flag_index)
 {
   bool open = (flag & (1 << *flag_index));
+  bool changed = (open == (bool)(panel->flag & PNL_CLOSEDY));
   if (open) {
     panel->flag &= ~PNL_CLOSEDY;
   }
@@ -498,8 +501,9 @@ static void panel_set_expand_from_list_data_recursive(Panel *panel, short flag,
   }
   LISTBASE_FOREACH (Panel *, child, &panel->children) {
     *flag_index = *flag_index + 1;
-    panel_set_expand_from_list_data_recursive(child, flag, flag_index);
+    changed |= panel_set_expand_from_list_data_recursive(child, flag, flag_index);
   }
+  return changed;
 }
 
 /**
@@ -518,7 +522,11 @@ void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel)
 
   short expand_flag = panel->type->get_list_data_expand_flag(C, panel);
   short flag_index = 0;
-  panel_set_expand_from_list_data_recursive(panel, expand_flag, &flag_index);
+
+  /* Start panel animation if the open state was changed. */
+  if (panel_set_expand_from_list_data_recursive(panel, expand_flag, &flag_index)) {
+    panel_activate_state(C, panel, PANEL_STATE_ANIMATION);
+  }
 }
 
 /**



More information about the Bf-blender-cvs mailing list