[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [30740] trunk/blender: * was suggested I combine all the direction modes into a single enumeration by using RNA_def_property_enum_funcs

Jason Wilkins Jason.A.Wilkins at gmail.com
Mon Jul 26 07:25:11 CEST 2010


Revision: 30740
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30740
Author:   jwilkins
Date:     2010-07-26 07:25:09 +0200 (Mon, 26 Jul 2010)

Log Message:
-----------
* was suggested I combine all the direction modes into a single enumeration by using RNA_def_property_enum_funcs

Modified Paths:
--------------
    trunk/blender/release/scripts/ui/space_view3d_toolbar.py
    trunk/blender/source/blender/makesrna/intern/rna_brush.c

Modified: trunk/blender/release/scripts/ui/space_view3d_toolbar.py
===================================================================
--- trunk/blender/release/scripts/ui/space_view3d_toolbar.py	2010-07-26 04:21:44 UTC (rev 30739)
+++ trunk/blender/release/scripts/ui/space_view3d_toolbar.py	2010-07-26 05:25:09 UTC (rev 30740)
@@ -643,29 +643,9 @@
             row= col.row()
             row.prop(brush, "use_frontface", text="Front Faces Only")
 
-            #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY', 'CLAY_TUBES'):
-            if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'LAYER', 'CLAY'):
-                col.separator()
-                col.row().prop(brush, "direction", expand=True)
-            elif brush.sculpt_tool in ('FLATTEN'):
-                col.separator()
-                col.row().prop(brush, "flatten_contrast", expand=True)
-            elif brush.sculpt_tool in ('FILL'):
-                col.separator()
-                col.row().prop(brush, "fill_deepen", expand=True)
-            elif brush.sculpt_tool in ('SCRAPE'):
-                col.separator()
-                col.row().prop(brush, "scrape_peaks", expand=True)
-            elif brush.sculpt_tool in ('INFLATE'):
-                col.separator()
-                col.row().prop(brush, "inflate_deflate", expand=True)
-            elif brush.sculpt_tool in ('PINCH'):
-                col.separator()
-                col.row().prop(brush, "pinch_magnify", expand=True)
+            col.separator()
+            col.row().prop(brush, "direction", expand=True)
 
-
-
-            #if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY', 'CLAY_TUBES'):
             if brush.sculpt_tool in ('DRAW', 'CREASE', 'BLOB', 'INFLATE', 'LAYER', 'CLAY'):
                 col.separator()
 

Modified: trunk/blender/source/blender/makesrna/intern/rna_brush.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_brush.c	2010-07-26 04:21:44 UTC (rev 30739)
+++ trunk/blender/source/blender/makesrna/intern/rna_brush.c	2010-07-26 05:25:09 UTC (rev 30740)
@@ -39,6 +39,11 @@
 
 #include "WM_types.h"
 
