[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60657] trunk/blender/source/blender: Cleanup: Consistent names for draw callbacks in bNodeType.

Lukas Toenne lukas.toenne at googlemail.com
Thu Oct 10 13:33:20 CEST 2013


Revision: 60657
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60657
Author:   lukastoenne
Date:     2013-10-10 11:33:20 +0000 (Thu, 10 Oct 2013)
Log Message:
-----------
Cleanup: Consistent names for draw callbacks in bNodeType.

This aims to establish a common pattern for the various confusing draw callback function pointers in bNodeType:

draw_<purpose>_<nodetype>[_ex]

Currently there are 4 different types of draw callbacks:
* draw_nodetype, draw_nodetype_prepare: Main draw functions, allows specialized node drawing for things like frames and reroute nodes. Not exposed in the API.
* draw_buttons, draw_buttons_ex: Optional non-socket buttons, most commonly used callback. Extended version used in sidebar for verbose buttons that don't fit into a node.
* draw_backdrop: Draw elements in the backdrop (compositor only). Not exposed in the API.
* draw_input, draw_output: Specialized socket drawing for some nodes, only for OutputFile node. Should not be used any further and be removed at some point. Not exposed in the API.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/BKE_node.h
    trunk/blender/source/blender/editors/space_node/drawnode.c
    trunk/blender/source/blender/editors/space_node/node_draw.c
    trunk/blender/source/blender/editors/space_node/node_edit.c
    trunk/blender/source/blender/editors/space_node/node_templates.c
    trunk/blender/source/blender/makesrna/intern/rna_nodetree.c

Modified: trunk/blender/source/blender/blenkernel/BKE_node.h
===================================================================
--- trunk/blender/source/blender/blenkernel/BKE_node.h	2013-10-10 11:00:12 UTC (rev 60656)
+++ trunk/blender/source/blender/blenkernel/BKE_node.h	2013-10-10 11:33:20 UTC (rev 60657)
@@ -162,24 +162,26 @@
 	
 	char storagename[64];			/* struct name for DNA */
 	
-	/// Main draw function for the node.
-	void (*drawfunc)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode,
+	/* Main draw function for the node */
+	void (*draw_nodetype)(const struct bContext *C, struct ARegion *ar, struct SpaceNode *snode,
 	                 struct bNodeTree *ntree, struct bNode *node, bNodeInstanceKey key);
-	/// Updates the node geometry attributes according to internal state before actual drawing.
-	void (*drawupdatefunc)(const struct bContext *C, struct bNodeTree *ntree, struct bNode *node);
-	/// Draw the option buttons on the node.
-	void (*uifunc)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
-	/// Additional parameters in the side panel.
-	void (*uifuncbut)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
-	/// Additional drawing on backdrop.
-	void (*uibackdropfunc)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y);
+	/* Updates the node geometry attributes according to internal state before actual drawing */
+	void (*draw_nodetype_prepare)(const struct bContext *C, struct bNodeTree *ntree, struct bNode *node);
 
-	/// Draw a node socket. Default draws the input value button.
+	/* Draw the option buttons on the node */
+	void (*draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
+	/* Additional parameters in the side panel */
+	void (*draw_buttons_ex)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr);
+
+	/* Additional drawing on backdrop */
+	void (*draw_backdrop)(struct SpaceNode *snode, struct ImBuf *backdrop, struct bNode *node, int x, int y);
+
+	/* Draw a node socket. Default draws the input value button. */
 	/* XXX deprecated, only used for the OutputFile node,
 	 * should be removed at some point.
 	 */
-	NodeSocketDrawFunction drawinputfunc;
-	NodeSocketDrawFunction drawoutputfunc;
+	NodeSocketDrawFunction draw_input;
+	NodeSocketDrawFunction draw_output;
 
 	/// Optional custom label function for the node header.
 	const char *(*labelfunc)(struct bNode *);

Modified: trunk/blender/source/blender/editors/space_node/drawnode.c
===================================================================
--- trunk/blender/source/blender/editors/space_node/drawnode.c	2013-10-10 11:00:12 UTC (rev 60656)
+++ trunk/blender/source/blender/editors/space_node/drawnode.c	2013-10-10 11:33:20 UTC (rev 60657)
@@ -339,7 +339,7 @@
 /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
 
 
-static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
 }
