2 * ***** BEGIN GPL LICENSE BLOCK *****
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * The Original Code is Copyright (C) 2005 Blender Foundation.
19 * All rights reserved.
21 * The Original Code is: all of this file.
23 * Contributor(s): David Millan Escriva, Juho Vepsäläinen, Bob Holcomb, Thomas Dinges
25 * ***** END GPL LICENSE BLOCK *****
28 /** \file blender/editors/space_node/drawnode.c
30 * \brief lower level node drawing for nodes (boarders, headers etc), also node layout.
33 #include "BLI_blenlib.h"
36 #include "DNA_node_types.h"
37 #include "DNA_object_types.h"
38 #include "DNA_space_types.h"
39 #include "DNA_screen_types.h"
41 #include "BKE_context.h"
42 #include "BKE_curve.h"
43 #include "BKE_image.h"
46 #include "BKE_scene.h"
47 #include "BKE_tracking.h"
50 #include "BLF_translation.h"
52 #include "NOD_texture.h"
55 #include "BIF_glutil.h"
57 #include "BLF_translation.h"
58 #include "MEM_guardedalloc.h"
60 #include "RNA_access.h"
61 #include "RNA_define.h"
62 #include "RNA_enum_types.h"
69 #include "UI_resources.h"
71 #include "IMB_colormanagement.h"
72 #include "IMB_imbuf.h"
73 #include "IMB_imbuf_types.h"
75 #include "node_intern.h" /* own include */
76 #include "NOD_composite.h"
77 #include "NOD_shader.h"
78 #include "NOD_texture.h"
81 /* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
83 static void node_socket_button_label(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr),
86 uiItemL(layout, text, 0);
89 static void node_draw_input_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
91 bNodeSocket *sock = (bNodeSocket *)ptr->data;
92 sock->typeinfo->draw(C, layout, ptr, node_ptr, IFACE_(sock->name));
95 static void node_draw_output_default(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
97 bNodeSocket *sock = ptr->data;
98 node_socket_button_label(C, layout, ptr, node_ptr, IFACE_(sock->name));
102 /* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
105 static void node_draw_socket_new(bNodeSocket *sock, float size)
107 float x = sock->locx, y = sock->locy;
109 /* 16 values of sin function */
110 static float si[16] = {
111 0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
112 0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
113 -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
114 -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
116 /* 16 values of cos function */
117 static float co[16] = {
118 1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
119 -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
120 -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
121 0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
125 glColor3ub(180, 180, 180);
128 for (a = 0; a < 16; a++)
129 glVertex2f(x + size * si[a], y + size * co[a]);
132 glColor4ub(0, 0, 0, 150);
134 glEnable(GL_LINE_SMOOTH);
135 glBegin(GL_LINE_LOOP);
136 for (a = 0; a < 16; a++)
137 glVertex2f(x + size * si[a], y + size * co[a]);
139 glDisable(GL_LINE_SMOOTH);
144 /* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
146 static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
148 bNode *node = ptr->data;
149 /* first output stores value */
150 bNodeSocket *output = node->outputs.first;
152 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
154 uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
157 static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
159 bNode *node = ptr->data;
160 /* first output stores value */
161 bNodeSocket *output = node->outputs.first;
164 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
166 col = uiLayoutColumn(layout, FALSE);
167 uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
168 uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
171 static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
175 bNodeTree *ntree = (bNodeTree *)ptr->id.data;
177 col = uiLayoutColumn(layout, FALSE);
178 row = uiLayoutRow(col, TRUE);
179 uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
180 if (ELEM(ntree->type, NTREE_COMPOSIT, NTREE_TEXTURE))
181 uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
183 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
186 static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
190 /* XXX no context access here .. */
191 bNode *node = ptr->data;
192 CurveMapping *cumap = node->storage;
195 cumap->flag |= CUMA_DRAW_CFRA;
196 if (node->custom1 < node->custom2)
197 cumap->sample[0] = (float)(CFRA - node->custom1) / (float)(node->custom2 - node->custom1);
201 uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0);
203 row = uiLayoutRow(layout, TRUE);
204 uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE);
205 uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
208 static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
210 uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
213 static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
215 uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
218 #define SAMPLE_FLT_ISNONE FLT_MAX
219 static float _sample_col[4] = {SAMPLE_FLT_ISNONE}; /* bad bad, 2.5 will do better?... no it won't... */
220 void ED_node_sample_set(const float col[4])
223 copy_v4_v4(_sample_col, col);
226 copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE);
230 static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
232 bNode *node = ptr->data;
233 CurveMapping *cumap = node->storage;
235 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
236 cumap->flag |= CUMA_DRAW_SAMPLE;
237 copy_v3_v3(cumap->sample, _sample_col);
240 cumap->flag &= ~CUMA_DRAW_SAMPLE;
243 uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
246 static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
248 bNode *node = ptr->data;
249 /* first output stores normal */
250 bNodeSocket *output = node->outputs.first;
252 RNA_pointer_create(ptr->id.data, &RNA_NodeSocket, output, &sockptr);
254 uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
257 #if 0 /* not used in 2.5x yet */
258 static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
260 Main *bmain = CTX_data_main(C);
261 bNodeTree *ntree = ntree_v;
262 bNode *node = node_v;
265 if (node->menunr < 1) return;
271 tex = BLI_findlink(&bmain->tex, node->menunr - 1);
274 id_us_plus(node->id);
275 BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
277 nodeSetActive(ntree, node);
279 if (ntree->type == NTREE_TEXTURE)
280 ntreeTexCheckCyclics(ntree);
282 // allqueue(REDRAWBUTSSHADING, 0);
283 // allqueue(REDRAWNODE, 0);
284 NodeTagChanged(ntree, node);
290 static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
292 bNode *node = ptr->data;
296 ((Tex *)node->id)->use_nodes &&
297 (node->type != CMP_NODE_TEXTURE) &&
298 (node->type != TEX_NODE_TEXTURE)
301 uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
304 /* Number Drawing not optimal here, better have a list*/
305 uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE);
309 static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
311 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
312 uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE);
315 static int node_resize_area_default(bNode *node, int x, int y)
317 if (node->flag & NODE_HIDDEN) {
318 rctf totr = node->totr;
319 /* right part of node */
320 totr.xmin = node->totr.xmax - 20.0f;
321 if (BLI_rctf_isect_pt(&totr, x, y))
322 return NODE_RESIZE_RIGHT;
327 const float size = 10.0f;
328 rctf totr = node->totr;
331 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
332 dir |= NODE_RESIZE_RIGHT;
333 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
334 dir |= NODE_RESIZE_LEFT;
339 /* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
342 static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
344 uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
347 /* XXX Does a bounding box update by iterating over all children.
348 * Not ideal to do this in every draw call, but doing as transform callback doesn't work,
349 * since the child node totr rects are not updated properly at that point.
351 static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
353 const float margin = 1.5f * U.widget_unit;
354 NodeFrame *data = (NodeFrame *)node->storage;
360 /* init rect from current frame size */
361 node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
362 node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
364 /* frame can be resized manually only if shrinking is disabled or no children are attached */
365 data->flag |= NODE_FRAME_RESIZEABLE;
366 /* for shrinking bbox, initialize the rect from first child node */
367 bbinit = (data->flag & NODE_FRAME_SHRINK);
368 /* fit bounding box to all children */
369 for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
370 if (tnode->parent != node)
373 /* add margin to node rect */
374 noderect = tnode->totr;
375 noderect.xmin -= margin;
376 noderect.xmax += margin;
377 noderect.ymin -= margin;
378 noderect.ymax += margin;
380 /* first child initializes frame */
384 data->flag &= ~NODE_FRAME_RESIZEABLE;
387 BLI_rctf_union(&rect, &noderect);
390 /* now adjust the frame size from view-space bounding box */
391 node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
392 node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax);
393 node->width = xmax - node->offsetx;
394 node->height = -ymax + node->offsety;
399 static void node_draw_frame_label(bNode *node, const float aspect)
401 /* XXX font id is crap design */
402 const int fontid = UI_GetStyle()->widgetlabel.uifont_id;
403 NodeFrame *data = (NodeFrame *)node->storage;
404 rctf *rct = &node->totr;
405 int color_id = node_get_colorid(node);
406 const char *label = nodeLabel(node);
407 /* XXX a bit hacky, should use separate align values for x and y */
408 float width, ascender;
410 const int font_size = data->label_size / aspect;
412 BLF_enable(fontid, BLF_ASPECT);
413 BLF_aspect(fontid, aspect, aspect, 1.0f);
414 BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
417 UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
419 width = BLF_width(fontid, label);
420 ascender = BLF_ascender(fontid);
422 /* 'x' doesn't need aspect correction */
423 x = BLI_rctf_cent_x(rct) - (0.5f * width);
424 y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
426 BLF_position(fontid, x, y, 0);
427 BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
429 BLF_disable(fontid, BLF_ASPECT);
432 static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode,
433 bNodeTree *UNUSED(ntree), bNode *node, bNodeInstanceKey UNUSED(key))
435 rctf *rct = &node->totr;
436 int color_id = node_get_colorid(node);
437 unsigned char color[4];
440 /* skip if out of view */
441 if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
442 uiEndBlock(C, node->block);
447 UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
448 alpha = (float)(color[3]) / 255.0f;
451 node_draw_shadow(snode, node, BASIS_RAD, alpha);
454 if (node->flag & NODE_CUSTOM_COLOR)
455 glColor4f(node->color[0], node->color[1], node->color[2], alpha);
457 UI_ThemeColor4(TH_NODE_FRAME);
459 uiSetRoundBox(UI_CNR_ALL);
460 uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
463 /* outline active and selected emphasis */
464 if (node->flag & SELECT) {
466 glEnable(GL_LINE_SMOOTH);
468 if (node->flag & NODE_ACTIVE)
469 UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
471 UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40);
472 uiSetRoundBox(UI_CNR_ALL);
473 uiDrawBox(GL_LINE_LOOP,
474 rct->xmin, rct->ymin,
475 rct->xmax, rct->ymax, BASIS_RAD);
477 glDisable(GL_LINE_SMOOTH);
482 node_draw_frame_label(node, snode->aspect);
484 UI_ThemeClearColor(color_id);
486 uiEndBlock(C, node->block);
487 uiDrawBlock(C, node->block);
491 static int node_resize_area_frame(bNode *node, int x, int y)
493 const float size = 10.0f;
494 NodeFrame *data = (NodeFrame *)node->storage;
495 rctf totr = node->totr;
498 /* shrinking frame size is determined by child nodes */
499 if (!(data->flag & NODE_FRAME_RESIZEABLE))
502 if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
503 dir |= NODE_RESIZE_RIGHT;
504 if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
505 dir |= NODE_RESIZE_LEFT;
506 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
507 dir |= NODE_RESIZE_TOP;
508 if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
509 dir |= NODE_RESIZE_BOTTOM;
514 static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
516 uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
517 uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
521 #define NODE_REROUTE_SIZE 8.0f
523 static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
527 float size = NODE_REROUTE_SIZE;
529 /* get "global" coords */
530 node_to_view(node, 0.0f, 0.0f, &locx, &locy);
532 /* reroute node has exactly one input and one output, both in the same place */
533 nsock = node->outputs.first;
537 nsock = node->inputs.first;
541 node->width = size * 2;
542 node->totr.xmin = locx - size;
543 node->totr.xmax = locx + size;
544 node->totr.ymax = locy + size;
545 node->totr.ymin = locy - size;
548 static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode),
549 bNodeTree *ntree, bNode *node, bNodeInstanceKey UNUSED(key))
552 char showname[128]; /* 128 used below */
553 rctf *rct = &node->totr;
556 float size = NODE_REROUTE_SIZE;
558 float socket_size = NODE_SOCKSIZE;
560 /* skip if out of view */
561 if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
562 node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax)
564 uiEndBlock(C, node->block);
569 /* XXX only kept for debugging
570 * selection state is indicated by socket outline below!
575 UI_ThemeColor4(TH_NODE);
577 uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
580 /* outline active and selected emphasis */
581 if (node->flag & SELECT) {
583 glEnable(GL_LINE_SMOOTH);
584 /* using different shades of TH_TEXT_HI for the empasis, like triangle */
585 if (node->flag & NODE_ACTIVE)
586 UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
588 UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
589 uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
591 glDisable(GL_LINE_SMOOTH);
596 if (node->label[0] != '\0') {
597 /* draw title (node label) */
598 BLI_strncpy(showname, node->label, sizeof(showname));
599 uiDefBut(node->block, LABEL, 0, showname,
600 (int)(rct->xmin - NODE_DYS), (int)(rct->ymax),
601 (short)512, (short)NODE_DY,
602 NULL, 0, 0, 0, 0, NULL);
605 /* only draw input socket. as they all are placed on the same position.
606 * highlight also if node itself is selected, since we don't display the node body separately!
608 for (sock = node->inputs.first; sock; sock = sock->next) {
609 node_socket_circle_draw(C, ntree, node, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT));
612 uiEndBlock(C, node->block);
613 uiDrawBlock(C, node->block);
617 /* Special tweak area for reroute node.
618 * Since this node is quite small, we use a larger tweak area for grabbing than for selection.
620 static int node_tweak_area_reroute(bNode *node, int x, int y)
622 /* square of tweak radius */
623 static const float tweak_radius_sq = 576; /* 24 * 24 */
625 bNodeSocket *sock = node->inputs.first;
626 float dx = sock->locx - x;
627 float dy = sock->locy - y;
628 return (dx * dx + dy * dy <= tweak_radius_sq);
631 static void node_common_set_butfunc(bNodeType *ntype)
633 switch (ntype->type) {
635 ntype->uifunc = node_uifunc_group;
638 ntype->drawfunc = node_draw_frame;
639 ntype->drawupdatefunc = node_update_frame;
640 ntype->uifuncbut = node_buts_frame_details;
641 ntype->resize_area_func = node_resize_area_frame;
644 ntype->drawfunc = node_draw_reroute;
645 ntype->drawupdatefunc = node_update_reroute;
646 ntype->tweak_area_func = node_tweak_area_reroute;
651 /* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
653 static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
654 PointerRNA *imaptr, PointerRNA *iuserptr)
662 col = uiLayoutColumn(layout, FALSE);
664 uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
666 source = RNA_enum_get(imaptr, "source");
668 if (source == IMA_SRC_SEQUENCE) {
669 /* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
670 Scene *scene = CTX_data_scene(C);
671 ImageUser *iuser = iuserptr->data;
673 const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
674 BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
675 uiItemL(layout, numstr, ICON_NONE);
678 if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
679 col = uiLayoutColumn(layout, TRUE);
680 uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
681 uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
682 uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
683 uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
684 uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
687 col = uiLayoutColumn(layout, FALSE);
689 if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
690 uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
693 static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
695 bNode *node = ptr->data;
698 uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
700 if (!node->id) return;
702 col = uiLayoutColumn(layout, FALSE);
703 uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
704 uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
705 uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
708 static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
712 uiItemL(layout, IFACE_("Location:"), ICON_NONE);
713 row = uiLayoutRow(layout, TRUE);
714 uiItemR(row, ptr, "translation", 0, "", ICON_NONE);
716 uiItemL(layout, IFACE_("Rotation:"), ICON_NONE);
717 row = uiLayoutRow(layout, TRUE);
718 uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
720 uiItemL(layout, IFACE_("Scale:"), ICON_NONE);
721 row = uiLayoutRow(layout, TRUE);
722 uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
724 row = uiLayoutRow(layout, TRUE);
725 uiItemR(row, ptr, "use_min", 0, IFACE_("Min"), ICON_NONE);
726 uiItemR(row, ptr, "min", 0, "", ICON_NONE);
728 row = uiLayoutRow(layout, TRUE);
729 uiItemR(row, ptr, "use_max", 0, IFACE_("Max"), ICON_NONE);
730 uiItemR(row, ptr, "max", 0, "", ICON_NONE);
733 static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
735 uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
738 static void node_shader_buts_vect_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
740 uiItemR(layout, ptr, "type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
741 uiItemR(layout, ptr, "convert_from", 0, "", ICON_NONE);
742 uiItemR(layout, ptr, "convert_to", 0, "", ICON_NONE);
745 static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
747 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
750 col = uiLayoutColumn(layout, FALSE);
752 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
753 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
755 uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
756 uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
759 uiItemR(col, ptr, "uv_layer", 0, IFACE_("UV"), ICON_NONE);
760 uiItemR(col, ptr, "color_layer", 0, IFACE_("VCol"), ICON_NONE);
764 static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
766 uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
769 static void node_shader_buts_wireframe(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
771 uiItemR(layout, ptr, "use_pixel_size", 0, NULL, 0);
774 static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
776 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
777 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
779 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
780 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
781 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
783 if (RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX) {
784 uiItemR(layout, ptr, "projection_blend", 0, "Blend", ICON_NONE);
787 /* note: image user properties used directly here, unlike compositor image node,
788 * which redefines them in the node struct RNA to get proper updates.
790 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
793 static void node_shader_buts_tex_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
795 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
796 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
799 static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
801 PointerRNA imaptr = RNA_pointer_get(ptr, "image");
802 PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
804 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
805 uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
806 uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
808 node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
811 static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
813 uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
814 uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
817 static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
819 uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
822 static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
824 uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
827 static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
831 col = uiLayoutColumn(layout, TRUE);
832 uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
833 uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
835 col = uiLayoutColumn(layout, TRUE);
836 uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
837 uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
840 static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
842 uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
845 static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
847 uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
850 static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
852 uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
855 static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
857 uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
860 static void node_shader_buts_bump(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
862 uiItemR(layout, ptr, "invert", 0, NULL, 0);
865 static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
867 uiItemR(layout, ptr, "space", 0, "", 0);
869 if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
870 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
872 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
873 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
874 uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
877 uiItemR(layout, ptr, "uv_map", 0, "", 0);
881 static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
883 uiLayout *split, *row;
885 split = uiLayoutSplit(layout, 0.0f, FALSE);
887 uiItemR(split, ptr, "direction_type", 0, "", 0);
889 row = uiLayoutRow(split, FALSE);
891 if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
892 PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
894 if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
895 PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
896 uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
899 uiItemR(row, ptr, "uv_map", 0, "", 0);
902 uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
905 static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
907 uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
910 static void node_shader_buts_subsurface(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
912 uiItemR(layout, ptr, "falloff", 0, "", ICON_NONE);
915 static void node_shader_buts_toon(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
917 uiItemR(layout, ptr, "component", 0, "", ICON_NONE);
920 static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
924 row = uiLayoutRow(layout, FALSE);
925 uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
927 row = uiLayoutRow(layout, TRUE);
929 if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
930 uiItemR(row, ptr, "script", 0, "", ICON_NONE);
932 uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
934 uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
937 static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
941 node_shader_buts_script(layout, C, ptr);
943 #if 0 /* not implemented yet */
944 if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
945 uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);
949 /* only once called */
950 static void node_shader_set_butfunc(bNodeType *ntype)
952 switch (ntype->type) {
953 case SH_NODE_MATERIAL:
954 case SH_NODE_MATERIAL_EXT:
955 ntype->uifunc = node_shader_buts_material;
957 case SH_NODE_TEXTURE:
958 ntype->uifunc = node_buts_texture;
961 ntype->uifunc = node_buts_normal;
963 case SH_NODE_CURVE_VEC:
964 ntype->uifunc = node_buts_curvevec;
966 case SH_NODE_CURVE_RGB:
967 ntype->uifunc = node_buts_curvecol;
969 case SH_NODE_MAPPING:
970 ntype->uifunc = node_shader_buts_mapping;
973 ntype->uifunc = node_buts_value;
976 ntype->uifunc = node_buts_rgb;
978 case SH_NODE_MIX_RGB:
979 ntype->uifunc = node_buts_mix_rgb;
981 case SH_NODE_VALTORGB:
982 ntype->uifunc = node_buts_colorramp;
985 ntype->uifunc = node_buts_math;
987 case SH_NODE_VECT_MATH:
988 ntype->uifunc = node_shader_buts_vect_math;
990 case SH_NODE_VECT_TRANSFORM:
991 ntype->uifunc = node_shader_buts_vect_transform;
993 case SH_NODE_GEOMETRY:
994 ntype->uifunc = node_shader_buts_geometry;
996 case SH_NODE_ATTRIBUTE:
997 ntype->uifunc = node_shader_buts_attribute;
999 case SH_NODE_WIREFRAME:
1000 ntype->uifunc = node_shader_buts_wireframe;
1002 case SH_NODE_TEX_SKY:
1003 ntype->uifunc = node_shader_buts_tex_sky;
1005 case SH_NODE_TEX_IMAGE:
1006 ntype->uifunc = node_shader_buts_tex_image;
1007 ntype->uifuncbut = node_shader_buts_tex_image_details;
1009 case SH_NODE_TEX_ENVIRONMENT:
1010 ntype->uifunc = node_shader_buts_tex_environment;
1012 case SH_NODE_TEX_GRADIENT:
1013 ntype->uifunc = node_shader_buts_tex_gradient;
1015 case SH_NODE_TEX_MAGIC:
1016 ntype->uifunc = node_shader_buts_tex_magic;
1018 case SH_NODE_TEX_BRICK:
1019 ntype->uifunc = node_shader_buts_tex_brick;
1021 case SH_NODE_TEX_WAVE:
1022 ntype->uifunc = node_shader_buts_tex_wave;
1024 case SH_NODE_TEX_MUSGRAVE:
1025 ntype->uifunc = node_shader_buts_tex_musgrave;
1027 case SH_NODE_TEX_VORONOI:
1028 ntype->uifunc = node_shader_buts_tex_voronoi;
1030 case SH_NODE_TEX_COORD:
1031 ntype->uifunc = node_shader_buts_tex_coord;
1034 ntype->uifunc = node_shader_buts_bump;
1036 case SH_NODE_NORMAL_MAP:
1037 ntype->uifunc = node_shader_buts_normal_map;
1039 case SH_NODE_TANGENT:
1040 ntype->uifunc = node_shader_buts_tangent;
1042 case SH_NODE_BSDF_GLOSSY:
1043 case SH_NODE_BSDF_GLASS:
1044 case SH_NODE_BSDF_REFRACTION:
1045 ntype->uifunc = node_shader_buts_glossy;
1047 case SH_NODE_SUBSURFACE_SCATTERING:
1048 ntype->uifunc = node_shader_buts_subsurface;
1050 case SH_NODE_BSDF_TOON:
1051 ntype->uifunc = node_shader_buts_toon;
1053 case SH_NODE_SCRIPT:
1054 ntype->uifunc = node_shader_buts_script;
1055 ntype->uifuncbut = node_shader_buts_script_details;
1060 /* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
1062 static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1064 bNode *node = ptr->data;
1065 PointerRNA imaptr, iuserptr;
1067 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1069 if (!node->id) return;
1071 imaptr = RNA_pointer_get(ptr, "image");
1072 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1074 node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1077 static void node_composit_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1079 bNode *node = ptr->data;
1080 PointerRNA iuserptr;
1082 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1083 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
1086 static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
1088 bNode *node = ptr->data;
1089 uiLayout *col, *row;
1093 const char *layer_name;
1094 char scene_name[MAX_ID_NAME - 2];
1095 wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
1097 BLI_assert(ot != 0);
1099 uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
1101 if (!node->id) return;
1103 col = uiLayoutColumn(layout, FALSE);
1104 row = uiLayoutRow(col, TRUE);
1105 uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
1107 prop = RNA_struct_find_property(ptr, "layer");
1108 if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
1111 scn_ptr = RNA_pointer_get(ptr, "scene");
1112 RNA_string_get(&scn_ptr, "name", scene_name);
1114 WM_operator_properties_create_ptr(&op_ptr, ot);
1115 RNA_string_set(&op_ptr, "layer", layer_name);
1116 RNA_string_set(&op_ptr, "scene", scene_name);
1117 uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
1122 static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1124 uiLayout *col, *row;
1128 col = uiLayoutColumn(layout, FALSE);
1129 filter = RNA_enum_get(ptr, "filter_type");
1130 reference = RNA_boolean_get(ptr, "use_variable_size");
1132 uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE);
1133 if (filter != R_FILTER_FAST_GAUSS) {
1134 uiItemR(col, ptr, "use_variable_size", 0, NULL, ICON_NONE);
1136 uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
1138 uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1141 uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
1143 if (RNA_boolean_get(ptr, "use_relative")) {
1144 uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE);
1145 row = uiLayoutRow(layout, TRUE);
1146 uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1148 col = uiLayoutColumn(layout, TRUE);
1149 uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE);
1150 uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE);
1153 col = uiLayoutColumn(layout, TRUE);
1154 uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE);
1155 uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE);
1159 static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1163 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1164 uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
1166 col = uiLayoutColumn(layout, TRUE);
1167 uiItemL(col, IFACE_("Center:"), ICON_NONE);
1168 uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE);
1169 uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE);
1173 col = uiLayoutColumn(layout, TRUE);
1174 uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
1175 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1179 uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE);
1180 uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE);
1183 static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1187 col = uiLayoutColumn(layout, TRUE);
1188 uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
1189 uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
1190 uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
1193 static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1195 uiLayout *sub, *col;
1197 col = uiLayoutColumn(layout, FALSE);
1198 uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE);
1199 uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
1200 uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1202 uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1204 col = uiLayoutColumn(layout, FALSE);
1205 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE);
1206 uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE);
1208 uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
1209 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1211 col = uiLayoutColumn(layout, FALSE);
1212 uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
1214 col = uiLayoutColumn(layout, FALSE);
1215 uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
1216 sub = uiLayoutColumn(col, FALSE);
1217 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE);
1218 uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE);
1221 /* qdn: glare node */
1222 static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1224 uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
1225 uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
1227 if (RNA_enum_get(ptr, "glare_type") != 1) {
1228 uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1230 if (RNA_enum_get(ptr, "glare_type") != 0)
1231 uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1234 uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
1235 uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1237 if (RNA_enum_get(ptr, "glare_type") == 2) {
1238 uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
1239 uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
1241 if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
1242 uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1244 if (RNA_enum_get(ptr, "glare_type") == 0)
1245 uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
1247 if (RNA_enum_get(ptr, "glare_type") == 1) {
1248 uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
1252 static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1256 col = uiLayoutColumn(layout, FALSE);
1257 uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
1258 if (RNA_enum_get(ptr, "tonemap_type") == 0) {
1259 uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1260 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1261 uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
1264 uiItemR(col, ptr, "intensity", 0, NULL, ICON_NONE);
1265 uiItemR(col, ptr, "contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1266 uiItemR(col, ptr, "adaptation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1267 uiItemR(col, ptr, "correction", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1271 static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1275 col = uiLayoutColumn(layout, FALSE);
1276 uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE);
1278 col = uiLayoutColumn(col, FALSE);
1279 uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE);
1280 uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE);
1281 uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE);
1284 static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1288 col = uiLayoutColumn(layout, FALSE);
1289 uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
1290 uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE);
1292 col = uiLayoutColumn(layout, TRUE);
1293 uiItemL(col, IFACE_("Speed:"), ICON_NONE);
1294 uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE);
1295 uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE);
1297 uiItemR(layout, ptr, "use_curved", 0, NULL, ICON_NONE);
1300 static void node_composit_buts_filter(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1302 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1305 static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1307 uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
1310 static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1314 uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE);
1315 uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE);
1317 col = uiLayoutColumn(layout, TRUE);
1318 if (RNA_boolean_get(ptr, "relative")) {
1319 uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE);
1320 uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE);
1321 uiItemR(col, ptr, "rel_min_y", 0, IFACE_("Up"), ICON_NONE);
1322 uiItemR(col, ptr, "rel_max_y", 0, IFACE_("Down"), ICON_NONE);
1325 uiItemR(col, ptr, "min_x", 0, IFACE_("Left"), ICON_NONE);
1326 uiItemR(col, ptr, "max_x", 0, IFACE_("Right"), ICON_NONE);
1327 uiItemR(col, ptr, "min_y", 0, IFACE_("Up"), ICON_NONE);
1328 uiItemR(col, ptr, "max_y", 0, IFACE_("Down"), ICON_NONE);
1332 static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1334 uiLayout *row, *col;
1336 col = uiLayoutColumn(layout, FALSE);
1337 row = uiLayoutRow(col, FALSE);
1338 uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1339 uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
1342 static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1346 col = uiLayoutColumn(layout, FALSE);
1348 uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE);
1349 uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
1350 uiItemL(col, IFACE_("Buffer Edge:"), ICON_NONE);
1351 uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
1354 static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1358 col = uiLayoutColumn(layout, TRUE);
1359 uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
1362 static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1364 uiLayout *sub, *col;
1366 col = uiLayoutColumn(layout, TRUE);
1367 uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1368 uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
1370 col = uiLayoutColumn(layout, TRUE);
1371 uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
1372 sub = uiLayoutColumn(col, FALSE);
1373 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
1374 uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
1376 col = uiLayoutColumn(layout, TRUE);
1377 uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
1378 sub = uiLayoutColumn(col, FALSE);
1379 uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
1380 uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
1383 static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1387 col = uiLayoutColumn(layout, TRUE);
1388 uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
1389 uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
1392 static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1396 col = uiLayoutColumn(layout, TRUE);
1397 uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
1398 uiItemR(col, ptr, "use_antialias_z", 0, NULL, ICON_NONE);
1402 static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1406 col = uiLayoutColumn(layout, FALSE);
1407 uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1408 uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1409 uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1412 static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1414 uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
1415 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1416 switch (RNA_enum_get(ptr, "mode")) {
1417 case CMP_NODE_DILATEERODE_DISTANCE_THRESH:
1418 uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
1420 case CMP_NODE_DILATEERODE_DISTANCE_FEATHER:
1421 uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE);
1426 static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1428 uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
1431 static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1435 col = uiLayoutColumn(layout, FALSE);
1436 uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1437 uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE);
1440 static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1444 col = uiLayoutColumn(layout, TRUE);
1445 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1446 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1449 static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1451 uiLayout *col, *row;
1453 col = uiLayoutColumn(layout, TRUE);
1455 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1456 row = uiLayoutRow(layout, FALSE);
1457 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1459 uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1460 uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1463 static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1465 uiLayout *row, *col;
1467 uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE);
1468 row = uiLayoutRow(layout, FALSE);
1469 uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1471 col = uiLayoutColumn(layout, FALSE);
1472 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1474 if (RNA_enum_get(ptr, "limit_method") == 0) {
1475 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1476 row = uiLayoutRow(col, FALSE);
1477 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1480 uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1481 uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE);
1482 if (RNA_boolean_get(ptr, "use_unspill") == TRUE) {
1483 uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1484 uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1485 uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1489 static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1493 col = uiLayoutColumn(layout, FALSE);
1494 uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
1495 uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1497 col = uiLayoutColumn(layout, TRUE);
1498 /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */
1499 uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1500 /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/
1503 static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1507 col = uiLayoutColumn(layout, TRUE);
1508 uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1509 uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1510 uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1513 static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1515 uiLayout *col, *row;
1517 uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
1518 row = uiLayoutRow(layout, FALSE);
1519 uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1521 col = uiLayoutColumn(layout, FALSE);
1522 uiItemL(col, IFACE_("Key Channel:"), ICON_NONE);
1523 row = uiLayoutRow(col, FALSE);
1524 uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1526 col = uiLayoutColumn(layout, FALSE);
1528 uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1529 if (RNA_enum_get(ptr, "limit_method") == 0) {
1530 uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
1531 row = uiLayoutRow(col, FALSE);
1532 uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1535 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1536 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1539 static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1543 col = uiLayoutColumn(layout, TRUE);
1544 uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1545 uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1548 static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1550 uiItemR(layout, ptr, "alpha", 0, NULL, ICON_NONE);
1553 static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1555 uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE);
1556 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
1559 /* draw function for file output node sockets, displays only sub-path and format, no value button */
1560 static void node_draw_input_file_output(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr)
1562 bNodeTree *ntree = ptr->id.data;
1563 bNodeSocket *sock = ptr->data;
1565 PointerRNA inputptr, imfptr;
1568 row = uiLayoutRow(layout, FALSE);
1570 imfptr = RNA_pointer_get(node_ptr, "format");
1571 imtype = RNA_enum_get(&imfptr, "file_format");
1572 if (imtype == R_IMF_IMTYPE_MULTILAYER) {
1573 NodeImageMultiFileSocket *input = sock->storage;
1574 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
1576 uiItemL(row, input->layer, ICON_NONE);
1579 NodeImageMultiFileSocket *input = sock->storage;
1580 PropertyRNA *imtype_prop;
1581 const char *imtype_name;
1583 RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
1585 uiItemL(row, input->path, ICON_NONE);
1587 if (!RNA_boolean_get(&inputptr, "use_node_format"))
1588 imfptr = RNA_pointer_get(&inputptr, "format");
1590 imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
1591 RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
1592 RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
1593 block = uiLayoutGetBlock(row);
1594 uiBlockSetEmboss(block, UI_EMBOSSP);
1595 uiItemL(row, imtype_name, ICON_NONE);
1596 uiBlockSetEmboss(block, UI_EMBOSSN);
1599 static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1601 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1602 int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1605 uiItemL(layout, IFACE_("Path:"), ICON_NONE);
1607 uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
1608 uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1610 static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1612 PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1613 PointerRNA active_input_ptr, op_ptr;
1614 uiLayout *row, *col;
1616 int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1618 node_composit_buts_file_output(layout, C, ptr);
1619 uiTemplateImageSettings(layout, &imfptr, FALSE);
1623 uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
1625 row = uiLayoutRow(layout, FALSE);
1626 col = uiLayoutColumn(row, TRUE);
1628 active_index = RNA_int_get(ptr, "active_input_index");
1629 /* using different collection properties if multilayer format is enabled */
1631 uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "layer_slots", ptr, "active_input_index",
1633 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"),
1634 active_index, &active_input_ptr);
1637 uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "file_slots", ptr, "active_input_index",
1639 RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"),
1640 active_index, &active_input_ptr);
1642 /* XXX collection lookup does not return the ID part of the pointer, setting this manually here */
1643 active_input_ptr.id.data = ptr->id.data;
1645 col = uiLayoutColumn(row, TRUE);
1646 op_ptr = uiItemFullO(col, "NODE_OT_output_file_move_active_socket", "",
1647 ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
1648 RNA_enum_set(&op_ptr, "direction", 1);
1649 op_ptr = uiItemFullO(col, "NODE_OT_output_file_move_active_socket", "",
1650 ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
1651 RNA_enum_set(&op_ptr, "direction", 2);
1653 if (active_input_ptr.data) {
1655 col = uiLayoutColumn(layout, TRUE);
1657 uiItemL(col, IFACE_("Layer:"), ICON_NONE);
1658 row = uiLayoutRow(col, FALSE);
1659 uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE);
1660 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
1661 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
1664 col = uiLayoutColumn(layout, TRUE);
1666 uiItemL(col, IFACE_("File Path:"), ICON_NONE);
1667 row = uiLayoutRow(col, FALSE);
1668 uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
1669 uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
1670 ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
1672 /* format details for individual files */
1673 imfptr = RNA_pointer_get(&active_input_ptr, "format");
1675 col = uiLayoutColumn(layout, TRUE);
1676 uiItemL(col, IFACE_("Format:"), ICON_NONE);
1677 uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE);
1679 col = uiLayoutColumn(layout, FALSE);
1680 uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
1681 uiTemplateImageSettings(col, &imfptr, FALSE);
1686 static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1688 uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
1690 if (RNA_enum_get(ptr, "space") == CMP_SCALE_RENDERPERCENT) {
1692 uiItemR(layout, ptr, "frame_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1693 row = uiLayoutRow(layout, TRUE);
1694 uiItemR(row, ptr, "offset_x", 0, "X", ICON_NONE);
1695 uiItemR(row, ptr, "offset_y", 0, "Y", ICON_NONE);
1699 static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1701 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1704 static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1708 col = uiLayoutColumn(layout, FALSE);
1709 uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
1710 uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
1713 static void node_composit_buts_premulkey(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1715 uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE);
1718 static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1720 uiItemR(layout, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1723 static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1725 uiLayout *split, *col, *row;
1727 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1729 if (RNA_enum_get(ptr, "correction_method") == 0) {
1731 split = uiLayoutSplit(layout, 0.0f, FALSE);
1732 col = uiLayoutColumn(split, FALSE);
1733 uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1);
1734 row = uiLayoutRow(col, FALSE);
1735 uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
1737 col = uiLayoutColumn(split, FALSE);
1738 uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1);
1739 row = uiLayoutRow(col, FALSE);
1740 uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
1742 col = uiLayoutColumn(split, FALSE);
1743 uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1);
1744 row = uiLayoutRow(col, FALSE);
1745 uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
1750 split = uiLayoutSplit(layout, 0.0f, FALSE);
1751 col = uiLayoutColumn(split, FALSE);
1752 uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1);
1753 row = uiLayoutRow(col, FALSE);
1754 uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
1756 col = uiLayoutColumn(split, FALSE);
1757 uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1);
1758 row = uiLayoutRow(col, FALSE);
1759 uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
1761 col = uiLayoutColumn(split, FALSE);
1762 uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1);
1763 row = uiLayoutRow(col, FALSE);
1764 uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
1768 static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1770 uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1772 if (RNA_enum_get(ptr, "correction_method") == 0) {
1774 uiTemplateColorPicker(layout, ptr, "lift", 1, 1, 0, 1);
1775 uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
1777 uiTemplateColorPicker(layout, ptr, "gamma", 1, 1, 1, 1);
1778 uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
1780 uiTemplateColorPicker(layout, ptr, "gain", 1, 1, 1, 1);
1781 uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
1784 uiTemplateColorPicker(layout, ptr, "offset", 1, 1, 0, 1);
1785 uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
1787 uiTemplateColorPicker(layout, ptr, "power", 1, 1, 0, 1);
1788 uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
1790 uiTemplateColorPicker(layout, ptr, "slope", 1, 1, 0, 1);
1791 uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
1796 static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1798 bNode *node = ptr->data;
1799 CurveMapping *cumap = node->storage;
1801 if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
1802 cumap->flag |= CUMA_DRAW_SAMPLE;
1803 copy_v3_v3(cumap->sample, _sample_col);
1806 cumap->flag &= ~CUMA_DRAW_SAMPLE;
1809 uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
1812 static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1814 uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
1817 static void node_composit_buts_movieclip(uiLayout *layout, bContext *C, PointerRNA *ptr)
1819 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1822 static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1824 bNode *node = ptr->data;
1827 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1832 clipptr = RNA_pointer_get(ptr, "clip");
1834 uiTemplateColorspaceSettings(layout, &clipptr, "colorspace_settings");
1837 static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
1839 bNode *node = ptr->data;
1841 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1846 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1849 static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1851 uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
1852 uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE);
1855 static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1857 uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1860 static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
1862 bNode *node = ptr->data;
1864 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1869 uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
1872 static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1876 row = uiLayoutRow(layout, FALSE);
1877 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
1878 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
1879 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
1881 row = uiLayoutRow(layout, FALSE);
1882 uiItemL(row, "", ICON_NONE);
1883 uiItemL(row, IFACE_("Saturation"), ICON_NONE);
1884 uiItemL(row, IFACE_("Contrast"), ICON_NONE);
1885 uiItemL(row, IFACE_("Gamma"), ICON_NONE);
1886 uiItemL(row, IFACE_("Gain"), ICON_NONE);
1887 uiItemL(row, IFACE_("Lift"), ICON_NONE);
1889 row = uiLayoutRow(layout, FALSE);
1890 uiItemL(row, IFACE_("Master"), ICON_NONE);
1891 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
1892 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
1893 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
1894 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
1895 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
1897 row = uiLayoutRow(layout, FALSE);
1898 uiItemL(row, IFACE_("Highlights"), ICON_NONE);
1899 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
1900 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
1901 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
1902 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
1903 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
1905 row = uiLayoutRow(layout, FALSE);
1906 uiItemL(row, IFACE_("Midtones"), ICON_NONE);
1907 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
1908 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
1909 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
1910 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
1911 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
1913 row = uiLayoutRow(layout, FALSE);
1914 uiItemL(row, IFACE_("Shadows"), ICON_NONE);
1915 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
1916 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
1917 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
1918 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
1919 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
1921 row = uiLayoutRow(layout, FALSE);
1922 uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1923 uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1926 static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1930 row = uiLayoutRow(layout, FALSE);
1931 uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
1932 uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
1933 uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
1935 uiItemL(row, IFACE_("Saturation"), ICON_NONE);
1936 uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1937 uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1938 uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1939 uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1941 uiItemL(row, IFACE_("Contrast"), ICON_NONE);
1942 uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1943 uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1944 uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1945 uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1947 uiItemL(row, IFACE_("Gamma"), ICON_NONE);
1948 uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1949 uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1950 uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1951 uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1953 uiItemL(row, IFACE_("Gain"), ICON_NONE);
1954 uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1955 uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1956 uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1957 uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1959 uiItemL(row, IFACE_("Lift"), ICON_NONE);
1960 uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1961 uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1962 uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1963 uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1965 row = uiLayoutRow(layout, FALSE);
1966 uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE);
1967 uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE);
1970 static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1972 uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
1975 static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1979 row = uiLayoutRow(layout, TRUE);
1980 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
1981 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
1983 row = uiLayoutRow(layout, TRUE);
1984 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1985 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1987 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
1988 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
1991 static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1993 uiItemR(layout, ptr, "flaps", 0, NULL, ICON_NONE);
1994 uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
1995 uiItemR(layout, ptr, "rounding", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1996 uiItemR(layout, ptr, "catadioptric", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1997 uiItemR(layout, ptr, "shift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2000 static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2002 uiItemR(layout, ptr, "use_variable_size", 0, NULL, ICON_NONE);
2003 // uiItemR(layout, ptr, "f_stop", 0, NULL, ICON_NONE); // UNUSED
2004 uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
2007 static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2009 // node_composit_backdrop_canvas(snode, backdrop, node, x, y);
2010 if (node->custom1 == 0) {
2011 const float backdropWidth = backdrop->x;
2012 const float backdropHeight = backdrop->y;
2013 const float cx = x + snode->zoom * backdropWidth * node->custom3;
2014 const float cy = y + snode->zoom * backdropHeight * node->custom4;
2016 glColor3f(1.0, 1.0, 1.0);
2019 glVertex2f(cx - 25, cy - 25);
2020 glVertex2f(cx + 25, cy + 25);
2021 glVertex2f(cx + 25, cy - 25);
2022 glVertex2f(cx - 25, cy + 25);
2027 static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2029 NodeBoxMask *boxmask = node->storage;
2030 const float backdropWidth = backdrop->x;
2031 const float backdropHeight = backdrop->y;
2032 const float aspect = backdropWidth / backdropHeight;
2033 const float rad = DEG2RADF(-boxmask->rotation);
2034 const float cosine = cosf(rad);
2035 const float sine = sinf(rad);
2036 const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
2037 const float halveBoxHeight = backdropHeight * (boxmask->height / 2.0f) * aspect;
2039 float cx, cy, x1, x2, x3, x4;
2040 float y1, y2, y3, y4;
2043 glColor3f(1.0, 1.0, 1.0);
2045 cx = x + snode->zoom * backdropWidth * boxmask->x;
2046 cy = y + snode->zoom * backdropHeight * boxmask->y;
2048 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2049 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2050 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2051 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2052 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2053 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2054 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2055 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2057 glBegin(GL_LINE_LOOP);
2065 static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2067 NodeEllipseMask *ellipsemask = node->storage;
2068 const float backdropWidth = backdrop->x;
2069 const float backdropHeight = backdrop->y;
2070 const float aspect = backdropWidth / backdropHeight;
2071 const float rad = DEG2RADF(-ellipsemask->rotation);
2072 const float cosine = cosf(rad);
2073 const float sine = sinf(rad);
2074 const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
2075 const float halveBoxHeight = backdropHeight * (ellipsemask->height / 2.0f) * aspect;
2077 float cx, cy, x1, x2, x3, x4;
2078 float y1, y2, y3, y4;
2081 glColor3f(1.0, 1.0, 1.0);
2083 cx = x + snode->zoom * backdropWidth * ellipsemask->x;
2084 cy = y + snode->zoom * backdropHeight * ellipsemask->y;
2086 x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2087 x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2088 x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2089 x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2090 y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2091 y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2092 y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2093 y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2095 glBegin(GL_LINE_LOOP);
2104 static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2107 row = uiLayoutRow(layout, TRUE);
2108 uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2109 uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2110 row = uiLayoutRow(layout, TRUE);
2111 uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2112 uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2114 uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2115 uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2118 static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2120 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2123 static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2125 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2128 static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2132 uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2133 uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
2134 if (RNA_enum_get(ptr, "tile_order") == 0) {
2135 col = uiLayoutColumn(layout, TRUE);
2136 uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
2137 uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
2141 static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
2143 bNode *node = ptr->data;
2145 uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
2146 uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
2147 uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
2149 uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
2151 if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
2152 uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
2153 uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
2156 uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
2157 if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
2158 uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
2159 uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
2163 static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
2165 bNode *node = ptr->data;
2167 uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
2170 MovieClip *clip = (MovieClip *) node->id;
2172 PointerRNA tracking_ptr;
2174 RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
2176 col = uiLayoutColumn(layout, TRUE);
2177 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2181 static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2183 /* bNode *node = ptr->data; */ /* UNUSED */
2185 uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
2186 uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
2187 uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
2188 uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
2189 uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
2190 uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
2191 uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
2192 uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE);
2193 uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE);
2194 uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE);
2195 uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE);
2196 uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
2199 static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
2201 bNode *node = ptr->data;
2203 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2206 MovieClip *clip = (MovieClip *) node->id;
2207 MovieTracking *tracking = &clip->tracking;
2208 MovieTrackingObject *object;
2210 PointerRNA tracking_ptr;
2211 NodeTrackPosData *data = node->storage;
2213 RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2215 col = uiLayoutColumn(layout, FALSE);
2216 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2218 object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2220 PointerRNA object_ptr;
2222 RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2224 uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
2227 uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
2230 uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
2232 if (ELEM(node->custom1, CMP_TRACKPOS_RELATIVE_FRAME, CMP_TRACKPOS_ABSOLUTE_FRAME)) {
2233 uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
2238 static void node_composit_buts_planetrackdeform(uiLayout *layout, bContext *C, PointerRNA *ptr)
2240 bNode *node = ptr->data;
2242 uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2245 MovieClip *clip = (MovieClip *) node->id;
2246 MovieTracking *tracking = &clip->tracking;
2247 MovieTrackingObject *object;
2249 PointerRNA tracking_ptr;
2250 NodeTrackPosData *data = node->storage;
2252 RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2254 col = uiLayoutColumn(layout, FALSE);
2255 uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2257 object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2259 PointerRNA object_ptr;
2261 RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2263 uiItemPointerR(col, ptr, "plane_track_name", &object_ptr, "plane_tracks", "", ICON_ANIM_DATA);
2266 uiItemR(layout, ptr, "plane_track_name", 0, "", ICON_ANIM_DATA);
2271 /* only once called */
2272 static void node_composit_set_butfunc(bNodeType *ntype)
2274 switch (ntype->type) {
2275 case CMP_NODE_IMAGE:
2276 ntype->uifunc = node_composit_buts_image;
2277 ntype->uifuncbut = node_composit_buts_image_details;
2279 case CMP_NODE_R_LAYERS:
2280 ntype->uifunc = node_composit_buts_renderlayers;
2282 case CMP_NODE_NORMAL:
2283 ntype->uifunc = node_buts_normal;
2285 case CMP_NODE_CURVE_VEC:
2286 ntype->uifunc = node_buts_curvevec;
2288 case CMP_NODE_CURVE_RGB:
2289 ntype->uifunc = node_buts_curvecol;
2291 case CMP_NODE_VALUE:
2292 ntype->uifunc = node_buts_value;
2295 ntype->uifunc = node_buts_rgb;
2298 ntype->uifunc = node_composit_buts_flip;
2300 case CMP_NODE_SPLITVIEWER:
2301 ntype->uifunc = node_composit_buts_splitviewer;
2303 case CMP_NODE_MIX_RGB:
2304 ntype->uifunc = node_buts_mix_rgb;
2306 case CMP_NODE_VALTORGB:
2307 ntype->uifunc = node_buts_colorramp;
2310 ntype->uifunc = node_composit_buts_crop;
2313 ntype->uifunc = node_composit_buts_blur;
2315 case CMP_NODE_DBLUR:
2316 ntype->uifunc = node_composit_buts_dblur;
2318 case CMP_NODE_BILATERALBLUR:
2319 ntype->uifunc = node_composit_buts_bilateralblur;
2321 case CMP_NODE_DEFOCUS:
2322 ntype->uifunc = node_composit_buts_defocus;
2324 case CMP_NODE_GLARE:
2325 ntype->uifunc = node_composit_buts_glare;
2327 case CMP_NODE_TONEMAP:
2328 ntype->uifunc = node_composit_buts_tonemap;
2330 case CMP_NODE_LENSDIST:
2331 ntype->uifunc = node_composit_buts_lensdist;
2333 case CMP_NODE_VECBLUR:
2334 ntype->uifunc = node_composit_buts_vecblur;
2336 case CMP_NODE_FILTER:
2337 ntype->uifunc = node_composit_buts_filter;
2339 case CMP_NODE_MAP_VALUE:
2340 ntype->uifunc = node_composit_buts_map_value;
2342 case CMP_NODE_MAP_RANGE:
2343 ntype->uifunc = node_composit_buts_map_range;
2346 ntype->uifunc = node_buts_time;
2348 case CMP_NODE_ALPHAOVER:
2349 ntype->uifunc = node_composit_buts_alphaover;
2351 case CMP_NODE_HUE_SAT:
2352 ntype->uifunc = node_composit_buts_hue_sat;
2354 case CMP_NODE_TEXTURE:
2355 ntype->uifunc = node_buts_texture;
2357 case CMP_NODE_DILATEERODE:
2358 ntype->uifunc = node_composit_buts_dilateerode;
2360 case CMP_NODE_INPAINT:
2361 ntype->uifunc = node_composit_buts_inpaint;
2363 case CMP_NODE_DESPECKLE:
2364 ntype->uifunc = node_composit_buts_despeckle;
2366 case CMP_NODE_OUTPUT_FILE:
2367 ntype->uifunc = node_composit_buts_file_output;
2368 ntype->uifuncbut = node_composit_buts_file_output_details;
2369 ntype->drawinputfunc = node_draw_input_file_output;
2371 case CMP_NODE_DIFF_MATTE:
2372 ntype->uifunc = node_composit_buts_diff_matte;
2374 case CMP_NODE_DIST_MATTE:
2375 ntype->uifunc = node_composit_buts_distance_matte;
2377 case CMP_NODE_COLOR_SPILL:
2378 ntype->uifunc = node_composit_buts_color_spill;
2380 case CMP_NODE_CHROMA_MATTE:
2381 ntype->uifunc = node_composit_buts_chroma_matte;
2383 case CMP_NODE_COLOR_MATTE:
2384 ntype->uifunc = node_composit_buts_color_matte;
2386 case CMP_NODE_SCALE:
2387 ntype->uifunc = node_composit_buts_scale;
2389 case CMP_NODE_ROTATE:
2390 ntype->uifunc = node_composit_buts_rotate;
2392 case CMP_NODE_CHANNEL_MATTE:
2393 ntype->uifunc = node_composit_buts_channel_matte;
2395 case CMP_NODE_LUMA_MATTE:
2396 ntype->uifunc = node_composit_buts_luma_matte;
2398 case CMP_NODE_MAP_UV:
2399 ntype->uifunc = node_composit_buts_map_uv;
2401 case CMP_NODE_ID_MASK:
2402 ntype->uifunc = node_composit_buts_id_mask;
2404 case CMP_NODE_DOUBLEEDGEMASK:
2405 ntype->uifunc = node_composit_buts_double_edge_mask;
2408 ntype->uifunc = node_buts_math;
2410 case CMP_NODE_INVERT:
2411 ntype->uifunc = node_composit_buts_invert;
2413 case CMP_NODE_PREMULKEY:
2414 ntype->uifunc = node_composit_buts_premulkey;
2416 case CMP_NODE_VIEW_LEVELS:
2417 ntype->uifunc = node_composit_buts_view_levels;
2419 case CMP_NODE_COLORBALANCE:
2420 ntype->uifunc = node_composit_buts_colorbalance;
2421 ntype->uifuncbut = node_composit_buts_colorbalance_but;
2423 case CMP_NODE_HUECORRECT:
2424 ntype->uifunc = node_composit_buts_huecorrect;
2426 case CMP_NODE_ZCOMBINE:
2427 ntype->uifunc = node_composit_buts_zcombine;
2429 case CMP_NODE_COMBYCCA:
2430 case CMP_NODE_SEPYCCA:
2431 ntype->uifunc = node_composit_buts_ycc;
2433 case CMP_NODE_MOVIECLIP:
2434 ntype->uifunc = node_composit_buts_movieclip;
2435 ntype->uifuncbut = node_composit_buts_movieclip_details;
2437 case CMP_NODE_STABILIZE2D:
2438 ntype->uifunc = node_composit_buts_stabilize2d;
2440 case CMP_NODE_TRANSFORM:
2441 ntype->uifunc = node_composit_buts_transform;
2443 case CMP_NODE_TRANSLATE:
2444 ntype->uifunc = node_composit_buts_translate;
2446 case CMP_NODE_MOVIEDISTORTION:
2447 ntype->uifunc = node_composit_buts_moviedistortion;
2449 case CMP_NODE_COLORCORRECTION:
2450 ntype->uifunc = node_composit_buts_colorcorrection;
2451 ntype->uifuncbut = node_composit_buts_colorcorrection_but;
2453 case CMP_NODE_SWITCH:
2454 ntype->uifunc = node_composit_buts_switch;
2456 case CMP_NODE_MASK_BOX:
2457 ntype->uifunc = node_composit_buts_boxmask;
2458 ntype->uibackdropfunc = node_composit_backdrop_boxmask;
2460 case CMP_NODE_MASK_ELLIPSE:
2461 ntype->uifunc = node_composit_buts_ellipsemask;
2462 ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
2464 case CMP_NODE_BOKEHIMAGE:
2465 ntype->uifunc = node_composit_buts_bokehimage;
2467 case CMP_NODE_BOKEHBLUR:
2468 ntype->uifunc = node_composit_buts_bokehblur;
2470 case CMP_NODE_VIEWER:
2471 ntype->uifunc = node_composit_buts_viewer;
2472 ntype->uifuncbut = node_composit_buts_viewer_but;
2473 ntype->uibackdropfunc = node_composit_backdrop_viewer;
2475 case CMP_NODE_COMPOSITE:
2476 ntype->uifunc = node_composit_buts_composite;
2479 ntype->uifunc = node_composit_buts_mask;
2481 case CMP_NODE_KEYINGSCREEN:
2482 ntype->uifunc = node_composit_buts_keyingscreen;
2484 case CMP_NODE_KEYING:
2485 ntype->uifunc = node_composit_buts_keying;
2487 case CMP_NODE_TRACKPOS:
2488 ntype->uifunc = node_composit_buts_trackpos;
2490 case CMP_NODE_PLANETRACKDEFORM:
2491 ntype->uifunc = node_composit_buts_planetrackdeform;
2496 /* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
2498 static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2502 col = uiLayoutColumn(layout, TRUE);
2503 uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
2504 uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2506 col = uiLayoutColumn(layout, TRUE);
2507 uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
2508 uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2511 static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2514 bNode *node = ptr->data;
2515 ID *id = ptr->id.data;
2516 Tex *tex = (Tex *)node->storage;
2517 uiLayout *col, *row;
2519 RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
2521 col = uiLayoutColumn(layout, FALSE);
2523 switch (tex->type) {
2525 uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
2526 row = uiLayoutRow(col, FALSE);
2527 uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2531 row = uiLayoutRow(col, FALSE);
2532 uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2533 row = uiLayoutRow(col, FALSE);
2534 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2535 row = uiLayoutRow(col, FALSE);
2536 uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2537 row = uiLayoutRow(col, FALSE);
2538 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2542 uiItemR(col, &tex_ptr, "noise_depth", 0, NULL, ICON_NONE);
2546 row = uiLayoutRow(col, FALSE);
2547 uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2548 row = uiLayoutRow(col, FALSE);
2549 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2550 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2554 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2555 uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE);
2556 row = uiLayoutRow(col, FALSE);
2557 uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2558 row = uiLayoutRow(col, FALSE);
2559 uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
2560 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2564 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2565 row = uiLayoutRow(col, FALSE);
2566 uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2567 row = uiLayoutRow(col, FALSE);
2568 uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2569 uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE);
2573 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2574 uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE);
2578 uiItemR(col, &tex_ptr, "musgrave_type", 0, "", ICON_NONE);
2579 uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2582 uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE);
2583 if (tex->vn_distm == TEX_MINKOVSKY) {
2584 uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE);
2586 uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE);
2591 static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
2593 uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
2596 static void node_texture_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
2598 bNode *node = ptr->data;
2599 PointerRNA iuserptr;
2601 RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
2602 uiTemplateImage(layout, C, ptr, "image", &iuserptr, 0);
2605 static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2607 uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
2610 /* only once called */
2611 static void node_texture_set_butfunc(bNodeType *ntype)
2613 if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
2614 ntype->uifunc = node_texture_buts_proc;
2617 switch (ntype->type) {
2620 ntype->uifunc = node_buts_math;
2623 case TEX_NODE_MIX_RGB:
2624 ntype->uifunc = node_buts_mix_rgb;
2627 case TEX_NODE_VALTORGB:
2628 ntype->uifunc = node_buts_colorramp;
2631 case TEX_NODE_CURVE_RGB:
2632 ntype->uifunc = node_buts_curvecol;
2635 case TEX_NODE_CURVE_TIME:
2636 ntype->uifunc = node_buts_time;
2639 case TEX_NODE_TEXTURE:
2640 ntype->uifunc = node_buts_texture;
2643 case TEX_NODE_BRICKS:
2644 ntype->uifunc = node_texture_buts_bricks;
2647 case TEX_NODE_IMAGE:
2648 ntype->uifunc = node_texture_buts_image;
2649 ntype->uifuncbut = node_texture_buts_image_details;
2652 case TEX_NODE_OUTPUT:
2653 ntype->uifunc = node_texture_buts_output;
2659 /* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
2661 static void node_property_update_default(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr)
2663 bNodeTree *ntree = ptr->id.data;
2664 ED_node_tag_update_nodetree(bmain, ntree);
2667 static void node_socket_template_properties_update(bNodeType *ntype, bNodeSocketTemplate *stemp)
2669 StructRNA *srna = ntype->ext.srna;
2670 PropertyRNA *prop = RNA_struct_type_find_property(srna, stemp->identifier);
2673 RNA_def_property_update_runtime(prop, node_property_update_default);
2676 static void node_template_properties_update(bNodeType *ntype)
2678 bNodeSocketTemplate *stemp;
2680 if (ntype->inputs) {
2681 for (stemp = ntype->inputs; stemp->type >= 0; ++stemp)
2682 node_socket_template_properties_update(ntype, stemp);
2684 if (ntype->outputs) {
2685 for (stemp = ntype->outputs; stemp->type >= 0; ++stemp)
2686 node_socket_template_properties_update(ntype, stemp);
2690 static void node_socket_undefined_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr),
2691 const char *UNUSED(text))
2693 uiItemL(layout, "Undefined Socket Type", ICON_ERROR);
2696 static void node_socket_undefined_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), float *r_color)
2704 static void node_socket_undefined_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *UNUSED(ptr))
2706 uiItemL(layout, "Undefined Socket Type", ICON_ERROR);
2709 static void node_socket_undefined_interface_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), float *r_color)
2717 void ED_node_init_butfuncs(void)
2719 /* Fallback types for undefined tree, nodes, sockets
2720 * Defined in blenkernel, but not registered in type hashes.
2722 /*extern bNodeTreeType NodeTreeTypeUndefined;*/
2723 extern bNodeType NodeTypeUndefined;
2724 extern bNodeSocketType NodeSocketTypeUndefined;
2726 /* default ui functions */
2727 NodeTypeUndefined.drawfunc = node_draw_default;
2728 NodeTypeUndefined.drawupdatefunc = node_update_default;
2729 NodeTypeUndefined.select_area_func = node_select_area_default;
2730 NodeTypeUndefined.tweak_area_func = node_tweak_area_default;
2731 NodeTypeUndefined.uifunc = NULL;
2732 NodeTypeUndefined.uifuncbut = NULL;
2733 NodeTypeUndefined.drawinputfunc = node_draw_input_default;
2734 NodeTypeUndefined.drawoutputfunc = node_draw_output_default;
2735 NodeTypeUndefined.resize_area_func = node_resize_area_default;
2737 NodeSocketTypeUndefined.draw = node_socket_undefined_draw;
2738 NodeSocketTypeUndefined.draw_color = node_socket_undefined_draw_color;
2739 NodeSocketTypeUndefined.interface_draw = node_socket_undefined_interface_draw;
2740 NodeSocketTypeUndefined.interface_draw_color = node_socket_undefined_interface_draw_color;
2742 /* node type ui functions */
2743 NODE_TYPES_BEGIN(ntype)
2744 /* default ui functions */
2745 ntype->drawfunc = node_draw_default;
2746 ntype->drawupdatefunc = node_update_default;
2747 ntype->select_area_func = node_select_area_default;
2748 ntype->tweak_area_func = node_tweak_area_default;
2749 ntype->uifunc = NULL;
2750 ntype->uifuncbut = NULL;
2751 ntype->drawinputfunc = node_draw_input_default;
2752 ntype->drawoutputfunc = node_draw_output_default;
2753 ntype->resize_area_func = node_resize_area_default;
2755 node_common_set_butfunc(ntype);
2757 node_composit_set_butfunc(ntype);
2758 node_shader_set_butfunc(ntype);
2759 node_texture_set_butfunc(ntype);
2761 /* define update callbacks for socket properties */
2762 node_template_properties_update(ntype);
2765 /* tree type icons */
2766 ntreeType_Composite->ui_icon = ICON_RENDERLAYERS;
2767 ntreeType_Shader->ui_icon = ICON_MATERIAL;
2768 ntreeType_Texture->ui_icon = ICON_TEXTURE;
2771 void ED_init_custom_node_type(bNodeType *ntype)
2773 /* default ui functions */
2774 ntype->drawfunc = node_draw_default;
2775 ntype->drawupdatefunc = node_update_default;
2776 ntype->drawinputfunc = node_draw_input_default;
2777 ntype->drawoutputfunc = node_draw_output_default;
2778 ntype->resize_area_func = node_resize_area_default;
2779 ntype->select_area_func = node_select_area_default;
2780 ntype->tweak_area_func = node_tweak_area_default;
2783 void ED_init_custom_node_socket_type(bNodeSocketType *stype)
2785 /* default ui functions */
2786 stype->draw = node_socket_button_label;
2789 /* maps standard socket integer type to a color */
2790 static const float std_node_socket_colors[][4] = {
2791 {0.63, 0.63, 0.63, 1.0}, /* SOCK_FLOAT */
2792 {0.39, 0.39, 0.78, 1.0}, /* SOCK_VECTOR */
2793 {0.78, 0.78, 0.16, 1.0}, /* SOCK_RGBA */
2794 {0.39, 0.78, 0.39, 1.0}, /* SOCK_SHADER */
2795 {0.70, 0.65, 0.19, 1.0}, /* SOCK_BOOLEAN */
2796 {0.0, 0.0, 0.0, 1.0}, /*__SOCK_MESH (deprecated) */
2797 {0.06, 0.52, 0.15, 1.0}, /* SOCK_INT */
2798 {1.0, 1.0, 1.0, 1.0}, /* SOCK_STRING */
2801 /* common color callbacks for standard types */
2802 static void std_node_socket_draw_color(bContext *UNUSED(C), PointerRNA *ptr, PointerRNA *UNUSED(node_ptr), float *r_color)
2804 bNodeSocket *sock = ptr->data;
2805 int type = sock->typeinfo->type;
2806 copy_v4_v4(r_color, std_node_socket_colors[type]);
2808 static void std_node_socket_interface_draw_color(bContext *UNUSED(C), PointerRNA *ptr, float *r_color)
2810 bNodeSocket *sock = ptr->data;
2811 int type = sock->typeinfo->type;
2812 copy_v4_v4(r_color, std_node_socket_colors[type]);
2815 static void std_node_socket_draw(bContext *C, uiLayout *layout, PointerRNA *ptr, PointerRNA *node_ptr, const char *text)
2817 bNodeSocket *sock = ptr->data;
2818 int type = sock->typeinfo->type;
2819 /*int subtype = sock->typeinfo->subtype;*/
2821 if ((sock->flag & SOCK_IN_USE) || (sock->flag & SOCK_HIDE_VALUE)) {
2822 node_socket_button_label(C, layout, ptr, node_ptr, text);
2830 uiItemR(layout, ptr, "default_value", 0, text, 0);
2833 uiTemplateComponentMenu(layout, ptr, "default_value", text);
2837 uiLayout *row = uiLayoutRow(layout, false);
2838 uiLayoutSetAlignment(row, UI_LAYOUT_ALIGN_LEFT);
2839 /* draw the socket name right of the actual button */
2840 uiItemR(row, ptr, "default_value", 0, "", 0);
2841 uiItemL(row, text, 0);
2846 uiLayout *row = uiLayoutRow(layout, true);
2847 /* draw the socket name right of the actual button */
2848 uiItemR(row, ptr, "default_value", 0, "", 0);
2849 uiItemL(row, text, 0);
2853 node_socket_button_label(C, layout, ptr, node_ptr, text);
2858 static void std_node_socket_interface_draw(bContext *UNUSED(C), uiLayout *layout, PointerRNA *ptr)
2860 bNodeSocket *sock = ptr->data;
2861 int type = sock->typeinfo->type;
2862 /*int subtype = sock->typeinfo->subtype;*/
2868 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
2869 row = uiLayoutRow(layout, true);
2870 uiItemR(row, ptr, "min_value", 0, "Min", 0);
2871 uiItemR(row, ptr, "max_value", 0, "Max", 0);
2877 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
2878 row = uiLayoutRow(layout, true);
2879 uiItemR(row, ptr, "min_value", 0, "Min", 0);
2880 uiItemR(row, ptr, "max_value", 0, "Max", 0);
2885 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
2891 uiItemR(layout, ptr, "default_value", UI_ITEM_R_EXPAND, NULL, 0);
2892 row = uiLayoutRow(layout, true);
2893 uiItemR(row, ptr, "min_value", 0, "Min", 0);
2894 uiItemR(row, ptr, "max_value", 0, "Max", 0);
2899 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
2904 uiItemR(layout, ptr, "default_value", 0, NULL, 0);
2910 void ED_init_standard_node_socket_type(bNodeSocketType *stype)
2912 stype->draw = std_node_socket_draw;
2913 stype->draw_color = std_node_socket_draw_color;
2914 stype->interface_draw = std_node_socket_interface_draw;
2915 stype->interface_draw_color = std_node_socket_interface_draw_color;
2918 static void node_socket_virtual_draw_color(bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PointerRNA *UNUSED(node_ptr), float *r_color)
2920 /* alpha = 0, empty circle */
2924 void ED_init_node_socket_type_virtual(bNodeSocketType *stype)
2926 stype->draw = node_socket_button_label;
2927 stype->draw_color = node_socket_virtual_draw_color;
2930 /* ************** Generic drawing ************** */
2932 void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeInstanceKey parent_key)
2934 bNodeInstanceKey active_viewer_key = (snode->nodetree ? snode->nodetree->active_viewer_key : NODE_INSTANCE_KEY_NONE);
2939 if (!(snode->flag & SNODE_BACKDRAW) || !ED_node_is_compositor(snode))
2942 if (parent_key.value != active_viewer_key.value)
2945 ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
2946 ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
2950 glMatrixMode(GL_PROJECTION);
2952 glMatrixMode(GL_MODELVIEW);
2955 /* somehow the offset has to be calculated inverse */
2957 glaDefine2DArea(&ar->winrct);
2958 /* ortho at pixel level curarea */
2959 wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
2961 x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
2962 y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
2964 if (ibuf->rect || ibuf->rect_float) {
2965 unsigned char *display_buffer = NULL;
2966 void *cache_handle = NULL;
2968 if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
2971 display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
2973 #ifdef __BIG_ENDIAN__
2974 if (snode->flag & SNODE_SHOW_R) ofs = 2;
2975 else if (snode->flag & SNODE_SHOW_G) ofs = 1;
2978 if (snode->flag & SNODE_SHOW_R) ofs = 1;
2979 else if (snode->flag & SNODE_SHOW_G) ofs = 2;
2983 glPixelZoom(snode->zoom, snode->zoom);
2984 /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
2986 glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
2987 display_buffer + ofs);
2989 glPixelZoom(1.0f, 1.0f);
2991 else if (snode->flag & SNODE_SHOW_ALPHA) {
2992 display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
2994 glPixelZoom(snode->zoom, snode->zoom);
2995 /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
2996 #ifdef __BIG_ENDIAN__
2997 glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
2999 glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
3001 #ifdef __BIG_ENDIAN__
3002 glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
3004 glPixelZoom(1.0f, 1.0f);
3006 else if (snode->flag & SNODE_USE_ALPHA) {
3008 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
3009 glPixelZoom(snode->zoom, snode->zoom);
3011 glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
3013 glPixelZoom(1.0f, 1.0f);
3014 glDisable(GL_BLEND);
3017 glPixelZoom(snode->zoom, snode->zoom);
3019 glaDrawImBuf_glsl_ctx(C, ibuf, x, y, GL_NEAREST);
3021 glPixelZoom(1.0f, 1.0f);
3025 IMB_display_buffer_release(cache_handle);
3028 /** @note draw selected info on backdrop */
3029 if (snode->edittree) {
3030 bNode *node = snode->edittree->nodes.first;
3031 rctf *viewer_border = &snode->nodetree->viewer_border;
3033 if (node->flag & NODE_SELECT) {
3034 if (node->typeinfo->uibackdropfunc) {
3035 node->typeinfo->uibackdropfunc(snode, ibuf, node, x, y);
3041 if ((snode->nodetree->flag & NTREE_VIEWER_BORDER) &&
3042 viewer_border->xmin < viewer_border->xmax &&
3043 viewer_border->ymin < viewer_border->ymax)
3045 glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
3049 glRectf(x + snode->zoom * viewer_border->xmin * ibuf->x,
3050 y + snode->zoom * viewer_border->ymin * ibuf->y,
3051 x + snode->zoom * viewer_border->xmax * ibuf->x,
3052 y + snode->zoom * viewer_border->ymax * ibuf->y);
3055 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
3059 glMatrixMode(GL_PROJECTION);
3061 glMatrixMode(GL_MODELVIEW);
3065 BKE_image_release_ibuf(ima, ibuf, lock);
3069 /* if v2d not NULL, it clips and returns 0 if not visible */
3070 int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
3072 float dist, vec[4][2];
3073 float deltax, deltay;
3074 int toreroute, fromreroute;
3075 /* in v0 and v3 we put begin/end points */
3076 if (link->fromsock) {
3077 vec[0][0] = link->fromsock->locx;
3078 vec[0][1] = link->fromsock->locy;
3079 fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE);
3082 if (snode == NULL) return 0;
3083 copy_v2_v2(vec[0], snode->cursor);
3087 vec[3][0] = link->tosock->locx;
3088 vec[3][1] = link->tosock->locy;
3089 toreroute = (link->tonode && link->tonode->type == NODE_REROUTE);
3092 if (snode == NULL) return 0;
3093 copy_v2_v2(vec[3], snode->cursor);
3097 dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * ABS(vec[0][0] - vec[3][0]);
3098 deltax = vec[3][0] - vec[0][0];
3099 deltay = vec[3][1] - vec[0][1];
3100 /* check direction later, for top sockets */
3102 if (ABS(deltax) > ABS(deltay)) {
3103 vec[1][1] = vec[0][1];
3104 vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist);
3107 vec[1][0] = vec[0][0];
3108 vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist);
3112 vec[1][0] = vec[0][0] + dist;
3113 vec[1][1] = vec[0][1];
3116 if (ABS(deltax) > ABS(deltay)) {
3117 vec[2][1] = vec[3][1];
3118 vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist);
3121 vec[2][0] = vec[3][0];
3122 vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist);
3127 vec[2][0] = vec[3][0] - dist;
3128 vec[2][1] = vec[3][1];
3130 if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {