[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41635] trunk/blender/source: UI/Nodes: templates to edit nodes from the properties editor using a tree view,

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Nov 7 23:28:49 CET 2011


Revision: 41635
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41635
Author:   blendix
Date:     2011-11-07 22:28:49 +0000 (Mon, 07 Nov 2011)
Log Message:
-----------
UI/Nodes: templates to edit nodes from the properties editor using a tree view,
to be used by cycles. For testing there's a panel in the node editor if you set
debug to 777, didn't enable it because I'm not sure it's very useful there.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface_intern.h
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_widgets.c
    trunk/blender/source/blender/editors/space_node/CMakeLists.txt
    trunk/blender/source/blender/editors/space_node/node_buttons.c
    trunk/blender/source/blender/makesrna/intern/rna_ui_api.c
    trunk/blender/source/blenderplayer/bad_level_call_stubs/stubs.c

Added Paths:
-----------
    trunk/blender/source/blender/editors/space_node/node_templates.c

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2011-11-07 22:28:49 UTC (rev 41635)
@@ -66,6 +66,9 @@
 struct Tex;
 struct MTex;
 struct ImBuf;
+struct bNodeTree;
+struct bNode;
+struct bNodeSocket;
 
 typedef struct uiBut uiBut;
 typedef struct uiBlock uiBlock;
@@ -74,6 +77,10 @@
 
 /* Defines */
 
+/* names */
+#define UI_MAX_DRAW_STR	400
+#define UI_MAX_NAME_STR	128
+
 /* uiBlock->dt */
 #define UI_EMBOSS		0	/* use widget style for drawing */
 #define UI_EMBOSSN		1	/* Nothing, only icon and/or text */
@@ -128,12 +135,12 @@
 #define UI_ICON_LEFT	128
 #define UI_ICON_SUBMENU	256
 #define UI_ICON_PREVIEW	512
-	/* control for button type block */
-#define UI_MAKE_TOP		1024
-#define UI_MAKE_DOWN	2048
-#define UI_MAKE_LEFT	4096
-#define UI_MAKE_RIGHT	8192
 
+#define UI_TEXT_RIGHT		1024
+#define UI_BUT_NODE_LINK	2048
+#define UI_BUT_NODE_ACTIVE	4096
+#define UI_FLAG_UNUSED		8192
+
 	/* button align flag, for drawing groups together */
 #define UI_BUT_ALIGN		(UI_BUT_ALIGN_TOP|UI_BUT_ALIGN_LEFT|UI_BUT_ALIGN_RIGHT|UI_BUT_ALIGN_DOWN)
 #define UI_BUT_ALIGN_TOP	(1<<14)
@@ -749,6 +756,8 @@
 void uiTemplateKeymapItemProperties(uiLayout *layout, struct PointerRNA *ptr);
 
 void uiTemplateList(uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, struct PointerRNA *activeptr, const char *activeprop, const char *prop_list, int rows, int maxrows, int type);
+void uiTemplateNodeLink(uiLayout *layout, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
+void uiTemplateNodeView(uiLayout *layout, struct bContext *C, struct bNodeTree *ntree, struct bNode *node, struct bNodeSocket *input);
 
 void uiTemplateMovieClip(struct uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const char *propname, int compact);
 void uiTemplateTrack(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname);

Modified: trunk/blender/source/blender/editors/interface/interface_intern.h
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_intern.h	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/interface/interface_intern.h	2011-11-07 22:28:49 UTC (rev 41635)
@@ -79,6 +79,7 @@
 	UI_WTYPE_MENU_RADIO,
 	UI_WTYPE_MENU_ICON_RADIO,
 	UI_WTYPE_MENU_POINTER_LINK,
+	UI_WTYPE_MENU_NODE_LINK,
 	
 	UI_WTYPE_PULLDOWN,
 	UI_WTYPE_MENU_ITEM,
@@ -96,11 +97,6 @@
 	
 } uiWidgetTypeEnum;
 
