[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43362] trunk/blender: theme settings - split space and space list into their own RNA members, display with own heading in userprefs.

Campbell Barton ideasman42 at gmail.com
Sat Jan 14 04:25:00 CET 2012


Revision: 43362
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43362
Author:   campbellbarton
Date:     2012-01-14 03:24:41 +0000 (Sat, 14 Jan 2012)
Log Message:
-----------
theme settings - split space and space list into their own RNA members, display with own heading in userprefs.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/source/blender/makesrna/RNA_access.h
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c

Modified: trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-01-13 18:27:33 UTC (rev 43361)
+++ trunk/blender/release/scripts/startup/bl_ui/space_userpref.py	2012-01-14 03:24:41 UTC (rev 43362)
@@ -507,33 +507,41 @@
     @staticmethod
     def _theme_generic(split, themedata):
 
-        row = split.row()
+        col = split.column()
 
-        subsplit = row.split(percentage=0.95)
+        def theme_generic_recurse(data):
+            col.label(data.rna_type.name)
+            row = col.row()
+            subsplit = row.split(percentage=0.95)
 
-        padding1 = subsplit.split(percentage=0.15)
-        padding1.column()
+            padding1 = subsplit.split(percentage=0.15)
+            padding1.column()
 
-        subsplit = row.split(percentage=0.85)
+            subsplit = row.split(percentage=0.85)
 
-        padding2 = subsplit.split(percentage=0.15)
-        padding2.column()
+            padding2 = subsplit.split(percentage=0.15)
+            padding2.column()
 
-        colsub_pair = padding1.column(), padding2.column()
+            colsub_pair = padding1.column(), padding2.column()
 
-        props_type = {}
+            props_type = {}
 
-        for i, prop in enumerate(themedata.rna_type.properties):
-            attr = prop.identifier
-            if attr == "rna_type":
-                continue
+            for i, prop in enumerate(data.rna_type.properties):
+                if prop.identifier == "rna_type":
+                    continue
 
-            props_type.setdefault((prop.type, prop.subtype), []).append(prop.identifier)
+                props_type.setdefault((prop.type, prop.subtype), []).append(prop)
 
-        for props_type, props_ls in sorted(props_type.items()):
-            for i, attr in enumerate(props_ls):
-                colsub_pair[i % 2].row().prop(themedata, attr)
+            for props_type, props_ls in sorted(props_type.items()):
+                if props_type[0] == 'POINTER':
+                    for i, prop in enumerate(props_ls):
+                        theme_generic_recurse(getattr(data, prop.identifier))
+                else:
+                    for i, prop in enumerate(props_ls):
+                        colsub_pair[i % 2].row().prop(data, prop.identifier)
 
+        theme_generic_recurse(themedata)
+
     @classmethod
     def poll(cls, context):
         userpref = context.user_preferences

Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h	2012-01-13 18:27:33 UTC (rev 43361)
+++ trunk/blender/source/blender/makesrna/RNA_access.h	2012-01-14 03:24:41 UTC (rev 43362)
@@ -546,6 +546,8 @@
 extern StructRNA RNA_ThemeOutliner;
 extern StructRNA RNA_ThemeProperties;
 extern StructRNA RNA_ThemeSequenceEditor;
+extern StructRNA RNA_ThemeSpaceGeneric;
+extern StructRNA RNA_ThemeSpaceListGeneric;
 extern StructRNA RNA_ThemeStyle;
 extern StructRNA RNA_ThemeTextEditor;
 extern StructRNA RNA_ThemeTimeline;

Modified: trunk/blender/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-01-13 18:27:33 UTC (rev 43361)
+++ trunk/blender/source/blender/makesrna/intern/rna_userdef.c	2012-01-14 03:24:41 UTC (rev 43362)
@@ -312,6 +312,17 @@
 	WM_main_add_notifier(NC_WINDOW, NULL);
 }
 
+static PointerRNA rna_Theme_space_generic_get(PointerRNA *ptr)
+{
+	return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceGeneric, ptr->data);
+}
+
+static PointerRNA rna_Theme_space_list_generic_get(PointerRNA *ptr)
+{
+	return rna_pointer_inherit_refine(ptr, &RNA_ThemeSpaceListGeneric, ptr->data);
+}
+
+
 #ifdef WITH_CYCLES
 static EnumPropertyItem *rna_userdef_compute_device_type_itemf(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), int *free)
 {
@@ -711,10 +722,15 @@
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 }
 