+static const EnumPropertyItem prop_direction_items[]= {
+	{0, "ADD", 0, "Add", "Add effect of brush"},
+	{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
+	{0, NULL, 0, NULL, NULL}};
+
 EnumPropertyItem brush_sculpt_tool_items[] = {
 	{SCULPT_TOOL_BLOB, "BLOB", ICON_BRUSH_BLOB, "Blob", ""},
 	{SCULPT_TOOL_CLAY, "CLAY", ICON_BRUSH_CLAY, "Clay", ""},
@@ -257,6 +262,66 @@
 	return brush_alpha(me);
 }
 
+static EnumPropertyItem *rna_Brush_direction_itemf(bContext *C, PointerRNA *ptr, int *free)
+{
+	static const EnumPropertyItem prop_default_items[]= {
+		{0, NULL, 0, NULL, NULL}};
+
+	static const EnumPropertyItem prop_flatten_contrast_items[]= {
+		{0, "FLATTEN", 0, "Flatten", "Add effect of brush"},
+		{BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"},
+		{0, NULL, 0, NULL, NULL}};
+
+	static const EnumPropertyItem prop_fill_deepen_items[]= {
+		{0, "FILL", 0, "Fill", "Add effect of brush"},
+		{BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"},
+		{0, NULL, 0, NULL, NULL}};
+
+	static const EnumPropertyItem prop_scrape_peaks_items[]= {
+		{0, "SCRAPE", 0, "Scrape", "Add effect of brush"},
+		{BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"},
+		{0, NULL, 0, NULL, NULL}};
+
+	static const EnumPropertyItem prop_pinch_magnify_items[]= {
+		{0, "PINCH", 0, "Pinch", "Add effect of brush"},
+		{BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"},
+		{0, NULL, 0, NULL, NULL}};
+
+	static const EnumPropertyItem prop_inflate_deflate_items[]= {
+		{0, "INFLATE", 0, "Inflate", "Add effect of brush"},
+		{BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"},
+		{0, NULL, 0, NULL, NULL}};
+
+	Brush *me= (Brush*)(ptr->data);
+
+	switch (me->sculpt_tool) {
+		case SCULPT_TOOL_DRAW:
+		case SCULPT_TOOL_CREASE:
+		case SCULPT_TOOL_BLOB:
+		case SCULPT_TOOL_LAYER:
+		case SCULPT_TOOL_CLAY:
+			return prop_direction_items;
+
+		case SCULPT_TOOL_FLATTEN:
+			return prop_flatten_contrast_items;
+
+		case SCULPT_TOOL_FILL:
+			return prop_fill_deepen_items;
+
+		case SCULPT_TOOL_SCRAPE:
+			return prop_scrape_peaks_items;
+
+		case SCULPT_TOOL_PINCH:
+			return prop_pinch_magnify_items;
+
+		case SCULPT_TOOL_INFLATE:
+			return prop_inflate_deflate_items;
+
+		default:
+			return prop_default_items;
+	}
+}
+
 #else
 
 static void rna_def_brush_texture_slot(BlenderRNA *brna)
@@ -322,36 +387,6 @@
 		{BRUSH_RAKE, "RAKE", 0, "Rake", ""},
 		{0, NULL, 0, NULL, NULL}};
 
-	static const EnumPropertyItem prop_flip_direction_items[]= {
-		{0, "ADD", 0, "Add", "Add effect of brush"},
-		{BRUSH_DIR_IN, "SUBTRACT", 0, "Subtract", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
-	static const EnumPropertyItem prop_flatten_contrast_items[]= {
-		{0, "FLATTEN", 0, "Flatten", "Add effect of brush"},
-		{BRUSH_DIR_IN, "CONTRAST", 0, "Contrast", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
-	static const EnumPropertyItem prop_fill_deepen_items[]= {
-		{0, "FILL", 0, "Fill", "Add effect of brush"},
-		{BRUSH_DIR_IN, "DEEPEN", 0, "Deepen", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
-	static const EnumPropertyItem prop_scrape_peaks_items[]= {
-		{0, "SCRAPE", 0, "Scrape", "Add effect of brush"},
-		{BRUSH_DIR_IN, "PEAKS", 0, "Peaks", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
-	static const EnumPropertyItem prop_pinch_magnify_items[]= {
-		{0, "PINCH", 0, "Pinch", "Add effect of brush"},
-		{BRUSH_DIR_IN, "MAGNIFY", 0, "Magnify", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
-	static const EnumPropertyItem prop_inflate_deflate_items[]= {
-		{0, "INFLATE", 0, "Inflate", "Add effect of brush"},
-		{BRUSH_DIR_IN, "DEFLATE", 0, "Deflate", "Subtract effect of brush"},
-		{0, NULL, 0, NULL, NULL}};
-
 	static EnumPropertyItem brush_sculpt_plane_items[] = {
 		{SCULPT_DISP_DIR_AREA, "AREA", 0, "Area Plane", ""},
 		{SCULPT_DISP_DIR_VIEW, "VIEW", 0, "View Plane", ""},
@@ -419,7 +454,8 @@
 
 	prop= RNA_def_property(srna, "direction", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_flip_direction_items);
+	RNA_def_property_enum_items(prop, prop_direction_items);
+	RNA_def_property_enum_funcs(prop, NULL, NULL, "rna_Brush_direction_itemf");
 	RNA_def_property_ui_text(prop, "Direction", "");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
@@ -441,36 +477,6 @@
 	RNA_def_property_ui_text(prop, "Texture Angle Source", "");
 	RNA_def_property_update(prop, 0, "rna_Brush_update");
 
-	prop= RNA_def_property(srna, "flatten_contrast", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_flatten_contrast_items);
-	RNA_def_property_ui_text(prop, "Flatten/Contrast", "");
-	RNA_def_property_update(prop, 0, "rna_Brush_update");
-
-	prop= RNA_def_property(srna, "inflate_deflate", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_inflate_deflate_items);
-	RNA_def_property_ui_text(prop, "Inflate/Deflate", "");
-	RNA_def_property_update(prop, 0, "rna_Brush_update");
-
-	prop= RNA_def_property(srna, "fill_deepen", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_fill_deepen_items);
-	RNA_def_property_ui_text(prop, "Fill/Deepen", "");
-	RNA_def_property_update(prop, 0, "rna_Brush_update");
-
-	prop= RNA_def_property(srna, "scrape_peaks", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_scrape_peaks_items);
-	RNA_def_property_ui_text(prop, "Scrape/Peaks", "");
-	RNA_def_property_update(prop, 0, "rna_Brush_update");
-
-	prop= RNA_def_property(srna, "pinch_magnify", PROP_ENUM, PROP_NONE);
-	RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
-	RNA_def_property_enum_items(prop, prop_pinch_magnify_items);
-	RNA_def_property_ui_text(prop, "Pinch/Magnify", "");
-	RNA_def_property_update(prop, 0, "rna_Brush_update");
-
 	prop= RNA_def_property(srna, "sculpt_plane", PROP_ENUM, PROP_NONE);
 	RNA_def_property_enum_items(prop, brush_sculpt_plane_items);
 	RNA_def_property_ui_text(prop, "Sculpt Plane", "");





More information about the Bf-blender-cvs mailing list