-
-
-#define UI_MAX_DRAW_STR	400
-#define UI_MAX_NAME_STR	128
-
 /* panel limits */
 #define UI_PANEL_MINX	100
 #define UI_PANEL_MINY	70

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2011-11-07 22:28:49 UTC (rev 41635)
@@ -1533,15 +1533,6 @@
 		if(ELEM(but->type, BLOCK, PULLDOWN))
 			block->xofs = -2;	/* for proper alignment */
 
-		/* only used for automatic toolbox, so can set the shift flag */
-		if(but->flag & UI_MAKE_TOP) {
-			block->direction= UI_TOP|UI_SHIFT_FLIPPED;
-			uiBlockFlipOrder(block);
-		}
-		if(but->flag & UI_MAKE_DOWN) block->direction= UI_DOWN|UI_SHIFT_FLIPPED;
-		if(but->flag & UI_MAKE_LEFT) block->direction |= UI_LEFT;
-		if(but->flag & UI_MAKE_RIGHT) block->direction |= UI_RIGHT;
-
 		ui_block_position(window, butregion, but, block);
 	}
 	else {

Modified: trunk/blender/source/blender/editors/interface/interface_widgets.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_widgets.c	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/interface/interface_widgets.c	2011-11-07 22:28:49 UTC (rev 41635)
@@ -1181,6 +1181,12 @@
 			
 			widget_draw_icon(but, ICON_DOT, dualset?1.0f:0.25f, rect);
 		}
+		else if(but->type==MENU && (but->flag & UI_BUT_NODE_LINK)) {
+			int tmp = rect->xmin;
+			rect->xmin = rect->xmax - (rect->ymax - rect->ymin) - 1;
+			widget_draw_icon(but, ICON_LAYER_USED, 1.0f, rect);
+			rect->xmin = tmp;
+		}
 		
 		/* If there's an icon too (made with uiDefIconTextBut) then draw the icon
 		and offset the text label to accommodate it */
@@ -1543,6 +1549,10 @@
 		char red[4]= {255, 0, 0};
 		widget_state_blend(wt->wcol.inner, red, 0.4f);
 	}
+	if(state & UI_BUT_NODE_ACTIVE) {
+		char blue[4]= {86, 128, 194};
+		widget_state_blend(wt->wcol.inner, blue, 0.3f);
+	}
 }
 
 /* sliders use special hack which sets 'item' as inner when drawing filling */
@@ -2530,6 +2540,29 @@
 	widgetbase_draw(&wtb, wcol);
 }
 
