2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
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,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2005 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): David Millan Escriva, Juho Vepsäläinen, Bob Holcomb, Thomas Dinges
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file blender/editors/space_node/drawnode.c
30 * \brief lower level node drawing for nodes (boarders, headers etc), also node layout.
33 #include "BLI_blenlib.h"
36 #include "DNA_node_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_space_types.h"
39 #include "DNA_screen_types.h"
41 #include "BKE_context.h"
42 #include "BKE_curve.h"
43 #include "BKE_image.h"
46 #include "BKE_tracking.h"
49 #include "BLF_translation.h"
53 #include "BIF_glutil.h"
55 #include "MEM_guardedalloc.h"
57 #include "RNA_access.h"
64 #include "UI_resources.h"
66 #include "IMB_colormanagement.h"
67 #include "IMB_imbuf.h"
68 #include "IMB_imbuf_types.h"
70 #include "node_intern.h" /* own include */
73 extern void ui_dropshadow(rctf *rct, float radius, float aspect, float alpha, int select);
75 /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
77 static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
79 SpaceNode *snode = snode_v;
81 if (snode->treetype == NTREE_SHADER) {
82 nodeShaderSynchronizeID(node_v, 1);
83 // allqueue(REDRAWBUTSSHADING, 0);
87 static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
88 bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
89 const char *UNUSED(name), int x, int y, int width)
91 uiDefBut(block, LABEL, 0, IFACE_(sock->name), x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
94 static void node_socket_button_default(const bContext *C, uiBlock *block,
95 bNodeTree *ntree, bNode *node, bNodeSocket *sock,
96 const char *name, int x, int y, int width)
98 if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
99 node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
104 RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
106 bt = uiDefButR(block, NUM, B_NODE_EXEC, IFACE_(name),
107 x, y + 1, width, NODE_DY - 2,
108 &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
110 uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
114 typedef struct SocketComponentMenuArgs {
119 } SocketComponentMenuArgs;
120 /* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
121 static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
123 SocketComponentMenuArgs *args = (SocketComponentMenuArgs *)args_v;
127 block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
128 uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
130 layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
131 args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE);
133 uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE);
137 static void node_socket_button_components(const bContext *C, uiBlock *block,
138 bNodeTree *ntree, bNode *node, bNodeSocket *sock,
139 const char *name, int x, int y, int width)
141 if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
142 node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
145 SocketComponentMenuArgs *args;
147 RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
149 args = MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
155 args->cb = node_sync_cb;
156 args->arg1 = CTX_wm_space_node(C);
159 uiDefBlockButN(block, socket_component_menu, args, IFACE_(name), x, y + 1, width, NODE_DY - 2, "");
163 static void node_socket_button_color(const bContext *C, uiBlock *block,
164 bNodeTree *ntree, bNode *node, bNodeSocket *sock,
165 const char *name, int x, int y, int width)
167 if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
168 node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
172 int labelw = width - 40;
173 RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
175 bt = uiDefButR(block, COL, B_NODE_EXEC, "",
176 x, y + 2, (labelw > 0 ? 40 : width), NODE_DY - 2,
177 &ptr, "default_value", 0, 0, 0, -1, -1, NULL);
179 uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
181 if (name[0] != '\0' && labelw > 0)
182 uiDefBut(block, LABEL, 0, IFACE_(name), x + 40, y + 2, labelw, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
186 /* standard draw function, display the default input value */
187 static void node_draw_input_default(const bContext *C, uiBlock *block,
188 bNodeTree *ntree, bNode *node, bNodeSocket *sock,
189 const char *name, int x, int y, int width)
191 bNodeSocketType *stype = ntreeGetSocketType(sock->type);
192 if (stype->buttonfunc)
193 stype->buttonfunc(C, block, ntree, node, sock, name, x, y, width);
195 node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
198 static void node_draw_output_default(const bContext *C, uiBlock *block,
199 bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock,
200 const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
202 SpaceNode *snode = CTX_wm_space_node(C);
205 const char *ui_name = IFACE_(name);
206 int len = strlen(ui_name);
207 UI_ThemeColor(TH_TEXT);
208 slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect_sqrt;
209 while (slen > node->width && ofs < len) {
211 slen = (UI_GetStringWidth(ui_name + ofs) + NODE_MARGIN_X) * snode->aspect_sqrt;
215 uiDefBut(block, LABEL, 0, ui_name + ofs,
216 (int)(sock->locx - slen), (int)(sock->locy - 9.0f),
217 (short)(node->width - NODE_DY), (short)NODE_DY,
218 NULL, 0, 0, 0, 0, "");
224 /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
227 static void node_draw_socket_new(bNodeSocket *sock, float size)
229 float x = sock->locx, y = sock->locy;
231 /* 16 values of sin function */
232 static float si[16] = {
233 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
234 0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
235 -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
236 -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
238 /* 16 values of cos function */
239 static float co[16] = {
240 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
241 -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
242 -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
243 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
247 glColor3ub(180, 180, 180);
250 for (a = 0; a < 16; a++)
251 glVertex2f(x + size * si[a], y + size * co[a]);
254 glColor4ub(0, 0, 0, 150);
256 glEnable(GL_LINE_SMOOTH);
257 glBegin(GL_LINE_LOOP);
258 for (a = 0; a < 16; a++)
259 glVertex2f(x + size * si[a], y + size * co[a]);
261 glDisable(GL_LINE_SMOOTH);
266 /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
268 static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
273 /* first socket stores value */
274 prop = RNA_struct_find_property(ptr, "outputs");
275 RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
277 uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
280 static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
286 /* first socket stores value */
287 prop = RNA_struct_find_property(ptr, "outputs");
288 RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
290 col = uiLayoutColumn(layout, FALSE);
291 uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0);
292 uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
295 static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
299 bNodeTree *ntree = (bNodeTree *)ptr->id.data;
301 col = uiLayoutColumn(layout, FALSE);
302 row = uiLayoutRow(col, TRUE);
303 uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
304 if (ntree->type == NTREE_COMPOSIT)
305 uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
307 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
310 static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
314 /* XXX no context access here .. */
315 bNode *node = ptr->data;
316 CurveMapping *cumap = node->storage;
319 cumap->flag |= CUMA_DRAW_CFRA;
320 if (node->custom1 < node->custom2)
321 cumap->sample[0] = (float)(CFRA - node->custom1) / (float)(node->custom2 - node->custom1);
325 uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0);
327 row = uiLayoutRow(layout, TRUE);
328 uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE);
329 uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
332 static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
334 uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
337 static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
339 uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
342 static float _sample_col[4]; /* bad bad, 2.5 will do better?... no it won't... */
343 #define SAMPLE_FLT_ISNONE FLT_MAX
344 void ED_node_sample_set(const float col[4])
347 copy_v4_v4(_sample_col, col);
350 copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE);
354 static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
356 bNode *node = ptr->data;
357 CurveMapping *cumap = node->storage;
359 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
360 cumap->flag |= CUMA_DRAW_SAMPLE;
361 copy_v3_v3(cumap->sample, _sample_col);
364 cumap->flag &= ~CUMA_DRAW_SAMPLE;
367 uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
370 static void node_normal_cb(bContext *C, void *ntree_v, void *node_v)
372 Main *bmain = CTX_data_main(C);
374 ED_node_generic_update(bmain, ntree_v, node_v);
375 WM_event_add_notifier(C, NC_NODE | NA_EDITED, ntree_v);
378 static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
380 uiBlock *block = uiLayoutAbsoluteBlock(layout);
381 bNodeTree *ntree = ptr->id.data;
382 bNode *node = ptr->data;
383 rctf *butr = &node->butr;
384 bNodeSocket *sock = node->outputs.first; /* first socket stores normal */
385 float *nor = ((bNodeSocketValueVector *)sock->default_value)->value;
388 bt = uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "",
389 (int)butr->xmin, (int)butr->xmin,
390 (short)(butr->xmax - butr->xmin), (short)(butr->xmax - butr->xmin),
391 nor, 0.0f, 1.0f, 0, 0, "");
392 uiButSetFunc(bt, node_normal_cb, ntree, node);
394 #if 0 /* not used in 2.5x yet */
395 static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
397 Main *bmain = CTX_data_main(C);
398 bNodeTree *ntree = ntree_v;
399 bNode *node = node_v;
402 if (node->menunr < 1) return;
408 tex = BLI_findlink(&bmain->tex, node->menunr - 1);
411 id_us_plus(node->id);
412 BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
414 nodeSetActive(ntree, node);
416 if (ntree->type == NTREE_TEXTURE)
417 ntreeTexCheckCyclics(ntree);
419 // allqueue(REDRAWBUTSSHADING, 0);
420 // allqueue(REDRAWNODE, 0);
421 NodeTagChanged(ntree, node);
427 static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
429 bNode *node = ptr->data;
433 ((Tex *)node->id)->use_nodes &&
434 (node->type != CMP_NODE_TEXTURE) &&
435 (node->type != TEX_NODE_TEXTURE)
438 uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
441 /* Number Drawing not optimal here, better have a list*/
442 uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE);
446 static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
448 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
449 uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE);
452 static int node_resize_area_default(bNode *node, int x, int y)
454 if (node->flag & NODE_HIDDEN) {
455 rctf totr = node->totr;
456 /* right part of node */
457 totr.xmin = node->totr.xmax - 20.0f;
458 if (BLI_in_rctf(&totr, x, y))
459 return NODE_RESIZE_RIGHT;
464 const float size = 10.0f;
465 rctf totr = node->totr;
468 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
469 dir |= NODE_RESIZE_RIGHT;
470 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
471 dir |= NODE_RESIZE_LEFT;
476 /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
478 /* width of socket columns in group display */
479 #define NODE_GROUP_FRAME 120
481 /* based on settings in node, sets drawing rect info. each redraw! */
482 /* note: this assumes only 1 group at a time is drawn (linked data) */
483 /* in node->totr the entire boundbox for the group is stored */
484 static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
486 if (!(gnode->flag & NODE_GROUP_EDIT)) {
487 node_update_default(C, ntree, gnode);
490 bNodeTree *ngroup = (bNodeTree *)gnode->id;
492 bNodeSocket *sock, *gsock;
494 rctf *rect = &gnode->totr;
495 float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72;
496 float group_header = 26 * U.dpi / 72;
500 /* get "global" coords */
501 nodeToView(gnode, 0.0f, 0.0f, &locx, &locy);
503 /* center them, is a bit of abuse of locx and locy though */
504 node_update_nodetree(C, ngroup, locx, locy);
506 rect->xmin = rect->xmax = locx;
507 rect->ymin = rect->ymax = locy;
510 for (node = ngroup->nodes.first; node; node = node->next) {
516 BLI_rctf_union(rect, &node->totr);
519 /* add some room for links to group sockets */
520 rect->xmin -= 4 * NODE_DY;
521 rect->xmax += 4 * NODE_DY;
522 rect->ymin -= NODE_DY;
523 rect->ymax += NODE_DY;
526 dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->inputs) - 1);
527 gsock = ngroup->inputs.first;
528 sock = gnode->inputs.first;
529 while (gsock || sock) {
530 while (sock && !sock->groupsock) {
531 sock->locx = rect->xmin - node_group_frame;
534 /* prevent long socket lists from growing out of the group box */
535 if (dy - 3 * NODE_DYS < rect->ymin)
536 rect->ymin = dy - 3 * NODE_DYS;
537 if (dy + 3 * NODE_DYS > rect->ymax)
538 rect->ymax = dy + 3 * NODE_DYS;
543 while (gsock && (!sock || sock->groupsock != gsock)) {
544 gsock->locx = rect->xmin;
547 /* prevent long socket lists from growing out of the group box */
548 if (dy - 3 * NODE_DYS < rect->ymin)
549 rect->ymin = dy - 3 * NODE_DYS;
550 if (dy + 3 * NODE_DYS > rect->ymax)
551 rect->ymax = dy + 3 * NODE_DYS;
556 while (sock && gsock && sock->groupsock == gsock) {
557 gsock->locx = rect->xmin;
558 sock->locx = rect->xmin - node_group_frame;
559 sock->locy = gsock->locy = dy;
561 /* prevent long socket lists from growing out of the group box */
562 if (dy - 3 * NODE_DYS < rect->ymin)
563 rect->ymin = dy - 3 * NODE_DYS;
564 if (dy + 3 * NODE_DYS > rect->ymax)
565 rect->ymax = dy + 3 * NODE_DYS;
574 dy = 0.5f * (rect->ymin + rect->ymax) + NODE_DY * (BLI_countlist(&gnode->outputs) - 1);
575 gsock = ngroup->outputs.first;
576 sock = gnode->outputs.first;
577 while (gsock || sock) {
578 while (sock && !sock->groupsock) {
579 sock->locx = rect->xmax + node_group_frame;
580 sock->locy = dy - NODE_DYS;
582 /* prevent long socket lists from growing out of the group box */
583 if (dy - 3 * NODE_DYS < rect->ymin)
584 rect->ymin = dy - 3 * NODE_DYS;
585 if (dy + 3 * NODE_DYS > rect->ymax)
586 rect->ymax = dy + 3 * NODE_DYS;
591 while (gsock && (!sock || sock->groupsock != gsock)) {
592 gsock->locx = rect->xmax;
593 gsock->locy = dy - NODE_DYS;
595 /* prevent long socket lists from growing out of the group box */
596 if (dy - 3 * NODE_DYS < rect->ymin)
597 rect->ymin = dy - 3 * NODE_DYS;
598 if (dy + 3 * NODE_DYS > rect->ymax)
599 rect->ymax = dy + 3 * NODE_DYS;
604 while (sock && gsock && sock->groupsock == gsock) {
605 gsock->locx = rect->xmax;
606 sock->locx = rect->xmax + node_group_frame;
607 sock->locy = gsock->locy = dy - NODE_DYS;
609 /* prevent long socket lists from growing out of the group box */
610 if (dy - 3 * NODE_DYS < rect->ymin)
611 rect->ymin = dy - 3 * NODE_DYS;
612 if (dy + 3 * NODE_DYS > rect->ymax)
613 rect->ymax = dy + 3 * NODE_DYS;
621 /* Set the block bounds to clip mouse events from underlying nodes.
622 * Add margin for header and input/output columns.
624 uiExplicitBoundsBlock(gnode->block,
625 rect->xmin - node_group_frame,
627 rect->xmax + node_group_frame,
628 rect->ymax + group_header);
632 static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
634 bNodeTree *ngroup = (bNodeTree *)ngroup_v;
636 ngroup->update |= NTREE_UPDATE_GROUP_IN;
637 ntreeUpdateTree(ngroup);
640 static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
642 bNodeTree *ngroup = (bNodeTree *)ngroup_v;
644 ngroup->update |= NTREE_UPDATE_GROUP_OUT;
645 ntreeUpdateTree(ngroup);
648 static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock,
649 int in_out, float xoffset, float yoffset)
651 bNodeTree *ngroup = (bNodeTree *)gnode->id;
653 const char *ui_name = IFACE_(sock->name);
655 if (sock->flag & SOCK_DYNAMIC) {
656 bt = uiDefBut(gnode->block, TEX, 0, "",
657 sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
658 sock->name, 0, sizeof(sock->name), 0, 0, "");
659 if (in_out == SOCK_IN)
660 uiButSetFunc(bt, update_group_input_cb, snode, ngroup);
662 uiButSetFunc(bt, update_group_output_cb, snode, ngroup);
665 uiDefBut(gnode->block, LABEL, 0, ui_name,
666 sock->locx + xoffset, sock->locy + 1 + yoffset, 72, NODE_DY,
667 NULL, 0, sizeof(ui_name), 0, 0, "");
671 static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
672 bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
674 bNodeTree *ngroup = (bNodeTree *)gnode->id;
675 bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
679 float node_group_frame = U.dpi * NODE_GROUP_FRAME / 72;
680 float socket_size = NODE_SOCKSIZE * U.dpi / 72;
681 float arrowbutw = 0.8f * UI_UNIT_X;
682 /* layout stuff for buttons on group left frame */
683 float colw = 0.6f * node_group_frame;
684 float col1 = 6 - node_group_frame;
685 float col2 = col1 + colw + 6;
686 float col3 = -arrowbutw - 6;
687 /* layout stuff for buttons on group right frame */
689 float cor2 = cor1 + arrowbutw + 6;
690 float cor3 = cor2 + arrowbutw + 6;
692 /* node and group socket circles */
694 node_socket_circle_draw(ntree, sock, socket_size, sock->flag & SELECT);
696 node_socket_circle_draw(ngroup, gsock, socket_size, gsock->flag & SELECT);
699 offset = (in_out == SOCK_IN ? col1 : cor3);
701 offset += (in_out == SOCK_IN ? node_group_frame : -node_group_frame);
703 /* draw both name and value button if:
704 * 1) input: not internal
705 * 2) output: (node type uses const outputs) and (group output is unlinked)
710 draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
713 if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
714 draw_value = !(gsock && gsock->link);
718 /* both name and value buttons */
720 draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0);
721 if (stype->buttonfunc)
722 stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "",
723 gsock->locx + offset, gsock->locy - NODE_DY, colw);
726 draw_group_socket_name(snode, gnode, sock, in_out, offset, 0);
727 if (stype->buttonfunc)
728 stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "",
729 sock->locx + offset, sock->locy - NODE_DY, colw);
733 /* only name, no value button */
735 draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS);
737 draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS);
740 if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
741 /* up/down buttons */
742 offset = (in_out == SOCK_IN ? col2 : cor2);
743 uiBlockSetDirection(gnode->block, UI_TOP);
744 uiBlockBeginAlign(gnode->block);
745 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP,
746 gsock->locx + offset, gsock->locy, arrowbutw, arrowbutw, "");
747 if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC))
748 uiButSetFlag(bt, UI_BUT_DISABLED);
749 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
750 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
751 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN,
752 gsock->locx + offset, gsock->locy - arrowbutw, arrowbutw, arrowbutw, "");
753 if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC))
754 uiButSetFlag(bt, UI_BUT_DISABLED);
755 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
756 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
757 uiBlockEndAlign(gnode->block);
758 uiBlockSetDirection(gnode->block, 0);
761 offset = (in_out == SOCK_IN ? col3 : cor1);
762 uiBlockSetEmboss(gnode->block, UI_EMBOSSN);
763 bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X,
764 gsock->locx + offset, gsock->locy - 0.5f * arrowbutw, arrowbutw, arrowbutw, "");
765 RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
766 RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
767 uiBlockSetEmboss(gnode->block, UI_EMBOSS);
771 /* groups are, on creation, centered around 0,0 */
772 static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
774 if (!(gnode->flag & NODE_GROUP_EDIT)) {
775 node_draw_default(C, ar, snode, ntree, gnode);
778 bNodeTree *ngroup = (bNodeTree *)gnode->id;
779 bNodeSocket *sock, *gsock;
782 rctf rect = gnode->totr;
783 const float dpi_fac = U.dpi / 72.0f;
784 float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
785 float group_header = 26 * dpi_fac;
789 /* backdrop header */
791 uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
792 UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70);
793 uiDrawBox(GL_POLYGON,
794 rect.xmin - node_group_frame, rect.ymax,
795 rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD);
798 UI_ThemeColorShadeAlpha(TH_BACK, -8, -70);
799 uiSetRoundBox(UI_CNR_NONE);
800 uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
803 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
804 uiSetRoundBox(UI_CNR_BOTTOM_LEFT);
805 uiDrawBox(GL_POLYGON, rect.xmin - node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
808 UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
809 uiSetRoundBox(UI_CNR_BOTTOM_RIGHT);
810 uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax + node_group_frame, rect.ymax, BASIS_RAD);
812 /* input column separator */
813 glColor4ub(200, 200, 200, 140);
815 glVertex2f(rect.xmin, rect.ymin);
816 glVertex2f(rect.xmin, rect.ymax);
819 /* output column separator */
820 glColor4ub(200, 200, 200, 140);
822 glVertex2f(rect.xmax, rect.ymin);
823 glVertex2f(rect.xmax, rect.ymax);
826 /* group node outline */
827 uiSetRoundBox(UI_CNR_ALL);
828 glColor4ub(200, 200, 200, 140);
829 glEnable(GL_LINE_SMOOTH);
830 uiDrawBox(GL_LINE_LOOP,
831 rect.xmin - node_group_frame, rect.ymin,
832 rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD);
833 glDisable(GL_LINE_SMOOTH);
837 UI_ThemeColor(TH_TEXT_HI);
839 layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
840 (int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
841 mini((int)(rect.xmax - rect.xmin - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
842 RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
843 uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
844 uiBlockLayoutResolve(gnode->block, NULL, NULL);
846 /* draw the internal tree nodes and links */
847 node_draw_nodetree(C, ar, snode, ngroup);
850 gsock = ngroup->inputs.first;
851 sock = gnode->inputs.first;
853 while (gsock || sock) {
854 while (sock && !sock->groupsock) {
855 draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_IN);
858 while (gsock && (!sock || sock->groupsock != gsock)) {
859 draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN);
863 while (sock && gsock && sock->groupsock == gsock) {
864 draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN);
870 gsock = ngroup->outputs.first;
871 sock = gnode->outputs.first;
873 while (gsock || sock) {
874 while (sock && !sock->groupsock) {
875 draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_OUT);
878 while (gsock && (!sock || sock->groupsock != gsock)) {
879 draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT);
883 while (sock && gsock && sock->groupsock == gsock) {
884 draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT);
891 uiEndBlock(C, gnode->block);
892 uiDrawBlock(C, gnode->block);
897 void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
899 uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
902 static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
904 uiItemR(layout, ptr, "max_iterations", 0, NULL, 0);
907 /* XXX Does a bounding box update by iterating over all children.
908 * Not ideal to do this in every draw call, but doing as transform callback doesn't work,
909 * since the child node totr rects are not updated properly at that point.
911 static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
913 const float margin = 30.0f;
914 NodeFrame *data = (NodeFrame *)node->storage;
920 /* init rect from current frame size */
921 nodeToView(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
922 nodeToView(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
924 /* frame can be resized manually only if shrinking is disabled or no children are attached */
925 data->flag |= NODE_FRAME_RESIZEABLE;
926 /* for shrinking bbox, initialize the rect from first child node */
927 bbinit = (data->flag & NODE_FRAME_SHRINK);
928 /* fit bounding box to all children */
929 for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
930 if (tnode->parent != node)
933 /* add margin to node rect */
934 noderect = tnode->totr;
935 noderect.xmin -= margin;
936 noderect.xmax += margin;
937 noderect.ymin -= margin;
938 noderect.ymax += margin;
940 /* first child initializes frame */
944 data->flag &= ~NODE_FRAME_RESIZEABLE;
947 BLI_rctf_union(&rect, &noderect);
950 /* now adjust the frame size from view-space bounding box */
951 nodeFromView(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
952 nodeFromView(node, rect.xmax, rect.ymin, &xmax, &ymax);
953 node->width = xmax - node->offsetx;
954 node->height = -ymax + node->offsety;
959 static void node_draw_frame_label(bNode *node, const float aspect)
961 /* XXX font id is crap design */
962 const int fontid = UI_GetStyle()->widgetlabel.uifont_id;
963 NodeFrame *data = (NodeFrame *)node->storage;
964 rctf *rct = &node->totr;
965 int color_id = node_get_colorid(node);
966 const char *label = nodeLabel(node);
967 /* XXX a bit hacky, should use separate align values for x and y */
968 float width, ascender;
970 const int font_size = data->label_size / aspect;
972 BLF_enable(fontid, BLF_ASPECT);
973 BLF_aspect(fontid, aspect, aspect, 1.0f);
974 BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
977 UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
979 width = BLF_width(fontid, label);
980 ascender = BLF_ascender(fontid);
982 /* 'x' doesn't need aspect correction */
983 x = 0.5f * (rct->xmin + rct->xmax) - 0.5f * width;
984 y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
986 BLF_position(fontid, x, y, 0);
987 BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
989 BLF_disable(fontid, BLF_ASPECT);
992 static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *UNUSED(ntree), bNode *node)
994 rctf *rct = &node->totr;
995 int color_id = node_get_colorid(node);
996 unsigned char color[4];
999 /* skip if out of view */
1000 if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
1001 uiEndBlock(C, node->block);
1006 UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
1007 alpha = (float)(color[3]) / 255.0f;
1010 node_draw_shadow(snode, node, BASIS_RAD, alpha);
1013 if (node->flag & NODE_CUSTOM_COLOR)
1014 glColor4f(node->color[0], node->color[1], node->color[2], alpha);
1016 UI_ThemeColor4(TH_NODE_FRAME);
1018 uiSetRoundBox(UI_CNR_ALL);
1019 uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
1020 glDisable(GL_BLEND);
1022 /* outline active and selected emphasis */
1023 if (node->flag & SELECT) {
1025 glEnable(GL_LINE_SMOOTH);
1027 if (node->flag & NODE_ACTIVE)
1028 UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
1030 UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40);
1031 uiSetRoundBox(UI_CNR_ALL);
1032 uiDrawBox(GL_LINE_LOOP,
1033 rct->xmin, rct->ymin,
1034 rct->xmax, rct->ymax, BASIS_RAD);
1036 glDisable(GL_LINE_SMOOTH);
1037 glDisable(GL_BLEND);
1041 node_draw_frame_label(node, snode->aspect);
1043 UI_ThemeClearColor(color_id);
1045 uiEndBlock(C, node->block);
1046 uiDrawBlock(C, node->block);
1050 static int node_resize_area_frame(bNode *node, int x, int y)
1052 const float size = 10.0f;
1053 NodeFrame *data = (NodeFrame *)node->storage;
1054 rctf totr = node->totr;
1057 /* shrinking frame size is determined by child nodes */
1058 if (!(data->flag & NODE_FRAME_RESIZEABLE))
1061 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
1062 dir |= NODE_RESIZE_RIGHT;
1063 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
1064 dir |= NODE_RESIZE_LEFT;
1065 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
1066 dir |= NODE_RESIZE_TOP;
1067 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
1068 dir |= NODE_RESIZE_BOTTOM;
1073 static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1075 uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
1076 uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
1080 #define NODE_REROUTE_SIZE 8.0f
1082 static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
1086 float size = NODE_REROUTE_SIZE;
1088 /* get "global" coords */
1089 nodeToView(node, 0.0f, 0.0f, &locx, &locy);
1091 /* reroute node has exactly one input and one output, both in the same place */
1092 nsock = node->outputs.first;
1096 nsock = node->inputs.first;
1100 node->width = size * 2;
1101 node->totr.xmin = locx - size;
1102 node->totr.xmax = locx + size;
1103 node->totr.ymax = locy + size;
1104 node->totr.ymin = locy - size;
1107 static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode), bNodeTree *ntree, bNode *node)
1111 rctf *rct = &node->totr;
1112 float size = NODE_REROUTE_SIZE;
1114 float socket_size = NODE_SOCKSIZE;
1116 /* skip if out of view */
1117 if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
1118 node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
1120 uiEndBlock(C, node->block);
1125 /* XXX only kept for debugging
1126 * selection state is indicated by socket outline below!
1131 UI_ThemeColor4(TH_NODE);
1133 uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
1134 glDisable(GL_BLEND);
1136 /* outline active and selected emphasis */
1137 if (node->flag & SELECT) {
1139 glEnable(GL_LINE_SMOOTH);
1140 /* using different shades of TH_TEXT_HI for the empasis, like triangle */
1141 if (node->flag & NODE_ACTIVE)
1142 UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
1144 UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
1145 uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
1147 glDisable(GL_LINE_SMOOTH);
1148 glDisable(GL_BLEND);
1152 /* only draw input socket. as they all are placed on the same position.
1153 * highlight also if node itself is selected, since we don't display the node body separately!
1155 for (sock = node->inputs.first; sock; sock = sock->next) {
1156 node_socket_circle_draw(ntree, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT));
1159 uiEndBlock(C, node->block);
1160 uiDrawBlock(C, node->block);
1164 /* Special tweak area for reroute node.
1165 * Since this node is quite small, we use a larger tweak area for grabbing than for selection.
1167 static int node_tweak_area_reroute(bNode *node, int x, int y)
1169 /* square of tweak radius */
1170 static const float tweak_radius_sq = 576; /* 24 * 24 */
1172 bNodeSocket *sock = node->inputs.first;
1173 float dx = sock->locx - x;
1174 float dy = sock->locy - y;
1175 return (dx * dx + dy * dy <= tweak_radius_sq);
1178 static void node_common_set_butfunc(bNodeType *ntype)
1180 switch (ntype->type) {
1182 ntype->uifunc = node_uifunc_group;
1183 ntype->drawfunc = node_draw_group;
1184 ntype->drawupdatefunc = node_update_group;
1187 // ntype->uifunc= node_common_buts_group;
1188 ntype->drawfunc = node_draw_group;
1189 ntype->drawupdatefunc = node_update_group;
1191 case NODE_WHILELOOP:
1192 ntype->uifunc = node_common_buts_whileloop;
1193 ntype->drawfunc = node_draw_group;
1194 ntype->drawupdatefunc = node_update_group;
1197 ntype->drawfunc = node_draw_frame;
1198 ntype->drawupdatefunc = node_update_frame;
1199 ntype->uifuncbut = node_buts_frame_details;
1200 ntype->resize_area_func = node_resize_area_frame;
1203 ntype->drawfunc = node_draw_reroute;
1204 ntype->drawupdatefunc = node_update_reroute;
1205 ntype->tweak_area_func = node_tweak_area_reroute;
1210 /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
1212 static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
1213 PointerRNA *imaptr, PointerRNA *iuserptr)
1221 col = uiLayoutColumn(layout, FALSE);
1223 uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
1225 source = RNA_enum_get(imaptr, "source");
1227 if (source == IMA_SRC_SEQUENCE) {
1228 /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
1229 Scene *scene = CTX_data_scene(C);
1230 ImageUser *iuser = iuserptr->data;
1232 const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
1233 BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
1234 uiItemL(layout, numstr, ICON_NONE);
1237 if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
1238 col = uiLayoutColumn(layout, TRUE);
1239 uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
1240 uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
1241 uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
1242 uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
1243 uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
1246 col = uiLayoutColumn(layout, FALSE);
1248 if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
1249 uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
1252 static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
1254 bNode *node = ptr->data;
1257 uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
1259 if (!node->id) return;
1261 col = uiLayoutColumn(layout, FALSE);
1262 uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
1263 uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
1264 uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
1267 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1271 uiItemL(layout, IFACE_("Location:"), ICON_NONE);
1272 row = uiLayoutRow(layout, TRUE);
1273 uiItemR(row, ptr, "translation", 0, "", ICON_NONE);
1275 uiItemL(layout, IFACE_("Rotation:"), ICON_NONE);
1276 row = uiLayoutRow(layout, TRUE);
1277 uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
1279 uiItemL(layout, IFACE_("Scale:"), ICON_NONE);
1280 row = uiLayoutRow(layout, TRUE);
1281 uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
1283 row = uiLayoutRow(layout, TRUE);
1284 uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
1285 uiItemR(row, ptr, "min", 0, "", ICON_NONE);
1287 row = uiLayoutRow(layout, TRUE);
1288 uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
1289 uiItemR(row, ptr, "max", 0, "", ICON_NONE);
1292 static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1294 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
1297 static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
1299 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
1302 col = uiLayoutColumn(layout, FALSE);
1304 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
1305 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
1307 uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
1308 uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
1311 uiItemR(col, ptr, "uv_layer", 0, IFACE_("UV"), ICON_NONE);
1312 uiItemR(col, ptr, "color_layer", 0, IFACE_("VCol"), ICON_NONE);
1316 static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1318 uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
1321 static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1323 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
1324 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
1326 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1327 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
1328 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
1330 if(RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX)
1331 uiItemR(layout, ptr, "projection_blend", 0, "Blend", ICON_NONE);
1333 /* note: image user properties used directly here, unlike compositor image node,
1334 * which redefines them in the node struct RNA to get proper updates.
1336 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
1339 static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
1341 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
1342 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
1344 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1345 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
1346 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
1348 node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1351 static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1353 uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
1354 uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
1357 static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1359 uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
1362 static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1364 uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
1367 static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1369 uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
1372 static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1374 uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
1377 static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1379 uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
1382 static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1384 uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
1387 /* only once called */
1388 static void node_shader_set_butfunc(bNodeType *ntype)
1390 switch (ntype->type) {
1391 /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
1393 case SH_NODE_MATERIAL:
1394 case SH_NODE_MATERIAL_EXT:
1395 ntype->uifunc = node_shader_buts_material;
1397 case SH_NODE_TEXTURE:
1398 ntype->uifunc = node_buts_texture;
1400 case SH_NODE_NORMAL:
1401 ntype->uifunc = node_buts_normal;
1403 case SH_NODE_CURVE_VEC:
1404 ntype->uifunc = node_buts_curvevec;
1406 case SH_NODE_CURVE_RGB:
1407 ntype->uifunc = node_buts_curvecol;
1409 case SH_NODE_MAPPING:
1410 ntype->uifunc = node_shader_buts_mapping;
1413 ntype->uifunc = node_buts_value;
1416 ntype->uifunc = node_buts_rgb;
1418 case SH_NODE_MIX_RGB:
1419 ntype->uifunc = node_buts_mix_rgb;
1421 case SH_NODE_VALTORGB:
1422 ntype->uifunc = node_buts_colorramp;
1425 ntype->uifunc = node_buts_math;
1427 case SH_NODE_VECT_MATH:
1428 ntype->uifunc = node_shader_buts_vect_math;
1430 case SH_NODE_GEOMETRY:
1431 ntype->uifunc = node_shader_buts_geometry;
1433 case SH_NODE_ATTRIBUTE:
1434 ntype->uifunc = node_shader_buts_attribute;
1436 case SH_NODE_TEX_SKY:
1437 ntype->uifunc = node_shader_buts_tex_sky;
1439 case SH_NODE_TEX_IMAGE:
1440 ntype->uifunc = node_shader_buts_tex_image;
1442 case SH_NODE_TEX_ENVIRONMENT:
1443 ntype->uifunc = node_shader_buts_tex_environment;
1445 case SH_NODE_TEX_GRADIENT:
1446 ntype->uifunc = node_shader_buts_tex_gradient;
1448 case SH_NODE_TEX_MAGIC:
1449 ntype->uifunc = node_shader_buts_tex_magic;
1451 case SH_NODE_TEX_WAVE:
1452 ntype->uifunc = node_shader_buts_tex_wave;
1454 case SH_NODE_TEX_MUSGRAVE:
1455 ntype->uifunc = node_shader_buts_tex_musgrave;
1457 case SH_NODE_TEX_VORONOI:
1458 ntype->uifunc = node_shader_buts_tex_voronoi;
1460 case SH_NODE_BSDF_GLOSSY:
1461 case SH_NODE_BSDF_GLASS:
1462 ntype->uifunc = node_shader_buts_glossy;
1467 /* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
1469 static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1471 bNode *node = ptr->data;
1472 PointerRNA imaptr, iuserptr;
1474 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1476 if (!node->id) return;
1478 imaptr = RNA_pointer_get(ptr, "image");
1479 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1481 node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1484 static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
1486 bNode *node = ptr->data;
1487 uiLayout *col, *row;
1491 const char *layer_name;
1492 char scene_name[MAX_ID_NAME - 2];
1493 wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
1495 BLI_assert(ot != 0);
1497 uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
1499 if (!node->id) return;
1501 col = uiLayoutColumn(layout, FALSE);
1502 row = uiLayoutRow(col, FALSE);
1503 uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
1505 prop = RNA_struct_find_property(ptr, "layer");
1506 if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
1509 scn_ptr = RNA_pointer_get(ptr, "scene");
1510 RNA_string_get(&scn_ptr, "name", scene_name);
1512 WM_operator_properties_create_ptr(&op_ptr, ot);
1513 RNA_string_set(&op_ptr, "layer", layer_name);
1514 RNA_string_set(&op_ptr, "scene", scene_name);
1515 uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
1520 static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1522 uiLayout *col, *row;
1526 col = uiLayoutColumn(layout, FALSE);
1527 filter = RNA_enum_get(ptr, "filter_type");
1528 reference = RNA_boolean_get(ptr, "use_reference");
1530 uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE);
1531 if (filter != R_FILTER_FAST_GAUSS) {
1532 uiItemR(col, ptr, "use_reference", 0, NULL, ICON_NONE);
1534 uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
1536 uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1539 uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
1541 if (RNA_boolean_get(ptr, "use_relative")) {
1542 uiItemL(col, IFACE_("Aspect Correction"), 0);
1543 row = uiLayoutRow(layout, TRUE);
1544 uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0);
1546 col = uiLayoutColumn(layout, TRUE);
1547 uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE);
1548 uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE);
1551 col = uiLayoutColumn(layout, TRUE);
1552 uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE);
1553 uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE);
1557 static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1561 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1562 uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
1564 col = uiLayoutColumn(layout, TRUE);
1565 uiItemL(col, IFACE_("Center:"), ICON_NONE);
1566 uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE);
1567 uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE);
1571 col = uiLayoutColumn(layout, TRUE);
1572 uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
1573 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1577 uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE);
1578 uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE);
1581 static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1585 col = uiLayoutColumn(layout, TRUE);
1586 uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
1587 uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
1588 uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
1591 static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1593 uiLayout *sub, *col;
1595 col = uiLayoutColumn(layout, FALSE);
1596 uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE);
1597 uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
1598 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1600 uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1602 col = uiLayoutColumn(layout, FALSE);
1603 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE);
1604 uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE);
1606 uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
1607 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1609 col = uiLayoutColumn(layout, FALSE);
1610 uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
1612 col = uiLayoutColumn(layout, FALSE);
1613 uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
1614 sub = uiLayoutColumn(col, FALSE);
1615 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE);
1616 uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE);
1619 /* qdn: glare node */
1620 static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1622 uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
1623 uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
1625 if (RNA_enum_get(ptr, "glare_type") != 1) {
1626 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1628 if (RNA_enum_get(ptr, "glare_type") != 0)
1629 uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1632 uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
1633 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1635 if (RNA_enum_get(ptr, "glare_type") == 2) {
1636 uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
1637 uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
1639 if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
1640 uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1642 if (RNA_enum_get(ptr, "glare_type") == 0)
1643 uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
1645 if (RNA_enum_get(ptr, "glare_type") == 1) {
1646 uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
1650 static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1654 col = uiLayoutColumn(layout, FALSE);
1655 uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
1656 if (RNA_enum_get(ptr, "tonemap_type") == 0) {
1657 uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1658 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1659 uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
1662 uiItemR(col, ptr, "intensity", 0, NULL, ICON_NONE);
1663 uiItemR(col, ptr, "contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1664 uiItemR(col, ptr, "adaptation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1665 uiItemR(col, ptr, "correction", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1669 static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1673 col = uiLayoutColumn(layout, FALSE);
1674 uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE);
1676 col = uiLayoutColumn(col, FALSE);
1677 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE);
1678 uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE);
1679 uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE);
1682 static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1686 col = uiLayoutColumn(layout, FALSE);
1687 uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
1688 uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE);
1690 col = uiLayoutColumn(layout, TRUE);
1691 uiItemL(col, IFACE_("Speed:"), ICON_NONE);
1692 uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE);
1693 uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE);
1695 uiItemR(layout, ptr, "use_curved", 0, NULL, ICON_NONE);
1698 static void node_composit_buts_filter(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1700 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1703 static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1705 uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
1708 static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1712 uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE);
1713 uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE);
1715 col = uiLayoutColumn(layout, TRUE);
1716 if (RNA_boolean_get(ptr, "relative")) {
1717 uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE);
1718 uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE);
1719 uiItemR(col, ptr, "rel_min_y", 0, IFACE_("Up"), ICON_NONE);
1720 uiItemR(col, ptr, "rel_max_y", 0, IFACE_("Down"), ICON_NONE);
1723 uiItemR(col, ptr, "min_x", 0, IFACE_("Left"), ICON_NONE);
1724 uiItemR(col, ptr, "max_x", 0, IFACE_("Right"), ICON_NONE);
1725 uiItemR(col, ptr, "min_y", 0, IFACE_("Up"), ICON_NONE);
1726 uiItemR(col, ptr, "max_y", 0, IFACE_("Down"), ICON_NONE);
1730 static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1732 uiLayout *row, *col;
1734 col = uiLayoutColumn(layout, FALSE);
1735 row = uiLayoutRow(col, FALSE);
1736 uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1737 uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
1740 static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1744 col = uiLayoutColumn(layout, FALSE);
1746 uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE);
1747 uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
1748 uiItemL(col, IFACE_("Buffer Edge:"), ICON_NONE);
1749 uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
1752 static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1754 uiLayout *sub, *col;
1756 col = uiLayoutColumn(layout, TRUE);
1757 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1758 uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
1760 col = uiLayoutColumn(layout, TRUE);
1761 uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
1762 sub = uiLayoutColumn(col, FALSE);
1763 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
1764 uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
1766 col = uiLayoutColumn(layout, TRUE);
1767 uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
1768 sub = uiLayoutColumn(col, FALSE);
1769 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
1770 uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
1773 static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1777 col = uiLayoutColumn(layout, TRUE);
1778 uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
1779 uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
1782 static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1786 col = uiLayoutColumn(layout, TRUE);
1787 uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
1791 static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1795 col = uiLayoutColumn(layout, FALSE);
1796 uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1797 uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1798 uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1801 static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1803 uiItemR(layout, ptr, "type", 0, NULL, ICON_NONE);
1804 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1805 switch (RNA_enum_get(ptr, "type")) {
1806 case CMP_NODE_DILATEERODE_DISTANCE_THRESH:
1807 uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
1809 case CMP_NODE_DILATEERODE_DISTANCE_FEATHER:
1810 uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE);
1815 static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1817 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1820 static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1824 col = uiLayoutColumn(layout, TRUE);
1825 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1826 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1829 static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1831 uiLayout *col, *row;
1833 col = uiLayoutColumn(layout, TRUE);
1835 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1836 row = uiLayoutRow(layout, FALSE);
1837 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1839 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1840 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1843 static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1845 uiLayout *row, *col;
1847 uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE);
1848 row = uiLayoutRow(layout, FALSE);
1849 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1851 col = uiLayoutColumn(layout, FALSE);
1852 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1854 if (RNA_enum_get(ptr, "limit_method") == 0) {
1855 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1856 row = uiLayoutRow(col, FALSE);
1857 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1860 uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1861 uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE);
1862 if (RNA_boolean_get(ptr, "use_unspill") == TRUE) {
1863 uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1864 uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1865 uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1869 static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1873 col = uiLayoutColumn(layout, FALSE);
1874 uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
1875 uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1877 col = uiLayoutColumn(layout, TRUE);
1878 /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */
1879 uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1880 /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/
1883 static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1887 col = uiLayoutColumn(layout, TRUE);
1888 uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1889 uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1890 uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1893 static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1895 uiLayout *col, *row;
1897 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1898 row = uiLayoutRow(layout, FALSE);
1899 uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1901 col = uiLayoutColumn(layout, FALSE);
1902 uiItemL(col, IFACE_("Key Channel:"), ICON_NONE);
1903 row = uiLayoutRow(col, FALSE);
1904 uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1906 col = uiLayoutColumn(layout, FALSE);
1908 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1909 if (RNA_enum_get(ptr, "limit_method") == 0) {
1910 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1911 row = uiLayoutRow(col, FALSE);
1912 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1915 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1916 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1919 static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1923 col = uiLayoutColumn(layout, TRUE);
1924 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1925 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1928 static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1930 uiItemR(layout, ptr, "alpha", 0, NULL, ICON_NONE);
1933 static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1935 uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE);
1936 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
1939 /* draw function for file output node sockets, displays only sub-path and format, no value button */
1940 static void node_draw_input_file_output(const bContext *C, uiBlock *block,
1941 bNodeTree *ntree, bNode *node, bNodeSocket *sock,
1942 const char *UNUSED(name), int x, int y, int width)
1944 uiLayout *layout, *row;
1945 PointerRNA nodeptr, inputptr, imfptr;
1948 RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
1950 layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle());
1951 row = uiLayoutRow(layout, FALSE);
1953 imfptr = RNA_pointer_get(&nodeptr, "format");
1954 imtype = RNA_enum_get(&imfptr, "file_format");
1955 if (imtype == R_IMF_IMTYPE_MULTILAYER) {
1956 NodeImageMultiFileSocket *input = sock->storage;
1957 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
1959 uiItemL(row, input->layer, 0);
1962 NodeImageMultiFileSocket *input = sock->storage;
1963 PropertyRNA *imtype_prop;
1964 const char *imtype_name;
1965 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
1967 uiItemL(row, input->path, 0);
1969 if (!RNA_boolean_get(&inputptr, "use_node_format"))
1970 imfptr = RNA_pointer_get(&inputptr, "format");
1972 imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
1973 RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
1974 RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
1975 uiBlockSetEmboss(block, UI_EMBOSSP);
1976 uiItemL(row, imtype_name, 0);
1977 uiBlockSetEmboss(block, UI_EMBOSSN);
1980 uiBlockLayoutResolve(block, &rx, &ry);
1982 static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1984 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1985 int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1988 uiItemL(layout, IFACE_("Path:"), 0);
1990 uiItemL(layout, IFACE_("Base Path:"), 0);
1991 uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1993 static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1995 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1996 PointerRNA active_input_ptr, op_ptr;
1999 int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
2001 node_composit_buts_file_output(layout, C, ptr);
2002 uiTemplateImageSettings(layout, &imfptr);
2006 uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
2008 active_index = RNA_int_get(ptr, "active_input_index");
2009 /* using different collection properties if multilayer format is enabled */
2011 uiTemplateList(layout, C, ptr, "layer_slots", ptr, "active_input_index", NULL, 0, 0, 0);
2012 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"),
2013 active_index, &active_input_ptr);
2016 uiTemplateList(layout, C, ptr, "file_slots", ptr, "active_input_index", NULL, 0, 0, 0);
2017 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"),
2018 active_index, &active_input_ptr);
2020 /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */
2021 active_input_ptr.id.data = ptr->id.data;
2023 row = uiLayoutRow(layout, TRUE);
2024 op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "",
2025 ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
2026 RNA_enum_set(&op_ptr, "direction", 1);
2027 op_ptr = uiItemFullO(row, "NODE_OT_output_file_move_active_socket", "",
2028 ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
2029 RNA_enum_set(&op_ptr, "direction", 2);
2031 if (active_input_ptr.data) {
2033 uiLayout *row, *col;
2034 col = uiLayoutColumn(layout, TRUE);
2036 uiItemL(col, IFACE_("Layer:"), 0);
2037 row = uiLayoutRow(col, FALSE);
2038 uiItemR(row, &active_input_ptr, "name", 0, "", 0);
2039 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
2040 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
2043 uiLayout *row, *col;
2044 col = uiLayoutColumn(layout, TRUE);
2046 uiItemL(col, IFACE_("File Path:"), 0);
2047 row = uiLayoutRow(col, FALSE);
2048 uiItemR(row, &active_input_ptr, "path", 0, "", 0);
2049 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
2050 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
2052 /* format details for individual files */
2053 imfptr = RNA_pointer_get(&active_input_ptr, "format");
2055 col = uiLayoutColumn(layout, TRUE);
2056 uiItemL(col, IFACE_("Format:"), 0);
2057 uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0);
2059 col = uiLayoutColumn(layout, FALSE);
2060 uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
2061 uiTemplateImageSettings(col, &imfptr);
2066 static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2068 uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
2070 if (RNA_enum_get(ptr, "space") == CMP_SCALE_RENDERPERCENT) {
2072 uiItemR(layout, ptr, "frame_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2073 row = uiLayoutRow(layout, TRUE);
2074 uiItemR(row, ptr, "offset_x", 0, "X", ICON_NONE);
2075 uiItemR(row, ptr, "offset_y", 0, "Y", ICON_NONE);
2079 static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2081 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
2084 static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2088 col = uiLayoutColumn(layout, FALSE);
2089 uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
2090 uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
2093 static void node_composit_buts_premulkey(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2095 uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE);
2098 static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2100 uiItemR(layout, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2103 static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2105 uiLayout *split, *col, *row;
2107 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
2109 if (RNA_enum_get(ptr, "correction_method") == 0) {
2111 split = uiLayoutSplit(layout, 0.0f, FALSE);
2112 col = uiLayoutColumn(split, FALSE);
2113 uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1);
2114 row = uiLayoutRow(col, FALSE);
2115 uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
2117 col = uiLayoutColumn(split, FALSE);
2118 uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1);
2119 row = uiLayoutRow(col, FALSE);
2120 uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
2122 col = uiLayoutColumn(split, FALSE);
2123 uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1);
2124 row = uiLayoutRow(col, FALSE);
2125 uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
2130 split = uiLayoutSplit(layout, 0.0f, FALSE);
2131 col = uiLayoutColumn(split, FALSE);
2132 uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1);
2133 row = uiLayoutRow(col, FALSE);
2134 uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
2136 col = uiLayoutColumn(split, FALSE);
2137 uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1);
2138 row = uiLayoutRow(col, FALSE);
2139 uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
2141 col = uiLayoutColumn(split, FALSE);
2142 uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1);
2143 row = uiLayoutRow(col, FALSE);
2144 uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
2148 static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2150 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
2152 if (RNA_enum_get(ptr, "correction_method") == 0) {
2154 uiTemplateColorWheel(layout, ptr, "lift", 1, 1, 0, 1);
2155 uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
2157 uiTemplateColorWheel(layout, ptr, "gamma", 1, 1, 1, 1);
2158 uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
2160 uiTemplateColorWheel(layout, ptr, "gain", 1, 1, 1, 1);
2161 uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
2164 uiTemplateColorWheel(layout, ptr, "offset", 1, 1, 0, 1);
2165 uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
2167 uiTemplateColorWheel(layout, ptr, "power", 1, 1, 0, 1);
2168 uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
2170 uiTemplateColorWheel(layout, ptr, "slope", 1, 1, 0, 1);
2171 uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
2176 static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2178 bNode *node = ptr->data;
2179 CurveMapping *cumap = node->storage;
2181 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
2182 cumap->flag |= CUMA_DRAW_SAMPLE;
2183 copy_v3_v3(cumap->sample, _sample_col);
2186 cumap->flag &= ~CUMA_DRAW_SAMPLE;
2189 uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
2192 static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2194 uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
2197 static void node_composit_buts_movieclip(uiLayout *layout, bContext *C, PointerRNA *ptr)
2199 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2202 static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
2204 bNode *node = ptr->data;
2206 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2211 uiItemR(layout, ptr, "filter_type", 0, "", 0);
2214 static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2216 uiItemR(layout, ptr, "filter_type", 0, "", 0);
2219 static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
2221 bNode *node = ptr->data;
2223 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2228 uiItemR(layout, ptr, "distortion_type", 0, "", 0);
2231 static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2235 row = uiLayoutRow(layout, FALSE);
2236 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2237 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2238 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2240 row = uiLayoutRow(layout, FALSE);
2241 uiItemL(row, "", 0);
2242 uiItemL(row, IFACE_("Saturation"), 0);
2243 uiItemL(row, IFACE_("Contrast"), 0);
2244 uiItemL(row, IFACE_("Gamma"), 0);
2245 uiItemL(row, IFACE_("Gain"), 0);
2246 uiItemL(row, IFACE_("Lift"), 0);
2248 row = uiLayoutRow(layout, FALSE);
2249 uiItemL(row, IFACE_("Master"), 0);
2250 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2251 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2252 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2253 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2254 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2256 row = uiLayoutRow(layout, FALSE);
2257 uiItemL(row, IFACE_("Highlights"), 0);
2258 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2259 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2260 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2261 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2262 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2264 row = uiLayoutRow(layout, FALSE);
2265 uiItemL(row, IFACE_("Midtones"), 0);
2266 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2267 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2268 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2269 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2270 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2272 row = uiLayoutRow(layout, FALSE);
2273 uiItemL(row, IFACE_("Shadows"), 0);
2274 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2275 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2276 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2277 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2278 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2280 row = uiLayoutRow(layout, FALSE);
2281 uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2282 uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2285 static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2289 row = uiLayoutRow(layout, FALSE);
2290 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2291 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2292 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2294 uiItemL(row, IFACE_("Saturation"), 0);
2295 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2296 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2297 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2298 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2300 uiItemL(row, IFACE_("Contrast"), 0);
2301 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2302 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2303 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2304 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2306 uiItemL(row, IFACE_("Gamma"), 0);
2307 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2308 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2309 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2310 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2312 uiItemL(row, IFACE_("Gain"), 0);
2313 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2314 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2315 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2316 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2318 uiItemL(row, IFACE_("Lift"), 0);
2319 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2320 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2321 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2322 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2324 row = uiLayoutRow(layout, FALSE);
2325 uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE);
2326 uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE);
2329 static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2331 uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
2334 static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2338 row = uiLayoutRow(layout, TRUE);
2339 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2340 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2342 row = uiLayoutRow(layout, TRUE);
2343 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2344 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2346 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2347 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2350 static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2352 uiItemR(layout, ptr, "flaps", 0, NULL, ICON_NONE);
2353 uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
2354 uiItemR(layout, ptr, "rounding", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2355 uiItemR(layout, ptr, "catadioptric", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2356 uiItemR(layout, ptr, "shift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2359 void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2361 // node_composit_backdrop_canvas(snode, backdrop, node, x, y);
2362 if (node->custom1 == 0) {
2363 const float backdropWidth = backdrop->x;
2364 const float backdropHeight = backdrop->y;
2365 const float cx = x + snode->zoom * backdropWidth * node->custom3;
2366 const float cy = y + snode->zoom * backdropHeight * node->custom4;
2368 glColor3f(1.0, 1.0, 1.0);
2371 glVertex2f(cx - 25, cy - 25);
2372 glVertex2f(cx + 25, cy + 25);
2373 glVertex2f(cx + 25, cy - 25);
2374 glVertex2f(cx - 25, cy + 25);
2379 void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2381 NodeBoxMask *boxmask = node->storage;
2382 const float backdropWidth = backdrop->x;
2383 const float backdropHeight = backdrop->y;
2384 const float aspect = backdropWidth / backdropHeight;
2385 const float rad = DEG2RADF(-boxmask->rotation);
2386 const float cosine = cosf(rad);
2387 const float sine = sinf(rad);
2388 const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
2389 const float halveBoxHeight = backdropHeight * (boxmask->height / 2.0f) * aspect;
2391 float cx, cy, x1, x2, x3, x4;
2392 float y1, y2, y3, y4;
2395 /* keep this, saves us from a version patch */
2396 if (snode->zoom == 0.0f) snode->zoom = 1.0f;
2398 glColor3f(1.0, 1.0, 1.0);
2400 cx = x + snode->zoom * backdropWidth * boxmask->x;
2401 cy = y + snode->zoom * backdropHeight * boxmask->y;
2403 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2404 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2405 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2406 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2407 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2408 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2409 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2410 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2412 glBegin(GL_LINE_LOOP);
2420 void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2422 NodeEllipseMask *ellipsemask = node->storage;
2423 const float backdropWidth = backdrop->x;
2424 const float backdropHeight = backdrop->y;
2425 const float aspect = backdropWidth / backdropHeight;
2426 const float rad = DEG2RADF(-ellipsemask->rotation);
2427 const float cosine = cosf(rad);
2428 const float sine = sinf(rad);
2429 const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
2430 const float halveBoxHeight = backdropHeight * (ellipsemask->height / 2.0f) * aspect;
2432 float cx, cy, x1, x2, x3, x4;
2433 float y1, y2, y3, y4;
2436 /* keep this, saves us from a version patch */
2437 if (snode->zoom == 0.0f) snode->zoom = 1.0f;
2439 glColor3f(1.0, 1.0, 1.0);
2441 cx = x + snode->zoom * backdropWidth * ellipsemask->x;
2442 cy = y + snode->zoom * backdropHeight * ellipsemask->y;
2444 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2445 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2446 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2447 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2448 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2449 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2450 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2451 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2453 glBegin(GL_LINE_LOOP);
2462 static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2465 row = uiLayoutRow(layout, TRUE);
2466 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2467 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2468 row = uiLayoutRow(layout, TRUE);
2469 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2470 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2472 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2473 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2476 static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2480 uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
2481 if (RNA_enum_get(ptr, "tile_order") == 0) {
2482 col = uiLayoutColumn(layout, TRUE);
2483 uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
2484 uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
2488 static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
2490 bNode *node = ptr->data;
2492 uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
2493 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
2494 uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
2496 uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
2498 if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
2499 uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
2500 uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
2503 uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
2504 if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
2505 uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
2506 uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
2510 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
2512 bNode *node = ptr->data;
2514 uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
2517 MovieClip *clip = (MovieClip *) node->id;
2519 PointerRNA tracking_ptr;
2521 RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
2523 col = uiLayoutColumn(layout, TRUE);
2524 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2528 static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2530 /* bNode *node= ptr->data; */ /* UNUSED */
2532 uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
2533 uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
2534 uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
2535 uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
2536 uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
2537 uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
2538 uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
2539 uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE);
2540 uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE);
2541 uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE);
2542 uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE);
2543 uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
2546 static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
2548 bNode *node = ptr->data;
2550 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2553 MovieClip *clip = (MovieClip *) node->id;
2554 MovieTracking *tracking = &clip->tracking;
2555 MovieTrackingObject *object;
2557 PointerRNA tracking_ptr;
2558 NodeTrackPosData *data = node->storage;
2560 RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2562 col = uiLayoutColumn(layout, 0);
2563 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2565 object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2567 PointerRNA object_ptr;
2569 RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2571 uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
2574 uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
2577 uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
2579 if (node->custom1 == 2) {
2580 uiItemR(layout, ptr, "relative_frame", 0, NULL, ICON_NONE);
2585 /* only once called */
2586 static void node_composit_set_butfunc(bNodeType *ntype)
2588 switch (ntype->type) {
2589 /* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
2591 case CMP_NODE_IMAGE:
2592 ntype->uifunc = node_composit_buts_image;
2594 case CMP_NODE_R_LAYERS:
2595 ntype->uifunc = node_composit_buts_renderlayers;
2597 case CMP_NODE_NORMAL:
2598 ntype->uifunc = node_buts_normal;
2600 case CMP_NODE_CURVE_VEC:
2601 ntype->uifunc = node_buts_curvevec;
2603 case CMP_NODE_CURVE_RGB:
2604 ntype->uifunc = node_buts_curvecol;
2606 case CMP_NODE_VALUE:
2607 ntype->uifunc = node_buts_value;
2610 ntype->uifunc = node_buts_rgb;
2613 ntype->uifunc = node_composit_buts_flip;
2615 case CMP_NODE_SPLITVIEWER:
2616 ntype->uifunc = node_composit_buts_splitviewer;
2618 case CMP_NODE_MIX_RGB:
2619 ntype->uifunc = node_buts_mix_rgb;
2621 case CMP_NODE_VALTORGB:
2622 ntype->uifunc = node_buts_colorramp;
2625 ntype->uifunc = node_composit_buts_crop;
2628 ntype->uifunc = node_composit_buts_blur;
2630 case CMP_NODE_DBLUR:
2631 ntype->uifunc = node_composit_buts_dblur;
2633 case CMP_NODE_BILATERALBLUR:
2634 ntype->uifunc = node_composit_buts_bilateralblur;
2636 case CMP_NODE_DEFOCUS:
2637 ntype->uifunc = node_composit_buts_defocus;
2639 case CMP_NODE_GLARE:
2640 ntype->uifunc = node_composit_buts_glare;
2642 case CMP_NODE_TONEMAP:
2643 ntype->uifunc = node_composit_buts_tonemap;
2645 case CMP_NODE_LENSDIST:
2646 ntype->uifunc = node_composit_buts_lensdist;
2648 case CMP_NODE_VECBLUR:
2649 ntype->uifunc = node_composit_buts_vecblur;
2651 case CMP_NODE_FILTER:
2652 ntype->uifunc = node_composit_buts_filter;
2654 case CMP_NODE_MAP_VALUE:
2655 ntype->uifunc = node_composit_buts_map_value;
2658 ntype->uifunc = node_buts_time;
2660 case CMP_NODE_ALPHAOVER:
2661 ntype->uifunc = node_composit_buts_alphaover;
2663 case CMP_NODE_HUE_SAT:
2664 ntype->uifunc = node_composit_buts_hue_sat;
2666 case CMP_NODE_TEXTURE:
2667 ntype->uifunc = node_buts_texture;
2669 case CMP_NODE_DILATEERODE:
2670 ntype->uifunc = node_composit_buts_dilateerode;
2672 case CMP_NODE_INPAINT:
2673 ntype->uifunc = node_composit_buts_inpaint;
2675 case CMP_NODE_OUTPUT_FILE:
2676 ntype->uifunc = node_composit_buts_file_output;
2677 ntype->uifuncbut = node_composit_buts_file_output_details;
2678 ntype->drawinputfunc = node_draw_input_file_output;
2680 case CMP_NODE_DIFF_MATTE:
2681 ntype->uifunc = node_composit_buts_diff_matte;
2683 case CMP_NODE_DIST_MATTE:
2684 ntype->uifunc = node_composit_buts_distance_matte;
2686 case CMP_NODE_COLOR_SPILL:
2687 ntype->uifunc = node_composit_buts_color_spill;
2689 case CMP_NODE_CHROMA_MATTE:
2690 ntype->uifunc = node_composit_buts_chroma_matte;
2692 case CMP_NODE_COLOR_MATTE:
2693 ntype->uifunc = node_composit_buts_color_matte;
2695 case CMP_NODE_SCALE:
2696 ntype->uifunc = node_composit_buts_scale;
2698 case CMP_NODE_ROTATE:
2699 ntype->uifunc = node_composit_buts_rotate;
2701 case CMP_NODE_CHANNEL_MATTE:
2702 ntype->uifunc = node_composit_buts_channel_matte;
2704 case CMP_NODE_LUMA_MATTE:
2705 ntype->uifunc = node_composit_buts_luma_matte;
2707 case CMP_NODE_MAP_UV:
2708 ntype->uifunc = node_composit_buts_map_uv;
2710 case CMP_NODE_ID_MASK:
2711 ntype->uifunc = node_composit_buts_id_mask;
2713 case CMP_NODE_DOUBLEEDGEMASK:
2714 ntype->uifunc = node_composit_buts_double_edge_mask;
2717 ntype->uifunc = node_buts_math;
2719 case CMP_NODE_INVERT:
2720 ntype->uifunc = node_composit_buts_invert;
2722 case CMP_NODE_PREMULKEY:
2723 ntype->uifunc = node_composit_buts_premulkey;
2725 case CMP_NODE_VIEW_LEVELS:
2726 ntype->uifunc = node_composit_buts_view_levels;
2728 case CMP_NODE_COLORBALANCE:
2729 ntype->uifunc = node_composit_buts_colorbalance;
2730 ntype->uifuncbut = node_composit_buts_colorbalance_but;
2732 case CMP_NODE_HUECORRECT:
2733 ntype->uifunc = node_composit_buts_huecorrect;
2735 case CMP_NODE_ZCOMBINE:
2736 ntype->uifunc = node_composit_buts_zcombine;
2738 case CMP_NODE_COMBYCCA:
2739 case CMP_NODE_SEPYCCA:
2740 ntype->uifunc = node_composit_buts_ycc;
2742 case CMP_NODE_MOVIECLIP:
2743 ntype->uifunc = node_composit_buts_movieclip;
2745 case CMP_NODE_STABILIZE2D:
2746 ntype->uifunc = node_composit_buts_stabilize2d;
2748 case CMP_NODE_TRANSFORM:
2749 ntype->uifunc = node_composit_buts_transform;
2751 case CMP_NODE_MOVIEDISTORTION:
2752 ntype->uifunc = node_composit_buts_moviedistortion;
2754 case CMP_NODE_COLORCORRECTION:
2755 ntype->uifunc = node_composit_buts_colorcorrection;
2756 ntype->uifuncbut = node_composit_buts_colorcorrection_but;
2758 case CMP_NODE_SWITCH:
2759 ntype->uifunc = node_composit_buts_switch;
2761 case CMP_NODE_MASK_BOX:
2762 ntype->uifunc = node_composit_buts_boxmask;
2763 ntype->uibackdropfunc = node_composit_backdrop_boxmask;
2765 case CMP_NODE_MASK_ELLIPSE:
2766 ntype->uifunc = node_composit_buts_ellipsemask;
2767 ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
2769 case CMP_NODE_BOKEHIMAGE:
2770 ntype->uifunc = node_composit_buts_bokehimage;
2772 case CMP_NODE_VIEWER:
2773 ntype->uifunc = NULL;
2774 ntype->uifuncbut = node_composit_buts_viewer_but;
2775 ntype->uibackdropfunc = node_composit_backdrop_viewer;
2778 ntype->uifunc = node_composit_buts_mask;
2780 case CMP_NODE_KEYINGSCREEN:
2781 ntype->uifunc = node_composit_buts_keyingscreen;
2783 case CMP_NODE_KEYING:
2784 ntype->uifunc = node_composit_buts_keying;
2786 case CMP_NODE_TRACKPOS:
2787 ntype->uifunc = node_composit_buts_trackpos;
2790 ntype->uifunc = NULL;
2794 /* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
2796 static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2800 col = uiLayoutColumn(layout, TRUE);
2801 uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
2802 uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2804 col = uiLayoutColumn(layout, TRUE);
2805 uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
2806 uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2809 static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2812 bNode *node = ptr->data;
2813 ID *id = ptr->id.data;
2814 Tex *tex = (Tex *)node->storage;
2815 uiLayout *col, *row;
2817 RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
2819 col = uiLayoutColumn(layout, FALSE);
2821 switch (tex->type) {
2823 uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
2824 row = uiLayoutRow(col, FALSE);
2825 uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2829 row = uiLayoutRow(col, FALSE);
2830 uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2831 row = uiLayoutRow(col, FALSE);
2832 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2833 row = uiLayoutRow(col, FALSE);
2834 uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2835 row = uiLayoutRow(col, FALSE);
2836 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2840 uiItemR(col, &tex_ptr, "noise_depth", 0, NULL, ICON_NONE);
2844 row = uiLayoutRow(col, FALSE);
2845 uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2846 row = uiLayoutRow(col, FALSE);
2847 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2848 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2852 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2853 uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE);
2854 row = uiLayoutRow(col, FALSE);
2855 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2856 row = uiLayoutRow(col, FALSE);
2857 uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
2858 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2862 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2863 row = uiLayoutRow(col, FALSE);
2864 uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2865 row = uiLayoutRow(col, FALSE);
2866 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2867 uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE);
2871 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2872 uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE);
2876 uiItemR(col, &tex_ptr, "musgrave_type", 0, "", ICON_NONE);
2877 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2880 uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE);
2881 if (tex->vn_distm == TEX_MINKOVSKY) {
2882 uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE);
2884 uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE);
2889 static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
2891 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
2894 static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2896 uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
2899 /* only once called */
2900 static void node_texture_set_butfunc(bNodeType *ntype)
2902 if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
2903 ntype->uifunc = node_texture_buts_proc;
2906 switch (ntype->type) {
2909 ntype->uifunc = node_buts_math;
2912 case TEX_NODE_MIX_RGB:
2913 ntype->uifunc = node_buts_mix_rgb;
2916 case TEX_NODE_VALTORGB:
2917 ntype->uifunc = node_buts_colorramp;
2920 case TEX_NODE_CURVE_RGB:
2921 ntype->uifunc = node_buts_curvecol;
2924 case TEX_NODE_CURVE_TIME:
2925 ntype->uifunc = node_buts_time;
2928 case TEX_NODE_TEXTURE:
2929 ntype->uifunc = node_buts_texture;
2932 case TEX_NODE_BRICKS:
2933 ntype->uifunc = node_texture_buts_bricks;
2936 case TEX_NODE_IMAGE:
2937 ntype->uifunc = node_texture_buts_image;
2940 case TEX_NODE_OUTPUT:
2941 ntype->uifunc = node_texture_buts_output;
2947 /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
2949 void ED_node_init_butfuncs(void)
2951 bNodeTreeType *treetype;
2953 bNodeSocketType *stype;
2956 /* node type ui functions */
2957 for (i = 0; i < NUM_NTREE_TYPES; ++i) {
2958 treetype = ntreeGetType(i);
2960 for (ntype = treetype->node_types.first; ntype; ntype = ntype->next) {
2961 /* default ui functions */
2962 ntype->drawfunc = node_draw_default;
2963 ntype->drawupdatefunc = node_update_default;
2964 ntype->select_area_func = node_select_area_default;
2965 ntype->tweak_area_func = node_tweak_area_default;
2966 ntype->uifunc = NULL;
2967 ntype->uifuncbut = NULL;
2968 ntype->drawinputfunc = node_draw_input_default;
2969 ntype->drawoutputfunc = node_draw_output_default;
2970 ntype->resize_area_func = node_resize_area_default;
2972 node_common_set_butfunc(ntype);
2975 case NTREE_COMPOSIT:
2976 node_composit_set_butfunc(ntype);
2979 node_shader_set_butfunc(ntype);
2982 node_texture_set_butfunc(ntype);
2989 /* socket type ui functions */
2990 for (i = 0; i < NUM_SOCKET_TYPES; ++i) {
2991 stype = ntreeGetSocketType(i);
2993 switch (stype->type) {
2997 stype->buttonfunc = node_socket_button_default;
3000 stype->buttonfunc = node_socket_button_components;
3003 stype->buttonfunc = node_socket_button_color;
3006 stype->buttonfunc = node_socket_button_label;
3009 stype->buttonfunc = NULL;
3015 /* ************** Generic drawing ************** */
3017 void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
3020 if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
3021 Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
3023 ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
3025 SpaceNode *snode = CTX_wm_space_node(C);
3026 wmWindow *win = CTX_wm_window(C);
3027 const ColorManagedViewSettings *view_settings;
3029 unsigned char *display_buffer;
3032 glMatrixMode(GL_PROJECTION);
3034 glMatrixMode(GL_MODELVIEW);
3037 /* keep this, saves us from a version patch */
3038 if (snode->zoom == 0.0f) snode->zoom = 1.0f;
3040 /* somehow the offset has to be calculated inverse */
3042 glaDefine2DArea(&ar->winrct);
3043 /* ortho at pixel level curarea */
3044 wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
3046 x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
3047 y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;