-static void rna_def_userdef_theme_spaces_main(StructRNA *srna, int spacetype)
+static void rna_def_userdef_theme_space_generic(BlenderRNA *brna)
 {
+	StructRNA *srna;
 	PropertyRNA *prop;
 
+	srna= RNA_def_struct(brna, "ThemeSpaceGeneric", NULL);
+	RNA_def_struct_sdna(srna, "ThemeSpace");
+	RNA_def_struct_ui_text(srna, "Theme Space Settings", "");
+
 	/* window */
 	prop= RNA_def_property(srna, "back", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
@@ -725,7 +741,7 @@
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Title", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	prop= RNA_def_property(srna, "text", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Text", "");
@@ -746,59 +762,89 @@
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Header Text", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	prop= RNA_def_property(srna, "header_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Header Text Highlight", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	/* buttons */
 //	if(! ELEM(spacetype, SPACE_BUTS, SPACE_OUTLINER)) {
 	prop= RNA_def_property(srna, "button", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Region Background", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	prop= RNA_def_property(srna, "button_title", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Region Text Titles", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	prop= RNA_def_property(srna, "button_text", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Region Text", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
-	
+
 	prop= RNA_def_property(srna, "button_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
 	RNA_def_property_ui_text(prop, "Region Text Highlight", "");
 	RNA_def_property_update(prop, 0, "rna_userdef_update");
 //	}
-	
-	/* list/channels */
-	if(ELEM5(spacetype, SPACE_IPO, SPACE_ACTION, SPACE_NLA, SPACE_NODE, SPACE_FILE)) {
-		prop= RNA_def_property(srna, "list", PROP_FLOAT, PROP_COLOR_GAMMA);
-		RNA_def_property_array(prop, 3);
-		RNA_def_property_ui_text(prop, "Source List", "");
-		RNA_def_property_update(prop, 0, "rna_userdef_update");
-		
-		prop= RNA_def_property(srna, "list_title", PROP_FLOAT, PROP_COLOR_GAMMA);
-		RNA_def_property_array(prop, 3);
-		RNA_def_property_ui_text(prop, "Source List Title", "");
-		RNA_def_property_update(prop, 0, "rna_userdef_update");
-		
-		prop= RNA_def_property(srna, "list_text", PROP_FLOAT, PROP_COLOR_GAMMA);
-		RNA_def_property_array(prop, 3);
-		RNA_def_property_ui_text(prop, "Source List Text", "");
-		RNA_def_property_update(prop, 0, "rna_userdef_update");
-		
-		prop= RNA_def_property(srna, "list_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
-		RNA_def_property_array(prop, 3);
-		RNA_def_property_ui_text(prop, "Source List Text Highlight", "");
-		RNA_def_property_update(prop, 0, "rna_userdef_update");
-	}	
 }
 
+/* list / channels */
+static void rna_def_userdef_theme_space_list_generic(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	srna= RNA_def_struct(brna, "ThemeSpaceListGeneric", NULL);
+	RNA_def_struct_sdna(srna, "ThemeSpace");
+	RNA_def_struct_ui_text(srna, "Theme Space List Settings", "");
+
+	prop= RNA_def_property(srna, "list", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Source List", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop= RNA_def_property(srna, "list_title", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Source List Title", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop= RNA_def_property(srna, "list_text", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Source List Text", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+
+	prop= RNA_def_property(srna, "list_text_hi", PROP_FLOAT, PROP_COLOR_GAMMA);
+	RNA_def_property_array(prop, 3);
+	RNA_def_property_ui_text(prop, "Source List Text Highlight", "");
+	RNA_def_property_update(prop, 0, "rna_userdef_update");
+}
+
+static void rna_def_userdef_theme_spaces_main(StructRNA *srna)
+{
+	PropertyRNA *prop;
+
+	prop= RNA_def_property(srna, "space", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_NEVER_NULL);
+	RNA_def_property_struct_type(prop, "ThemeSpaceGeneric");
+	RNA_def_property_pointer_funcs(prop, "rna_Theme_space_generic_get", NULL, NULL, NULL);
+	RNA_def_property_ui_text(prop, "Theme Space", "Settings for space");
+}
+
+static void rna_def_userdef_theme_spaces_list_main(StructRNA *srna)
+{
+	PropertyRNA *prop;
+
+	prop= RNA_def_property(srna, "space_list", PROP_POINTER, PROP_NONE);
+	RNA_def_property_flag(prop, PROP_NEVER_NULL);
+	RNA_def_property_struct_type(prop, "ThemeSpaceListGeneric");
+	RNA_def_property_pointer_funcs(prop, "rna_Theme_space_list_generic_get", NULL, NULL, NULL);
+	RNA_def_property_ui_text(prop, "Theme Space List", "Settings for space list");
+}
+
 static void rna_def_userdef_theme_spaces_vertex(StructRNA *srna)
 {
 	PropertyRNA *prop;
@@ -992,7 +1038,7 @@
 	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
 	RNA_def_struct_ui_text(srna, "Theme 3D View", "Theme settings for the 3D View");
 
-	rna_def_userdef_theme_spaces_main(srna, SPACE_VIEW3D);
+	rna_def_userdef_theme_spaces_main(srna);
 
 	prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
@@ -1130,7 +1176,8 @@
 	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);
 	RNA_def_struct_ui_text(srna, "Theme Graph Editor", "Theme settings for the graph editor");
 
-	rna_def_userdef_theme_spaces_main(srna, SPACE_IPO);
+	rna_def_userdef_theme_spaces_main(srna);
+	rna_def_userdef_theme_spaces_list_main(srna);
 
 	prop= RNA_def_property(srna, "grid", PROP_FLOAT, PROP_COLOR_GAMMA);
 	RNA_def_property_array(prop, 3);
@@ -1215,7 +1262,8 @@
 	RNA_def_struct_clear_flag(srna, STRUCT_UNDO);

@@ Diff output truncated at 10240 characters. @@


More information about the Bf-blender-cvs mailing list