[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31640] branches/particles-2010/source/ blender: Made a separate function for getting the node socket color and declared it in the internal node header , so it can be used in other places for indicating socket types.
Lukas Toenne
lukas.toenne at googlemail.com
Sun Aug 29 14:30:35 CEST 2010
Revision: 31640
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31640
Author: lukastoenne
Date: 2010-08-29 14:30:35 +0200 (Sun, 29 Aug 2010)
Log Message:
-----------
Made a separate function for getting the node socket color and declared it in the internal node header, so it can be used in other places for indicating socket types.
Modified Paths:
--------------
branches/particles-2010/source/blender/editors/space_node/node_draw.c
branches/particles-2010/source/blender/editors/space_node/node_edit.c
branches/particles-2010/source/blender/editors/space_node/node_intern.h
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_program.c
branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_subprogram.c
Modified: branches/particles-2010/source/blender/editors/space_node/node_draw.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-08-29 10:06:23 UTC (rev 31639)
+++ branches/particles-2010/source/blender/editors/space_node/node_draw.c 2010-08-29 12:30:35 UTC (rev 31640)
@@ -525,8 +525,7 @@
}
/* nice AA filled circle */
-/* this might have some more generic use */
-static void circle_draw(float x, float y, float size, int type, int col[3])
+void node_circle_draw(float x, float y, float size, int col[3])
{
/* 16 values of sin function */
static float si[16] = {
@@ -562,51 +561,51 @@
glDisable(GL_BLEND);
}
-static void socket_circle_draw(bNodeSocket *sock, float size)
+void node_socket_get_color(int type, int r_col[4])
{
- int col[3];
-
- if(sock->type==-1) {
- col[0]= 0; col[1]= 0; col[2]= 0;
+ switch (type) {
+ case -1:
+ r_col[0]= 0; r_col[1]= 0; r_col[2]= 0; r_col[3]= 0;
+ break;
+ case SOCK_VALUE:
+ r_col[0]= 160; r_col[1]= 160; r_col[2]= 160; r_col[3]= 255;
+ break;
+ case SOCK_VECTOR:
+ r_col[0]= 100; r_col[1]= 100; r_col[2]= 200; r_col[3]= 255;
+ break;
+ case SOCK_RGBA:
+ r_col[0]= 200; r_col[1]= 200; r_col[2]= 40; r_col[3]= 255;
+ break;
+ case SOCK_OP:
+ r_col[0]= 174; r_col[1]= 58; r_col[2]= 5; r_col[3]= 255;
+ break;
+ case SOCK_ANY:
+ r_col[0]= 30; r_col[1]= 30; r_col[2]= 30; r_col[3]= 255;
+ break;
+ case SOCK_INT:
+ r_col[0]= 86; r_col[1]= 185; r_col[2]= 86; r_col[3]= 255;
+ break;
+ case SOCK_FLOAT:
+ r_col[0]= 124; r_col[1]= 242; r_col[2]= 154; r_col[3]= 255;
+ break;
+ case SOCK_BOOL:
+ r_col[0]= 200; r_col[1]= 137; r_col[2]= 52; r_col[3]= 255;
+ break;
+ case SOCK_STRING:
+ r_col[0]= 180; r_col[1]= 180; r_col[2]= 180; r_col[3]= 255;
+ break;
+ default:
+ r_col[0]= 100; r_col[1]= 200; r_col[2]= 100; r_col[3]= 255;
}
- else if(sock->type==SOCK_VALUE) {
- col[0]= 160; col[1]= 160; col[2]= 160;
- }
- else if(sock->type==SOCK_VECTOR) {
- col[0]= 100; col[1]= 100; col[2]= 200;
- }
- else if(sock->type==SOCK_RGBA) {
- col[0]= 200; col[1]= 200; col[2]= 40;
- }
- else if(sock->type==SOCK_OP) {
- if (sock->link == NULL) {
- col[0]= 174; col[1]= 58; col[2]= 5;
- } else {
- col[0]= 220; col[1]= 74; col[2]= 6;
- }
- }
- else if(sock->type==SOCK_ANY) {
- col[0]= 30; col[1]= 30; col[2]= 30;
- }
- else if(sock->type==SOCK_INT) {
- col[0]= 86; col[1]= 185; col[2]= 86;
- }
- else if(sock->type==SOCK_FLOAT) {
- col[0]= 124; col[1]= 242; col[2]= 154;
- }
- else if(sock->type==SOCK_BOOL) {
- col[0]= 200; col[1]= 137; col[2]= 52;
- }
- else if(sock->type==SOCK_STRING) {
- col[0]= 180; col[1]= 180; col[2]= 180;
- }
- else {
- col[0]= 100; col[1]= 200; col[2]= 100;
- }
-
- circle_draw(sock->locx, sock->locy, size, sock->type, col);
}
+static void socket_circle_draw(bNodeSocket *sock, float size)
+{
+ int col[4];
+ node_socket_get_color(sock->type, col);
+ node_circle_draw(sock->locx, sock->locy, size, col);
+}
+
static void node_sync_cb(bContext *C, void *snode_v, void *node_v)
{
SpaceNode *snode= snode_v;
Modified: branches/particles-2010/source/blender/editors/space_node/node_edit.c
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_edit.c 2010-08-29 10:06:23 UTC (rev 31639)
+++ branches/particles-2010/source/blender/editors/space_node/node_edit.c 2010-08-29 12:30:35 UTC (rev 31640)
@@ -2448,32 +2448,6 @@
if(0==uiSearchItemAdd(items, name, prop, RNA_property_ui_icon(prop)))
break;
}
-
- #if 0
- wmOperatorType *ot = WM_operatortype_first();
-
- for(; ot; ot= ot->next) {
-
- if(BLI_strcasestr(ot->name, str)) {
- if(WM_operator_poll((bContext*)C, ot)) {
- char name[256];
- int len= strlen(ot->name);
-
- /* display name for menu, can hold hotkey */
- BLI_strncpy(name, ot->name, 256);
-
- /* check for hotkey */
- if(len < 256-6) {
- if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, &name[len+1], 256-len-1))
- name[len]= '|';
- }
-
- if(0==uiSearchItemAdd(items, name, ot, 0))
- break;
- }
- }
- }
- #endif
}
void simnode_getdata_add_rna_socket_search(uiLayout *layout, bNode *node)
Modified: branches/particles-2010/source/blender/editors/space_node/node_intern.h
===================================================================
--- branches/particles-2010/source/blender/editors/space_node/node_intern.h 2010-08-29 10:06:23 UTC (rev 31639)
+++ branches/particles-2010/source/blender/editors/space_node/node_intern.h 2010-08-29 12:30:35 UTC (rev 31640)
@@ -45,6 +45,8 @@
/* node_draw.c */
void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d);
+void node_socket_get_color(int type, int r_col[4]);
+void node_circle_draw(float x, float y, float size, int col[3]);
/* node_buttons.c */
void node_buttons_register(struct ARegionType *art);
Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_program.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_program.c 2010-08-29 10:06:23 UTC (rev 31639)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_program.c 2010-08-29 12:30:35 UTC (rev 31640)
@@ -53,6 +53,7 @@
/* add an unlinked last socket, so the list can be extended */
sock = nodeAddInputSocket(node, "", SOCK_OP, default_value, 0.0f, 0.0f);
sprintf(sock->name, "Op %d", i);
+ sock->flag &= ~SOCK_ADAPT_CONTEXT;
}
static int opexec(SimNodeThreadContext *ctx, bNode *node, int level, int *r_opsock)
Modified: branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_subprogram.c
===================================================================
--- branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_subprogram.c 2010-08-29 10:06:23 UTC (rev 31639)
+++ branches/particles-2010/source/blender/nodes/intern/SIM_nodes/SIM_subprogram.c 2010-08-29 12:30:35 UTC (rev 31640)
@@ -56,6 +56,7 @@
/* add an unlinked last socket, so the list can be extended */
sock = nodeAddInputSocket(node, "", SOCK_OP, default_value, 0.0f, 0.0f);
sprintf(sock->name, "Op %d", i);
+ sock->flag &= ~SOCK_ADAPT_CONTEXT;
}
static int opexec(SimNodeThreadContext *ctx, bNode *node, int level, int *r_opsock)
More information about the Bf-blender-cvs
mailing list