[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [37077] trunk/blender/source/blender/ editors/interface/interface_templates.c: UI: template_ID now takes into account if the property is editable.

Brecht Van Lommel brechtvanlommel at pandora.be
Wed Jun 1 18:13:48 CEST 2011


Revision: 37077
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=37077
Author:   blendix
Date:     2011-06-01 16:13:48 +0000 (Wed, 01 Jun 2011)
Log Message:
-----------
UI: template_ID now takes into account if the property is editable.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/interface/interface_templates.c

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2011-06-01 15:45:09 UTC (rev 37076)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2011-06-01 16:13:48 UTC (rev 37077)
@@ -332,6 +332,7 @@
 	PointerRNA idptr;
 	// ListBase *lb; // UNUSED
 	ID *id, *idfrom;
+	int editable= RNA_property_editable(&template->ptr, template->prop);
 
 	idptr= RNA_property_pointer_get(&template->ptr, template->prop);
 	id= idptr.data;
@@ -352,14 +353,12 @@
 			if (id) but->icon = ui_id_icon_get(C, id, 1);
 			uiButSetFlag(but, UI_HAS_ICON|UI_ICON_PREVIEW);
 		}
-		if((idfrom && idfrom->lib))
+		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 		
-		
 		uiLayoutRow(layout, 1);
-	} else 
-		
-	if(flag & UI_ID_BROWSE) {
+	}
+	else if(flag & UI_ID_BROWSE) {
 		but= uiDefBlockButN(block, id_search_menu, MEM_dupallocN(template), "", 0, 0, UI_UNIT_X*1.6, UI_UNIT_Y, template_id_browse_tip(type));
 		if(type) {
 			but->icon= RNA_struct_ui_icon(type);
@@ -368,7 +367,7 @@
 			uiButSetFlag(but, UI_HAS_ICON|UI_ICON_LEFT);
 		}
 
-		if((idfrom && idfrom->lib))
+		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 	}
 
@@ -410,7 +409,7 @@
 				but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X+10,UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
 
 			uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
-			if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib))
+			if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)
 				uiButSetFlag(but, UI_BUT_DISABLED);
 		}
 	
@@ -433,7 +432,7 @@
 			uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ADD_NEW));
 		}
 
-		if((idfrom && idfrom->lib))
+		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 	}
 
@@ -449,7 +448,7 @@
 			uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_OPEN));
 		}
 
-		if((idfrom && idfrom->lib))
+		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 	}
 	
@@ -468,7 +467,7 @@
 				uiButSetFlag(but, UI_BUT_DISABLED);
 		}
 
-		if((idfrom && idfrom->lib))
+		if((idfrom && idfrom->lib) || !editable)
 			uiButSetFlag(but, UI_BUT_DISABLED);
 	}
 	




More information about the Bf-blender-cvs mailing list