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"
40 #include "DNA_userdef_types.h"
41 #include "DNA_text_types.h"
43 #include "BKE_context.h"
44 #include "BKE_curve.h"
45 #include "BKE_image.h"
48 #include "BKE_tracking.h"
51 #include "BLT_translation.h"
53 #include "BIF_glutil.h"
56 #include "GPU_immediate.h"
57 #include "GPU_matrix.h"
59 #include "RNA_access.h"
60 #include "RNA_define.h"
67 #include "UI_resources.h"
68 #include "UI_view2d.h"
70 #include "IMB_colormanagement.h"
71 #include "IMB_imbuf_types.h"
73 #include "node_intern.h" /* own include */
74 #include "NOD_composite.h"
75 #include "NOD_shader.h"
76 #include "NOD_texture.h"
79 /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
81 static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr),
84 uiItemL(layout, text, 0);
87 /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
89 static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
91 bNode *node = ptr->data;
92 /* first output stores value */
93 bNodeSocket *output = node->outputs.first;
95 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
97 uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
100 static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
102 bNode *node = ptr->data;
103 /* first output stores value */
104 bNodeSocket *output = node->outputs.first;
107 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
109 col = uiLayoutColumn(layout, false);
110 uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
111 uiItemR(col, &sockptr, "default_value", UI_ITEM_R_SLIDER, "", ICON_NONE);
114 static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
118 bNodeTree *ntree = (bNodeTree *)ptr->id.data;
120 col = uiLayoutColumn(layout, false);
121 row = uiLayoutRow(col, true);
122 uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
123 if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE))
124 uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
126 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
129 static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
133 /* XXX no context access here .. */
134 bNode *node = ptr->data;
135 CurveMapping *cumap = node->storage;
138 cumap->flag |= CUMA_DRAW_CFRA;
139 if (node->custom1 < node->custom2)
140 cumap->sample[0] = (float)(CFRA - node->custom1) / (float)(node->custom2 - node->custom1);
144 uiTemplateCurveMapping(layout, ptr, "curve", 's', false, false, false);
146 row = uiLayoutRow(layout, true);
147 uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE);
148 uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
151 static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
153 uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
156 static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
158 uiTemplateCurveMapping(layout, ptr, "mapping", 'v', false, false, false);
161 #define SAMPLE_FLT_ISNONE FLT_MAX
162 static float _sample_col[4] = {SAMPLE_FLT_ISNONE}; /* bad bad, 2.5 will do better?... no it won't... */
163 void ED_node_sample_set(const float col[4])
166 copy_v4_v4(_sample_col, col);
169 copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE);
173 static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
175 bNode *node = ptr->data;
176 CurveMapping *cumap = node->storage;
178 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
179 cumap->flag |= CUMA_DRAW_SAMPLE;
180 copy_v3_v3(cumap->sample, _sample_col);
183 cumap->flag &= ~CUMA_DRAW_SAMPLE;
186 uiTemplateCurveMapping(layout, ptr, "mapping", 'c', false, false, false);
189 static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
191 bNode *node = ptr->data;
192 /* first output stores normal */
193 bNodeSocket *output = node->outputs.first;
195 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
197 uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
200 #if 0 /* not used in 2.5x yet */
201 static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
203 Main *bmain = CTX_data_main(C);
204 bNodeTree *ntree = ntree_v;
205 bNode *node = node_v;
208 if (node->menunr < 1) return;
214 tex = BLI_findlink(&bmain->tex, node->menunr - 1);
217 id_us_plus(node->id);
218 BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
220 nodeSetActive(ntree, node);
222 if (ntree->type == NTREE_TEXTURE)
223 ntreeTexCheckCyclics(ntree);
225 // allqueue(REDRAWBUTSSHADING, 0);
226 // allqueue(REDRAWNODE, 0);
227 NodeTagChanged(ntree, node);
233 static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
235 bNode *node = ptr->data;
239 ((Tex *)node->id)->use_nodes &&
240 (node->type != CMP_NODE_TEXTURE) &&
241 (node->type != TEX_NODE_TEXTURE)
244 uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
247 /* Number Drawing not optimal here, better have a list*/
248 uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE);
252 static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
254 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
255 uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE);
258 static int node_resize_area_default(bNode *node, int x, int y)
260 if (node->flag & NODE_HIDDEN) {
261 rctf totr = node->totr;
262 /* right part of node */
263 totr.xmin = node->totr.xmax - 20.0f;
264 if (BLI_rctf_isect_pt(&totr, x, y))
265 return NODE_RESIZE_RIGHT;
270 const float size = 10.0f;
271 rctf totr = node->totr;
274 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
275 dir |= NODE_RESIZE_RIGHT;
276 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
277 dir |= NODE_RESIZE_LEFT;
282 /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
285 static void node_draw_buttons_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
287 uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
290 /* XXX Does a bounding box update by iterating over all children.
291 * Not ideal to do this in every draw call, but doing as transform callback doesn't work,
292 * since the child node totr rects are not updated properly at that point.
294 static void node_draw_frame_prepare(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
296 const float margin = 1.5f * U.widget_unit;
297 NodeFrame *data = (NodeFrame *)node->storage;
303 /* init rect from current frame size */
304 node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
305 node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
307 /* frame can be resized manually only if shrinking is disabled or no children are attached */
308 data->flag |= NODE_FRAME_RESIZEABLE;
309 /* for shrinking bbox, initialize the rect from first child node */
310 bbinit = (data->flag & NODE_FRAME_SHRINK);
311 /* fit bounding box to all children */
312 for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
313 if (tnode->parent != node)
316 /* add margin to node rect */
317 noderect = tnode->totr;
318 noderect.xmin -= margin;
319 noderect.xmax += margin;
320 noderect.ymin -= margin;
321 noderect.ymax += margin;
323 /* first child initializes frame */
327 data->flag &= ~NODE_FRAME_RESIZEABLE;
330 BLI_rctf_union(&rect, &noderect);
333 /* now adjust the frame size from view-space bounding box */
334 node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
335 node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax);
336 node->width = xmax - node->offsetx;
337 node->height = -ymax + node->offsety;
342 static void node_draw_frame_label(bNodeTree *ntree, bNode *node, const float aspect)
344 /* XXX font id is crap design */
345 const int fontid = UI_style_get()->widgetlabel.uifont_id;
346 NodeFrame *data = (NodeFrame *)node->storage;
347 rctf *rct = &node->totr;
348 int color_id = node_get_colorid(node);
349 char label[MAX_NAME];
350 /* XXX a bit hacky, should use separate align values for x and y */
351 float width, ascender;
353 const int font_size = data->label_size / aspect;
354 const float margin = (float)(NODE_DY / 4);
356 unsigned char color[3];
358 nodeLabel(ntree, node, label, sizeof(label));
360 BLF_enable(fontid, BLF_ASPECT);
361 BLF_aspect(fontid, aspect, aspect, 1.0f);
362 BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
365 UI_GetThemeColorBlendShade3ubv(TH_TEXT, color_id, 0.4f, 10, color);
366 BLF_color3ubv(fontid, color);
368 width = BLF_width(fontid, label, sizeof(label));
369 ascender = BLF_ascender(fontid);
370 label_height = ((margin / aspect) + (ascender * aspect));
372 /* 'x' doesn't need aspect correction */
373 x = BLI_rctf_cent_x(rct) - (0.5f * width);
374 y = rct->ymax - label_height;
376 BLF_position(fontid, x, y, 0);
377 BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
381 Text *text = (Text *)node->id;
383 const int line_height_max = BLF_height_max(fontid);
384 const float line_spacing = (line_height_max * aspect);
385 const float line_width = (BLI_rctf_size_x(rct) - margin) / aspect;
388 /* 'x' doesn't need aspect correction */
389 x = rct->xmin + margin;
390 y = rct->ymax - (label_height + line_spacing);
392 y_min = y + ((margin * 2) - (y - rct->ymin));
394 BLF_enable(fontid, BLF_CLIPPING | BLF_WORD_WRAP);
398 /* round to avoid clipping half-way through a line */
399 y - (floorf(((y - rct->ymin) - (margin * 2)) / line_spacing) * line_spacing),
400 rct->xmin + line_width,
403 BLF_wordwrap(fontid, line_width);
405 for (line = text->lines.first; line; line = line->next) {
406 struct ResultBLF info;
408 BLF_position(fontid, x, y, 0);
409 BLF_draw_ex(fontid, line->line, line->len, &info);
410 y -= line_spacing * info.lines;
420 BLF_disable(fontid, BLF_CLIPPING | BLF_WORD_WRAP);
423 BLF_disable(fontid, BLF_ASPECT);
426 static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
427 bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
429 rctf *rct = &node->totr;
430 int color_id = node_get_colorid(node);
434 /* skip if out of view */
435 if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == false) {
436 UI_block_end(C, node->block);
441 UI_GetThemeColor4fv(TH_NODE_FRAME, color);
445 node_draw_shadow(snode, node, BASIS_RAD, alpha);
448 if (node->flag & NODE_CUSTOM_COLOR) {
449 rgba_float_args_set(color, node->color[0], node->color[1], node->color[2], alpha);
452 UI_GetThemeColor4fv(TH_NODE_FRAME, color);
454 UI_draw_roundbox_corner_set(UI_CNR_ALL);
455 UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
457 /* outline active and selected emphasis */
458 if (node->flag & SELECT) {
459 if (node->flag & NODE_ACTIVE)
460 UI_GetThemeColorShadeAlpha4fv(TH_ACTIVE, 0, -40, color);
462 UI_GetThemeColorShadeAlpha4fv(TH_SELECT, 0, -40, color);
464 UI_draw_roundbox_aa(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD, color);
468 node_draw_frame_label(ntree, node, snode->aspect);
470 UI_ThemeClearColor(color_id);
472 UI_block_end(C, node->block);
473 UI_block_draw(C, node->block);
477 static int node_resize_area_frame(bNode *node, int x, int y)
479 const float size = 10.0f;
480 NodeFrame *data = (NodeFrame *)node->storage;
481 rctf totr = node->totr;
484 /* shrinking frame size is determined by child nodes */
485 if (!(data->flag & NODE_FRAME_RESIZEABLE))
488 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
489 dir |= NODE_RESIZE_RIGHT;
490 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
491 dir |= NODE_RESIZE_LEFT;
492 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
493 dir |= NODE_RESIZE_TOP;
494 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
495 dir |= NODE_RESIZE_BOTTOM;
500 static void node_buts_frame_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
502 uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
503 uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
504 uiItemR(layout, ptr, "text", 0, NULL, ICON_NONE);
508 #define NODE_REROUTE_SIZE 8.0f
510 static void node_draw_reroute_prepare(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
514 float size = NODE_REROUTE_SIZE;
516 /* get "global" coords */
517 node_to_view(node, 0.0f, 0.0f, &locx, &locy);
519 /* reroute node has exactly one input and one output, both in the same place */
520 nsock = node->outputs.first;
524 nsock = node->inputs.first;
528 node->width = size * 2;
529 node->totr.xmin = locx - size;
530 node->totr.xmax = locx + size;
531 node->totr.ymax = locy + size;
532 node->totr.ymin = locy - size;
535 static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode),
536 bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
538 char showname[128]; /* 128 used below */
539 rctf *rct = &node->totr;
541 /* skip if out of view */
542 if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
543 node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
545 UI_block_end(C, node->block);
550 /* XXX only kept for debugging
551 * selection state is indicated by socket outline below!
554 float size = NODE_REROUTE_SIZE;
557 float debug_color[4];
558 UI_draw_roundbox_corner_set(UI_CNR_ALL);
559 UI_GetThemeColor4fv(TH_NODE, debug_color);
560 UI_draw_roundbox_aa(true, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color);
562 /* outline active and selected emphasis */
563 if (node->flag & SELECT) {
565 glEnable(GL_LINE_SMOOTH);
566 /* using different shades of TH_TEXT_HI for the empasis, like triangle */
567 if (node->flag & NODE_ACTIVE) {
568 UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, 0, -40, debug_color);
571 UI_GetThemeColorShadeAlpha4fv(TH_TEXT_HI, -20, -120, debug_color);
573 UI_draw_roundbox_4fv(false, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size, debug_color);
575 glDisable(GL_LINE_SMOOTH);
580 if (node->label[0] != '\0') {
581 /* draw title (node label) */
582 BLI_strncpy(showname, node->label, sizeof(showname));
583 uiDefBut(node->block, UI_BTYPE_LABEL, 0, showname,
584 (int)(rct->xmin - NODE_DYS), (int)(rct->ymax),
585 (short)512, (short)NODE_DY,
586 NULL, 0, 0, 0, 0, NULL);
589 /* only draw input socket. as they all are placed on the same position.
590 * highlight also if node itself is selected, since we don't display the node body separately!
592 node_draw_sockets(&ar->v2d, C, ntree, node, false, node->flag & SELECT);
594 UI_block_end(C, node->block);
595 UI_block_draw(C, node->block);
599 /* Special tweak area for reroute node.
600 * Since this node is quite small, we use a larger tweak area for grabbing than for selection.
602 static int node_tweak_area_reroute(bNode *node, int x, int y)
604 /* square of tweak radius */
605 const float tweak_radius_sq = SQUARE(24);
607 bNodeSocket *sock = node->inputs.first;
608 float dx = sock->locx - x;
609 float dy = sock->locy - y;
610 return (dx * dx + dy * dy <= tweak_radius_sq);
613 static void node_common_set_butfunc(bNodeType *ntype)
615 switch (ntype->type) {
617 ntype->draw_buttons = node_draw_buttons_group;
620 ntype->draw_nodetype = node_draw_frame;
621 ntype->draw_nodetype_prepare = node_draw_frame_prepare;
622 ntype->draw_buttons_ex = node_buts_frame_ex;
623 ntype->resize_area_func = node_resize_area_frame;
626 ntype->draw_nodetype = node_draw_reroute;
627 ntype->draw_nodetype_prepare = node_draw_reroute_prepare;
628 ntype->tweak_area_func = node_tweak_area_reroute;
633 /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
635 static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
636 PointerRNA *imaptr, PointerRNA *iuserptr)
644 col = uiLayoutColumn(layout, false);
646 uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
648 source = RNA_enum_get(imaptr, "source");
650 if (source == IMA_SRC_SEQUENCE) {
651 /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
652 Scene *scene = CTX_data_scene(C);
653 ImageUser *iuser = iuserptr->data;
654 /* Image *ima = imaptr->data; */ /* UNUSED */
657 const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
658 BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
659 uiItemL(layout, numstr, ICON_NONE);
662 if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
663 col = uiLayoutColumn(layout, true);
664 uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
665 uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
666 uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
667 uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
668 uiItemR(col, ptr, "use_auto_refresh", 0, NULL, ICON_NONE);
671 if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER &&
672 RNA_boolean_get(ptr, "has_layers"))
674 col = uiLayoutColumn(layout, false);
675 uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
679 static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
681 bNode *node = ptr->data;
684 uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
686 if (!node->id) return;
688 col = uiLayoutColumn(layout, false);
689 uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
690 uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
691 uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
694 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
696 uiLayout *row, *col, *sub;
698 uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
700 row = uiLayoutRow(layout, false);
702 col = uiLayoutColumn(row, true);
703 uiItemL(col, IFACE_("Location:"), ICON_NONE);
704 uiItemR(col, ptr, "translation", 0, "", ICON_NONE);
706 col = uiLayoutColumn(row, true);
707 uiItemL(col, IFACE_("Rotation:"), ICON_NONE);
708 uiItemR(col, ptr, "rotation", 0, "", ICON_NONE);
710 col = uiLayoutColumn(row, true);
711 uiItemL(col, IFACE_("Scale:"), ICON_NONE);
712 uiItemR(col, ptr, "scale", 0, "", ICON_NONE);
714 row = uiLayoutRow(layout, false);
716 col = uiLayoutColumn(row, true);
717 uiItemR(col, ptr, "use_min", 0, IFACE_("Min"), ICON_NONE);
718 sub = uiLayoutColumn(col, true);
719 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
720 uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
722 col = uiLayoutColumn(row, true);
723 uiItemR(col, ptr, "use_max", 0, IFACE_("Max"), ICON_NONE);
724 sub = uiLayoutColumn(col, true);
725 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
726 uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
729 static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
731 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
734 static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
736 uiItemR(layout, ptr, "vector_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
737 uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE);
738 uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
741 static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
743 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
746 col = uiLayoutColumn(layout, false);
748 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
749 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
751 uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
752 uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
755 uiItemR(col, ptr, "uv_layer", 0, IFACE_("UV"), ICON_NONE);
756 uiItemR(col, ptr, "color_layer", 0, IFACE_("VCol"), ICON_NONE);
760 static void node_shader_buts_lamp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
762 uiItemR(layout, ptr, "lamp_object", 0, IFACE_("Lamp Object"), ICON_NONE);
765 static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
767 uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
770 static void node_shader_buts_wireframe(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
772 uiItemR(layout, ptr, "use_pixel_size", 0, NULL, 0);
775 static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
777 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
778 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
780 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
781 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
782 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
783 uiItemR(layout, ptr, "interpolation", 0, "", ICON_NONE);
784 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
786 if (RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX) {
787 uiItemR(layout, ptr, "projection_blend", 0, "Blend", ICON_NONE);
790 uiItemR(layout, ptr, "extension", 0, "", ICON_NONE);
792 /* note: image user properties used directly here, unlike compositor image node,
793 * which redefines them in the node struct RNA to get proper updates.
795 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
798 static void node_shader_buts_tex_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
800 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
801 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0, 0);
804 static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
806 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
807 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
809 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
810 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
812 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
814 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
815 uiItemR(layout, ptr, "interpolation", 0, "", ICON_NONE);
816 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
819 static void node_shader_buts_tex_environment_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
821 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
822 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
823 Image *ima = imaptr.data;
825 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
826 uiTemplateID(layout, C, ptr, "image", ima ? NULL : "IMAGE_OT_new", "IMAGE_OT_open", NULL);
831 uiItemR(layout, &imaptr, "source", 0, IFACE_("Source"), ICON_NONE);
833 if (!(ELEM(ima->source, IMA_SRC_GENERATED, IMA_SRC_VIEWER))) {
834 uiLayout *row = uiLayoutRow(layout, true);
835 const bool is_packed = BKE_image_has_packedfile(ima);
838 uiItemO(row, "", ICON_PACKAGE, "image.unpack");
840 uiItemO(row, "", ICON_UGLYPACKAGE, "image.pack");
842 row = uiLayoutRow(row, true);
843 uiLayoutSetEnabled(row, !is_packed);
844 uiItemR(row, &imaptr, "filepath", 0, "", ICON_NONE);
845 uiItemO(row, "", ICON_FILE_REFRESH, "image.reload");
849 if (ima->type == IMA_TYPE_MULTILAYER && ima->rr) {
850 uiTemplateImageLayers(layout, C, ima, iuserptr.data);
852 else if (ima->source != IMA_SRC_GENERATED) {
853 uiTemplateImageInfo(layout, C, ima, iuserptr.data);
856 uiItemR(layout, ptr, "color_space", 0, IFACE_("Color Space"), ICON_NONE);
857 uiItemR(layout, ptr, "interpolation", 0, IFACE_("Interpolation"), ICON_NONE);
858 uiItemR(layout, ptr, "projection", 0, IFACE_("Projection"), ICON_NONE);
861 static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
863 uiItemR(layout, ptr, "sky_type", 0, "", ICON_NONE);
864 uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
865 uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
867 if (RNA_enum_get(ptr, "sky_type") == SHD_SKY_NEW)
868 uiItemR(layout, ptr, "ground_albedo", 0, NULL, ICON_NONE);
871 static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
873 uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
876 static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
878 uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
881 static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
885 col = uiLayoutColumn(layout, true);
886 uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
887 uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
889 col = uiLayoutColumn(layout, true);
890 uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
891 uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
894 static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
896 uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
897 uiItemR(layout, ptr, "wave_profile", 0, "", ICON_NONE);
900 static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
902 uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
905 static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
907 uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
910 static void node_shader_buts_tex_pointdensity(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
912 bNode *node = ptr->data;
913 NodeShaderTexPointDensity *shader_point_density = node->storage;
914 Object *ob = (Object *)node->id;
915 PointerRNA ob_ptr, obdata_ptr;
917 RNA_id_pointer_create((ID *)ob, &ob_ptr);
918 RNA_id_pointer_create(ob ? (ID *)ob->data : NULL, &obdata_ptr);
920 uiItemR(layout, ptr, "point_source", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
921 uiItemR(layout, ptr, "object", 0, NULL, ICON_NONE);
923 if (node->id && shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) {
925 RNA_id_pointer_create((ID *)node->id, &dataptr);
926 uiItemPointerR(layout, ptr, "particle_system", &dataptr, "particle_systems", NULL, ICON_NONE);
929 uiItemR(layout, ptr, "space", 0, NULL, ICON_NONE);
930 uiItemR(layout, ptr, "radius", 0, NULL, ICON_NONE);
931 uiItemR(layout, ptr, "interpolation", 0, NULL, ICON_NONE);
932 uiItemR(layout, ptr, "resolution", 0, NULL, ICON_NONE);
933 if (shader_point_density->point_source == SHD_POINTDENSITY_SOURCE_PSYS) {
934 uiItemR(layout, ptr, "particle_color_source", 0, NULL, ICON_NONE);
937 uiItemR(layout, ptr, "vertex_color_source", 0, NULL, ICON_NONE);
938 if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTWEIGHT) {
940 uiItemPointerR(layout, ptr, "vertex_attribute_name", &ob_ptr, "vertex_groups", "", ICON_NONE);
942 if (shader_point_density->ob_color_source == SHD_POINTDENSITY_COLOR_VERTCOL) {
944 uiItemPointerR(layout, ptr, "vertex_attribute_name", &obdata_ptr, "vertex_colors", "", ICON_NONE);
949 static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
951 uiItemR(layout, ptr, "object", 0, NULL, 0);
952 uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
955 static void node_shader_buts_bump(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
957 uiItemR(layout, ptr, "invert", 0, NULL, 0);
960 static void node_shader_buts_uvmap(uiLayout *layout, bContext *C, PointerRNA *ptr)
962 uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
964 if (!RNA_boolean_get(ptr, "from_dupli")) {
965 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
967 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
968 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
969 uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
974 static void node_shader_buts_uvalongstroke(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
976 uiItemR(layout, ptr, "use_tips", 0, NULL, 0);
979 static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
981 uiItemR(layout, ptr, "space", 0, "", 0);
983 if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
984 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
986 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
987 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
988 uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
991 uiItemR(layout, ptr, "uv_map", 0, "", 0);
995 static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
997 uiLayout *split, *row;
999 split = uiLayoutSplit(layout, 0.0f, false);
1001 uiItemR(split, ptr, "direction_type", 0, "", 0);
1003 row = uiLayoutRow(split, false);
1005 if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
1006 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
1008 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
1009 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
1010 uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
1013 uiItemR(row, ptr, "uv_map", 0, "", 0);
1016 uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
1019 static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1021 uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
1024 static void node_shader_buts_anisotropic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1026 uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
1029 static void node_shader_buts_subsurface(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1031 uiItemR(layout, ptr, "falloff", 0, "", ICON_NONE);
1035 static void node_shader_buts_toon(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1037 uiItemR(layout, ptr, "component", 0, "", ICON_NONE);
1040 static void node_shader_buts_hair(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1042 uiItemR(layout, ptr, "component", 0, "", ICON_NONE);
1045 static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1049 row = uiLayoutRow(layout, false);
1050 uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1052 row = uiLayoutRow(layout, true);
1054 if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
1055 uiItemR(row, ptr, "script", 0, "", ICON_NONE);
1057 uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
1059 uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
1062 static void node_shader_buts_script_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1066 node_shader_buts_script(layout, C, ptr);
1068 #if 0 /* not implemented yet */
1069 if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
1070 uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);
1074 static void node_buts_output_linestyle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1076 uiLayout *row, *col;
1078 col = uiLayoutColumn(layout, false);
1079 row = uiLayoutRow(col, true);
1080 uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
1081 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
1084 /* only once called */
1085 static void node_shader_set_butfunc(bNodeType *ntype)
1087 switch (ntype->type) {
1088 case SH_NODE_MATERIAL:
1089 case SH_NODE_MATERIAL_EXT:
1090 ntype->draw_buttons = node_shader_buts_material;
1092 case SH_NODE_TEXTURE:
1093 ntype->draw_buttons = node_buts_texture;
1095 case SH_NODE_NORMAL:
1096 ntype->draw_buttons = node_buts_normal;
1098 case SH_NODE_CURVE_VEC:
1099 ntype->draw_buttons = node_buts_curvevec;
1101 case SH_NODE_CURVE_RGB:
1102 ntype->draw_buttons = node_buts_curvecol;
1104 case SH_NODE_MAPPING:
1105 ntype->draw_buttons = node_shader_buts_mapping;
1108 ntype->draw_buttons = node_buts_value;
1111 ntype->draw_buttons = node_buts_rgb;
1113 case SH_NODE_MIX_RGB:
1114 ntype->draw_buttons = node_buts_mix_rgb;
1116 case SH_NODE_VALTORGB:
1117 ntype->draw_buttons = node_buts_colorramp;
1120 ntype->draw_buttons = node_buts_math;
1122 case SH_NODE_VECT_MATH:
1123 ntype->draw_buttons = node_shader_buts_vect_math;
1125 case SH_NODE_VECT_TRANSFORM:
1126 ntype->draw_buttons = node_shader_buts_vect_transform;
1128 case SH_NODE_GEOMETRY:
1129 ntype->draw_buttons = node_shader_buts_geometry;
1132 ntype->draw_buttons = node_shader_buts_lamp;
1134 case SH_NODE_ATTRIBUTE:
1135 ntype->draw_buttons = node_shader_buts_attribute;
1137 case SH_NODE_WIREFRAME:
1138 ntype->draw_buttons = node_shader_buts_wireframe;
1140 case SH_NODE_TEX_SKY:
1141 ntype->draw_buttons = node_shader_buts_tex_sky;
1143 case SH_NODE_TEX_IMAGE:
1144 ntype->draw_buttons = node_shader_buts_tex_image;
1145 ntype->draw_buttons_ex = node_shader_buts_tex_image_ex;
1147 case SH_NODE_TEX_ENVIRONMENT:
1148 ntype->draw_buttons = node_shader_buts_tex_environment;
1149 ntype->draw_buttons_ex = node_shader_buts_tex_environment_ex;
1151 case SH_NODE_TEX_GRADIENT:
1152 ntype->draw_buttons = node_shader_buts_tex_gradient;
1154 case SH_NODE_TEX_MAGIC:
1155 ntype->draw_buttons = node_shader_buts_tex_magic;
1157 case SH_NODE_TEX_BRICK:
1158 ntype->draw_buttons = node_shader_buts_tex_brick;
1160 case SH_NODE_TEX_WAVE:
1161 ntype->draw_buttons = node_shader_buts_tex_wave;
1163 case SH_NODE_TEX_MUSGRAVE:
1164 ntype->draw_buttons = node_shader_buts_tex_musgrave;
1166 case SH_NODE_TEX_VORONOI:
1167 ntype->draw_buttons = node_shader_buts_tex_voronoi;
1169 case SH_NODE_TEX_POINTDENSITY:
1170 ntype->draw_buttons = node_shader_buts_tex_pointdensity;
1172 case SH_NODE_TEX_COORD:
1173 ntype->draw_buttons = node_shader_buts_tex_coord;
1176 ntype->draw_buttons = node_shader_buts_bump;
1178 case SH_NODE_NORMAL_MAP:
1179 ntype->draw_buttons = node_shader_buts_normal_map;
1181 case SH_NODE_TANGENT:
1182 ntype->draw_buttons = node_shader_buts_tangent;
1184 case SH_NODE_BSDF_GLOSSY:
1185 case SH_NODE_BSDF_GLASS:
1186 case SH_NODE_BSDF_REFRACTION:
1187 case SH_NODE_BSDF_PRINCIPLED:
1188 ntype->draw_buttons = node_shader_buts_glossy;
1190 case SH_NODE_BSDF_ANISOTROPIC:
1191 ntype->draw_buttons = node_shader_buts_anisotropic;
1193 case SH_NODE_SUBSURFACE_SCATTERING:
1194 ntype->draw_buttons = node_shader_buts_subsurface;
1196 case SH_NODE_BSDF_TOON:
1197 ntype->draw_buttons = node_shader_buts_toon;
1199 case SH_NODE_BSDF_HAIR:
1200 ntype->draw_buttons = node_shader_buts_hair;
1202 case SH_NODE_SCRIPT:
1203 ntype->draw_buttons = node_shader_buts_script;
1204 ntype->draw_buttons_ex = node_shader_buts_script_ex;
1207 ntype->draw_buttons = node_shader_buts_uvmap;
1209 case SH_NODE_UVALONGSTROKE:
1210 ntype->draw_buttons = node_shader_buts_uvalongstroke;
1212 case SH_NODE_OUTPUT_LINESTYLE:
1213 ntype->draw_buttons = node_buts_output_linestyle;
1218 /* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
1220 static void node_buts_image_views(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr,
1228 col = uiLayoutColumn(layout, false);
1230 if (RNA_boolean_get(ptr, "has_views")) {
1231 if (RNA_enum_get(ptr, "view") == 0)
1232 uiItemR(col, ptr, "view", 0, NULL, ICON_CAMERA_STEREO);
1234 uiItemR(col, ptr, "view", 0, NULL, ICON_SCENE);
1238 static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1240 bNode *node = ptr->data;
1241 PointerRNA imaptr, iuserptr;
1243 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1244 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
1245 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1246 if (!node->id) return;
1248 imaptr = RNA_pointer_get(ptr, "image");
1250 node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1252 node_buts_image_views(layout, C, ptr, &imaptr);
1255 static void node_composit_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1257 bNode *node = ptr->data;
1258 PointerRNA iuserptr;
1260 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1261 uiLayoutSetContextPointer(layout, "image_user", &iuserptr);
1262 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0, 1);
1265 static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
1267 bNode *node = ptr->data;
1268 uiLayout *col, *row;
1272 const char *layer_name;
1273 char scene_name[MAX_ID_NAME - 2];
1275 uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
1277 if (!node->id) return;
1279 col = uiLayoutColumn(layout, false);
1280 row = uiLayoutRow(col, true);
1281 uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
1283 prop = RNA_struct_find_property(ptr, "layer");
1284 if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
1287 scn_ptr = RNA_pointer_get(ptr, "scene");
1288 RNA_string_get(&scn_ptr, "name", scene_name);
1290 op_ptr = uiItemFullO(row, "RENDER_OT_render", "", ICON_RENDER_STILL, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
1291 RNA_string_set(&op_ptr, "layer", layer_name);
1292 RNA_string_set(&op_ptr, "scene", scene_name);
1296 static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1298 uiLayout *col, *row;
1302 col = uiLayoutColumn(layout, false);
1303 filter = RNA_enum_get(ptr, "filter_type");
1304 reference = RNA_boolean_get(ptr, "use_variable_size");
1306 uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE);
1307 if (filter != R_FILTER_FAST_GAUSS) {
1308 uiItemR(col, ptr, "use_variable_size", 0, NULL, ICON_NONE);
1310 uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
1312 uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1315 uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
1317 if (RNA_boolean_get(ptr, "use_relative")) {
1318 uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE);
1319 row = uiLayoutRow(layout, true);
1320 uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1322 col = uiLayoutColumn(layout, true);
1323 uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE);
1324 uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE);
1327 col = uiLayoutColumn(layout, true);
1328 uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE);
1329 uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE);
1331 uiItemR(col, ptr, "use_extended_bounds", 0, NULL, ICON_NONE);
1334 static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1338 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1339 uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
1341 col = uiLayoutColumn(layout, true);
1342 uiItemL(col, IFACE_("Center:"), ICON_NONE);
1343 uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE);
1344 uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE);
1348 col = uiLayoutColumn(layout, true);
1349 uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
1350 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1354 uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE);
1355 uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE);
1358 static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1362 col = uiLayoutColumn(layout, true);
1363 uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
1364 uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
1365 uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
1368 static void node_composit_buts_defocus(uiLayout *layout, bContext *C, PointerRNA *ptr)
1370 uiLayout *sub, *col;
1372 col = uiLayoutColumn(layout, false);
1373 uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE);
1374 uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
1375 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1377 uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1379 col = uiLayoutColumn(layout, false);
1380 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == true);
1381 uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE);
1383 uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
1384 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1386 col = uiLayoutColumn(layout, false);
1387 uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
1389 uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
1391 col = uiLayoutColumn(layout, false);
1392 uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
1393 sub = uiLayoutColumn(col, false);
1394 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == false);
1395 uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE);
1398 /* qdn: glare node */
1399 static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1401 uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
1402 uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
1404 if (RNA_enum_get(ptr, "glare_type") != 1) {
1405 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1407 if (RNA_enum_get(ptr, "glare_type") != 0)
1408 uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1411 uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
1412 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1414 if (RNA_enum_get(ptr, "glare_type") == 2) {
1415 uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
1416 uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
1418 if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
1419 uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1421 if (RNA_enum_get(ptr, "glare_type") == 0)
1422 uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
1424 if (RNA_enum_get(ptr, "glare_type") == 1) {
1425 uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
1429 static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1433 col = uiLayoutColumn(layout, false);
1434 uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
1435 if (RNA_enum_get(ptr, "tonemap_type") == 0) {
1436 uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1437 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1438 uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
1441 uiItemR(col, ptr, "intensity", 0, NULL, ICON_NONE);
1442 uiItemR(col, ptr, "contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1443 uiItemR(col, ptr, "adaptation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1444 uiItemR(col, ptr, "correction", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1448 static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1452 col = uiLayoutColumn(layout, false);
1453 uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE);
1455 col = uiLayoutColumn(col, false);
1456 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == false);
1457 uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE);
1458 uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE);
1461 static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1465 col = uiLayoutColumn(layout, false);
1466 uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
1467 uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE);
1469 col = uiLayoutColumn(layout, true);
1470 uiItemL(col, IFACE_("Speed:"), ICON_NONE);
1471 uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE);
1472 uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE);
1474 uiItemR(layout, ptr, "use_curved", 0, NULL, ICON_NONE);
1477 static void node_composit_buts_filter(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1479 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1482 static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1484 uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
1487 static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1491 uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE);
1492 uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE);
1494 col = uiLayoutColumn(layout, true);
1495 if (RNA_boolean_get(ptr, "relative")) {
1496 uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE);
1497 uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE);
1498 uiItemR(col, ptr, "rel_min_y", 0, IFACE_("Up"), ICON_NONE);
1499 uiItemR(col, ptr, "rel_max_y", 0, IFACE_("Down"), ICON_NONE);
1502 uiItemR(col, ptr, "min_x", 0, IFACE_("Left"), ICON_NONE);
1503 uiItemR(col, ptr, "max_x", 0, IFACE_("Right"), ICON_NONE);
1504 uiItemR(col, ptr, "min_y", 0, IFACE_("Up"), ICON_NONE);
1505 uiItemR(col, ptr, "max_y", 0, IFACE_("Down"), ICON_NONE);
1509 static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1511 uiLayout *row, *col;
1513 col = uiLayoutColumn(layout, false);
1514 row = uiLayoutRow(col, false);
1515 uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1516 uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
1519 static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1523 col = uiLayoutColumn(layout, false);
1525 uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE);
1526 uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
1527 uiItemL(col, IFACE_("Buffer Edge:"), ICON_NONE);
1528 uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
1531 static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1535 col = uiLayoutColumn(layout, true);
1536 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
1539 static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1541 uiLayout *sub, *col;
1543 col = uiLayoutColumn(layout, true);
1544 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1545 uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
1547 col = uiLayoutColumn(layout, true);
1548 uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
1549 sub = uiLayoutColumn(col, false);
1550 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
1551 uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
1553 col = uiLayoutColumn(layout, true);
1554 uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
1555 sub = uiLayoutColumn(col, false);
1556 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
1557 uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
1560 static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1564 col = uiLayoutColumn(layout, true);
1565 uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
1566 uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
1569 static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1573 col = uiLayoutColumn(layout, true);
1574 uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
1575 uiItemR(col, ptr, "use_antialias_z", 0, NULL, ICON_NONE);
1578 static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1580 uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
1581 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1582 switch (RNA_enum_get(ptr, "mode")) {
1583 case CMP_NODE_DILATEERODE_DISTANCE_THRESH:
1584 uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
1586 case CMP_NODE_DILATEERODE_DISTANCE_FEATHER:
1587 uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE);
1592 static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1594 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1597 static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1601 col = uiLayoutColumn(layout, false);
1602 uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1603 uiItemR(col, ptr, "threshold_neighbor", 0, NULL, ICON_NONE);
1606 static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1610 col = uiLayoutColumn(layout, true);
1611 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1612 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1615 static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1617 uiLayout *col, *row;
1619 col = uiLayoutColumn(layout, true);
1621 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1622 row = uiLayoutRow(layout, false);
1623 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1625 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1626 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1629 static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1631 uiLayout *row, *col;
1633 uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE);
1634 row = uiLayoutRow(layout, false);
1635 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1637 col = uiLayoutColumn(layout, false);
1638 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1640 if (RNA_enum_get(ptr, "limit_method") == 0) {
1641 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1642 row = uiLayoutRow(col, false);
1643 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1646 uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1647 uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE);
1648 if (RNA_boolean_get(ptr, "use_unspill") == true) {
1649 uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1650 uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1651 uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1655 static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1659 col = uiLayoutColumn(layout, false);
1660 uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
1661 uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1663 col = uiLayoutColumn(layout, true);
1664 /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */
1665 uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1666 /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/
1669 static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1673 col = uiLayoutColumn(layout, true);
1674 uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1675 uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1676 uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1679 static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1681 uiLayout *col, *row;
1683 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1684 row = uiLayoutRow(layout, false);
1685 uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1687 col = uiLayoutColumn(layout, false);
1688 uiItemL(col, IFACE_("Key Channel:"), ICON_NONE);
1689 row = uiLayoutRow(col, false);
1690 uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1692 col = uiLayoutColumn(layout, false);
1694 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1695 if (RNA_enum_get(ptr, "limit_method") == 0) {
1696 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1697 row = uiLayoutRow(col, false);
1698 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1701 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1702 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1705 static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1709 col = uiLayoutColumn(layout, true);
1710 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1711 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1714 static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1716 uiItemR(layout, ptr, "alpha", 0, NULL, ICON_NONE);
1719 static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1721 uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE);
1722 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
1725 static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1727 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1728 const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
1731 uiItemL(layout, IFACE_("Path:"), ICON_NONE);
1733 uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
1734 uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1736 static void node_composit_buts_file_output_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1738 Scene *scene = CTX_data_scene(C);
1739 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1740 PointerRNA active_input_ptr, op_ptr;
1742 uiLayout *row, *col;
1744 const bool multilayer = RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER;
1745 const bool is_multiview = (scene->r.scemode & R_MULTIVIEW) != 0;
1747 node_composit_buts_file_output(layout, C, ptr);
1748 uiTemplateImageSettings(layout, &imfptr, false);
1750 /* disable stereo output for multilayer, too much work for something that no one will use */
1751 /* if someone asks for that we can implement it */
1753 uiTemplateImageFormatViews(layout, &imfptr, NULL);
1757 uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
1759 row = uiLayoutRow(layout, false);
1760 col = uiLayoutColumn(row, true);
1762 active_index = RNA_int_get(ptr, "active_input_index");
1763 /* using different collection properties if multilayer format is enabled */
1765 uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "layer_slots", ptr, "active_input_index",
1767 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"),
1768 active_index, &active_input_ptr);
1771 uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "file_slots", ptr, "active_input_index",
1773 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"),
1774 active_index, &active_input_ptr);
1776 /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */
1777 active_input_ptr.id.data = ptr->id.data;
1779 col = uiLayoutColumn(row, true);
1780 ot = WM_operatortype_find("NODE_OT_output_file_move_active_socket", false);
1781 op_ptr = uiItemFullO_ptr(col, ot, "", ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
1782 RNA_enum_set(&op_ptr, "direction", 1);
1783 op_ptr = uiItemFullO_ptr(col, ot, "", ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
1784 RNA_enum_set(&op_ptr, "direction", 2);
1786 if (active_input_ptr.data) {
1788 col = uiLayoutColumn(layout, true);
1790 uiItemL(col, IFACE_("Layer:"), ICON_NONE);
1791 row = uiLayoutRow(col, false);
1792 uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE);
1793 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
1794 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
1797 col = uiLayoutColumn(layout, true);
1799 uiItemL(col, IFACE_("File Subpath:"), ICON_NONE);
1800 row = uiLayoutRow(col, false);
1801 uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
1802 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
1803 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
1805 /* format details for individual files */
1806 imfptr = RNA_pointer_get(&active_input_ptr, "format");
1808 col = uiLayoutColumn(layout, true);
1809 uiItemL(col, IFACE_("Format:"), ICON_NONE);
1810 uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE);
1812 col = uiLayoutColumn(layout, false);
1813 uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == false);
1814 uiTemplateImageSettings(col, &imfptr, false);
1817 uiTemplateImageFormatViews(layout, &imfptr, NULL);
1822 static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1824 uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
1826 if (RNA_enum_get(ptr, "space") == CMP_SCALE_RENDERPERCENT) {
1828 uiItemR(layout, ptr, "frame_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1829 row = uiLayoutRow(layout, true);
1830 uiItemR(row, ptr, "offset_x", 0, "X", ICON_NONE);
1831 uiItemR(row, ptr, "offset_y", 0, "Y", ICON_NONE);
1835 static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1837 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1840 static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1844 col = uiLayoutColumn(layout, false);
1845 uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
1846 uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
1849 static void node_composit_buts_premulkey(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1851 uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE);
1854 static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1856 uiItemR(layout, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1859 static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1861 uiLayout *split, *col, *row;
1863 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1865 if (RNA_enum_get(ptr, "correction_method") == 0) {
1867 split = uiLayoutSplit(layout, 0.0f, false);
1868 col = uiLayoutColumn(split, false);
1869 uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1);
1870 row = uiLayoutRow(col, false);
1871 uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
1873 col = uiLayoutColumn(split, false);
1874 uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1);
1875 row = uiLayoutRow(col, false);
1876 uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
1878 col = uiLayoutColumn(split, false);
1879 uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1);
1880 row = uiLayoutRow(col, false);
1881 uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
1886 split = uiLayoutSplit(layout, 0.0f, false);
1887 col = uiLayoutColumn(split, false);
1888 uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1);
1889 row = uiLayoutRow(col, false);
1890 uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
1891 uiItemR(col, ptr, "offset_basis", 0, NULL, ICON_NONE);
1893 col = uiLayoutColumn(split, false);
1894 uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1);
1895 row = uiLayoutRow(col, false);
1896 uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
1898 col = uiLayoutColumn(split, false);
1899 uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1);
1900 row = uiLayoutRow(col, false);
1901 uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
1905 static void node_composit_buts_colorbalance_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1907 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1909 if (RNA_enum_get(ptr, "correction_method") == 0) {
1911 uiTemplateColorPicker(layout, ptr, "lift", 1, 1, 0, 1);
1912 uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
1914 uiTemplateColorPicker(layout, ptr, "gamma", 1, 1, 1, 1);
1915 uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
1917 uiTemplateColorPicker(layout, ptr, "gain", 1, 1, 1, 1);
1918 uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
1921 uiTemplateColorPicker(layout, ptr, "offset", 1, 1, 0, 1);
1922 uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
1924 uiTemplateColorPicker(layout, ptr, "power", 1, 1, 0, 1);
1925 uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
1927 uiTemplateColorPicker(layout, ptr, "slope", 1, 1, 0, 1);
1928 uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
1933 static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1935 bNode *node = ptr->data;
1936 CurveMapping *cumap = node->storage;
1938 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
1939 cumap->flag |= CUMA_DRAW_SAMPLE;
1940 copy_v3_v3(cumap->sample, _sample_col);
1943 cumap->flag &= ~CUMA_DRAW_SAMPLE;
1946 uiTemplateCurveMapping(layout, ptr, "mapping", 'h', false, false, false);
1949 static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1951 uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
1954 static void node_composit_buts_movieclip(uiLayout *layout, bContext *C, PointerRNA *ptr)
1956 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1959 static void node_composit_buts_movieclip_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
1961 bNode *node = ptr->data;
1964 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1969 clipptr = RNA_pointer_get(ptr, "clip");
1971 uiTemplateColorspaceSettings(layout, &clipptr, "colorspace_settings");
1974 static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
1976 bNode *node = ptr->data;
1978 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1983 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1984 uiItemR(layout, ptr, "invert", 0, NULL, ICON_NONE);
1987 static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1989 uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
1990 uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE);
1993 static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1995 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1998 static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
2000 bNode *node = ptr->data;
2002 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2007 uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
2010 static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2014 row = uiLayoutRow(layout, false);
2015 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2016 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2017 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2019 row = uiLayoutRow(layout, false);
2020 uiItemL(row, "", ICON_NONE);
2021 uiItemL(row, IFACE_("Saturation"), ICON_NONE);
2022 uiItemL(row, IFACE_("Contrast"), ICON_NONE);
2023 uiItemL(row, IFACE_("Gamma"), ICON_NONE);
2024 uiItemL(row, IFACE_("Gain"), ICON_NONE);
2025 uiItemL(row, IFACE_("Lift"), ICON_NONE);
2027 row = uiLayoutRow(layout, false);
2028 uiItemL(row, IFACE_("Master"), ICON_NONE);
2029 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2030 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2031 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2032 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2033 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2035 row = uiLayoutRow(layout, false);
2036 uiItemL(row, IFACE_("Highlights"), ICON_NONE);
2037 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2038 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2039 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2040 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2041 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2043 row = uiLayoutRow(layout, false);
2044 uiItemL(row, IFACE_("Midtones"), ICON_NONE);
2045 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2046 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2047 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2048 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2049 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2051 row = uiLayoutRow(layout, false);
2052 uiItemL(row, IFACE_("Shadows"), ICON_NONE);
2053 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2054 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2055 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2056 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2057 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2059 row = uiLayoutRow(layout, false);
2060 uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2061 uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2064 static void node_composit_buts_colorcorrection_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2068 row = uiLayoutRow(layout, false);
2069 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2070 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2071 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2073 uiItemL(row, IFACE_("Saturation"), ICON_NONE);
2074 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2075 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2076 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2077 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2079 uiItemL(row, IFACE_("Contrast"), ICON_NONE);
2080 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2081 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2082 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2083 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2085 uiItemL(row, IFACE_("Gamma"), ICON_NONE);
2086 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2087 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2088 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2089 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2091 uiItemL(row, IFACE_("Gain"), ICON_NONE);
2092 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2093 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2094 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2095 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2097 uiItemL(row, IFACE_("Lift"), ICON_NONE);
2098 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2099 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2100 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2101 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2103 row = uiLayoutRow(layout, false);
2104 uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE);
2105 uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE);
2108 static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2110 uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
2113 static void node_composit_buts_switch_view_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *UNUSED(ptr))
2115 uiItemFullO(layout, "NODE_OT_switch_view_update", "Update Views", ICON_FILE_REFRESH, NULL, WM_OP_INVOKE_DEFAULT, 0);
2118 static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2122 row = uiLayoutRow(layout, true);
2123 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2124 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2126 row = uiLayoutRow(layout, true);
2127 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2128 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2130 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2131 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2134 static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2136 uiItemR(layout, ptr, "flaps", 0, NULL, ICON_NONE);
2137 uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
2138 uiItemR(layout, ptr, "rounding", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2139 uiItemR(layout, ptr, "catadioptric", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2140 uiItemR(layout, ptr, "shift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2143 static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2145 uiItemR(layout, ptr, "use_variable_size", 0, NULL, ICON_NONE);
2146 // uiItemR(layout, ptr, "f_stop", 0, NULL, ICON_NONE); // UNUSED
2147 uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
2148 uiItemR(layout, ptr, "use_extended_bounds", 0, NULL, ICON_NONE);
2151 static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2153 // node_composit_backdrop_canvas(snode, backdrop, node, x, y);
2154 if (node->custom1 == 0) {
2155 const float backdropWidth = backdrop->x;
2156 const float backdropHeight = backdrop->y;
2157 const float cx = x + snode->zoom * backdropWidth * node->custom3;
2158 const float cy = y + snode->zoom * backdropHeight * node->custom4;
2160 VertexFormat *format = immVertexFormat();
2161 unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
2163 immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
2165 immUniformColor3f(1.0f, 1.0f, 1.0f);
2167 immBegin(PRIM_LINES, 4);
2168 immVertex2f(pos, cx - 25, cy - 25);
2169 immVertex2f(pos, cx + 25, cy + 25);
2170 immVertex2f(pos, cx + 25, cy - 25);
2171 immVertex2f(pos, cx - 25, cy + 25);
2178 static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2180 NodeBoxMask *boxmask = node->storage;
2181 const float backdropWidth = backdrop->x;
2182 const float backdropHeight = backdrop->y;
2183 const float aspect = backdropWidth / backdropHeight;
2184 const float rad = -boxmask->rotation;
2185 const float cosine = cosf(rad);
2186 const float sine = sinf(rad);
2187 const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
2188 const float halveBoxHeight = backdropHeight * (boxmask->height / 2.0f) * aspect;
2190 float cx, cy, x1, x2, x3, x4;
2191 float y1, y2, y3, y4;
2193 cx = x + snode->zoom * backdropWidth * boxmask->x;
2194 cy = y + snode->zoom * backdropHeight * boxmask->y;
2196 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2197 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2198 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2199 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2200 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2201 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2202 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2203 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2205 VertexFormat *format = immVertexFormat();
2206 unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
2208 immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
2210 immUniformColor3f(1.0f, 1.0f, 1.0f);
2212 immBegin(PRIM_LINE_LOOP, 4);
2213 immVertex2f(pos, x1, y1);
2214 immVertex2f(pos, x2, y2);
2215 immVertex2f(pos, x3, y3);
2216 immVertex2f(pos, x4, y4);
2222 static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2224 NodeEllipseMask *ellipsemask = node->storage;
2225 const float backdropWidth = backdrop->x;
2226 const float backdropHeight = backdrop->y;
2227 const float aspect = backdropWidth / backdropHeight;
2228 const float rad = -ellipsemask->rotation;
2229 const float cosine = cosf(rad);
2230 const float sine = sinf(rad);
2231 const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
2232 const float halveBoxHeight = backdropHeight * (ellipsemask->height / 2.0f) * aspect;
2234 float cx, cy, x1, x2, x3, x4;
2235 float y1, y2, y3, y4;
2237 cx = x + snode->zoom * backdropWidth * ellipsemask->x;
2238 cy = y + snode->zoom * backdropHeight * ellipsemask->y;
2240 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2241 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2242 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2243 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2244 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2245 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2246 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2247 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2249 VertexFormat *format = immVertexFormat();
2250 unsigned int pos = VertexFormat_add_attrib(format, "pos", COMP_F32, 2, KEEP_FLOAT);
2252 immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
2254 immUniformColor3f(1.0f, 1.0f, 1.0f);
2256 immBegin(PRIM_LINE_LOOP, 4);
2257 immVertex2f(pos, x1, y1);
2258 immVertex2f(pos, x2, y2);
2259 immVertex2f(pos, x3, y3);
2260 immVertex2f(pos, x4, y4);
2266 static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2269 row = uiLayoutRow(layout, true);
2270 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2271 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2272 row = uiLayoutRow(layout, true);
2273 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2274 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2276 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2277 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2280 static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2282 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2285 static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2287 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2290 static void node_composit_buts_viewer_ex(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2294 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2295 uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
2296 if (RNA_enum_get(ptr, "tile_order") == 0) {
2297 col = uiLayoutColumn(layout, true);
2298 uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
2299 uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
2303 static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
2305 bNode *node = ptr->data;
2307 uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
2308 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
2309 uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
2311 uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
2313 if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
2314 uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
2315 uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
2318 uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
2319 if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
2320 uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
2321 uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
2325 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
2327 bNode *node = ptr->data;
2329 uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
2332 MovieClip *clip = (MovieClip *) node->id;
2334 PointerRNA tracking_ptr;
2336 RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
2338 col = uiLayoutColumn(layout, true);
2339 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2343 static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2345 /* bNode *node = ptr->data; */ /* UNUSED */
2347 uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
2348 uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
2349 uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
2350 uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
2351 uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
2352 uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
2353 uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
2354 uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE);
2355 uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE);
2356 uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE);
2357 uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE);
2358 uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
2361 static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
2363 bNode *node = ptr->data;
2365 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2368 MovieClip *clip = (MovieClip *) node->id;
2369 MovieTracking *tracking = &clip->tracking;
2370 MovieTrackingObject *object;
2372 PointerRNA tracking_ptr;
2373 NodeTrackPosData *data = node->storage;
2375 RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2377 col = uiLayoutColumn(layout, false);
2378 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2380 object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2382 PointerRNA object_ptr;
2384 RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2386 uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
2389 uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
2392 uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
2394 if (ELEM(node->custom1, CMP_TRACKPOS_RELATIVE_FRAME, CMP_TRACKPOS_ABSOLUTE_FRAME)) {
2395 uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
2400 static void node_composit_buts_planetrackdeform(uiLayout *layout, bContext *C, PointerRNA *ptr)
2402 bNode *node = ptr->data;
2403 NodePlaneTrackDeformData *data = node->storage;
2405 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2408 MovieClip *clip = (MovieClip *) node->id;
2409 MovieTracking *tracking = &clip->tracking;
2410 MovieTrackingObject *object;
2412 PointerRNA tracking_ptr;
2414 RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2416 col = uiLayoutColumn(layout, false);
2417 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2419 object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2421 PointerRNA object_ptr;
2423 RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2425 uiItemPointerR(col, ptr, "plane_track_name", &object_ptr, "plane_tracks", "", ICON_ANIM_DATA);
2428 uiItemR(layout, ptr, "plane_track_name", 0, "", ICON_ANIM_DATA);
2432 uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
2433 if (data->flag & CMP_NODEFLAG_PLANETRACKDEFORM_MOTION_BLUR) {
2434 uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
2435 uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
2439 static void node_composit_buts_cornerpin(uiLayout *UNUSED(layout), bContext *UNUSED(C), PointerRNA *UNUSED(ptr))
2443 static void node_composit_buts_sunbeams(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2445 uiItemR(layout, ptr, "source", UI_ITEM_R_EXPAND, "", ICON_NONE);
2446 uiItemR(layout, ptr, "ray_length", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2449 /* only once called */
2450 static void node_composit_set_butfunc(bNodeType *ntype)
2452 switch (ntype->type) {
2453 case CMP_NODE_IMAGE:
2454 ntype->draw_buttons = node_composit_buts_image;
2455 ntype->draw_buttons_ex = node_composit_buts_image_ex;
2457 case CMP_NODE_R_LAYERS:
2458 ntype->draw_buttons = node_composit_buts_renderlayers;
2460 case CMP_NODE_NORMAL:
2461 ntype->draw_buttons = node_buts_normal;
2463 case CMP_NODE_CURVE_VEC:
2464 ntype->draw_buttons = node_buts_curvevec;
2466 case CMP_NODE_CURVE_RGB:
2467 ntype->draw_buttons = node_buts_curvecol;
2469 case CMP_NODE_VALUE:
2470 ntype->draw_buttons = node_buts_value;
2473 ntype->draw_buttons = node_buts_rgb;
2476 ntype->draw_buttons = node_composit_buts_flip;
2478 case CMP_NODE_SPLITVIEWER:
2479 ntype->draw_buttons = node_composit_buts_splitviewer;
2481 case CMP_NODE_MIX_RGB:
2482 ntype->draw_buttons = node_buts_mix_rgb;
2484 case CMP_NODE_VALTORGB:
2485 ntype->draw_buttons = node_buts_colorramp;
2488 ntype->draw_buttons = node_composit_buts_crop;
2491 ntype->draw_buttons = node_composit_buts_blur;
2493 case CMP_NODE_DBLUR:
2494 ntype->draw_buttons = node_composit_buts_dblur;
2496 case CMP_NODE_BILATERALBLUR:
2497 ntype->draw_buttons = node_composit_buts_bilateralblur;
2499 case CMP_NODE_DEFOCUS:
2500 ntype->draw_buttons = node_composit_buts_defocus;
2502 case CMP_NODE_GLARE:
2503 ntype->draw_buttons = node_composit_buts_glare;
2505 case CMP_NODE_TONEMAP:
2506 ntype->draw_buttons = node_composit_buts_tonemap;
2508 case CMP_NODE_LENSDIST:
2509 ntype->draw_buttons = node_composit_buts_lensdist;
2511 case CMP_NODE_VECBLUR:
2512 ntype->draw_buttons = node_composit_buts_vecblur;
2514 case CMP_NODE_FILTER:
2515 ntype->draw_buttons = node_composit_buts_filter;
2517 case CMP_NODE_MAP_VALUE:
2518 ntype->draw_buttons = node_composit_buts_map_value;
2520 case CMP_NODE_MAP_RANGE:
2521 ntype->draw_buttons = node_composit_buts_map_range;
2524 ntype->draw_buttons = node_buts_time;
2526 case CMP_NODE_ALPHAOVER:
2527 ntype->draw_buttons = node_composit_buts_alphaover;
2529 case CMP_NODE_TEXTURE:
2530 ntype->draw_buttons = node_buts_texture;
2532 case CMP_NODE_DILATEERODE:
2533 ntype->draw_buttons = node_composit_buts_dilateerode;
2535 case CMP_NODE_INPAINT:
2536 ntype->draw_buttons = node_composit_buts_inpaint;
2538 case CMP_NODE_DESPECKLE:
2539 ntype->draw_buttons = node_composit_buts_despeckle;
2541 case CMP_NODE_OUTPUT_FILE:
2542 ntype->draw_buttons = node_composit_buts_file_output;
2543 ntype->draw_buttons_ex = node_composit_buts_file_output_ex;
2545 case CMP_NODE_DIFF_MATTE:
2546 ntype->draw_buttons = node_composit_buts_diff_matte;
2548 case CMP_NODE_DIST_MATTE:
2549 ntype->draw_buttons = node_composit_buts_distance_matte;
2551 case CMP_NODE_COLOR_SPILL:
2552 ntype->draw_buttons = node_composit_buts_color_spill;
2554 case CMP_NODE_CHROMA_MATTE:
2555 ntype->draw_buttons = node_composit_buts_chroma_matte;
2557 case CMP_NODE_COLOR_MATTE:
2558 ntype->draw_buttons = node_composit_buts_color_matte;
2560 case CMP_NODE_SCALE:
2561 ntype->draw_buttons = node_composit_buts_scale;
2563 case CMP_NODE_ROTATE:
2564 ntype->draw_buttons = node_composit_buts_rotate;
2566 case CMP_NODE_CHANNEL_MATTE:
2567 ntype->draw_buttons = node_composit_buts_channel_matte;
2569 case CMP_NODE_LUMA_MATTE:
2570 ntype->draw_buttons = node_composit_buts_luma_matte;
2572 case CMP_NODE_MAP_UV:
2573 ntype->draw_buttons = node_composit_buts_map_uv;
2575 case CMP_NODE_ID_MASK:
2576 ntype->draw_buttons = node_composit_buts_id_mask;
2578 case CMP_NODE_DOUBLEEDGEMASK:
2579 ntype->draw_buttons = node_composit_buts_double_edge_mask;
2582 ntype->draw_buttons = node_buts_math;
2584 case CMP_NODE_INVERT:
2585 ntype->draw_buttons = node_composit_buts_invert;
2587 case CMP_NODE_PREMULKEY:
2588 ntype->draw_buttons = node_composit_buts_premulkey;
2590 case CMP_NODE_VIEW_LEVELS:
2591 ntype->draw_buttons = node_composit_buts_view_levels;
2593 case CMP_NODE_COLORBALANCE:
2594 ntype->draw_buttons = node_composit_buts_colorbalance;
2595 ntype->draw_buttons_ex = node_composit_buts_colorbalance_ex;
2597 case CMP_NODE_HUECORRECT:
2598 ntype->draw_buttons = node_composit_buts_huecorrect;
2600 case CMP_NODE_ZCOMBINE:
2601 ntype->draw_buttons = node_composit_buts_zcombine;
2603 case CMP_NODE_COMBYCCA:
2604 case CMP_NODE_SEPYCCA:
2605 ntype->draw_buttons = node_composit_buts_ycc;
2607 case CMP_NODE_MOVIECLIP:
2608 ntype->draw_buttons = node_composit_buts_movieclip;
2609 ntype->draw_buttons_ex = node_composit_buts_movieclip_ex;
2611 case CMP_NODE_STABILIZE2D:
2612 ntype->draw_buttons = node_composit_buts_stabilize2d;
2614 case CMP_NODE_TRANSFORM:
2615 ntype->draw_buttons = node_composit_buts_transform;
2617 case CMP_NODE_TRANSLATE:
2618 ntype->draw_buttons = node_composit_buts_translate;
2620 case CMP_NODE_MOVIEDISTORTION:
2621 ntype->draw_buttons = node_composit_buts_moviedistortion;
2623 case CMP_NODE_COLORCORRECTION:
2624 ntype->draw_buttons = node_composit_buts_colorcorrection;
2625 ntype->draw_buttons_ex = node_composit_buts_colorcorrection_ex;
2627 case CMP_NODE_SWITCH:
2628 ntype->draw_buttons = node_composit_buts_switch;
2630 case CMP_NODE_SWITCH_VIEW:
2631 ntype->draw_buttons_ex = node_composit_buts_switch_view_ex;
2633 case CMP_NODE_MASK_BOX:
2634 ntype->draw_buttons = node_composit_buts_boxmask;
2635 ntype->draw_backdrop = node_composit_backdrop_boxmask;
2637 case CMP_NODE_MASK_ELLIPSE:
2638 ntype->draw_buttons = node_composit_buts_ellipsemask;
2639 ntype->draw_backdrop = node_composit_backdrop_ellipsemask;
2641 case CMP_NODE_BOKEHIMAGE:
2642 ntype->draw_buttons = node_composit_buts_bokehimage;
2644 case CMP_NODE_BOKEHBLUR:
2645 ntype->draw_buttons = node_composit_buts_bokehblur;
2647 case CMP_NODE_VIEWER:
2648 ntype->draw_buttons = node_composit_buts_viewer;
2649 ntype->draw_buttons_ex = node_composit_buts_viewer_ex;
2650 ntype->draw_backdrop = node_composit_backdrop_viewer;
2652 case CMP_NODE_COMPOSITE:
2653 ntype->draw_buttons = node_composit_buts_composite;
2656 ntype->draw_buttons = node_composit_buts_mask;
2658 case CMP_NODE_KEYINGSCREEN:
2659 ntype->draw_buttons = node_composit_buts_keyingscreen;
2661 case CMP_NODE_KEYING:
2662 ntype->draw_buttons = node_composit_buts_keying;
2664 case CMP_NODE_TRACKPOS:
2665 ntype->draw_buttons = node_composit_buts_trackpos;
2667 case CMP_NODE_PLANETRACKDEFORM:
2668 ntype->draw_buttons = node_composit_buts_planetrackdeform;
2670 case CMP_NODE_CORNERPIN:
2671 ntype->draw_buttons = node_composit_buts_cornerpin;
2673 case CMP_NODE_SUNBEAMS:
2674 ntype->draw_buttons = node_composit_buts_sunbeams;
2679 /* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
2681 static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2685 col = uiLayoutColumn(layout, true);
2686 uiItemR(col, ptr, "offset", UI_ITEM_R_SLIDER, IFACE_("Offset"), ICON_NONE);
2687 uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2689 col = uiLayoutColumn(layout, true);
2690 uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
2691 uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2694 static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2697 bNode *node = ptr->data;
2698 ID *id = ptr->id.data;
2699 Tex *tex = (Tex *)node->storage;
2700 uiLayout *col, *row;
2702 RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
2704 col = uiLayoutColumn(layout, false);
2706 switch (tex->type) {
2708 uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
2709 row = uiLayoutRow(col, false);
2710 uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2714 row = uiLayoutRow(col, false);
2715 uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2716 row = uiLayoutRow(col, false);
2717 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2718 row = uiLayoutRow(col, false);
2719 uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2720 row = uiLayoutRow(col, false);
2721 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2725 uiItemR(col, &tex_ptr, "noise_depth", 0, NULL, ICON_NONE);
2729 row = uiLayoutRow(col, false);
2730 uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2731 row = uiLayoutRow(col, false);
2732 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2733 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2737 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2738 uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE);
2739 row = uiLayoutRow(col, false);
2740 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2741 row = uiLayoutRow(col, false);
2742 uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
2743 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2747 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2748 row = uiLayoutRow(col, false);
2749 uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2750 row = uiLayoutRow(col, false);
2751 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2752 uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE);
2756 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2757 uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE);
2761 uiItemR(col, &tex_ptr, "musgrave_type", 0, "", ICON_NONE);
2762 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2765 uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE);
2766 if (tex->vn_distm == TEX_MINKOVSKY) {
2767 uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE);
2769 uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE);
2774 static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
2776 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
2779 static void node_texture_buts_image_ex(uiLayout *layout, bContext *C, PointerRNA *ptr)
2781 bNode *node = ptr->data;
2782 PointerRNA iuserptr;
2784 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
2785 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0, 0);
2788 static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2790 uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
2793 /* only once called */
2794 static void node_texture_set_butfunc(bNodeType *ntype)
2796 if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
2797 ntype->draw_buttons = node_texture_buts_proc;
2800 switch (ntype->type) {
2803 ntype->draw_buttons = node_buts_math;
2806 case TEX_NODE_MIX_RGB:
2807 ntype->draw_buttons = node_buts_mix_rgb;
2810 case TEX_NODE_VALTORGB:
2811 ntype->draw_buttons = node_buts_colorramp;
2814 case TEX_NODE_CURVE_RGB:
2815 ntype->draw_buttons = node_buts_curvecol;
2818 case TEX_NODE_CURVE_TIME:
2819 ntype->draw_buttons = node_buts_time;
2822 case TEX_NODE_TEXTURE:
2823 ntype->draw_buttons = node_buts_texture;
2826 case TEX_NODE_BRICKS:
2827 ntype->draw_buttons = node_texture_buts_bricks;
2830 case TEX_NODE_IMAGE:
2831 ntype->draw_buttons = node_texture_buts_image;
2832 ntype->draw_buttons_ex = node_texture_buts_image_ex;
2835 case TEX_NODE_OUTPUT:
2836 ntype->draw_buttons = node_texture_buts_output;
2842 /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
2844 static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
2846 bNodeTree *ntree = ptr->id.data;
2847 bNode *node = ptr->data;
2848 ED_node_tag_update_nodetree(bmain, ntree, node);
2851 static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocketTemplate *stemp)
2853 StructRNA *srna = ntype->ext.srna;
2854 PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
2857 RNA_def_property_update_runtime(prop, node_property_update_default);
2860 static void node_template_properties_update(bNodeType *ntype)
2862 bNodeSocketTemplate *stemp;
2864 if (ntype->inputs) {
2865 for (stemp = ntype->inputs; stemp->type >= 0; ++stemp)
2866 node_socket_template_properties_update(ntype, stemp);
2868 if (ntype->outputs) {
2869 for (stemp = ntype->outputs; stemp->type >= 0; ++stemp)
2870 node_socket_template_properties_update(ntype, stemp);
2874 static void node_socket_undefined_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr),
2875 const char *UNUSED(text))
2877 uiItemL(layout, IFACE_("Undefined Socket Type"), ICON_ERROR);
2880 static void node_socket_undefined_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), float *r_color)
2888 static void node_socket_undefined_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr))
2890 uiItemL(layout, IFACE_("Undefined Socket Type"), ICON_ERROR);
2893 static void node_socket_undefined_interface_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), float *r_color)
2901 void ED_node_init_butfuncs(void)
2903 /* Fallback types for undefined tree, nodes, sockets
2904 * Defined in blenkernel, but not registered in type hashes.
2906 /*extern bNodeTreeType NodeTreeTypeUndefined;*/
2907 extern bNodeType NodeTypeUndefined;
2908 extern bNodeSocketType NodeSocketTypeUndefined;
2910 /* default ui functions */
2911 NodeTypeUndefined.draw_nodetype = node_draw_default;
2912 NodeTypeUndefined.draw_nodetype_prepare = node_update_default;
2913 NodeTypeUndefined.select_area_func = node_select_area_default;
2914 NodeTypeUndefined.tweak_area_func = node_tweak_area_default;
2915 NodeTypeUndefined.draw_buttons = NULL;
2916 NodeTypeUndefined.draw_buttons_ex = NULL;
2917 NodeTypeUndefined.resize_area_func = node_resize_area_default;
2919 NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
2920 NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color;
2921 NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw;
2922 NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color;
2924 /* node type ui functions */
2925 NODE_TYPES_BEGIN(ntype)
2926 /* default ui functions */
2927 ntype->draw_nodetype = node_draw_default;
2928 ntype->draw_nodetype_prepare = node_update_default;
2929 ntype->select_area_func = node_select_area_default;
2930 ntype->tweak_area_func = node_tweak_area_default;
2931 ntype->draw_buttons = NULL;
2932 ntype->draw_buttons_ex = NULL;
2933 ntype->resize_area_func = node_resize_area_default;
2935 node_common_set_butfunc(ntype);
2937 node_composit_set_butfunc(ntype);
2938 node_shader_set_butfunc(ntype);
2939 node_texture_set_butfunc(ntype);
2941 /* define update callbacks for socket properties */
2942 node_template_properties_update(ntype);
2945 /* tree type icons */
2946 ntreeType_Composite->ui_icon = ICON_RENDERLAYERS;
2947 ntreeType_Shader->ui_icon = ICON_MATERIAL;
2948 ntreeType_Texture->ui_icon = ICON_TEXTURE;
2951 void ED_init_custom_node_type(bNodeType *ntype)
2953 /* default ui functions */
2954 ntype->draw_nodetype = node_draw_default;
2955 ntype->draw_nodetype_prepare = node_update_default;
2956 ntype->resize_area_func = node_resize_area_default;
2957 ntype->select_area_func = node_select_area_default;
2958 ntype->tweak_area_func = node_tweak_area_default;
2961 void ED_init_custom_node_socket_type(bNodeSocketType *stype)
2963 /* default ui functions */
2964 stype->draw = node_socket_button_label;
2967 /* maps standard socket integer type to a color */
2968 static const float std_node_socket_colors[][4] = {
2969 {0.63, 0.63, 0.63, 1.0}, /* SOCK_FLOAT */
2970 {0.39, 0.39, 0.78, 1.0}, /* SOCK_VECTOR */
2971 {0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
2972 {0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
2973 {0.70, 0.65, 0.19, 1.0}, /* SOCK_BOOLEAN */
2974 {0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */
2975 {0.06, 0.52, 0.15, 1.0}, /* SOCK_INT */
2976 {1.0, 1.0, 1.0, 1.0}, /* SOCK_STRING */
2979 /* common color callbacks for standard types */
2980 static void std_node_socket_draw_color(bContext *UNUSED(C), PointerRNA *ptr, PointerRNA *UNUSED(node_ptr), float *r_color)
2982 bNodeSocket *sock = ptr->data;
2983 int type = sock->typeinfo->type;
2984 copy_v4_v4(r_color, std_node_socket_colors[type]);
2986 static void std_node_socket_interface_draw_color(bContext *UNUSED(C), PointerRNA *ptr, float *r_color)
2988 bNodeSocket *sock = ptr->data;
2989 int type = sock->typeinfo->type;
2990 copy_v4_v4(r_color, std_node_socket_colors[type]);
2993 /* draw function for file output node sockets, displays only sub-path and format, no value button */
2994 static void node_file_output_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
2996 bNodeTree *ntree = ptr->id.data;
2997 bNodeSocket *sock = ptr->data;
2999 PointerRNA inputptr, imfptr;
3002 row = uiLayoutRow(layout, false);
3004 imfptr = RNA_pointer_get(node_ptr, "format");
3005 imtype = RNA_enum_get(&imfptr, "file_format");
3007 if (imtype == R_IMF_IMTYPE_MULTILAYER) {
3008 NodeImageMultiFileSocket *input = sock->storage;
3009 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
3011 uiItemL(row, input->layer, ICON_NONE);
3014 NodeImageMultiFileSocket *input = sock->storage;
3015 PropertyRNA *imtype_prop;
3016 const char *imtype_name;
3018 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
3020 uiItemL(row, input->path, ICON_NONE);
3022 if (!RNA_boolean_get(&inputptr, "use_node_format"))
3023 imfptr = RNA_pointer_get(&inputptr, "format");
3025 imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
3026 RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
3027 RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
3028 block = uiLayoutGetBlock(row);
3029 UI_block_emboss_set(block, UI_EMBOSS_PULLDOWN);
3030 uiItemL(row, imtype_name, ICON_NONE);
3031 UI_block_emboss_set(block, UI_EMBOSS_NONE);
3035 static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
3037 bNode *node = node_ptr->data;
3038 bNodeSocket *sock = ptr->data;
3039 int type = sock->typeinfo->type;
3040 bool connected_to_virtual = (sock->link && (sock->link->fromsock->flag & SOCK_VIRTUAL));
3041 /*int subtype = sock->typeinfo->subtype;*/
3043 /* XXX not nice, eventually give this node its own socket type ... */
3044 if (node->type == CMP_NODE_OUTPUT_FILE) {
3045 node_file_output_socket_draw(C, layout, ptr, node_ptr);
3049 if ((sock->in_out == SOCK_OUT) || ((sock->flag & SOCK_IN_USE) && !connected_to_virtual) || (sock->flag & SOCK_HIDE_VALUE)) {
3050 node_socket_button_label(C, layout, ptr, node_ptr, text);
3058 uiItemR(layout, ptr, "default_value", 0, text, 0);
3061 uiTemplateComponentMenu(layout, ptr, "default_value", text);
3065 uiLayout *row = uiLayoutRow(layout, false);
3066 uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
3067 /* draw the socket name right of the actual button */
3068 uiItemR(row, ptr, "default_value", 0, "", 0);
3069 uiItemL(row, text, 0);
3074 uiLayout *row = uiLayoutRow(layout, true);
3075 /* draw the socket name right of the actual button */
3076 uiItemR(row, ptr, "default_value", 0, "", 0);
3077 uiItemL(row, text, 0);
3081 node_socket_button_label(C, layout, ptr, node_ptr, text);
3086 static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *ptr)
3088 bNodeSocket *sock = ptr->data;
3089 int type = sock->typeinfo->type;
3090 /*int subtype = sock->typeinfo->subtype;*/
3096 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
3097 row = uiLayoutRow(layout, true);
3098 uiItemR(row, ptr, "min_value", 0, IFACE_("Min"), 0);
3099 uiItemR(row, ptr, "max_value", 0, IFACE_("Max"), 0);
3105 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
3106 row = uiLayoutRow(layout, true);
3107 uiItemR(row, ptr, "min_value", 0, IFACE_("Min"), 0);
3108 uiItemR(row, ptr, "max_value", 0, IFACE_("Max"), 0);
3113 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
3119 uiItemR(layout, ptr, "default_value", UI_ITEM_R_EXPAND, NULL, 0);
3120 row = uiLayoutRow(layout, true);
3121 uiItemR(row, ptr, "min_value", 0, IFACE_("Min"), 0);
3122 uiItemR(row, ptr, "max_value", 0, IFACE_("Max"), 0);
3127 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
3132 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
3138 void ED_init_standard_node_socket_type(bNodeSocketType *stype)
3140 stype->draw = std_node_socket_draw;
3141 stype->draw_color = std_node_socket_draw_color;
3142 stype->interface_draw = std_node_socket_interface_draw;
3143 stype->interface_draw_color = std_node_socket_interface_draw_color;
3146 static void node_socket_virtual_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), float *r_color)
3148 /* alpha = 0, empty circle */
3152 void ED_init_node_socket_type_virtual(bNodeSocketType *stype)
3154 stype->draw = node_socket_button_label;
3155 stype->draw_color = node_socket_virtual_draw_color;
3158 /* ************** Generic drawing ************** */
3160 void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key)
3162 bNodeInstanceKey active_viewer_key = (snode->nodetree ? snode->nodetree->active_viewer_key : NODE_INSTANCE_KEY_NONE);
3163 float shuffle[4] = {0.0f, 0.0f, 0.0f, 0.0f};
3168 if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode))
3171 if (parent_key.value != active_viewer_key.value)
3174 ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
3175 ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
3179 gpuPushProjectionMatrix();
3182 /* somehow the offset has to be calculated inverse */
3184 glaDefine2DArea(&ar->winrct);
3185 wmOrtho2_region_pixelspace(ar);
3187 x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
3188 y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
3190 if (ibuf->rect || ibuf->rect_float) {
3191 unsigned char *display_buffer = NULL;
3192 void *cache_handle = NULL;
3194 if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B | SNODE_SHOW_ALPHA)) {
3196 display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
3198 if (snode->flag & SNODE_SHOW_R)
3200 else if (snode->flag & SNODE_SHOW_G)
3202 else if (snode->flag & SNODE_SHOW_B)
3207 IMMDrawPixelsTexState state = immDrawPixelsTexSetup(GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR);
3208 GPU_shader_uniform_vector(state.shader, GPU_shader_get_uniform(state.shader, "shuffle"), 4, 1, shuffle);
3210 immDrawPixelsTex(&state, x, y, ibuf->x, ibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_NEAREST,
3211 display_buffer, snode->zoom, snode->zoom, NULL);
3213 GPU_shader_unbind();
3215 else if (snode->flag & SNODE_USE_ALPHA) {
3217 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
3219 glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST, snode->zoom, snode->zoom);
3221 glDisable(GL_BLEND);