[Bf-blender-cvs] [94fb309372c] modifier-panels-ui: Add list panel index to RNA

Hans Goudey noreply at git.blender.org
Sat Apr 18 22:12:07 CEST 2020


Commit: 94fb309372c82aff47047d8ed62a41cc4474aed3
Author: Hans Goudey
Date:   Sat Apr 18 15:01:46 2020 -0500
Branches: modifier-panels-ui
https://developer.blender.org/rB94fb309372c82aff47047d8ed62a41cc4474aed3

Add list panel index to RNA

Needed to support creating list panel layouts in python.

Also check for unimplemented list panel functions before calling.

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

M	source/blender/editors/interface/interface_panel.c
M	source/blender/makesrna/intern/rna_ui.c

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

diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c
index f732e32c267..5ff2e0bcec6 100644
--- a/source/blender/editors/interface/interface_panel.c
+++ b/source/blender/editors/interface/interface_panel.c
@@ -277,6 +277,10 @@ void UI_panel_set_expand_from_list_data(const bContext *C, Panel *panel)
 {
   BLI_assert(panel->type != NULL);
   BLI_assert(panel->type->flag & PNL_LIST);
+  if (panel->type->get_list_data_expand_flag) {
+    /* List panel doesn't support loading expansion. */
+    return;
+  }
 
   short expand_flag = panel->type->get_list_data_expand_flag(C, panel);
   short flag_index = 0;
@@ -321,7 +325,9 @@ static void set_panels_list_data_expand_flag(const bContext *C, ARegion *region)
       short expand_flag;
       short flag_index = 0;
       get_panel_expand_flag(panel, &expand_flag, &flag_index);
-      panel->type->set_list_data_expand_flag(C, panel, expand_flag);
+      if (panel->type->set_list_data_expand_flag) {
+        panel->type->set_list_data_expand_flag(C, panel, expand_flag);
+      }
     }
   }
 }
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index c8fae94d052..e1567f5b041 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -1343,6 +1343,10 @@ static void rna_def_panel(BlenderRNA *brna)
   RNA_def_property_string_sdna(prop, NULL, "drawname");
   RNA_def_property_ui_text(prop, "Text", "XXX todo");
 
+  prop = RNA_def_int(srna, "list_panel_index", 0, 0, INT_MAX, "List Panel Index", "", 0, 1000);
+  RNA_def_property_int_sdna(prop, NULL, "runtime.list_index");
+  RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
   /* registration */
   prop = RNA_def_property(srna, "bl_idname", PROP_STRING, PROP_NONE);
   RNA_def_property_string_sdna(prop, NULL, "type->idname");



More information about the Bf-blender-cvs mailing list