Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Goudey <h.goudey@me.com>2020-05-26 22:39:49 +0300
committerHans Goudey <h.goudey@me.com>2020-05-26 22:39:49 +0300
commit5171d86806a338aa885cdddf3ad83dfcf15c40aa (patch)
tree00fd7c3fc9c245485f742c73a175cf6c9a0adb30 /source/blender/makesrna/intern/rna_ui.c
parentde257b6366455ba6a3604c0830a92245df11f7bc (diff)
UI: List Panel System
This implements a general system to implement drag and drop, subpanels, and UI animation for the stack UIs in Blender. There are NO functional changes in this patch, but it makes it relatively trivial to implement these features for stacks. The biggest complication to using panels to implement the UI for lists is that there can be multiple modifiers of the same type. Currently there is an assumed 1 to 1 relationship between every panel and its type, but there can be multiple list items of the same type, so we have to break this relationship. The mapping between panels and their data is stored with an index in the panel's runtime struct. To make use the system for a list like modifiers, four components must be added: 1. A panel type defined and registered for each list data type, with a known mapping between list data types and panel idnames. 1. A function called by interface code to build the add the panel layouts with the provided helper functions. - UI_panel_list_matches_data will check if the panel list needs to be rebuilt. - UI_panels_free_instanced will remove the existing list panels - UI_panel_add_instanced adds a list panel of a given type. 3. An expand flag for the list data and implementations of get_list_data_expand_flag and set_list_data_expand_flag. 4. For reordering, the panel type's reorder callback. This is called when the instanced panels are drag-dropped. This requires implementing a "move to index" operator for the list data. Reviewed By: Severin, brecht Differential Revision: https://developer.blender.org/D7490
Diffstat (limited to 'source/blender/makesrna/intern/rna_ui.c')
-rw-r--r--source/blender/makesrna/intern/rna_ui.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c
index ca466ce2821..1449c410d18 100644
--- a/source/blender/makesrna/intern/rna_ui.c
+++ b/source/blender/makesrna/intern/rna_ui.c
@@ -1285,6 +1285,18 @@ static void rna_def_panel(BlenderRNA *brna)
"Hide Header",
"If set to False, the panel shows a header, which contains a clickable "
"arrow to collapse the panel and the label (see bl_label)"},
+ {PNL_INSTANCED,
+ "INSTANCED",
+ 0,
+ "Instanced Panel",
+ "Multiple panels with this type can be used as part of a list depending on data external "
+ "to the UI. Used to create panels for the modifiers and other stacks."},
+ {PNL_LAYOUT_HEADER_EXPAND,
+ "HEADER_LAYOUT_EXPAND",
+ 0,
+ "Expand Header Layout",
+ "Allow buttons in the header to stretch and shrink to fill the entire layout width"},
+ {PNL_DRAW_BOX, "DRAW_BOX", 0, "Box Style", "Draw panel with the box widget theme"},
{0, NULL, 0, NULL, NULL},
};
@@ -1332,6 +1344,11 @@ 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, "Instanced Panel Data Index", "", 0, INT_MAX);
+ 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");