[Bf-blender-cvs] [53a1708] pie-menus: Separate property for viewport shade pies.

Antony Riakiotakis noreply at git.blender.org
Tue Jul 8 17:15:08 CEST 2014


Commit: 53a17088602873f12da9666047d1aae30de71038
Author: Antony Riakiotakis
Date:   Tue Jul 8 18:14:56 2014 +0300
https://developer.blender.org/rB53a17088602873f12da9666047d1aae30de71038

Separate property for viewport shade pies.

This is fine tuned for using with pie menus, where solid/wire mode
is given the most important west/east positions.

There were two possibilities with supporting custom pie enums for an
existing property. One is to add an extra function that dynamically
fills the pie items to fit a pie scheme. The other is make a separate
python property. I feel this is the correct way because it does not
burden all enum properties with extra function storage and it does not
always need to be dynamic either.

Also cleanup minor debug line

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

M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/makesrna/intern/rna_access.c
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 386d3f2..3ba8435 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -1429,7 +1429,7 @@ class VIEW3D_PIE_shade(Menu):
         layout = self.layout
 
         pie = layout.menu_pie()
-        pie.prop(context.space_data, "viewport_shade", expand=True)
+        pie.prop(context.space_data, "viewport_shade_pie", expand=True)
 
         if context.active_object:
             if(context.mode == 'EDIT_MESH'):
diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c
index c16f19d..2da1e5e 100644
--- a/source/blender/makesrna/intern/rna_access.c
+++ b/source/blender/makesrna/intern/rna_access.c
@@ -1356,8 +1356,6 @@ void RNA_property_enum_items_gettexted_all(bContext *C, PointerRNA *ptr, Propert
 			}
 		}
 
-		fflush(stdout);
-
 		if (free)
 			MEM_freeN(item);
 	}
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 39d6e66..7297cd9 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -134,6 +134,15 @@ EnumPropertyItem viewport_shade_items[] = {
 	{0, NULL, 0, NULL, NULL}
 };
 
+EnumPropertyItem viewport_shade_items_pie[] = {
+    {OB_SOLID, "SOLID", ICON_SOLID, "Solid", "Display the object solid, lit with default OpenGL lights"},
+    {OB_WIRE, "WIREFRAME", ICON_WIRE, "Wireframe", "Display the object as wire edges"},
+    {OB_TEXTURE, "TEXTURED", ICON_POTATO, "Texture", "Display the object solid, with a texture"},
+    {OB_MATERIAL, "MATERIAL", ICON_MATERIAL_DATA, "Material", "Display objects solid, with GLSL material"},
+	{OB_BOUNDBOX, "BOUNDBOX", ICON_BBOX, "Bounding Box", "Display the object's local bounding boxes only"},
+	{OB_RENDER, "RENDERED", ICON_SMOOTH, "Rendered", "Display render preview"},
+	{0, NULL, 0, NULL, NULL}
+};
 
 EnumPropertyItem clip_editor_mode_items[] = {
 	{SC_MODE_TRACKING, "TRACKING", ICON_ANIM_DATA, "Tracking", "Show tracking and solving tools"},
@@ -650,6 +659,33 @@ static EnumPropertyItem *rna_SpaceView3D_viewport_shade_itemf(bContext *UNUSED(C
 	return item;
 }
 
+static EnumPropertyItem *rna_SpaceView3D_viewport_shade_pie_itemf(bContext *UNUSED(C), PointerRNA *ptr,
+                                                              PropertyRNA *UNUSED(prop), bool *r_free)
+{
+	Scene *scene = ((bScreen *)ptr->id.data)->scene;
+	RenderEngineType *type = RE_engines_find(scene->r.engine);
+
+	EnumPropertyItem *item = NULL;
+	int totitem = 0;
+
+	RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_SOLID);
+	RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_WIRE);
+	RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_TEXTURE);
+
+	if (BKE_scene_use_new_shading_nodes(scene))
+		RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_MATERIAL);
+
+	if (type && type->view_draw)
+		RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_RENDER);
+
+	RNA_enum_items_add_value(&item, &totitem, viewport_shade_items_pie, OB_BOUNDBOX);
+
+	RNA_enum_item_end(&item, &totitem);
+	*r_free = true;
+
+	return item;
+}
+
 /* Space Image Editor */
 
 static PointerRNA rna_SpaceImageEditor_uvedit_get(PointerRNA *ptr)
@@ -1888,6 +1924,14 @@ static void rna_def_space_view3d(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View");
 	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
 
+	prop = RNA_def_property(srna, "viewport_shade_pie", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "drawtype");
+	RNA_def_property_enum_items(prop, viewport_shade_items_pie);
+	RNA_def_property_enum_funcs(prop, "rna_SpaceView3D_viewport_shade_get", NULL,
+	                            "rna_SpaceView3D_viewport_shade_pie_itemf");
+	RNA_def_property_ui_text(prop, "Viewport Shading", "Method to display/shade objects in the 3D View");
+	RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_viewport_shade_update");
+
 	prop = RNA_def_property(srna, "local_view", PROP_POINTER, PROP_NONE);
 	RNA_def_property_pointer_sdna(prop, NULL, "localvd");
 	RNA_def_property_ui_text(prop, "Local View",




More information about the Bf-blender-cvs mailing list