[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [20482] branches/blender2.5/blender/source /blender/editors: UI:

Brecht Van Lommel brecht at blender.org
Fri May 29 01:41:12 CEST 2009


Revision: 20482
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20482
Author:   blendix
Date:     2009-05-29 01:41:12 +0200 (Fri, 29 May 2009)

Log Message:
-----------
UI:
* Added a dummy preview render template, to test some layout
  engine features on tomorrow.

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
    branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
    branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c

Modified: branches/blender2.5/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-05-28 23:37:55 UTC (rev 20481)
+++ branches/blender2.5/blender/source/blender/editors/include/UI_interface.h	2009-05-28 23:41:12 UTC (rev 20482)
@@ -583,6 +583,7 @@
 	char *newop, char *openop, char *unlinkop);
 uiLayout *uiTemplateModifier(uiLayout *layout, struct PointerRNA *ptr);
 uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
+void uiTemplatePreview(uiLayout *layout, struct ID *id);
 
 /* items */
 void uiItemO(uiLayout *layout, char *name, int icon, char *opname);

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_api.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_api.c	2009-05-28 23:37:55 UTC (rev 20481)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_api.c	2009-05-28 23:41:12 UTC (rev 20482)
@@ -209,5 +209,10 @@
 	RNA_def_property_flag(parm, PROP_REQUIRED);
 	parm= RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to put items in.");
 	RNA_def_function_return(func, parm);
+
+	func= RNA_def_function(srna, "template_preview", "uiTemplatePreview");
+	parm= RNA_def_pointer(func, "id", "ID", "", "ID datablock.");
+	RNA_def_property_flag(parm, PROP_REQUIRED);
+
 }
 

Modified: branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c	2009-05-28 23:37:55 UTC (rev 20481)
+++ branches/blender2.5/blender/source/blender/editors/interface/interface_templates.c	2009-05-28 23:41:12 UTC (rev 20482)
@@ -699,7 +699,6 @@
 	}
 
 	if (md->error) {
-
 		row = uiLayoutRow(uiLayoutBox(column), 0);
 
 		/* XXX uiBlockSetCol(block, color); */
@@ -1241,17 +1240,6 @@
 				uiBlockEndAlign(block);
 			}
 			break;
-		case CONSTRAINT_TYPE_LOCLIKE:
-			{
-				bLocateLikeConstraint *data = con->data;
-				
-				result= uiLayoutColumn(box, 0);
-
-				/* constraint space settings */
-				block= uiLayoutFreeBlock(box);
-				draw_constraint_spaceselect(block, con, 0, 0, is_armature_owner(ob), is_armature_target(data->tar));
-			}
-			break;
 		case CONSTRAINT_TYPE_ROTLIKE:
 			{
 				bRotateLikeConstraint *data = con->data;
@@ -2074,16 +2062,6 @@
 			break;
 		}
 	}
-
-	if (ELEM(con->type, CONSTRAINT_TYPE_NULL, CONSTRAINT_TYPE_RIGIDBODYJOINT)==0) {
-		box= uiLayoutBox(col);
-		block= uiLayoutFreeBlock(box);
-		uiBlockBeginAlign(block);
-		uiDefButF(block, NUMSLI, B_CONSTRAINT_INF, "Influence ", xco, yco, width, 20, &(con->enforce), 0.0, 1.0, 0.0, 0.0, "Amount of influence this constraint will have on the final solution");
-		uiBlockEndAlign(block);
-
-		// XXX Show/Key buttons, functionaly can be replaced with right click menu?
-	} 
 	
 	/* clear any locks set up for proxies/lib-linking */
 	uiBlockClearButLock(block);
@@ -2122,3 +2100,152 @@
 	return draw_constraint(layout, ob, con);
 }
 
