[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37376] branches/cycles: Cycles: button to switch to texture tab from e.g.

Brecht Van Lommel brechtvanlommel at pandora.be
Fri Jun 10 20:17:34 CEST 2011


Revision: 37376
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37376
Author:   blendix
Date:     2011-06-10 18:17:34 +0000 (Fri, 10 Jun 2011)
Log Message:
-----------
Cycles: button to switch to texture tab from e.g. modifiers and field, with the
relevant texture selected, and some cosmetic tweaks to the menu.

Modified Paths:
--------------
    branches/cycles/release/scripts/startup/bl_ui/properties_data_modifier.py
    branches/cycles/release/scripts/startup/bl_ui/properties_physics_field.py
    branches/cycles/source/blender/editors/include/UI_interface.h
    branches/cycles/source/blender/editors/interface/interface_templates.c
    branches/cycles/source/blender/editors/space_buttons/buttons_texture.c

Modified: branches/cycles/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- branches/cycles/release/scripts/startup/bl_ui/properties_data_modifier.py	2011-06-10 17:17:25 UTC (rev 37375)
+++ branches/cycles/release/scripts/startup/bl_ui/properties_data_modifier.py	2011-06-10 18:17:34 UTC (rev 37376)
@@ -666,7 +666,7 @@
         split = layout.split()
         col = split.column()
         col.label(text="Texture:")
-        col.prop(md, "texture", text="")
+        col.template_ID(md, "texture", new="texture.new")
 
         col = split.column()
         col.label(text="Texture Coordinates:")

Modified: branches/cycles/release/scripts/startup/bl_ui/properties_physics_field.py
===================================================================
--- branches/cycles/release/scripts/startup/bl_ui/properties_physics_field.py	2011-06-10 17:17:25 UTC (rev 37375)
+++ branches/cycles/release/scripts/startup/bl_ui/properties_physics_field.py	2011-06-10 18:17:34 UTC (rev 37376)
@@ -61,6 +61,10 @@
             split = layout.split(percentage=0.2)
             split.label(text="Shape:")
             split.prop(field, "shape", text="")
+        elif field.type == 'TEXTURE':
+            split = layout.split(percentage=0.2)
+            split.label(text="Texture:")
+            split.row().template_ID(field, "texture", new="texture.new")
 
         split = layout.split()
 
@@ -103,7 +107,6 @@
         elif field.type == 'TEXTURE':
             col = split.column()
             col.prop(field, "strength")
-            col.prop(field, "texture", text="")
             col.prop(field, "texture_mode", text="")
             col.prop(field, "texture_nabla")
 

Modified: branches/cycles/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/cycles/source/blender/editors/include/UI_interface.h	2011-06-10 17:17:25 UTC (rev 37375)
+++ branches/cycles/source/blender/editors/include/UI_interface.h	2011-06-10 18:17:34 UTC (rev 37376)
@@ -730,6 +730,7 @@
 void uiTemplateNodeLink(uiLayout *layout, struct ID *id, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
 void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct ID *id, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
 void uiTemplateTextureUser(uiLayout *layout, struct bContext *C);
+void uiTemplateTextureShow(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop);
 
 /* items */
 void uiItemO(uiLayout *layout, const char *name, int icon, const char *opname);

Modified: branches/cycles/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/cycles/source/blender/editors/interface/interface_templates.c	2011-06-10 17:17:25 UTC (rev 37375)
+++ branches/cycles/source/blender/editors/interface/interface_templates.c	2011-06-10 18:17:34 UTC (rev 37376)
@@ -325,7 +325,7 @@
 	return "Browse ID data to be linked";
 }
 
-static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, int flag, const char *newop, const char *openop, const char *unlinkop)
+static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, StructRNA *type, short idcode, int flag, const char *newop, const char *openop, const char *unlinkop)
 {
 	uiBut *but;
 	uiBlock *block;
@@ -470,6 +470,9 @@
 		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 	}
+
+	if(idcode == ID_TE)
+		uiTemplateTextureShow(layout, C, &template->ptr, template->prop);
 	
 	uiBlockEndAlign(block);
 }