@@ -348,7 +348,7 @@
  * Not ideal to do this in every draw call, but doing as transform callback doesn't work,
  * since the child node totr rects are not updated properly at that point.
  */
-static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
+static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
 {
 	const float margin = 1.5f * U.widget_unit;
 	NodeFrame *data = (NodeFrame *)node->storage;
@@ -511,7 +511,7 @@
 	return dir;
 }
 
-static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
+static void node_buts_frame_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 {
 	uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
 	uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
@@ -520,7 +520,7 @@
 
 #define NODE_REROUTE_SIZE   8.0f
 
-static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
+static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
 {
 	bNodeSocket *nsock;
 	float locx, locy;
@@ -632,17 +632,17 @@
 {
 	switch (ntype->type) {
 		case NODE_GROUP:
-			ntype->uifunc = node_uifunc_group;
+			ntype->draw_buttons = node_draw_buttons_group;
 			break;
 		case NODE_FRAME:
-			ntype->drawfunc = node_draw_frame;
-			ntype->drawupdatefunc = node_update_frame;
-			ntype->uifuncbut = node_buts_frame_details;
+			ntype->draw_nodetype = node_draw_frame;
+			ntype->draw_nodetype_prepare = node_draw_frame_prepare;
+			ntype->draw_buttons_ex = node_buts_frame_ex;
 			ntype->resize_area_func = node_resize_area_frame;
 			break;
 		case NODE_REROUTE:
-			ntype->drawfunc = node_draw_reroute;
-			ntype->drawupdatefunc = node_update_reroute;
+			ntype->draw_nodetype = node_draw_reroute;
+			ntype->draw_nodetype_prepare = node_draw_reroute_prepare;
 			ntype->tweak_area_func = node_tweak_area_reroute;
 			break;
 	}
@@ -792,7 +792,7 @@
 	node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
 }
 
-static void node_shader_buts_tex_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_shader_buts_tex_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
 	uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
@@ -953,7 +953,7 @@
 	uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
 }
 
-static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
+static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
 {
 	uiItemS(layout);
 
@@ -971,110 +971,110 @@
 	switch (ntype->type) {
 		case SH_NODE_MATERIAL:
 		case SH_NODE_MATERIAL_EXT:
-			ntype->uifunc = node_shader_buts_material;
+			ntype->draw_buttons = node_shader_buts_material;
 			break;
 		case SH_NODE_TEXTURE:
-			ntype->uifunc = node_buts_texture;
+			ntype->draw_buttons = node_buts_texture;
 			break;
 		case SH_NODE_NORMAL:
-			ntype->uifunc = node_buts_normal;
+			ntype->draw_buttons = node_buts_normal;
 			break;
 		case SH_NODE_CURVE_VEC:
-			ntype->uifunc = node_buts_curvevec;
+			ntype->draw_buttons = node_buts_curvevec;
 			break;
 		case SH_NODE_CURVE_RGB:
-			ntype->uifunc = node_buts_curvecol;
+			ntype->draw_buttons = node_buts_curvecol;
 			break;
 		case SH_NODE_MAPPING:
-			ntype->uifunc = node_shader_buts_mapping;
+			ntype->draw_buttons = node_shader_buts_mapping;
 			break;
 		case SH_NODE_VALUE:
-			ntype->uifunc = node_buts_value;
+			ntype->draw_buttons = node_buts_value;
 			break;
 		case SH_NODE_RGB:
-			ntype->uifunc = node_buts_rgb;
+			ntype->draw_buttons = node_buts_rgb;
 			break;
 		case SH_NODE_MIX_RGB:
-			ntype->uifunc = node_buts_mix_rgb;
+			ntype->draw_buttons = node_buts_mix_rgb;
 			break;
 		case SH_NODE_VALTORGB:
-			ntype->uifunc = node_buts_colorramp;
+			ntype->draw_buttons = node_buts_colorramp;
 			break;
 		case SH_NODE_MATH: 
-			ntype->uifunc = node_buts_math;
+			ntype->draw_buttons = node_buts_math;
 			break; 
 		case SH_NODE_VECT_MATH: 
-			ntype->uifunc = node_shader_buts_vect_math;
+			ntype->draw_buttons = node_shader_buts_vect_math;
 			break; 
 		case SH_NODE_VECT_TRANSFORM: 
-			ntype->uifunc = node_shader_buts_vect_transform;
+			ntype->draw_buttons = node_shader_buts_vect_transform;
 			break; 
 		case SH_NODE_GEOMETRY:
-			ntype->uifunc = node_shader_buts_geometry;
+			ntype->draw_buttons = node_shader_buts_geometry;
 			break;
 		case SH_NODE_ATTRIBUTE:
-			ntype->uifunc = node_shader_buts_attribute;
+			ntype->draw_buttons = node_shader_buts_attribute;
 			break;
 		case SH_NODE_WIREFRAME:
-			ntype->uifunc = node_shader_buts_wireframe;
+			ntype->draw_buttons = node_shader_buts_wireframe;
 			break;
 		case SH_NODE_TEX_SKY:
-			ntype->uifunc = node_shader_buts_tex_sky;
+			ntype->draw_buttons = node_shader_buts_tex_sky;
 			break;
 		case SH_NODE_TEX_IMAGE:
-			ntype->uifunc = node_shader_buts_tex_image;
-			ntype->uifuncbut = node_shader_buts_tex_image_details;
+			ntype->draw_buttons = node_shader_buts_tex_image;
+			ntype->draw_buttons_ex = node_shader_buts_tex_image_ex;
 			break;
 		case SH_NODE_TEX_ENVIRONMENT:
-			ntype->uifunc = node_shader_buts_tex_environment;
+			ntype->draw_buttons = node_shader_buts_tex_environment;
 			break;
 		case SH_NODE_TEX_GRADIENT:
-			ntype->uifunc = node_shader_buts_tex_gradient;
+			ntype->draw_buttons = node_shader_buts_tex_gradient;
 			break;
 		case SH_NODE_TEX_MAGIC:
-			ntype->uifunc = node_shader_buts_tex_magic;
+			ntype->draw_buttons = node_shader_buts_tex_magic;
 			break;
 		case SH_NODE_TEX_BRICK:
-			ntype->uifunc = node_shader_buts_tex_brick;
+			ntype->draw_buttons = node_shader_buts_tex_brick;
 			break;
 		case SH_NODE_TEX_WAVE:
-			ntype->uifunc = node_shader_buts_tex_wave;
+			ntype->draw_buttons = node_shader_buts_tex_wave;
 			break;
 		case SH_NODE_TEX_MUSGRAVE:
-			ntype->uifunc = node_shader_buts_tex_musgrave;
+			ntype->draw_buttons = node_shader_buts_tex_musgrave;
 			break;
 		case SH_NODE_TEX_VORONOI:
-			ntype->uifunc = node_shader_buts_tex_voronoi;
+			ntype->draw_buttons = node_shader_buts_tex_voronoi;
 			break;
 		case SH_NODE_TEX_COORD:
-			ntype->uifunc = node_shader_buts_tex_coord;
+			ntype->draw_buttons = node_shader_buts_tex_coord;
 			break;
 		case SH_NODE_BUMP:
-			ntype->uifunc = node_shader_buts_bump;
+			ntype->draw_buttons = node_shader_buts_bump;
 			break;
 		case SH_NODE_NORMAL_MAP:
-			ntype->uifunc = node_shader_buts_normal_map;
+			ntype->draw_buttons = node_shader_buts_normal_map;
 			break;
 		case SH_NODE_TANGENT:
-			ntype->uifunc = node_shader_buts_tangent;
+			ntype->draw_buttons = node_shader_buts_tangent;
 			break;
 		case SH_NODE_BSDF_GLOSSY:
 		case SH_NODE_BSDF_GLASS:
 		case SH_NODE_BSDF_REFRACTION:
-			ntype->uifunc = node_shader_buts_glossy;
+			ntype->draw_buttons = node_shader_buts_glossy;
 			break;
 		case SH_NODE_SUBSURFACE_SCATTERING:
-			ntype->uifunc = node_shader_buts_subsurface;
+			ntype->draw_buttons = node_shader_buts_subsurface;
 			break;
 		case SH_NODE_BSDF_TOON:
-			ntype->uifunc = node_shader_buts_toon;
+			ntype->draw_buttons = node_shader_buts_toon;
 			break;
 		case SH_NODE_BSDF_HAIR:
-			ntype->uifunc = node_shader_buts_hair;
+			ntype->draw_buttons = node_shader_buts_hair;
 			break;

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list