[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [45381] branches/asset-browser: == asset browser ==

Andrea Weikert elubie at gmx.net
Tue Apr 3 22:47:12 CEST 2012


Revision: 45381
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=45381
Author:   elubie
Date:     2012-04-03 20:46:58 +0000 (Tue, 03 Apr 2012)
Log Message:
-----------
== asset browser ==
* small improvement, added callback for draw_item and column layout for itemlist.

Modified Paths:
--------------
    branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
    branches/asset-browser/source/blender/blenkernel/BKE_screen.h
    branches/asset-browser/source/blender/editors/screen/area.c
    branches/asset-browser/source/blender/makesrna/intern/rna_ui.c

Modified: branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py
===================================================================
--- branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py	2012-04-03 19:08:06 UTC (rev 45380)
+++ branches/asset-browser/release/scripts/startup/bl_ui/space_asset.py	2012-04-03 20:46:58 UTC (rev 45381)
@@ -47,11 +47,14 @@
         return True
 
     def draw(self, context):
+        pass
+        
+    def draw_item(self, context, column, row):
         layout = self.layout
         sasset = context.space_data
-        
+        labeltext = 'Label(' + str(column) + ',' + str(row) + ')'
         col = layout.column(align=True)
-        col.label(text="Hello World!")
+        col.label(text=labeltext)
     
 class AssetCollectionsPanel(bpy.types.Panel):
     bl_label = "Asset Collections"

Modified: branches/asset-browser/source/blender/blenkernel/BKE_screen.h
===================================================================
--- branches/asset-browser/source/blender/blenkernel/BKE_screen.h	2012-04-03 19:08:06 UTC (rev 45380)
+++ branches/asset-browser/source/blender/blenkernel/BKE_screen.h	2012-04-03 20:46:58 UTC (rev 45381)
@@ -239,10 +239,11 @@
 	int			region_type;
 
 	/* verify if the item list should draw or not */
-	int			(*poll)(const struct bContext *, struct MenuType *);
+	int			(*poll)(const struct bContext *, struct ItemListType *);
 	/* draw entirely, view changes should be handled here */
-	void		(*draw)(const struct bContext *, struct Menu *);	
-
+	void		(*draw)(const struct bContext *, struct ItemList *);	
+	/* draw entirely, view changes should be handled here */
+	void		(*draw_item)(const struct bContext *, int column, int row, struct ItemList *);
 	/* RNA integration */
 	ExtensionRNA ext;
 } ItemListType;

Modified: branches/asset-browser/source/blender/editors/screen/area.c
===================================================================
--- branches/asset-browser/source/blender/editors/screen/area.c	2012-04-03 19:08:06 UTC (rev 45380)
+++ branches/asset-browser/source/blender/editors/screen/area.c	2012-04-03 20:46:58 UTC (rev 45381)
@@ -1750,25 +1750,30 @@
 
 	/* draw all headers types */
 	for(ilt= ar->type->itemlisttypes.first; ilt; ilt= ilt->next) {
+		int col, row;
 		block= uiBeginBlock(C, ar, ilt->idname, UI_EMBOSS);
 		layout= uiBlockLayout(block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, xco, yco, UI_UNIT_Y, 1, style);
 
-		if(ilt->draw) {
-			itemList.type= ilt;
-			itemList.layout= layout;
-			ilt->draw(C, &itemList);
-			
-			/* for view2d */
-			xco= uiLayoutGetWidth(layout);
-			if(xco > maxco)
-				maxco= xco;
+		for (col=0; col<4; col++) {
+			uiLayout *column = uiLayoutColumn(layout, 1);
+			for (row=0; row<6; row++) {
+
+				if(ilt->draw_item) {
+					itemList.type= ilt;
+					itemList.layout= column;
+					ilt->draw_item(C, col,row, &itemList);
+					
+				}
+			}
 		}
 
 		uiBlockLayoutResolve(block, &xco, &yco);
-		
+				
 		/* for view2d */
 		if(xco > maxco)
 			maxco= xco;
+
+		yco -= UI_UNIT_Y;
 		
 		uiEndBlock(C, block);
 		uiDrawBlock(C, block);

Modified: branches/asset-browser/source/blender/makesrna/intern/rna_ui.c
===================================================================
--- branches/asset-browser/source/blender/makesrna/intern/rna_ui.c	2012-04-03 19:08:06 UTC (rev 45380)
+++ branches/asset-browser/source/blender/makesrna/intern/rna_ui.c	2012-04-03 20:46:58 UTC (rev 45381)
@@ -540,6 +540,26 @@
 	RNA_parameter_list_free(&list);
 }
 
+static void itemlist_draw_item(const bContext *C, int column, int row, ItemList *il)
+{
+	extern FunctionRNA rna_ItemList_draw_item_func;
+
+	PointerRNA mtr;
+	ParameterList list;
+	FunctionRNA *func;
+
+	RNA_pointer_create(&CTX_wm_screen(C)->id, il->type->ext.srna, il, &mtr);
+	func = &rna_ItemList_draw_item_func; /* RNA_struct_find_function(&mtr, "draw"); */
+
+	RNA_parameter_list_create(&list, &mtr, func);
+	RNA_parameter_set_lookup(&list, "context", &C);
+	RNA_parameter_set_lookup(&list, "column", &column);
+	RNA_parameter_set_lookup(&list, "row", &row);
+	il->type->ext.call((bContext *)C, &mtr, func, &list);
+
+	RNA_parameter_list_free(&list);
+}
+
 static void rna_ItemList_unregister(Main *UNUSED(bmain), StructRNA *type)
 {
 	ARegionType *art;
@@ -609,7 +629,7 @@
 
 	ilt->poll = (have_function[0])? itemlist_poll: NULL;
 	ilt->draw = (have_function[1])? itemlist_draw: NULL;
-
+	ilt->draw_item = (have_function[2])? itemlist_draw_item: NULL;
 	BLI_addtail(&art->itemlisttypes, ilt);
 
 	/* update while blender is running */
@@ -1003,6 +1023,16 @@
 	parm = RNA_def_pointer(func, "context", "Context", "", "");
 	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
 
+	func = RNA_def_function(srna, "draw_item", NULL);
+	RNA_def_function_ui_description(func, "Draw UI elements into the panel's header UI layout");
+	RNA_def_function_flag(func, FUNC_REGISTER);
+	parm = RNA_def_pointer(func, "context", "Context", "", "");
+	RNA_def_property_flag(parm, PROP_REQUIRED|PROP_NEVER_NULL);
+	parm = RNA_def_int(func, "column", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+	parm = RNA_def_int(func, "row", 0, 0, INT_MAX, "", "", 0, INT_MAX);
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+
 	RNA_define_verify_sdna(0); /* not in sdna */
 
 	prop = RNA_def_property(srna, "layout", PROP_POINTER, PROP_NONE);




More information about the Bf-blender-cvs mailing list