@@ -479,6 +482,7 @@
 	TemplateID *template;
 	PropertyRNA *prop;
 	StructRNA *type;
+	short idcode;
 
 	prop= RNA_struct_find_property(ptr, propname);
 
@@ -499,14 +503,15 @@
 		flag |= UI_ID_OPEN;
 
 	type= RNA_property_pointer_type(ptr, prop);
-	template->idlb= which_libbase(CTX_data_main(C), RNA_type_to_ID_code(type));
+	idcode= RNA_type_to_ID_code(type);
+	template->idlb= which_libbase(CTX_data_main(C), idcode);
 	
 	/* create UI elements for this template
 	 *	- template_ID makes a copy of the template data and assigns it to the relevant buttons
 	 */
 	if(template->idlb) {
 		uiLayoutRow(layout, 1);
-		template_ID(C, layout, template, type, flag, newop, openop, unlinkop);
+		template_ID(C, layout, template, type, idcode, flag, newop, openop, unlinkop);
 	}
 
 	MEM_freeN(template);

Modified: branches/cycles/source/blender/editors/space_buttons/buttons_texture.c
===================================================================
--- branches/cycles/source/blender/editors/space_buttons/buttons_texture.c	2011-06-10 17:17:25 UTC (rev 37375)
+++ branches/cycles/source/blender/editors/space_buttons/buttons_texture.c	2011-06-10 18:17:34 UTC (rev 37376)
@@ -45,6 +45,7 @@
 #include "DNA_material_types.h"
 #include "DNA_node_types.h"
 #include "DNA_object_types.h"
+#include "DNA_object_force.h"
 #include "DNA_particle_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
@@ -56,12 +57,15 @@
 #include "BKE_modifier.h"
 #include "BKE_node.h"
 #include "BKE_paint.h"
+#include "BKE_particle.h"
 
 #include "RNA_access.h"
 
 #include "UI_interface.h"
 #include "UI_resources.h"
 
+#include "ED_screen.h"
+
 #include "../interface/interface_intern.h"
 
 #include "buttons_intern.h"	// own include
@@ -99,7 +103,8 @@
 				RNA_pointer_create(&ntree->id, &RNA_Node, node, &ptr);
 				prop = RNA_struct_find_property(&ptr, "texture");
 
-				buttons_texture_user_add(users, id, ptr, prop, category, ICON_NODE, node->name);
+				buttons_texture_user_add(users, id, ptr, prop,
+					category, RNA_struct_ui_icon(ptr.type), node->name);
 			}
 			else if(node->type == NODE_GROUP && node->id) {
 				buttons_texture_users_find_nodetree(users, id, (bNodeTree*)node->id, category);
@@ -117,7 +122,8 @@
 	RNA_pointer_create(&ob->id, &RNA_Modifier, md, &ptr);
 	prop = RNA_struct_find_property(&ptr, propname);
 
-	buttons_texture_user_add(users, &ob->id, ptr, prop, "Modifiers", ICON_MODIFIER, md->name);
+	buttons_texture_user_add(users, &ob->id, ptr, prop,
+		"Modifiers", RNA_struct_ui_icon(ptr.type), md->name);
 }
 
 static void buttons_texture_users_from_context(ListBase *users, const bContext *C, SpaceButs *sbuts)
