LEFT | RIGHT |
1 /* | 1 /* |
2 * ***** BEGIN GPL LICENSE BLOCK ***** | 2 * ***** BEGIN GPL LICENSE BLOCK ***** |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or | 4 * This program is free software; you can redistribute it and/or |
5 * modify it under the terms of the GNU General Public License | 5 * modify it under the terms of the GNU General Public License |
6 * as published by the Free Software Foundation; either version 2 | 6 * as published by the Free Software Foundation; either version 2 |
7 * of the License, or (at your option) any later version.· | 7 * of the License, or (at your option) any later version.· |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 14 * You should have received a copy of the GNU General Public License |
15 * along with this program; if not, write to the Free Software Foundation, | 15 * along with this program; if not, write to the Free Software Foundation, |
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 * | 17 * |
18 * The Original Code is Copyright (C) 2005 Blender Foundation. | 18 * The Original Code is Copyright (C) 2005 Blender Foundation. |
19 * All rights reserved. | 19 * All rights reserved. |
20 * | 20 * |
21 * The Original Code is: all of this file. | 21 * The Original Code is: all of this file. |
22 * | 22 * |
23 * Contributor(s): David Millan Escriva, Juho Vepsäläinen, Bob Holcomb, Thomas D
inges | 23 * Contributor(s): David Millan Escriva, Juho Vepsäläinen, Bob Holcomb, Thomas D
inges |
24 * | 24 * |
25 * ***** END GPL LICENSE BLOCK ***** | 25 * ***** END GPL LICENSE BLOCK ***** |
26 */ | 26 */ |
27 | 27 |
28 /** \file blender/editors/space_node/drawnode.c | 28 /** \file blender/editors/space_node/drawnode.c |
29 * \ingroup spnode | 29 * \ingroup spnode |
| 30 * \brief lower level node drawing for nodes (boarders, headers etc), also node
layout. |
30 */ | 31 */ |
31 | |
32 | |
33 #include <math.h> | |
34 #include <stdio.h> | |
35 #include <string.h> | |
36 | 32 |
37 #include "BLI_blenlib.h" | 33 #include "BLI_blenlib.h" |
38 #include "BLI_math.h" | 34 #include "BLI_math.h" |
39 #include "BLI_utildefines.h" | |
40 | 35 |
41 #include "DNA_node_types.h" | 36 #include "DNA_node_types.h" |
42 #include "DNA_material_types.h" | |
43 #include "DNA_object_types.h" | 37 #include "DNA_object_types.h" |
44 #include "DNA_scene_types.h" | |
45 #include "DNA_space_types.h" | 38 #include "DNA_space_types.h" |
46 #include "DNA_screen_types.h" | 39 #include "DNA_screen_types.h" |
47 | 40 |
48 #include "BKE_context.h" | 41 #include "BKE_context.h" |
49 #include "BKE_curve.h" | 42 #include "BKE_curve.h" |
50 #include "BKE_global.h" | |
51 #include "BKE_image.h" | 43 #include "BKE_image.h" |
52 #include "BKE_library.h" | |
53 #include "BKE_main.h" | 44 #include "BKE_main.h" |
54 #include "BKE_node.h" | 45 #include "BKE_node.h" |
55 | 46 #include "BKE_scene.h" |
| 47 #include "BKE_tracking.h" |
| 48 |
| 49 #include "BLF_api.h" |
| 50 #include "BLF_translation.h" |
| 51 |
| 52 #include "NOD_texture.h" |
| 53 |
| 54 #include "BIF_gl.h" |
| 55 #include "BIF_glutil.h" |
| 56 |
| 57 #include "BLF_translation.h" |
| 58 #include "MEM_guardedalloc.h" |
| 59 |
| 60 #include "RNA_access.h" |
| 61 #include "RNA_define.h" |
| 62 #include "RNA_enum_types.h" |
| 63 |
| 64 #include "ED_node.h" |
| 65 |
| 66 #include "WM_api.h" |
| 67 #include "WM_types.h" |
| 68 |
| 69 #include "UI_resources.h" |
| 70 |
| 71 #include "IMB_colormanagement.h" |
| 72 #include "IMB_imbuf.h" |
| 73 #include "IMB_imbuf_types.h" |
| 74 |
| 75 #include "node_intern.h" /* own include */ |
56 #include "NOD_composite.h" | 76 #include "NOD_composite.h" |
57 #include "NOD_shader.h" | 77 #include "NOD_shader.h" |
58 | 78 #include "NOD_texture.h" |
59 #include "BIF_gl.h" | 79 |
60 #include "BIF_glutil.h" | |
61 | |
62 #include "BLF_api.h" | |
63 | |
64 #include "MEM_guardedalloc.h" | |
65 | |
66 | |
67 #include "RNA_access.h" | |
68 | |
69 #include "ED_node.h" | |
70 | |
71 #include "WM_api.h" | |
72 #include "WM_types.h" | |
73 | |
74 #include "UI_interface.h" | |
75 #include "UI_resources.h" | |
76 | |
77 #include "IMB_imbuf.h" | |
78 #include "IMB_imbuf_types.h" | |
79 | |
80 #include "node_intern.h" | |
81 | |
82 | |
83 // XXX interface.h | |
84 extern void ui_dropshadow(rctf *rct, float radius, float aspect, int select); | |
85 | 80 |
86 /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */ | 81 /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */ |
87 | 82 |
88 static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v) | 83 static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, Poin
terRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), |
89 { | 84 const char *text) |
90 » SpaceNode *snode= snode_v; | 85 { |
91 »······· | 86 » uiItemL(layout, text, 0); |
92 » if(snode->treetype==NTREE_SHADER) { | 87 } |
93 » » nodeShaderSynchronizeID(node_v, 1); | 88 |
94 » » // allqueue(REDRAWBUTSSHADING, 0); | 89 |
| 90 /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************
** */ |
| 91 |
| 92 #if 0 /* UNUSED */ |
| 93 static void node_draw_socket_new(bNodeSocket *sock, float size) |
| 94 { |
| 95 » float x = sock->locx, y = sock->locy; |
| 96 »······· |
| 97 » /* 16 values of sin function */ |
| 98 » static float si[16] = { |
| 99 » » 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f, |
| 100 » » 0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f, |
| 101 » » -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f, |
| 102 » » -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f |
| 103 » }; |
| 104 » /* 16 values of cos function */ |
| 105 » static float co[16] = { |
| 106 » » 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f, |
| 107 » » -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f, |
| 108 » » -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f, |
| 109 » » 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f, |
| 110 » }; |
| 111 » int a; |
| 112 »······· |
| 113 » glColor3ub(180, 180, 180); |
| 114 »······· |
| 115 » glBegin(GL_POLYGON); |
| 116 » for (a = 0; a < 16; a++) |
| 117 » » glVertex2f(x + size * si[a], y + size * co[a]); |
| 118 » glEnd(); |
| 119 »······· |
| 120 » glColor4ub(0, 0, 0, 150); |
| 121 » glEnable(GL_BLEND); |
| 122 » glEnable(GL_LINE_SMOOTH); |
| 123 » glBegin(GL_LINE_LOOP); |
| 124 » for (a = 0; a < 16; a++) |
| 125 » » glVertex2f(x + size * si[a], y + size * co[a]); |
| 126 » glEnd(); |
| 127 » glDisable(GL_LINE_SMOOTH); |
| 128 » glDisable(GL_BLEND); |
| 129 } |
| 130 #endif |
| 131 |
| 132 /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */ |
| 133 |
| 134 static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *p
tr) |
| 135 { |
| 136 » bNode *node = ptr->data; |
| 137 » /* first output stores value */ |
| 138 » bNodeSocket *output = node->outputs.first; |
| 139 » PointerRNA sockptr; |
| 140 » RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); |
| 141 »······· |
| 142 » uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE); |
| 143 } |
| 144 |
| 145 static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr
) |
| 146 { |
| 147 » bNode *node = ptr->data; |
| 148 » /* first output stores value */ |
| 149 » bNodeSocket *output = node->outputs.first; |
| 150 » PointerRNA sockptr; |
| 151 » uiLayout *col; |
| 152 » RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr); |
| 153 »······· |
| 154 » col = uiLayoutColumn(layout, FALSE); |
| 155 » uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0); |
| 156 » uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE); |
| 157 } |
| 158 |
| 159 static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA
*ptr) |
| 160 {»······ |
| 161 » uiLayout *row, *col; |
| 162 |
| 163 » bNodeTree *ntree = (bNodeTree *)ptr->id.data; |
| 164 |
| 165 » col = uiLayoutColumn(layout, FALSE); |
| 166 » row = uiLayoutRow(col, TRUE); |
| 167 » uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE); |
| 168 » if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE)) |
| 169 » » uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA); |
| 170 |
| 171 » uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE); |
| 172 } |
| 173 |
| 174 static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *pt
r) |
| 175 { |
| 176 » uiLayout *row; |
| 177 #if 0 |
| 178 » /* XXX no context access here .. */ |
| 179 » bNode *node = ptr->data; |
| 180 » CurveMapping *cumap = node->storage; |
| 181 »······· |
| 182 » if (cumap) { |
| 183 » » cumap->flag |= CUMA_DRAW_CFRA; |
| 184 » » if (node->custom1 < node->custom2) |
| 185 » » » cumap->sample[0] = (float)(CFRA - node->custom1) / (floa
t)(node->custom2 - node->custom1); |
95 } | 186 } |
96 } | 187 #endif |
97 | 188 |
98 static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block, | 189 » uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0); |
99 » » » » » » » bNodeTree *UNUSED(ntre
e), bNode *UNUSED(node), bNodeSocket *sock, | 190 |
100 » » » » » » » const char *UNUSED(nam
e), int x, int y, int width) | 191 » row = uiLayoutRow(layout, TRUE); |
101 { | 192 » uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE); |
102 » uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0,
0, 0, ""); | 193 » uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE); |
103 } | 194 } |
104 | 195 |
105 | 196 static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRN
A *ptr) |
106 static void node_socket_button_default(const bContext *C, uiBlock *block, | 197 { |
107 » » » » » » » » bNodeTree *ntree
, bNode *node, bNodeSocket *sock, | 198 » uiTemplateColorRamp(layout, ptr, "color_ramp", 0); |
108 » » » » » » » » const char *name
, int x, int y, int width) | 199 } |
109 { | 200 » » } |
110 » PointerRNA ptr; | 201 » » break; |
111 » uiBut *bt; | 202 » } |
112 »······· | 203 » case SOCK_STRUCT_OUTPUT_MULTI_FILE: { |
113 » RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr); | 204 » » uiLayout *layout, *row; |
114 »······· | 205 » » PointerRNA ptr, imfptr; |
115 » bt = uiDefButR(block, NUM, B_NODE_EXEC, name, | 206 » » PropertyRNA *imtype_prop; |
116 » » » » x, y+1, width, NODE_DY-2,· | 207 » » const char *imtype_name; |
117 » » » » &ptr, "default_value", 0, 0, 0, -1, -1, NULL)
; | 208 » » int rx, ry; |
118 » if (node) | 209 » » RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr); |
119 » » uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node); | 210 » » imfptr = RNA_pointer_get(&ptr, "format"); |
120 } | 211 » »······· |
121 | 212 » » layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANE
L, x, y+NODE_DY, width, 20, UI_GetStyle()); |
122 typedef struct SocketComponentMenuArgs { | 213 » » row = uiLayoutRow(layout, 0);» »······· |
| 214 » »······· |
| 215 » » uiItemL(row, sock->name, 0); |
| 216 » » imtype_prop = RNA_struct_find_property(&imfptr, "file_format"); |
| 217 » » RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_p
roperty_enum_get(&imfptr, imtype_prop), &imtype_name); |
| 218 » » uiBlockSetEmboss(block, UI_EMBOSSP); |
| 219 » » uiItemL(row, imtype_name, 0); |
| 220 » » uiBlockSetEmboss(block, UI_EMBOSSN); |
| 221 » »······· |
| 222 » » uiBlockLayoutResolve(block, &rx, &ry); |
| 223 » » break; |
| 224 » } |
LEFT | RIGHT |