Page MenuHome

ui_template_list_svn35798.patch

ui_template_list_svn35798.patch

diff -Naur -x '*.svn' -x doc -x '*.pyc' -x '*.pyu' -x addons blender_src/build_files/cmake/buildinfo.cmake src_work_c/build_files/cmake/buildinfo.cmake
--- blender_src/build_files/cmake/buildinfo.cmake 2011-02-25 11:19:07.000000000 +0000
+++ src_work_c/build_files/cmake/buildinfo.cmake 2011-03-26 11:35:35.163637997 +0000
@@ -27,7 +27,7 @@
# Write a file with the SVNVERSION define
file(WRITE buildinfo.h.txt
- "#define BUILD_REV ${MY_WC_REVISION}\n"
+ "#define BUILD_REV ${MY_WC_REVISION}m\n"
"#define BUILD_DATE ${BUILD_DATE}\n"
"#define BUILD_TIME ${BUILD_TIME}\n"
)
diff -Naur -x '*.svn' -x doc -x '*.pyc' -x '*.pyu' -x addons blender_src/source/blender/editors/interface/interface_templates.c src_work_c/source/blender/editors/interface/interface_templates.c
--- blender_src/source/blender/editors/interface/interface_templates.c 2011-03-25 15:02:14.967632085 +0000
+++ src_work_c/source/blender/editors/interface/interface_templates.c 2011-03-26 11:35:35.163637997 +0000
@@ -2096,8 +2096,61 @@
//uiItemR(row, itemptr, "mute", 0, "", ICON_MUTE_IPO_OFF);
uiBlockSetEmboss(block, UI_EMBOSS);
}
- else
- uiItemL(sub, name, icon); /* fails, backdrop LISTROW... */
+ /* Default.
+ * There is a last chance to display custom sontrols (in addition to the name/label):
+ * If the given item property group features a “template_list_enum_controls” enum property,
+ * this tries to add controls for all properties of the item listed in that enum property.
+ *
+ * This is especially useful for python. E.g., if you list a collection of this property
+ * group:
+ *
+ * class TestPropertyGroup(bpy.types.PropertyGroup):
+ * bool = BoolProperty(default=False)
+ * integer = IntProperty()
+ * string = StringProperty()
+ *
+ * # A collection of identifiers (as strings) which property’s controls should be displayed
+ * # in a template_list.
+ * # XXX: The initialization of this collection is done via a dedicated init() func.
+ * # This isn’t really nice, but there seems to be no ways to specifies a default set of
+ * # items for a collection. User has to define and call this func manually…
+ * # There should be a way to automatize all this, but I’m not skill enough with BPY
+ * # to figure it (seems inheritance and/or __init__ and/or __new__ don’t work here…).
+ * template_list_controls = CollectionProperty(type=TemplateListControl, options={"HIDDEN"})
+ * def init_TemplateListControls(self):
+ * self.template_list_controls.add().identifier = "integer"
+ * self.template_list_controls.add().identifier = "bool"
+ * self.template_list_controls.add().identifier = "string"
+ *
+ * … you’ll get a check box for the copy prop, and a numfield for the test prop, after the
+ * name of each item of the collection.
+ */
+ else {
+ PropertyRNA *enum_ctrls;
+ row = uiLayoutRow(sub, 1);
+ uiItemL(row, name, icon);
+
+ /* If the special property is set for the item, and it is a collection… */
+ enum_ctrls = RNA_struct_find_property(itemptr, "template_list_controls");
+ if(enum_ctrls) {
+ if(RNA_property_type(enum_ctrls) == PROP_COLLECTION) {
+ CollectionPropertyIterator ctrls;
+ for(RNA_property_collection_begin(itemptr, enum_ctrls, &ctrls); ctrls.valid;
+ RNA_property_collection_next(&ctrls)) {
+ PointerRNA ctrl = ctrls.ptr;
+ PropertyRNA *identifier = RNA_struct_find_property(&ctrl, "identifier");
+ if(identifier) {
+ if(RNA_property_type(identifier) == PROP_STRING) {
+ char *id = RNA_property_string_get_alloc(&ctrl, identifier, NULL, 0);
+ uiItemR(row, itemptr, id, 0, NULL, 0);
+ MEM_freeN(id);
+ }
+ }
+ }
+ RNA_property_collection_end(&ctrls);
+ }
+ }
+ }
/* free name */
if(namebuf)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
14/65/f7ef9151186b27b048756007954c

Event Timeline