@@ -171,7 +177,7 @@
 		buttons_texture_users_find_nodetree(users, &wrld->id, wrld->nodetree, "World");
 
 	if(ob) {
-		ParticleSystem *psys;
+		ParticleSystem *psys= psys_get_current(ob);
 		MTex *mtex;
 		int a;
 
@@ -179,8 +185,8 @@
 		modifiers_foreachTexLink(ob, buttons_texture_modifier_foreach, users);
 
 		/* particle systems */
-		/* todo: these slots are not in the UI */
-		for(psys=ob->particlesystem.first; psys; psys=psys->next) {
+		if(psys) {
+			/* todo: these slots are not in the UI */
 			for(a=0; a<MAX_MTEX; a++) {
 				mtex = psys->part->mtex[a];
 
@@ -191,10 +197,23 @@
 					RNA_pointer_create(&psys->part->id, &RNA_ParticleSettingsTextureSlot, mtex, &ptr);
 					prop = RNA_struct_find_property(&ptr, "texture");
 
-					buttons_texture_user_add(users, &psys->part->id, ptr, prop, "Particles", ICON_PARTICLES, psys->name);
+					buttons_texture_user_add(users, &psys->part->id, ptr, prop,
+						"Particles", RNA_struct_ui_icon(&RNA_ParticleSettings), psys->name);
 				}
 			}
 		}
+
+		/* field */
+		if(ob->pd && ob->pd->forcefield == PFIELD_TEXTURE) {
+			PointerRNA ptr;
+			PropertyRNA *prop;
+
+			RNA_pointer_create(&ob->id, &RNA_FieldSettings, ob->pd, &ptr);
+			prop = RNA_struct_find_property(&ptr, "texture");
+
+			buttons_texture_user_add(users, &ob->id, ptr, prop,
+				"Fields", ICON_FORCE_TEXTURE, "Texture Field");
+		}
 	}
 
 	/* brush */
@@ -203,9 +222,10 @@
 		PropertyRNA *prop;
 
 		RNA_pointer_create(&brush->id, &RNA_BrushTextureSlot, &brush->mtex, &ptr);
-		prop = RNA_struct_find_property(&ptr, "texture");
+		prop= RNA_struct_find_property(&ptr, "texture");
 
-		buttons_texture_user_add(users, &brush->id, ptr, prop, "Brush", ICON_BRUSH_DATA, brush->id.name+2);
+		buttons_texture_user_add(users, &brush->id, ptr, prop,
+			"Brush", ICON_BRUSH_DATA, brush->id.name+2);
 	}
 }
 
@@ -335,3 +355,59 @@
 	but->flag &= ~UI_ICON_SUBMENU;
 }
 
+/************************* Texture Show **************************/
+
+static void template_texture_show(bContext *C, void *data_p, void *prop_p)
+{
+	SpaceButs *sbuts = CTX_wm_space_buts(C);
+	ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL;
+	ButsTextureUser *user;
+
+	if(!ct)
+		return;
+
+	for(user=ct->users.first; user; user=user->next)
+		if(user->ptr.data == data_p && user->prop == prop_p)
+			break;
+	
+	if(user) {
+		/* select texture */
+		template_texture_select(C, user, NULL);
+
+		/* change context */
+		sbuts->mainb= BCONTEXT_TEXTURE;
+		sbuts->mainbuser= sbuts->mainb;
+		sbuts->preview= 1;
+
+		/* redraw editor */
+		ED_area_tag_redraw(CTX_wm_area(C));
+	}
+}
+
+void uiTemplateTextureShow(uiLayout *layout, bContext *C, PointerRNA *ptr, PropertyRNA *prop)
+{
+	/* button to quickly show texture in texture tab */
+	SpaceButs *sbuts = CTX_wm_space_buts(C);
+	ButsContextTexture *ct= (sbuts)? sbuts->texuser: NULL;
+	ButsTextureUser *user;
+
+	/* only show button in other tabs in properties editor */
+	if(!ct || sbuts->mainb == BCONTEXT_TEXTURE)
+		return;
+
+	/* find corresponding texture user */
+	for(user=ct->users.first; user; user=user->next)
+		if(user->ptr.data == ptr->data && user->prop == prop)
+			break;
+	
+	/* draw button */
+	if(user) {
+		uiBlock *block = uiLayoutGetBlock(layout);
+		uiBut *but;
+		
+		but= uiDefIconBut(block, BUT, 0, ICON_BUTS, 0, 0, UI_UNIT_X, UI_UNIT_Y,
+			NULL, 0.0, 0.0, 0.0, 0.0, "Show texture in texture tab");
+		uiButSetFunc(but, template_texture_show, user->ptr.data, user->prop);
+	}
+}
+




More information about the Bf-blender-cvs mailing list