+/************************* Group Template ***************************/
+
+#if 0
+static void do_add_groupmenu(void *arg, int event)
+{
+	Object *ob= OBACT;
+	
+	if(ob) {
+		
+		if(event== -1) {
+			Group *group= add_group( "Group" );
+			add_to_group(group, ob);
+		}
+		else
+			add_to_group(BLI_findlink(&G.main->group, event), ob);
+			
+		ob->flag |= OB_FROMGROUP;
+		BASACT->flag |= OB_FROMGROUP;
+		allqueue(REDRAWBUTSOBJECT, 0);
+		allqueue(REDRAWVIEW3D, 0);
+	}		
+}
+
+static uiBlock *add_groupmenu(void *arg_unused)
+{
+	uiBlock *block;
+	Group *group;
+	short xco=0, yco= 0, index=0;
+	char str[32];
+	
+	block= uiNewBlock(&curarea->uiblocks, "add_constraintmenu", UI_EMBOSSP, UI_HELV, curarea->win);
+	uiBlockSetButmFunc(block, do_add_groupmenu, NULL);
+
+	uiDefBut(block, BUTM, B_NOP, "ADD NEW",		0, 20, 160, 19, NULL, 0.0, 0.0, 1, -1, "");
+	for(group= G.main->group.first; group; group= group->id.next, index++) {
+		
+		/*if(group->id.lib) strcpy(str, "L  ");*/ /* we cant allow adding objects inside linked groups, it wont be saved anyway */
+		if(group->id.lib==0) {
+			strcpy(str, "   ");
+			strcat(str, group->id.name+2);
+			uiDefBut(block, BUTM, B_NOP, str,	xco*160, -20*yco, 160, 19, NULL, 0.0, 0.0, 1, index, "");
+			
+			yco++;
+			if(yco>24) {
+				yco= 0;
+				xco++;
+			}
+		}
+	}
+	
+	uiTextBoundsBlock(block, 50);
+	uiBlockSetDirection(block, UI_DOWN);	
+	
+	return block;
+}
+
+static void group_ob_rem(void *gr_v, void *ob_v)
+{
+	Object *ob= OBACT;
+	
+	if(rem_from_group(gr_v, ob) && find_group(ob, NULL)==NULL) {
+		ob->flag &= ~OB_FROMGROUP;
+		BASACT->flag &= ~OB_FROMGROUP;
+	}
+	allqueue(REDRAWBUTSOBJECT, 0);
+	allqueue(REDRAWVIEW3D, 0);
+
+}
+
+static void group_local(void *gr_v, void *unused)
+{
+	Group *group= gr_v;
+	
+	group->id.lib= NULL;
+	
+	allqueue(REDRAWBUTSOBJECT, 0);
+	allqueue(REDRAWVIEW3D, 0);
+	
+}
+
+uiLayout *uiTemplateGroup(uiLayout *layout, Object *ob, Group *group)
+{
+	uiSetButLock(1, NULL);
+	uiDefBlockBut(block, add_groupmenu, NULL, "Add to Group", 10,150,150,20, "Add Object to a new Group");
+
+	/* all groups */
+	if(group->id.lib) {
+		uiLayoutRow()
+		uiBlockBeginAlign(block);
+		uiSetButLock(GET_INT_FROM_POINTER(group->id.lib), ERROR_LIBDATA_MESSAGE); /* We cant actually use this button */
+		uiDefBut(block, TEX, B_IDNAME, "GR:",	10, 120-yco, 100, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
+		uiClearButLock();
+		
+		but= uiDefIconBut(block, BUT, B_NOP, ICON_PARLIB, 110, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Make Group local");
+		uiButSetFunc(but, group_local, group, NULL);
+		uiBlockEndAlign(block);
+	} else {
+		but = uiDefBut(block, TEX, B_IDNAME, "GR:",	10, 120-yco, 120, 20, group->id.name+2, 0.0, 21.0, 0, 0, "Displays Group name. Click to change.");
+		uiButSetFunc(but, test_idbutton_cb, group->id.name, NULL);
+	}
+	
+	xco = 290;
+	if(group->id.lib==0) { /* cant remove objects from linked groups */
+		but = uiDefIconBut(block, BUT, B_NOP, VICON_X, xco, 120-yco, 20, 20, NULL, 0.0, 0.0, 0.0, 0.0, "Remove Group membership");
+		uiButSetFunc(but, group_ob_rem, group, ob);
+	}
+}
+#endif
+
+/************************* Preview Template ***************************/
+
+#include "DNA_material_types.h"
+
+#define B_MATPRV 1
+
+void uiTemplatePreview(uiLayout *layout, ID *id)
+{
+	uiLayout *row, *col;
+	uiBlock *block;
+	Material *ma;
+
+	if(!id || !ELEM3(GS(id->name), ID_MA, ID_TE, ID_WO)) {
+		printf("uiTemplatePreview: expected ID of type material, texture or world.\n");
+		return;
+	}
+
+	block= uiLayoutGetBlock(layout);
+
+	row= uiLayoutRow(layout, 0);
+
+	col= uiLayoutColumn(row, 0);
+	uiLayoutSetKeepAspect(col, 1);
+	uiDefBut(block, ROUNDBOX, 0, "", 0, 0, UI_UNIT_X*6, UI_UNIT_Y*6, NULL, 0.0, 0.0, 0, 0, "");
+
+	if(GS(id->name) == ID_MA) {
+		ma= (Material*)id;
+
+		uiLayoutColumn(row, 1);
+
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_MATPLANE,  0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_FLAT, 0, 0, "Preview type: Flat XY plane");
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE, 0, 0, "Preview type: Sphere");
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_MATCUBE,   0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_CUBE, 0, 0, "Preview type: Cube");
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_MONKEY,    0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_MONKEY, 0, 0, "Preview type: Monkey");
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_HAIR,      0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_HAIR, 0, 0, "Preview type: Hair strands");
+		uiDefIconButC(block, ROW, B_MATPRV, ICON_MATSPHERE, 0, 0,UI_UNIT_X,UI_UNIT_Y, &(ma->pr_type), 10, MA_SPHERE_A, 0, 0, "Preview type: Large sphere with sky");
+	}
+
+}
+





More information about the Bf-blender-cvs mailing list