71
61
#include "WM_api.h"
72
62
#include "WM_types.h"
74
#include "UI_interface.h"
75
64
#include "UI_resources.h"
66
#include "IMB_colormanagement.h"
77
67
#include "IMB_imbuf.h"
78
68
#include "IMB_imbuf_types.h"
80
#include "node_intern.h"
70
#include "node_intern.h" /* own include */
82
72
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
84
74
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
86
SpaceNode *snode= snode_v;
76
SpaceNode *snode = snode_v;
88
if (snode->treetype==NTREE_SHADER) {
78
if (snode->treetype == NTREE_SHADER) {
89
79
nodeShaderSynchronizeID(node_v, 1);
90
80
// allqueue(REDRAWBUTSSHADING, 0);
94
84
static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
95
bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
96
const char *UNUSED(name), int x, int y, int width)
98
uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
101
/* draw function for file output node sockets.
102
* XXX a bit ugly use atm, called from datatype button functions,
103
* since all node types and callbacks only use data type without struct_type.
105
static void node_socket_button_output_file(const bContext *C, uiBlock *block,
106
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
107
const char *UNUSED(name), int x, int y, int width)
109
uiLayout *layout, *row;
110
PointerRNA nodeptr, sockptr, imfptr;
113
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
114
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
116
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
117
row = uiLayoutRow(layout, 0);
119
uiItemL(row, sock->name, 0);
121
imfptr = RNA_pointer_get(&nodeptr, "format");
122
imtype = RNA_enum_get(&imfptr, "file_format");
123
/* in multilayer format all socket format details are ignored */
124
if (imtype != R_IMF_IMTYPE_MULTILAYER) {
125
PropertyRNA *imtype_prop;
126
const char *imtype_name;
128
if (!RNA_boolean_get(&sockptr, "use_node_format"))
129
imfptr = RNA_pointer_get(&sockptr, "format");
131
imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
132
RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
133
uiBlockSetEmboss(block, UI_EMBOSSP);
134
uiItemL(row, imtype_name, 0);
135
uiBlockSetEmboss(block, UI_EMBOSSN);
138
uiBlockLayoutResolve(block, &rx, &ry);
85
bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
86
const char *UNUSED(name), int x, int y, int width)
88
uiDefBut(block, LABEL, 0, IFACE_(sock->name), x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
141
91
static void node_socket_button_default(const bContext *C, uiBlock *block,
142
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
143
const char *name, int x, int y, int width)
145
switch (sock->struct_type) {
146
case SOCK_STRUCT_NONE: {
147
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
148
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
153
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
155
bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
156
x, y+1, width, NODE_DY-2,
157
&ptr, "default_value", 0, 0, 0, -1, -1, NULL);
159
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
92
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
93
const char *name, int x, int y, int width)
95
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
96
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
101
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
103
bt = uiDefButR(block, NUM, B_NODE_EXEC, IFACE_(name),
104
x, y + 1, width, NODE_DY - 2,
105
&ptr, "default_value", 0, 0, 0, -1, -1, NULL);
107
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
111
static void node_socket_button_string(const bContext *C, uiBlock *block,
112
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
113
const char *name, int x, int y, int width)
115
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
116
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
121
SpaceNode *snode = CTX_wm_space_node(C);
122
const char *ui_name = IFACE_(name);
125
UI_ThemeColor(TH_TEXT);
126
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect; /* XXX, check for dpis */
127
while (slen > (width * 0.5f) && *ui_name) {
128
ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
129
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) * snode->aspect;
163
case SOCK_STRUCT_OUTPUT_FILE:
164
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
132
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
137
bt = uiDefButR(block, TEX, B_NODE_EXEC, "",
138
x, y + 1, width - slen, NODE_DY - 2,
139
&ptr, "default_value", 0, 0, 0, -1, -1, "");
141
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
144
uiDefBut(block, LABEL, 0, IFACE_(name), x + (width - slen), y + 2, slen, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
175
154
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
176
155
static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
178
SocketComponentMenuArgs *args= (SocketComponentMenuArgs*)args_v;
157
SocketComponentMenuArgs *args = (SocketComponentMenuArgs *)args_v;
180
159
uiLayout *layout;
182
block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
161
block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
183
162
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
185
layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0);
164
layout = uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
165
args->x, args->y + 2, args->width, NODE_DY, UI_GetStyle()), FALSE);
187
167
uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE);
191
171
static void node_socket_button_components(const bContext *C, uiBlock *block,
192
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
193
const char *name, int x, int y, int width)
172
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
173
const char *name, int x, int y, int width)
195
switch (sock->struct_type) {
196
case SOCK_STRUCT_NONE: {
197
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
198
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
201
SocketComponentMenuArgs *args;
203
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
205
args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
211
args->cb = node_sync_cb;
212
args->arg1 = CTX_wm_space_node(C);
215
uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
219
case SOCK_STRUCT_OUTPUT_FILE:
220
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
175
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
176
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
179
SocketComponentMenuArgs *args;
181
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
183
args = MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
189
args->cb = node_sync_cb;
190
args->arg1 = CTX_wm_space_node(C);
193
uiDefBlockButN(block, socket_component_menu, args, IFACE_(name), x, y + 1, width, NODE_DY - 2, "");
225
197
static void node_socket_button_color(const bContext *C, uiBlock *block,
226
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
227
const char *name, int x, int y, int width)
229
/* XXX would be nicer to have draw function based on sock->struct_type as well,
230
* but currently socket types are completely identified by data type only.
198
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
199
const char *name, int x, int y, int width)
201
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
202
node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
206
int labelw = width - 40;
207
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
209
bt = uiDefButR(block, COLOR, B_NODE_EXEC, "",
210
x, y + 2, (labelw > 0 ? 40 : width), NODE_DY - 2,
211
&ptr, "default_value", -1, 0, 0, -1, -1, NULL);
213
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
215
if (name[0] != '\0' && labelw > 0)
216
uiDefBut(block, LABEL, 0, IFACE_(name), x + 40, y + 2, labelw, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
220
/* standard draw function, display the default input value */
221
static void node_draw_input_default(const bContext *C, uiBlock *block,
222
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
223
const char *name, int x, int y, int width)
225
bNodeSocketType *stype = ntreeGetSocketType(sock->type);
226
if (stype->buttonfunc)
227
stype->buttonfunc(C, block, ntree, node, sock, name, x, y, width);
229
node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
232
static void node_draw_output_default(const bContext *UNUSED(C), uiBlock *block,
233
bNodeTree *UNUSED(ntree), bNode *node, bNodeSocket *sock,
234
const char *name, int UNUSED(x), int UNUSED(y), int UNUSED(width))
236
const char *ui_name = IFACE_(name);
239
UI_ThemeColor(TH_TEXT);
240
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X) ;
241
while (slen > NODE_WIDTH(node) && *ui_name) {
242
ui_name = BLI_str_find_next_char_utf8(ui_name, NULL);
243
slen = (UI_GetStringWidth(ui_name) + NODE_MARGIN_X);
233
switch (sock->struct_type) {
234
case SOCK_STRUCT_NONE: {
235
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
236
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
240
int labelw= width - 40;
241
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
243
bt=uiDefButR(block, COL, B_NODE_EXEC, "",
244
x, y+2, (labelw>0 ? 40 : width), NODE_DY-2,
245
&ptr, "default_value", 0, 0, 0, -1, -1, NULL);
247
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
249
if (name[0]!='\0' && labelw>0)
250
uiDefBut(block, LABEL, 0, name, x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, "");
254
case SOCK_STRUCT_OUTPUT_FILE:
255
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
247
uiDefBut(block, LABEL, 0, ui_name,
248
(int)(sock->locx - slen), (int)(sock->locy - 9.0f),
249
(short)slen, (short)NODE_DY,
250
NULL, 0, 0, 0, 0, "");
870
845
/* group node outline */
871
846
uiSetRoundBox(UI_CNR_ALL);
872
847
glColor4ub(200, 200, 200, 140);
873
glEnable( GL_LINE_SMOOTH );
874
uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD);
875
glDisable( GL_LINE_SMOOTH );
848
glEnable(GL_LINE_SMOOTH);
849
uiDrawBox(GL_LINE_LOOP,
850
rect.xmin - node_group_frame, rect.ymin,
851
rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD);
852
glDisable(GL_LINE_SMOOTH);
876
853
glDisable(GL_BLEND);
878
855
/* backdrop title */
879
856
UI_ThemeColor(TH_TEXT_HI);
881
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header),
882
MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, UI_GetStyle());
858
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL,
859
(int)(rect.xmin + NODE_MARGIN_X), (int)(rect.ymax + (group_header - (2.5f * dpi_fac))),
860
min_ii((int)(BLI_rctf_size_x(&rect) - 18.0f), node_group_frame + 20), group_header, UI_GetStyle());
883
861
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
884
uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL);
862
uiTemplateIDBrowse(layout, (bContext *)C, &ptr, "node_tree", NULL, NULL, NULL);
885
863
uiBlockLayoutResolve(gnode->block, NULL, NULL);
887
865
/* draw the internal tree nodes and links */
888
866
node_draw_nodetree(C, ar, snode, ngroup);
890
868
/* group sockets */
891
gsock=ngroup->inputs.first;
892
sock=gnode->inputs.first;
869
gsock = ngroup->inputs.first;
870
sock = gnode->inputs.first;
894
872
while (gsock || sock) {
895
873
while (sock && !sock->groupsock) {
896
874
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_IN);
897
875
sock = sock->next;
899
while (gsock && (!sock || sock->groupsock!=gsock)) {
877
while (gsock && (!sock || sock->groupsock != gsock)) {
900
878
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN);
901
879
gsock = gsock->next;
904
while (sock && gsock && sock->groupsock==gsock) {
882
while (sock && gsock && sock->groupsock == gsock) {
905
883
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN);
906
884
sock = sock->next;
907
885
gsock = gsock->next;
911
gsock=ngroup->outputs.first;
912
sock=gnode->outputs.first;
889
gsock = ngroup->outputs.first;
890
sock = gnode->outputs.first;
914
892
while (gsock || sock) {
915
893
while (sock && !sock->groupsock) {
916
894
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_OUT);
917
895
sock = sock->next;
919
while (gsock && (!sock || sock->groupsock!=gsock)) {
897
while (gsock && (!sock || sock->groupsock != gsock)) {
920
898
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT);
921
899
gsock = gsock->next;
924
while (sock && gsock && sock->groupsock==gsock) {
902
while (sock && gsock && sock->groupsock == gsock) {
925
903
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT);
926
904
sock = sock->next;
927
905
gsock = gsock->next;
932
910
uiEndBlock(C, gnode->block);
933
911
uiDrawBlock(C, gnode->block);
938
void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
916
static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
940
918
uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
943
static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
945
uiItemR(layout, ptr, "max_iterations", 0, NULL, 0);
948
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
921
/* XXX Does a bounding box update by iterating over all children.
922
* Not ideal to do this in every draw call, but doing as transform callback doesn't work,
923
* since the child node totr rects are not updated properly at that point.
925
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
927
const float margin = 1.5f * U.widget_unit;
928
NodeFrame *data = (NodeFrame *)node->storage;
934
/* init rect from current frame size */
935
node_to_view(node, node->offsetx, node->offsety, &rect.xmin, &rect.ymax);
936
node_to_view(node, node->offsetx + node->width, node->offsety - node->height, &rect.xmax, &rect.ymin);
938
/* frame can be resized manually only if shrinking is disabled or no children are attached */
939
data->flag |= NODE_FRAME_RESIZEABLE;
940
/* for shrinking bbox, initialize the rect from first child node */
941
bbinit = (data->flag & NODE_FRAME_SHRINK);
942
/* fit bounding box to all children */
943
for (tnode = ntree->nodes.first; tnode; tnode = tnode->next) {
944
if (tnode->parent != node)
947
/* add margin to node rect */
948
noderect = tnode->totr;
949
noderect.xmin -= margin;
950
noderect.xmax += margin;
951
noderect.ymin -= margin;
952
noderect.ymax += margin;
954
/* first child initializes frame */
958
data->flag &= ~NODE_FRAME_RESIZEABLE;
961
BLI_rctf_union(&rect, &noderect);
964
/* now adjust the frame size from view-space bounding box */
965
node_from_view(node, rect.xmin, rect.ymax, &node->offsetx, &node->offsety);
966
node_from_view(node, rect.xmax, rect.ymin, &xmax, &ymax);
967
node->width = xmax - node->offsetx;
968
node->height = -ymax + node->offsety;
973
static void node_draw_frame_label(bNode *node, const float aspect)
975
/* XXX font id is crap design */
976
const int fontid = UI_GetStyle()->widgetlabel.uifont_id;
977
NodeFrame *data = (NodeFrame *)node->storage;
978
rctf *rct = &node->totr;
979
int color_id = node_get_colorid(node);
980
const char *label = nodeLabel(node);
981
/* XXX a bit hacky, should use separate align values for x and y */
982
float width, ascender;
984
const int font_size = data->label_size / aspect;
986
BLF_enable(fontid, BLF_ASPECT);
987
BLF_aspect(fontid, aspect, aspect, 1.0f);
988
BLF_size(fontid, MIN2(24, font_size), U.dpi); /* clamp otherwise it can suck up a LOT of memory */
991
UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
993
width = BLF_width(fontid, label);
994
ascender = BLF_ascender(fontid);
996
/* 'x' doesn't need aspect correction */
997
x = BLI_rctf_cent_x(rct) - (0.5f * width);
998
y = rct->ymax - (((NODE_DY / 4) / aspect) + (ascender * aspect));
1000
BLF_position(fontid, x, y, 0);
1001
BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
1003
BLF_disable(fontid, BLF_ASPECT);
1006
static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *UNUSED(ntree), bNode *node)
1008
rctf *rct = &node->totr;
1009
int color_id = node_get_colorid(node);
1010
unsigned char color[4];
1013
/* skip if out of view */
1014
if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
1015
uiEndBlock(C, node->block);
1020
UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
1021
alpha = (float)(color[3]) / 255.0f;
1024
node_draw_shadow(snode, node, BASIS_RAD, alpha);
1027
if (node->flag & NODE_CUSTOM_COLOR)
1028
glColor4f(node->color[0], node->color[1], node->color[2], alpha);
1030
UI_ThemeColor4(TH_NODE_FRAME);
1032
uiSetRoundBox(UI_CNR_ALL);
1033
uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
1034
glDisable(GL_BLEND);
1036
/* outline active and selected emphasis */
1037
if (node->flag & SELECT) {
1039
glEnable(GL_LINE_SMOOTH);
1041
if (node->flag & NODE_ACTIVE)
1042
UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
1044
UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40);
1045
uiSetRoundBox(UI_CNR_ALL);
1046
uiDrawBox(GL_LINE_LOOP,
1047
rct->xmin, rct->ymin,
1048
rct->xmax, rct->ymax, BASIS_RAD);
1050
glDisable(GL_LINE_SMOOTH);
1051
glDisable(GL_BLEND);
1055
node_draw_frame_label(node, snode->aspect);
1057
UI_ThemeClearColor(color_id);
1059
uiEndBlock(C, node->block);
1060
uiDrawBlock(C, node->block);
1064
static int node_resize_area_frame(bNode *node, int x, int y)
1066
const float size = 10.0f;
1067
NodeFrame *data = (NodeFrame *)node->storage;
1068
rctf totr = node->totr;
1071
/* shrinking frame size is determined by child nodes */
1072
if (!(data->flag & NODE_FRAME_RESIZEABLE))
1075
if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
1076
dir |= NODE_RESIZE_RIGHT;
1077
if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
1078
dir |= NODE_RESIZE_LEFT;
1079
if (x >= totr.xmin && x < totr.xmax && y >= totr.ymax - size && y < totr.ymax)
1080
dir |= NODE_RESIZE_TOP;
1081
if (x >= totr.xmin && x < totr.xmax && y >= totr.ymin && y < totr.ymin + size)
1082
dir |= NODE_RESIZE_BOTTOM;
1087
static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1089
uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
1090
uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
1094
#define NODE_REROUTE_SIZE 8.0f
1096
static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
950
1099
float locx, locy;
1100
float size = NODE_REROUTE_SIZE;
952
1102
/* get "global" coords */
953
nodeSpaceCoords(node, &locx, &locy);
955
node->prvr.xmin = locx + NODE_DYS;
956
node->prvr.xmax = locx + node->width- NODE_DYS;
958
node->totr.xmin = locx;
959
node->totr.xmax = locx + node->width;
960
node->totr.ymax = locy;
961
node->totr.ymin = locy - node->height;
1103
node_to_view(node, 0.0f, 0.0f, &locx, &locy);
1105
/* reroute node has exactly one input and one output, both in the same place */
1106
nsock = node->outputs.first;
1110
nsock = node->inputs.first;
1114
node->width = size * 2;
1115
node->totr.xmin = locx - size;
1116
node->totr.xmax = locx + size;
1117
node->totr.ymax = locy + size;
1118
node->totr.ymin = locy - size;
1121
static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode), bNodeTree *ntree, bNode *node)
1124
char showname[128]; /* 128 used below */
1125
rctf *rct = &node->totr;
1128
float size = NODE_REROUTE_SIZE;
1130
float socket_size = NODE_SOCKSIZE;
1132
/* skip if out of view */
1133
if (node->totr.xmax < ar->v2d.cur.xmin || node->totr.xmin > ar->v2d.cur.xmax ||
1134
node->totr.ymax < ar->v2d.cur.ymin || node->totr.ymin > ar->v2d.cur.ymax) {
1136
uiEndBlock(C, node->block);
1141
/* XXX only kept for debugging
1142
* selection state is indicated by socket outline below!
1147
UI_ThemeColor4(TH_NODE);
1149
uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
1150
glDisable(GL_BLEND);
1152
/* outline active and selected emphasis */
1153
if (node->flag & SELECT) {
1155
glEnable(GL_LINE_SMOOTH);
1156
/* using different shades of TH_TEXT_HI for the empasis, like triangle */
1157
if (node->flag & NODE_ACTIVE)
1158
UI_ThemeColorShadeAlpha(TH_TEXT_HI, 0, -40);
1160
UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
1161
uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
1163
glDisable(GL_LINE_SMOOTH);
1164
glDisable(GL_BLEND);
1168
if (node->label[0] != '\0') {
1169
/* draw title (node label) */
1170
BLI_strncpy(showname, node->label, sizeof(showname));
1171
uiDefBut(node->block, LABEL, 0, showname,
1172
(int)(rct->xmin - NODE_DYS), (int)(rct->ymax),
1173
(short)512, (short)NODE_DY,
1174
NULL, 0, 0, 0, 0, NULL);
1177
/* only draw input socket. as they all are placed on the same position.
1178
* highlight also if node itself is selected, since we don't display the node body separately!
1180
for (sock = node->inputs.first; sock; sock = sock->next) {
1181
node_socket_circle_draw(ntree, sock, socket_size, (sock->flag & SELECT) || (node->flag & SELECT));
1184
uiEndBlock(C, node->block);
1185
uiDrawBlock(C, node->block);
1189
/* Special tweak area for reroute node.
1190
* Since this node is quite small, we use a larger tweak area for grabbing than for selection.
1192
static int node_tweak_area_reroute(bNode *node, int x, int y)
1194
/* square of tweak radius */
1195
static const float tweak_radius_sq = 576; /* 24 * 24 */
1197
bNodeSocket *sock = node->inputs.first;
1198
float dx = sock->locx - x;
1199
float dy = sock->locy - y;
1200
return (dx * dx + dy * dy <= tweak_radius_sq);
964
1203
static void node_common_set_butfunc(bNodeType *ntype)
966
switch(ntype->type) {
1205
switch (ntype->type) {
967
1206
case NODE_GROUP:
968
ntype->uifunc= node_uifunc_group;
969
ntype->drawfunc= node_draw_group;
970
ntype->drawupdatefunc= node_update_group;
973
// ntype->uifunc= node_common_buts_group;
974
ntype->drawfunc= node_draw_group;
975
ntype->drawupdatefunc= node_update_group;
978
ntype->uifunc= node_common_buts_whileloop;
979
ntype->drawfunc= node_draw_group;
980
ntype->drawupdatefunc= node_update_group;
1207
ntype->uifunc = node_uifunc_group;
1208
ntype->drawfunc = node_draw_group;
1209
ntype->drawupdatefunc = node_update_group;
982
1211
case NODE_FRAME:
983
ntype->drawupdatefunc= node_update_frame;
1212
ntype->drawfunc = node_draw_frame;
1213
ntype->drawupdatefunc = node_update_frame;
1214
ntype->uifuncbut = node_buts_frame_details;
1215
ntype->resize_area_func = node_resize_area_frame;
1218
ntype->drawfunc = node_draw_reroute;
1219
ntype->drawupdatefunc = node_update_reroute;
1220
ntype->tweak_area_func = node_tweak_area_reroute;
988
1225
/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
990
static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v)
1227
static void node_buts_image_user(uiLayout *layout, bContext *C, PointerRNA *ptr,
1228
PointerRNA *imaptr, PointerRNA *iuserptr)
992
Main *bmain= CTX_data_main(C);
993
bNodeTree *ntree= ntree_v;
995
/* ID *oldid; */ /* UNUSED */
997
if (node->menunr<1) return;
1002
/* oldid= node->id; */ /* UNUSED */
1003
node->id= BLI_findlink(&bmain->text, node->menunr-1);
1004
id_us_plus(node->id);
1005
BLI_strncpy(node->name, node->id->name+2, sizeof(node->name));
1007
node->custom1= BSET(node->custom1, NODE_DYNAMIC_NEW);
1009
nodeSetActive(ntree, node);
1011
// allqueue(REDRAWBUTSSHADING, 0);
1012
// allqueue(REDRAWNODE, 0);
1236
col = uiLayoutColumn(layout, FALSE);
1238
uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
1240
source = RNA_enum_get(imaptr, "source");
1242
if (source == IMA_SRC_SEQUENCE) {
1243
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
1244
Scene *scene = CTX_data_scene(C);
1245
ImageUser *iuser = iuserptr->data;
1247
const int framenr = BKE_image_user_frame_get(iuser, CFRA, 0, NULL);
1248
BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr);
1249
uiItemL(layout, numstr, ICON_NONE);
1252
if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
1253
col = uiLayoutColumn(layout, TRUE);
1254
uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
1255
uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
1256
uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
1257
uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
1258
uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
1261
col = uiLayoutColumn(layout, FALSE);
1263
if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
1264
uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
1017
1267
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
1019
bNode *node= ptr->data;
1269
bNode *node = ptr->data;
1022
1272
uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
1024
1274
if (!node->id) return;
1026
col= uiLayoutColumn(layout, 0);
1276
col = uiLayoutColumn(layout, FALSE);
1027
1277
uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
1028
1278
uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
1029
1279
uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
1128
1408
uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
1411
static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1413
uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
1416
static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
1418
uiItemR(layout, ptr, "space", 0, "", 0);
1420
if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
1421
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
1423
if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
1424
PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
1425
uiItemPointerR(layout, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
1428
uiItemR(layout, ptr, "uv_map", 0, "", 0);
1432
static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
1434
uiLayout *split, *row;
1436
split = uiLayoutSplit(layout, 0.0f, FALSE);
1438
uiItemR(split, ptr, "direction_type", 0, "", 0);
1440
row = uiLayoutRow(split, FALSE);
1442
if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
1443
PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
1445
if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
1446
PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
1447
uiItemPointerR(row, ptr, "uv_map", &dataptr, "uv_textures", "", ICON_NONE);
1450
uiItemR(row, ptr, "uv_map", 0, "", 0);
1453
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
1131
1456
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1133
1458
uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
1136
static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
1138
Main *bmain= CTX_data_main(C);
1139
uiBlock *block= uiLayoutAbsoluteBlock(layout);
1140
bNode *node= ptr->data;
1141
bNodeTree *ntree= ptr->id.data;
1142
rctf *butr= &node->butr;
1144
// XXX SpaceNode *snode= curarea->spacedata.first;
1145
short dy= (short)butr->ymin;
1148
/* B_NODE_EXEC is handled in butspace.c do_node_buts */
1151
IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL);
1153
bt= uiDefButS(block, MENU, B_NODE_EXEC/*+node->nr*/, strp,
1154
butr->xmin, dy, 19, 19,
1155
&node->menunr, 0, 0, 0, 0, "Browses existing choices");
1156
uiButSetFunc(bt, node_browse_text_cb, ntree, node);
1158
if (strp) MEM_freeN((void *)strp);
1161
bt = uiDefBut(block, BUT, B_NOP, "Update",
1162
butr->xmin+xoff, butr->ymin+20, 50, 19,
1163
&node->menunr, 0.0, 19.0, 0, 0, "Refresh this node (and all others that use the same script)");
1164
uiButSetFunc(bt, node_dynamic_update_cb, ntree, node);
1166
if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) {
1167
// UI_ThemeColor(TH_REDALERT);
1168
// XXX ui_rasterpos_safe(butr->xmin + xoff, butr->ymin + 5, snode->aspect);
1169
// XXX snode_drawstring(snode, "Error! Check console...", butr->xmax - butr->xmin);
1461
static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1465
row = uiLayoutRow(layout, FALSE);
1466
uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1468
row = uiLayoutRow(layout, TRUE);
1470
if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
1471
uiItemR(row, ptr, "script", 0, "", ICON_NONE);
1473
uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
1475
uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
1478
static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1482
node_shader_buts_script(layout, C, ptr);
1484
#if 0 /* not implemented yet */
1485
if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_EXTERNAL)
1486
uiItemR(layout, ptr, "use_auto_update", 0, NULL, ICON_NONE);
1175
1490
/* only once called */
1176
1491
static void node_shader_set_butfunc(bNodeType *ntype)
1178
ntype->uifuncbut = NULL;
1179
switch(ntype->type) {
1180
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
1493
switch (ntype->type) {
1494
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
1182
1496
case SH_NODE_MATERIAL:
1183
1497
case SH_NODE_MATERIAL_EXT:
1184
ntype->uifunc= node_shader_buts_material;
1498
ntype->uifunc = node_shader_buts_material;
1186
1500
case SH_NODE_TEXTURE:
1187
ntype->uifunc= node_buts_texture;
1501
ntype->uifunc = node_buts_texture;
1189
1503
case SH_NODE_NORMAL:
1190
ntype->uifunc= node_buts_normal;
1504
ntype->uifunc = node_buts_normal;
1192
1506
case SH_NODE_CURVE_VEC:
1193
ntype->uifunc= node_buts_curvevec;
1507
ntype->uifunc = node_buts_curvevec;
1195
1509
case SH_NODE_CURVE_RGB:
1196
ntype->uifunc= node_buts_curvecol;
1510
ntype->uifunc = node_buts_curvecol;
1198
1512
case SH_NODE_MAPPING:
1199
ntype->uifunc= node_shader_buts_mapping;
1513
ntype->uifunc = node_shader_buts_mapping;
1201
1515
case SH_NODE_VALUE:
1202
ntype->uifunc= node_buts_value;
1516
ntype->uifunc = node_buts_value;
1204
1518
case SH_NODE_RGB:
1205
ntype->uifunc= node_buts_rgb;
1519
ntype->uifunc = node_buts_rgb;
1207
1521
case SH_NODE_MIX_RGB:
1208
ntype->uifunc= node_buts_mix_rgb;
1522
ntype->uifunc = node_buts_mix_rgb;
1210
1524
case SH_NODE_VALTORGB:
1211
ntype->uifunc= node_buts_colorramp;
1525
ntype->uifunc = node_buts_colorramp;
1213
1527
case SH_NODE_MATH:
1214
ntype->uifunc= node_buts_math;
1528
ntype->uifunc = node_buts_math;
1216
1530
case SH_NODE_VECT_MATH:
1217
ntype->uifunc= node_shader_buts_vect_math;
1531
ntype->uifunc = node_shader_buts_vect_math;
1219
1533
case SH_NODE_GEOMETRY:
1220
ntype->uifunc= node_shader_buts_geometry;
1534
ntype->uifunc = node_shader_buts_geometry;
1222
1536
case SH_NODE_ATTRIBUTE:
1223
ntype->uifunc= node_shader_buts_attribute;
1537
ntype->uifunc = node_shader_buts_attribute;
1225
1539
case SH_NODE_TEX_SKY:
1226
ntype->uifunc= node_shader_buts_tex_sky;
1540
ntype->uifunc = node_shader_buts_tex_sky;
1228
1542
case SH_NODE_TEX_IMAGE:
1229
ntype->uifunc= node_shader_buts_tex_image;
1543
ntype->uifunc = node_shader_buts_tex_image;
1231
1545
case SH_NODE_TEX_ENVIRONMENT:
1232
ntype->uifunc= node_shader_buts_tex_environment;
1546
ntype->uifunc = node_shader_buts_tex_environment;
1234
1548
case SH_NODE_TEX_GRADIENT:
1235
ntype->uifunc= node_shader_buts_tex_gradient;
1549
ntype->uifunc = node_shader_buts_tex_gradient;
1237
1551
case SH_NODE_TEX_MAGIC:
1238
ntype->uifunc= node_shader_buts_tex_magic;
1552
ntype->uifunc = node_shader_buts_tex_magic;
1554
case SH_NODE_TEX_BRICK:
1555
ntype->uifunc = node_shader_buts_tex_brick;
1240
1557
case SH_NODE_TEX_WAVE:
1241
ntype->uifunc= node_shader_buts_tex_wave;
1558
ntype->uifunc = node_shader_buts_tex_wave;
1243
1560
case SH_NODE_TEX_MUSGRAVE:
1244
ntype->uifunc= node_shader_buts_tex_musgrave;
1561
ntype->uifunc = node_shader_buts_tex_musgrave;
1246
1563
case SH_NODE_TEX_VORONOI:
1247
ntype->uifunc= node_shader_buts_tex_voronoi;
1564
ntype->uifunc = node_shader_buts_tex_voronoi;
1566
case SH_NODE_TEX_COORD:
1567
ntype->uifunc = node_shader_buts_tex_coord;
1569
case SH_NODE_NORMAL_MAP:
1570
ntype->uifunc = node_shader_buts_normal_map;
1572
case SH_NODE_TANGENT:
1573
ntype->uifunc = node_shader_buts_tangent;
1249
1575
case SH_NODE_BSDF_GLOSSY:
1250
1576
case SH_NODE_BSDF_GLASS:
1251
ntype->uifunc= node_shader_buts_glossy;
1577
case SH_NODE_BSDF_REFRACTION:
1578
ntype->uifunc = node_shader_buts_glossy;
1254
ntype->uifunc= node_shader_buts_dynamic;
1580
case SH_NODE_SCRIPT:
1581
ntype->uifunc = node_shader_buts_script;
1582
ntype->uifuncbut = node_shader_buts_script_details;
1257
if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
1260
1587
/* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
1262
1589
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1265
bNode *node= ptr->data;
1591
bNode *node = ptr->data;
1592
PointerRNA imaptr, iuserptr;
1594
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1596
if (!node->id) return;
1598
imaptr = RNA_pointer_get(ptr, "image");
1599
RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
1601
node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
1604
static void node_composit_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1606
bNode *node = ptr->data;
1266
1607
PointerRNA imaptr;
1270
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1272
if (!node->id) return;
1274
prop = RNA_struct_find_property(ptr, "image");
1275
if (!prop || RNA_property_type(prop) != PROP_POINTER) return;
1276
imaptr= RNA_property_pointer_get(ptr, prop);
1278
col= uiLayoutColumn(layout, 0);
1280
uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
1282
source= RNA_enum_get(&imaptr, "source");
1284
if (source == IMA_SRC_SEQUENCE) {
1285
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
1286
Scene *scene= CTX_data_scene(C);
1287
ImageUser *iuser= node->storage;
1289
const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0);
1290
BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr);
1291
uiItemL(layout, numstr, ICON_NONE);
1294
if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
1295
col= uiLayoutColumn(layout, 1);
1296
uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
1297
uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
1298
uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
1299
uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
1300
uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
1303
col= uiLayoutColumn(layout, 0);
1305
if (RNA_enum_get(&imaptr, "type")== IMA_TYPE_MULTILAYER)
1306
uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
1609
node_composit_buts_image(layout, C, ptr);
1611
uiItemR(layout, ptr, "use_straight_alpha_output", 0, NULL, 0);
1616
imaptr = RNA_pointer_get(ptr, "image");
1618
uiTemplateColorspaceSettings(layout, &imaptr, "colorspace_settings");
1619
uiItemR(layout, &imaptr, "alpha_mode", 0, NULL, 0);
1309
1622
static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
1311
bNode *node= ptr->data;
1624
bNode *node = ptr->data;
1312
1625
uiLayout *col, *row;
1313
1626
PointerRNA op_ptr;
1314
1627
PointerRNA scn_ptr;
1315
1628
PropertyRNA *prop;
1316
1629
const char *layer_name;
1317
char scene_name[MAX_ID_NAME-2];
1630
char scene_name[MAX_ID_NAME - 2];
1318
1631
wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
1320
1633
BLI_assert(ot != 0);
1740
2088
static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1742
2090
uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE);
1743
uiItemR(layout, ptr, "use_smooth_mask", 0, NULL, ICON_NONE);
2091
uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
2094
/* draw function for file output node sockets, displays only sub-path and format, no value button */
2095
static void node_draw_input_file_output(const bContext *C, uiBlock *block,
2096
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
2097
const char *UNUSED(name), int x, int y, int width)
2099
uiLayout *layout, *row;
2100
PointerRNA nodeptr, inputptr, imfptr;
2103
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
2105
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle());
2106
row = uiLayoutRow(layout, FALSE);
2108
imfptr = RNA_pointer_get(&nodeptr, "format");
2109
imtype = RNA_enum_get(&imfptr, "file_format");
2110
if (imtype == R_IMF_IMTYPE_MULTILAYER) {
2111
NodeImageMultiFileSocket *input = sock->storage;
2112
RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotLayer, input, &inputptr);
2114
uiItemL(row, input->layer, ICON_NONE);
2117
NodeImageMultiFileSocket *input = sock->storage;
2118
PropertyRNA *imtype_prop;
2119
const char *imtype_name;
2120
RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
2122
uiItemL(row, input->path, ICON_NONE);
2124
if (!RNA_boolean_get(&inputptr, "use_node_format"))
2125
imfptr = RNA_pointer_get(&inputptr, "format");
2127
imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
2128
RNA_property_enum_name((bContext *)C, &imfptr, imtype_prop,
2129
RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
2130
uiBlockSetEmboss(block, UI_EMBOSSP);
2131
uiItemL(row, imtype_name, ICON_NONE);
2132
uiBlockSetEmboss(block, UI_EMBOSSN);
2135
uiBlockLayoutResolve(block, &rx, &ry);
1746
2137
static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1748
2139
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1749
2140
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1751
2142
if (multilayer)
1752
uiItemL(layout, "Path:", 0);
2143
uiItemL(layout, IFACE_("Path:"), ICON_NONE);
1754
uiItemL(layout, "Base Path:", 0);
2145
uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
1755
2146
uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1757
2148
static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1759
2150
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1760
PointerRNA active_input_ptr = RNA_pointer_get(ptr, "active_input");
2151
PointerRNA active_input_ptr, op_ptr;
2152
uiLayout *row, *col;
1761
2154
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1763
2156
node_composit_buts_file_output(layout, C, ptr);
1764
uiTemplateImageSettings(layout, &imfptr);
2157
uiTemplateImageSettings(layout, &imfptr, FALSE);
1766
2159
uiItemS(layout);
1768
uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
1770
uiTemplateList(layout, C, ptr, "inputs", ptr, "active_input_index", NULL, 0, 0, 0);
2161
uiItemO(layout, IFACE_("Add Input"), ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
2163
row = uiLayoutRow(layout, FALSE);
2164
col = uiLayoutColumn(row, TRUE);
2166
active_index = RNA_int_get(ptr, "active_input_index");
2167
/* using different collection properties if multilayer format is enabled */
2169
uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "layer_slots", ptr, "active_input_index", 0, 0, 0);
2170
RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "layer_slots"),
2171
active_index, &active_input_ptr);
2174
uiTemplateList(col, C, "UI_UL_list", "file_output_node", ptr, "file_slots", ptr, "active_input_index", 0, 0, 0);
2175
RNA_property_collection_lookup_int(ptr, RNA_struct_find_property(ptr, "file_slots"),
2176
active_index, &active_input_ptr);
2178
/* XXX collection lookup does not return the ID part of the pointer, setting this manually here */
2179
active_input_ptr.id.data = ptr->id.data;
2181
col = uiLayoutColumn(row, TRUE);
2182
op_ptr = uiItemFullO(col, "NODE_OT_output_file_move_active_socket", "",
2183
ICON_TRIA_UP, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
2184
RNA_enum_set(&op_ptr, "direction", 1);
2185
op_ptr = uiItemFullO(col, "NODE_OT_output_file_move_active_socket", "",
2186
ICON_TRIA_DOWN, NULL, WM_OP_INVOKE_DEFAULT, UI_ITEM_O_RETURN_PROPS);
2187
RNA_enum_set(&op_ptr, "direction", 2);
1772
2189
if (active_input_ptr.data) {
1773
uiLayout *row, *col;
1775
col = uiLayoutColumn(layout, 1);
1777
uiItemL(col, "Layer Name:", 0);
1779
uiItemL(col, "File Path:", 0);
1780
row = uiLayoutRow(col, 0);
1781
uiItemR(row, &active_input_ptr, "name", 0, "", 0);
1782
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
1784
/* in multilayer format all socket format details are ignored */
2191
col = uiLayoutColumn(layout, TRUE);
2193
uiItemL(col, IFACE_("Layer:"), ICON_NONE);
2194
row = uiLayoutRow(col, FALSE);
2195
uiItemR(row, &active_input_ptr, "name", 0, "", ICON_NONE);
2196
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
2197
ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
2200
col = uiLayoutColumn(layout, TRUE);
2202
uiItemL(col, IFACE_("File Path:"), ICON_NONE);
2203
row = uiLayoutRow(col, FALSE);
2204
uiItemR(row, &active_input_ptr, "path", 0, "", ICON_NONE);
2205
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "",
2206
ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
2208
/* format details for individual files */
1786
2209
imfptr = RNA_pointer_get(&active_input_ptr, "format");
1788
col = uiLayoutColumn(layout, 1);
1789
uiItemL(col, "Format:", 0);
1790
uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0);
2211
col = uiLayoutColumn(layout, TRUE);
2212
uiItemL(col, IFACE_("Format:"), ICON_NONE);
2213
uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, ICON_NONE);
1792
col= uiLayoutColumn(layout, 0);
1793
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format")==0);
1794
uiTemplateImageSettings(col, &imfptr);
2215
col = uiLayoutColumn(layout, FALSE);
2216
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format") == FALSE);
2217
uiTemplateImageSettings(col, &imfptr, FALSE);
1913
2355
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2358
static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
2360
bNode *node = ptr->data;
2363
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2368
clipptr = RNA_pointer_get(ptr, "clip");
2370
uiTemplateColorspaceSettings(layout, &clipptr, "colorspace_settings");
1916
2373
static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
1918
bNode *node= ptr->data;
2375
bNode *node = ptr->data;
1920
2377
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1925
uiItemR(layout, ptr, "filter_type", 0, "", 0);
2382
uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
2385
static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2387
uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
2388
uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE);
1928
2391
static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1930
uiItemR(layout, ptr, "filter_type", 0, "", 0);
2393
uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1933
2396
static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
1935
bNode *node= ptr->data;
2398
bNode *node = ptr->data;
1937
2400
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1942
uiItemR(layout, ptr, "distortion_type", 0, "", 0);
2405
uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
2408
static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2412
row = uiLayoutRow(layout, FALSE);
2413
uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2414
uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2415
uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2417
row = uiLayoutRow(layout, FALSE);
2418
uiItemL(row, "", ICON_NONE);
2419
uiItemL(row, IFACE_("Saturation"), ICON_NONE);
2420
uiItemL(row, IFACE_("Contrast"), ICON_NONE);
2421
uiItemL(row, IFACE_("Gamma"), ICON_NONE);
2422
uiItemL(row, IFACE_("Gain"), ICON_NONE);
2423
uiItemL(row, IFACE_("Lift"), ICON_NONE);
2425
row = uiLayoutRow(layout, FALSE);
2426
uiItemL(row, IFACE_("Master"), ICON_NONE);
2427
uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2428
uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2429
uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2430
uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2431
uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2433
row = uiLayoutRow(layout, FALSE);
2434
uiItemL(row, IFACE_("Highlights"), ICON_NONE);
2435
uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2436
uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2437
uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2438
uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2439
uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2441
row = uiLayoutRow(layout, FALSE);
2442
uiItemL(row, IFACE_("Midtones"), ICON_NONE);
2443
uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2444
uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2445
uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2446
uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2447
uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2449
row = uiLayoutRow(layout, FALSE);
2450
uiItemL(row, IFACE_("Shadows"), ICON_NONE);
2451
uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, "", ICON_NONE);
2452
uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, "", ICON_NONE);
2453
uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, "", ICON_NONE);
2454
uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, "", ICON_NONE);
2455
uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, "", ICON_NONE);
2457
row = uiLayoutRow(layout, FALSE);
2458
uiItemR(row, ptr, "midtones_start", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2459
uiItemR(row, ptr, "midtones_end", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2462
static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2466
row = uiLayoutRow(layout, FALSE);
2467
uiItemR(row, ptr, "red", 0, NULL, ICON_NONE);
2468
uiItemR(row, ptr, "green", 0, NULL, ICON_NONE);
2469
uiItemR(row, ptr, "blue", 0, NULL, ICON_NONE);
2471
uiItemL(row, IFACE_("Saturation"), ICON_NONE);
2472
uiItemR(row, ptr, "master_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2473
uiItemR(row, ptr, "highlights_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2474
uiItemR(row, ptr, "midtones_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2475
uiItemR(row, ptr, "shadows_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2477
uiItemL(row, IFACE_("Contrast"), ICON_NONE);
2478
uiItemR(row, ptr, "master_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2479
uiItemR(row, ptr, "highlights_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2480
uiItemR(row, ptr, "midtones_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2481
uiItemR(row, ptr, "shadows_contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2483
uiItemL(row, IFACE_("Gamma"), ICON_NONE);
2484
uiItemR(row, ptr, "master_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2485
uiItemR(row, ptr, "highlights_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2486
uiItemR(row, ptr, "midtones_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2487
uiItemR(row, ptr, "shadows_gamma", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2489
uiItemL(row, IFACE_("Gain"), ICON_NONE);
2490
uiItemR(row, ptr, "master_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2491
uiItemR(row, ptr, "highlights_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2492
uiItemR(row, ptr, "midtones_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2493
uiItemR(row, ptr, "shadows_gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2495
uiItemL(row, IFACE_("Lift"), ICON_NONE);
2496
uiItemR(row, ptr, "master_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2497
uiItemR(row, ptr, "highlights_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2498
uiItemR(row, ptr, "midtones_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2499
uiItemR(row, ptr, "shadows_lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2501
row = uiLayoutRow(layout, FALSE);
2502
uiItemR(row, ptr, "midtones_start", 0, NULL, ICON_NONE);
2503
uiItemR(row, ptr, "midtones_end", 0, NULL, ICON_NONE);
2506
static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2508
uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
2511
static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2515
row = uiLayoutRow(layout, TRUE);
2516
uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2517
uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2519
row = uiLayoutRow(layout, TRUE);
2520
uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2521
uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2523
uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2524
uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2527
static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2529
uiItemR(layout, ptr, "flaps", 0, NULL, ICON_NONE);
2530
uiItemR(layout, ptr, "angle", 0, NULL, ICON_NONE);
2531
uiItemR(layout, ptr, "rounding", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2532
uiItemR(layout, ptr, "catadioptric", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2533
uiItemR(layout, ptr, "shift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2536
static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2538
uiItemR(layout, ptr, "use_variable_size", 0, NULL, ICON_NONE);
2539
// uiItemR(layout, ptr, "f_stop", 0, NULL, ICON_NONE); // UNUSED
2540
uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
2543
static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2545
// node_composit_backdrop_canvas(snode, backdrop, node, x, y);
2546
if (node->custom1 == 0) {
2547
const float backdropWidth = backdrop->x;
2548
const float backdropHeight = backdrop->y;
2549
const float cx = x + snode->zoom * backdropWidth * node->custom3;
2550
const float cy = y + snode->zoom * backdropHeight * node->custom4;
2552
glColor3f(1.0, 1.0, 1.0);
2555
glVertex2f(cx - 25, cy - 25);
2556
glVertex2f(cx + 25, cy + 25);
2557
glVertex2f(cx + 25, cy - 25);
2558
glVertex2f(cx - 25, cy + 25);
2563
static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2565
NodeBoxMask *boxmask = node->storage;
2566
const float backdropWidth = backdrop->x;
2567
const float backdropHeight = backdrop->y;
2568
const float aspect = backdropWidth / backdropHeight;
2569
const float rad = DEG2RADF(-boxmask->rotation);
2570
const float cosine = cosf(rad);
2571
const float sine = sinf(rad);
2572
const float halveBoxWidth = backdropWidth * (boxmask->width / 2.0f);
2573
const float halveBoxHeight = backdropHeight * (boxmask->height / 2.0f) * aspect;
2575
float cx, cy, x1, x2, x3, x4;
2576
float y1, y2, y3, y4;
2579
/* keep this, saves us from a version patch */
2580
if (snode->zoom == 0.0f) snode->zoom = 1.0f;
2582
glColor3f(1.0, 1.0, 1.0);
2584
cx = x + snode->zoom * backdropWidth * boxmask->x;
2585
cy = y + snode->zoom * backdropHeight * boxmask->y;
2587
x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2588
x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2589
x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2590
x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2591
y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2592
y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2593
y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2594
y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2596
glBegin(GL_LINE_LOOP);
2604
static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
2606
NodeEllipseMask *ellipsemask = node->storage;
2607
const float backdropWidth = backdrop->x;
2608
const float backdropHeight = backdrop->y;
2609
const float aspect = backdropWidth / backdropHeight;
2610
const float rad = DEG2RADF(-ellipsemask->rotation);
2611
const float cosine = cosf(rad);
2612
const float sine = sinf(rad);
2613
const float halveBoxWidth = backdropWidth * (ellipsemask->width / 2.0f);
2614
const float halveBoxHeight = backdropHeight * (ellipsemask->height / 2.0f) * aspect;
2616
float cx, cy, x1, x2, x3, x4;
2617
float y1, y2, y3, y4;
2620
/* keep this, saves us from a version patch */
2621
if (snode->zoom == 0.0f) snode->zoom = 1.0f;
2623
glColor3f(1.0, 1.0, 1.0);
2625
cx = x + snode->zoom * backdropWidth * ellipsemask->x;
2626
cy = y + snode->zoom * backdropHeight * ellipsemask->y;
2628
x1 = cx - (cosine * halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2629
x2 = cx - (cosine * -halveBoxWidth + sine * halveBoxHeight) * snode->zoom;
2630
x3 = cx - (cosine * -halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2631
x4 = cx - (cosine * halveBoxWidth + sine * -halveBoxHeight) * snode->zoom;
2632
y1 = cy - (-sine * halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2633
y2 = cy - (-sine * -halveBoxWidth + cosine * halveBoxHeight) * snode->zoom;
2634
y3 = cy - (-sine * -halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2635
y4 = cy - (-sine * halveBoxWidth + cosine * -halveBoxHeight) * snode->zoom;
2637
glBegin(GL_LINE_LOOP);
2646
static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2649
row = uiLayoutRow(layout, TRUE);
2650
uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
2651
uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
2652
row = uiLayoutRow(layout, TRUE);
2653
uiItemR(row, ptr, "width", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2654
uiItemR(row, ptr, "height", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
2656
uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
2657
uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
2660
static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2662
uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2665
static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2667
uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2670
static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2674
uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
2675
uiItemR(layout, ptr, "tile_order", 0, NULL, ICON_NONE);
2676
if (RNA_enum_get(ptr, "tile_order") == 0) {
2677
col = uiLayoutColumn(layout, TRUE);
2678
uiItemR(col, ptr, "center_x", 0, NULL, ICON_NONE);
2679
uiItemR(col, ptr, "center_y", 0, NULL, ICON_NONE);
2683
static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
2685
bNode *node = ptr->data;
2687
uiTemplateID(layout, C, ptr, "mask", NULL, NULL, NULL);
2688
uiItemR(layout, ptr, "use_antialiasing", 0, NULL, ICON_NONE);
2689
uiItemR(layout, ptr, "use_feather", 0, NULL, ICON_NONE);
2691
uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
2693
if (node->custom1 & (CMP_NODEFLAG_MASK_FIXED | CMP_NODEFLAG_MASK_FIXED_SCENE)) {
2694
uiItemR(layout, ptr, "size_x", 0, NULL, ICON_NONE);
2695
uiItemR(layout, ptr, "size_y", 0, NULL, ICON_NONE);
2698
uiItemR(layout, ptr, "use_motion_blur", 0, NULL, ICON_NONE);
2699
if (node->custom1 & CMP_NODEFLAG_MASK_MOTION_BLUR) {
2700
uiItemR(layout, ptr, "motion_blur_samples", 0, NULL, ICON_NONE);
2701
uiItemR(layout, ptr, "motion_blur_shutter", 0, NULL, ICON_NONE);
2705
static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
2707
bNode *node = ptr->data;
2709
uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
2712
MovieClip *clip = (MovieClip *) node->id;
2714
PointerRNA tracking_ptr;
2716
RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
2718
col = uiLayoutColumn(layout, TRUE);
2719
uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2723
static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2725
/* bNode *node = ptr->data; */ /* UNUSED */
2727
uiItemR(layout, ptr, "blur_pre", 0, NULL, ICON_NONE);
2728
uiItemR(layout, ptr, "screen_balance", 0, NULL, ICON_NONE);
2729
uiItemR(layout, ptr, "despill_factor", 0, NULL, ICON_NONE);
2730
uiItemR(layout, ptr, "despill_balance", 0, NULL, ICON_NONE);
2731
uiItemR(layout, ptr, "edge_kernel_radius", 0, NULL, ICON_NONE);
2732
uiItemR(layout, ptr, "edge_kernel_tolerance", 0, NULL, ICON_NONE);
2733
uiItemR(layout, ptr, "clip_black", 0, NULL, ICON_NONE);
2734
uiItemR(layout, ptr, "clip_white", 0, NULL, ICON_NONE);
2735
uiItemR(layout, ptr, "dilate_distance", 0, NULL, ICON_NONE);
2736
uiItemR(layout, ptr, "feather_falloff", 0, NULL, ICON_NONE);
2737
uiItemR(layout, ptr, "feather_distance", 0, NULL, ICON_NONE);
2738
uiItemR(layout, ptr, "blur_post", 0, NULL, ICON_NONE);
2741
static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
2743
bNode *node = ptr->data;
2745
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
2748
MovieClip *clip = (MovieClip *) node->id;
2749
MovieTracking *tracking = &clip->tracking;
2750
MovieTrackingObject *object;
2752
PointerRNA tracking_ptr;
2753
NodeTrackPosData *data = node->storage;
2755
RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
2757
col = uiLayoutColumn(layout, FALSE);
2758
uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
2760
object = BKE_tracking_object_get_named(tracking, data->tracking_object);
2762
PointerRNA object_ptr;
2764
RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
2766
uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
2769
uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
2772
uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
2774
if (node->custom1 == 2) {
2775
uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
1945
2780
/* only once called */
1946
2781
static void node_composit_set_butfunc(bNodeType *ntype)
1948
ntype->uifuncbut = NULL;
1949
switch(ntype->type) {
1950
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
2783
switch (ntype->type) {
2784
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
1952
2786
case CMP_NODE_IMAGE:
1953
ntype->uifunc= node_composit_buts_image;
2787
ntype->uifunc = node_composit_buts_image;
2788
ntype->uifuncbut = node_composit_buts_image_details;
1955
2790
case CMP_NODE_R_LAYERS:
1956
ntype->uifunc= node_composit_buts_renderlayers;
2791
ntype->uifunc = node_composit_buts_renderlayers;
1958
2793
case CMP_NODE_NORMAL:
1959
ntype->uifunc= node_buts_normal;
2794
ntype->uifunc = node_buts_normal;
1961
2796
case CMP_NODE_CURVE_VEC:
1962
ntype->uifunc= node_buts_curvevec;
2797
ntype->uifunc = node_buts_curvevec;
1964
2799
case CMP_NODE_CURVE_RGB:
1965
ntype->uifunc= node_buts_curvecol;
2800
ntype->uifunc = node_buts_curvecol;
1967
2802
case CMP_NODE_VALUE:
1968
ntype->uifunc= node_buts_value;
2803
ntype->uifunc = node_buts_value;
1970
2805
case CMP_NODE_RGB:
1971
ntype->uifunc= node_buts_rgb;
2806
ntype->uifunc = node_buts_rgb;
1973
2808
case CMP_NODE_FLIP:
1974
ntype->uifunc= node_composit_buts_flip;
2809
ntype->uifunc = node_composit_buts_flip;
1976
2811
case CMP_NODE_SPLITVIEWER:
1977
ntype->uifunc= node_composit_buts_splitviewer;
2812
ntype->uifunc = node_composit_buts_splitviewer;
1979
2814
case CMP_NODE_MIX_RGB:
1980
ntype->uifunc= node_buts_mix_rgb;
2815
ntype->uifunc = node_buts_mix_rgb;
1982
2817
case CMP_NODE_VALTORGB:
1983
ntype->uifunc= node_buts_colorramp;
2818
ntype->uifunc = node_buts_colorramp;
1985
2820
case CMP_NODE_CROP:
1986
ntype->uifunc= node_composit_buts_crop;
2821
ntype->uifunc = node_composit_buts_crop;
1988
2823
case CMP_NODE_BLUR:
1989
ntype->uifunc= node_composit_buts_blur;
2824
ntype->uifunc = node_composit_buts_blur;
1991
2826
case CMP_NODE_DBLUR:
1992
ntype->uifunc= node_composit_buts_dblur;
2827
ntype->uifunc = node_composit_buts_dblur;
1994
2829
case CMP_NODE_BILATERALBLUR:
1995
ntype->uifunc= node_composit_buts_bilateralblur;
2830
ntype->uifunc = node_composit_buts_bilateralblur;
1997
2832
case CMP_NODE_DEFOCUS:
1998
2833
ntype->uifunc = node_composit_buts_defocus;