+static void widget_menunodebut(uiWidgetColors *wcol, rcti *rect, int UNUSED(state), int roundboxalign)
+{
+	/* silly node link button hacks */
+	uiWidgetBase wtb;
+	uiWidgetColors wcol_backup= *wcol;
+	
+	widget_init(&wtb);
+	
+	/* half rounded */
+	round_box_edges(&wtb, roundboxalign, rect, 4.0f);
+
+	wcol->inner[0] += 15;
+	wcol->inner[1] += 15;
+	wcol->inner[2] += 15;
+	wcol->outline[0] += 15;
+	wcol->outline[1] += 15;
+	wcol->outline[2] += 15;
+	
+	/* decoration */
+	widgetbase_draw(&wtb, wcol);
+	*wcol= wcol_backup;
+}
+
 static void widget_pulldownbut(uiWidgetColors *wcol, rcti *rect, int state, int UNUSED(roundboxalign))
 {
 	if(state & UI_ACTIVE) {
@@ -2804,6 +2837,11 @@
 			wt.wcol_theme= &btheme->tui.wcol_menu;
 			wt.draw= widget_menubut;
 			break;
+
+		case UI_WTYPE_MENU_NODE_LINK:
+			wt.wcol_theme= &btheme->tui.wcol_menu;
+			wt.draw= widget_menunodebut;
+			break;
 			
 		case UI_WTYPE_PULLDOWN:
 			wt.wcol_theme= &btheme->tui.wcol_pulldown;
@@ -2996,7 +3034,9 @@
 			case MENU:
 			case BLOCK:
 			case ICONTEXTROW:
-				if(!but->str[0] && but->icon)
+				if(but->flag & UI_BUT_NODE_LINK)
+					wt= widget_type(UI_WTYPE_MENU_NODE_LINK);
+				else if(!but->str[0] && but->icon)
 					wt= widget_type(UI_WTYPE_MENU_ICON_RADIO);
 				else
 					wt= widget_type(UI_WTYPE_MENU_RADIO);

Modified: trunk/blender/source/blender/editors/space_node/CMakeLists.txt
===================================================================
--- trunk/blender/source/blender/editors/space_node/CMakeLists.txt	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/space_node/CMakeLists.txt	2011-11-07 22:28:49 UTC (rev 41635)
@@ -47,6 +47,7 @@
 	node_ops.c
 	node_select.c
 	node_state.c
+	node_templates.c
 	space_node.c
 
 	node_intern.h

Modified: trunk/blender/source/blender/editors/space_node/node_buttons.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_buttons.c	2011-11-07 22:24:14 UTC (rev 41634)
+++ trunk/blender/source/blender/editors/space_node/node_buttons.c	2011-11-07 22:28:49 UTC (rev 41635)
@@ -45,6 +45,7 @@
 #include "BLI_utildefines.h"
 
 #include "BKE_context.h"
+#include "BKE_global.h"
 #include "BKE_node.h"
 #include "BKE_screen.h"
 
@@ -122,6 +123,34 @@
 		node->typeinfo->uifunc(layout, (bContext *)C, &ptr);
 }
 
+static int node_sockets_poll(const bContext *C, PanelType *UNUSED(pt))
+{
+	SpaceNode *snode= CTX_wm_space_node(C);
+	
+	return (snode && snode->nodetree && G.rt == 777);
+}
+
+static void node_sockets_panel(const bContext *C, Panel *pa)
+{
+	SpaceNode *snode= CTX_wm_space_node(C);
+	bNodeTree *ntree= (snode) ? snode->edittree : NULL;
+	bNode *node = (ntree) ? nodeGetActive(ntree) : NULL;
+	bNodeSocket *sock;
+	uiLayout *layout= pa->layout, *split;
+	char name[UI_MAX_NAME_STR];
+	
+	if(ELEM(NULL, ntree, node))
+		return;
+	
+	for(sock=node->inputs.first; sock; sock=sock->next) {
+		BLI_snprintf(name, sizeof(name), "%s:", sock->name);
+
+		split = uiLayoutSplit(layout, 0.35f, 0);
+		uiItemL(split, name, ICON_NONE);
+		uiTemplateNodeLink(split, ntree, node, sock);
+	}
+}
+
 /* ******************* node buttons registration ************** */
 
 void node_buttons_register(ARegionType *art)
@@ -134,6 +163,14 @@
 	pt->draw= active_node_panel;
 	pt->poll= active_node_poll;
 	BLI_addtail(&art->paneltypes, pt);
+
+	pt= MEM_callocN(sizeof(PanelType), "spacetype node panel node sockets");
+	strcpy(pt->idname, "NODE_PT_sockets");
+	strcpy(pt->label, "Sockets");
+	pt->draw= node_sockets_panel;
+	pt->poll= node_sockets_poll;
+	pt->flag |= PNL_DEFAULT_CLOSED;
+	BLI_addtail(&art->paneltypes, pt);
 	
 	pt= MEM_callocN(sizeof(PanelType), "spacetype node panel gpencil");
 	strcpy(pt->idname, "NODE_PT_gpencil");

Added: trunk/blender/source/blender/editors/space_node/node_templates.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/node_templates.c	                        (rev 0)
+++ trunk/blender/source/blender/editors/space_node/node_templates.c	2011-11-07 22:28:49 UTC (rev 41635)
@@ -0,0 +1,636 @@
+/*
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributor(s): Blender Foundation 2009.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/editors/interface/interface_node.c
+ *  \ingroup edinterface
+ */
+
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_node_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_screen_types.h"
+
+#include "BLI_listbase.h"
+#include "BLI_string.h"
+#include "BLI_utildefines.h"
+
+#include "BKE_context.h"
+#include "BKE_depsgraph.h"
+#include "BKE_library.h"
+#include "BKE_main.h"
+#include "BKE_node.h"
+#include "BKE_scene.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list