~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/editors/space_node/drawnode.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
/** \file blender/editors/space_node/drawnode.c
29
29
 *  \ingroup spnode
 
30
 *  \brief lower level node drawing for nodes (boarders, headers etc), also node layout.
30
31
 */
31
32
 
32
 
 
33
 
#include <math.h>
34
 
#include <stdio.h>
35
 
#include <string.h>
36
 
 
37
33
#include "BLI_blenlib.h"
38
34
#include "BLI_math.h"
39
 
#include "BLI_utildefines.h"
40
35
 
41
36
#include "DNA_node_types.h"
42
 
#include "DNA_material_types.h"
43
37
#include "DNA_object_types.h"
44
 
#include "DNA_scene_types.h"
45
38
#include "DNA_space_types.h"
46
39
#include "DNA_screen_types.h"
47
40
 
48
41
#include "BKE_context.h"
49
42
#include "BKE_curve.h"
50
 
#include "BKE_global.h"
51
43
#include "BKE_image.h"
52
 
#include "BKE_library.h"
53
44
#include "BKE_main.h"
54
45
#include "BKE_node.h"
55
 
 
56
 
#include "NOD_composite.h"
57
 
#include "NOD_shader.h"
 
46
#include "BKE_tracking.h"
 
47
 
 
48
#include "BLF_api.h"
 
49
#include "BLF_translation.h"
 
50
 
58
51
 
59
52
#include "BIF_gl.h"
60
53
#include "BIF_glutil.h"
61
54
 
62
 
#include "BLF_api.h"
63
 
 
64
55
#include "MEM_guardedalloc.h"
65
56
 
66
 
 
67
57
#include "RNA_access.h"
68
58
 
69
59
#include "ED_node.h"
71
61
#include "WM_api.h"
72
62
#include "WM_types.h"
73
63
 
74
 
#include "UI_interface.h"
75
64
#include "UI_resources.h"
76
65
 
 
66
#include "IMB_colormanagement.h"
77
67
#include "IMB_imbuf.h"
78
68
#include "IMB_imbuf_types.h"
79
69
 
80
 
#include "node_intern.h"
 
70
#include "node_intern.h"  /* own include */
81
71
 
82
72
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
83
73
 
84
74
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
85
75
{
86
 
        SpaceNode *snode= snode_v;
 
76
        SpaceNode *snode = snode_v;
87
77
        
88
 
        if (snode->treetype==NTREE_SHADER) {
 
78
        if (snode->treetype == NTREE_SHADER) {
89
79
                nodeShaderSynchronizeID(node_v, 1);
90
80
                // allqueue(REDRAWBUTSSHADING, 0);
91
81
        }
92
82
}
93
83
 
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)
97
 
{
98
 
        uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
99
 
}
100
 
 
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.
104
 
 */
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)
108
 
{
109
 
        uiLayout *layout, *row;
110
 
        PointerRNA nodeptr, sockptr, imfptr;
111
 
        int imtype;
112
 
        int rx, ry;
113
 
        RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
114
 
        RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
115
 
        
116
 
        layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
117
 
        row = uiLayoutRow(layout, 0);           
118
 
        
119
 
        uiItemL(row, sock->name, 0);
120
 
        
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;
127
 
                
128
 
                if (!RNA_boolean_get(&sockptr, "use_node_format"))
129
 
                        imfptr = RNA_pointer_get(&sockptr, "format");
130
 
                
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);
136
 
        }
137
 
        
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)
 
87
{
 
88
        uiDefBut(block, LABEL, 0, IFACE_(sock->name), x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
139
89
}
140
90
 
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)
144
 
{
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);
149
 
                else {
150
 
                        PointerRNA ptr;
151
 
                        uiBut *bt;
152
 
                        
153
 
                        RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
154
 
                        
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);
158
 
                        if (node)
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)
 
94
{
 
95
        if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
 
96
                node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
 
97
        else {
 
98
                PointerRNA ptr;
 
99
                uiBut *bt;
 
100
                
 
101
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
 
102
                
 
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);
 
106
                if (node)
 
107
                        uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
 
108
        }
 
109
}
 
110
 
 
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)
 
114
{
 
115
        if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
 
116
                node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
 
117
        else {
 
118
                PointerRNA ptr;
 
119
                uiBut *bt;
 
120
 
 
121
                SpaceNode *snode = CTX_wm_space_node(C);
 
122
                const char *ui_name = IFACE_(name);
 
123
                float slen;
 
124
 
 
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;
160
130
                }
161
 
                break;
162
 
        }
163
 
        case SOCK_STRUCT_OUTPUT_FILE:
164
 
                node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
165
 
                break;
 
131
 
 
132
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
 
133
                
 
134
                if (name[0] == '\0')
 
135
                        slen = 0.0;
 
136
                
 
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, "");
 
140
                if (node)
 
141
                        uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
 
142
                
 
143
                if (slen > 0.0f)
 
144
                        uiDefBut(block, LABEL, 0, IFACE_(name), x + (width - slen), y + 2, slen, NODE_DY - 2, NULL, 0, 0, 0, 0, "");
166
145
        }
167
146
}
168
147
 
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)
177
156
{
178
 
        SocketComponentMenuArgs *args= (SocketComponentMenuArgs*)args_v;
 
157
        SocketComponentMenuArgs *args = (SocketComponentMenuArgs *)args_v;
179
158
        uiBlock *block;
180
159
        uiLayout *layout;
181
160
        
182
 
        block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
 
161
        block = uiBeginBlock(C, ar, __func__, UI_EMBOSS);
183
162
        uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
184
163
        
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);
186
166
        
187
167
        uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE);
188
168
        
189
169
        return block;
190
170
}
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)
194
174
{
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);
199
 
                else {
200
 
                        PointerRNA ptr;
201
 
                        SocketComponentMenuArgs *args;
202
 
                        
203
 
                        RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
204
 
                        
205
 
                        args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
206
 
                        
207
 
                        args->ptr = ptr;
208
 
                        args->x = x;
209
 
                        args->y = y;
210
 
                        args->width = width;
211
 
                        args->cb = node_sync_cb;
212
 
                        args->arg1 = CTX_wm_space_node(C);
213
 
                        args->arg2 = node;
214
 
                        
215
 
                        uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
216
 
                }
217
 
                break;
218
 
        }
219
 
        case SOCK_STRUCT_OUTPUT_FILE:
220
 
                node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
221
 
                break;
 
175
        if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
 
176
                node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
 
177
        else {
 
178
                PointerRNA ptr;
 
179
                SocketComponentMenuArgs *args;
 
180
                
 
181
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
 
182
                
 
183
                args = MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
 
184
                
 
185
                args->ptr = ptr;
 
186
                args->x = x;
 
187
                args->y = y;
 
188
                args->width = width;
 
189
                args->cb = node_sync_cb;
 
190
                args->arg1 = CTX_wm_space_node(C);
 
191
                args->arg2 = node;
 
192
                
 
193
                uiDefBlockButN(block, socket_component_menu, args, IFACE_(name), x, y + 1, width, NODE_DY - 2, "");
222
194
        }
223
195
}
224
196
 
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)
228
 
{
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.
231
 
         */
 
198
                                     bNodeTree *ntree, bNode *node, bNodeSocket *sock,
 
199
                                     const char *name, int x, int y, int width)
 
200
{
 
201
        if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
 
202
                node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
 
203
        else {
 
204
                PointerRNA ptr;
 
205
                uiBut *bt;
 
206
                int labelw = width - 40;
 
207
                RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
 
208
                
 
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);
 
212
                if (node)
 
213
                        uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
 
214
                
 
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, "");
 
217
        }
 
218
}
 
219
 
 
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)
 
224
{
 
225
        bNodeSocketType *stype = ntreeGetSocketType(sock->type);
 
226
        if (stype->buttonfunc)
 
227
                stype->buttonfunc(C, block, ntree, node, sock, name, x, y, width);
 
228
        else
 
229
                node_socket_button_label(C, block, ntree, node, sock, IFACE_(name), x, y, width);
 
230
}
 
231
 
 
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))
 
235
{
 
236
        const char *ui_name = IFACE_(name);
 
237
        float slen;
 
238
 
 
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);
 
244
        }
232
245
        
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);
237
 
                else {
238
 
                        PointerRNA ptr;
239
 
                        uiBut *bt;
240
 
                        int labelw= width - 40;
241
 
                        RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
242
 
                        
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);
246
 
                        if (node)
247
 
                                uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
248
 
                        
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, "");
251
 
                }
252
 
                break;
253
 
        }
254
 
        case SOCK_STRUCT_OUTPUT_FILE:
255
 
                node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
256
 
                break;
 
246
        if (*ui_name) {
 
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, "");
257
251
        }
258
252
}
259
253
 
262
256
#if 0 /* UNUSED */
263
257
static void node_draw_socket_new(bNodeSocket *sock, float size)
264
258
{
265
 
        float x=sock->locx, y=sock->locy;
 
259
        float x = sock->locx, y = sock->locy;
266
260
        
267
261
        /* 16 values of sin function */
268
262
        static float si[16] = {
269
 
                0.00000000f, 0.39435585f,0.72479278f,0.93775213f,
270
 
                0.99871650f,0.89780453f,0.65137248f,0.29936312f,
271
 
                -0.10116832f,-0.48530196f,-0.79077573f,-0.96807711f,
272
 
                -0.98846832f,-0.84864425f,-0.57126821f,-0.20129852f
 
263
                0.00000000f, 0.39435585f, 0.72479278f, 0.93775213f,
 
264
                0.99871650f, 0.89780453f, 0.65137248f, 0.29936312f,
 
265
                -0.10116832f, -0.48530196f, -0.79077573f, -0.96807711f,
 
266
                -0.98846832f, -0.84864425f, -0.57126821f, -0.20129852f
273
267
        };
274
268
        /* 16 values of cos function */
275
 
        static float co[16] ={
276
 
                1.00000000f,0.91895781f,0.68896691f,0.34730525f,
277
 
                -0.05064916f,-0.44039415f,-0.75875812f,-0.95413925f,
278
 
                -0.99486932f,-0.87434661f,-0.61210598f,-0.25065253f,
279
 
                0.15142777f,0.52896401f,0.82076344f,0.97952994f,
 
269
        static float co[16] = {
 
270
                1.00000000f, 0.91895781f, 0.68896691f, 0.34730525f,
 
271
                -0.05064916f, -0.44039415f, -0.75875812f, -0.95413925f,
 
272
                -0.99486932f, -0.87434661f, -0.61210598f, -0.25065253f,
 
273
                0.15142777f, 0.52896401f, 0.82076344f, 0.97952994f,
280
274
        };
281
275
        int a;
282
276
        
283
277
        glColor3ub(180, 180, 180);
284
278
        
285
279
        glBegin(GL_POLYGON);
286
 
        for (a=0; a<16; a++)
287
 
                glVertex2f(x+size*si[a], y+size*co[a]);
 
280
        for (a = 0; a < 16; a++)
 
281
                glVertex2f(x + size * si[a], y + size * co[a]);
288
282
        glEnd();
289
283
        
290
284
        glColor4ub(0, 0, 0, 150);
291
285
        glEnable(GL_BLEND);
292
 
        glEnable( GL_LINE_SMOOTH );
 
286
        glEnable(GL_LINE_SMOOTH);
293
287
        glBegin(GL_LINE_LOOP);
294
 
        for (a=0; a<16; a++)
295
 
                glVertex2f(x+size*si[a], y+size*co[a]);
 
288
        for (a = 0; a < 16; a++)
 
289
                glVertex2f(x + size * si[a], y + size * co[a]);
296
290
        glEnd();
297
 
        glDisable( GL_LINE_SMOOTH );
 
291
        glDisable(GL_LINE_SMOOTH);
298
292
        glDisable(GL_BLEND);
299
293
}
300
294
#endif
323
317
        prop = RNA_struct_find_property(ptr, "outputs");
324
318
        RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
325
319
        
326
 
        col = uiLayoutColumn(layout, 0);
327
 
        uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0);
 
320
        col = uiLayoutColumn(layout, FALSE);
 
321
        uiTemplateColorPicker(col, &sockptr, "default_value", 1, 0, 0, 0);
328
322
        uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
329
323
}
330
324
 
331
325
static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
332
326
{       
333
 
        uiLayout *row;
334
 
 
335
 
        bNodeTree *ntree= (bNodeTree*)ptr->id.data;
336
 
 
337
 
        row= uiLayoutRow(layout, 1);
 
327
        uiLayout *row, *col;
 
328
 
 
329
        bNodeTree *ntree = (bNodeTree *)ptr->id.data;
 
330
 
 
331
        col = uiLayoutColumn(layout, FALSE);
 
332
        row = uiLayoutRow(col, TRUE);
338
333
        uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
339
334
        if (ntree->type == NTREE_COMPOSIT)
340
335
                uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
 
336
 
 
337
        uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
341
338
}
342
339
 
343
340
static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
345
342
        uiLayout *row;
346
343
#if 0
347
344
        /* XXX no context access here .. */
348
 
        bNode *node= ptr->data;
349
 
        CurveMapping *cumap= node->storage;
 
345
        bNode *node = ptr->data;
 
346
        CurveMapping *cumap = node->storage;
350
347
        
351
348
        if (cumap) {
352
349
                cumap->flag |= CUMA_DRAW_CFRA;
353
 
                if (node->custom1<node->custom2)
354
 
                        cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
 
350
                if (node->custom1 < node->custom2)
 
351
                        cumap->sample[0] = (float)(CFRA - node->custom1) / (float)(node->custom2 - node->custom1);
355
352
        }
356
353
#endif
357
354
 
358
355
        uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0);
359
356
 
360
 
        row= uiLayoutRow(layout, 1);
361
 
        uiItemR(row, ptr, "frame_start", 0, "Sta", ICON_NONE);
362
 
        uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE);
 
357
        row = uiLayoutRow(layout, TRUE);
 
358
        uiItemR(row, ptr, "frame_start", 0, IFACE_("Sta"), ICON_NONE);
 
359
        uiItemR(row, ptr, "frame_end", 0, IFACE_("End"), ICON_NONE);
363
360
}
364
361
 
365
362
static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
372
369
        uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
373
370
}
374
371
 
375
 
static float *_sample_col= NULL;        // bad bad, 2.5 will do better?
376
 
#if 0
377
 
static void node_curvemap_sample(float *col)
 
372
#define SAMPLE_FLT_ISNONE FLT_MAX
 
373
static float _sample_col[4] = {SAMPLE_FLT_ISNONE};  /* bad bad, 2.5 will do better?... no it won't... */
 
374
void ED_node_sample_set(const float col[4])
378
375
{
379
 
        _sample_col= col;
 
376
        if (col) {
 
377
                copy_v4_v4(_sample_col, col);
 
378
        }
 
379
        else {
 
380
                copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE);
 
381
        }
380
382
}
381
 
#endif
382
383
 
383
384
static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
384
385
{
385
 
        bNode *node= ptr->data;
386
 
        CurveMapping *cumap= node->storage;
 
386
        bNode *node = ptr->data;
 
387
        CurveMapping *cumap = node->storage;
387
388
 
388
 
        if (_sample_col) {
 
389
        if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
389
390
                cumap->flag |= CUMA_DRAW_SAMPLE;
390
391
                copy_v3_v3(cumap->sample, _sample_col);
391
392
        }
392
 
        else 
 
393
        else {
393
394
                cumap->flag &= ~CUMA_DRAW_SAMPLE;
 
395
        }
394
396
 
395
397
        uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
396
398
}
397
399
 
398
 
static void node_normal_cb(bContext *C, void *ntree_v, void *node_v)
399
 
{
400
 
        Main *bmain = CTX_data_main(C);
401
 
 
402
 
        ED_node_generic_update(bmain, ntree_v, node_v);
403
 
        WM_event_add_notifier(C, NC_NODE|NA_EDITED, ntree_v);
404
 
}
405
 
 
406
400
static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
407
401
{
408
 
        uiBlock *block= uiLayoutAbsoluteBlock(layout);
409
 
        bNodeTree *ntree= ptr->id.data;
410
 
        bNode *node= ptr->data;
411
 
        rctf *butr= &node->butr;
412
 
        bNodeSocket *sock= node->outputs.first;         /* first socket stores normal */
413
 
        float *nor= ((bNodeSocketValueVector*)sock->default_value)->value;
414
 
        uiBut *bt;
415
 
        
416
 
        bt= uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "", 
417
 
                      (short)butr->xmin, (short)butr->xmin,
418
 
                      butr->xmax-butr->xmin, butr->xmax-butr->xmin,
419
 
                      nor, 0.0f, 1.0f, 0, 0, "");
420
 
        uiButSetFunc(bt, node_normal_cb, ntree, node);
 
402
        bNodeTree *ntree = (bNodeTree *)ptr->id.data;
 
403
        bNode *node = (bNode *)ptr->data;
 
404
        bNodeSocket *sock = node->outputs.first;     /* first socket stores normal */
 
405
        PointerRNA sockptr;
 
406
 
 
407
        RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
 
408
        uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
421
409
}
422
 
#if 0 // not used in 2.5x yet
 
410
#if 0 /* not used in 2.5x yet */
423
411
static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
424
412
{
425
 
        Main *bmain= CTX_data_main(C);
426
 
        bNodeTree *ntree= ntree_v;
427
 
        bNode *node= node_v;
 
413
        Main *bmain = CTX_data_main(C);
 
414
        bNodeTree *ntree = ntree_v;
 
415
        bNode *node = node_v;
428
416
        Tex *tex;
429
417
        
430
 
        if (node->menunr<1) return;
 
418
        if (node->menunr < 1) return;
431
419
        
432
420
        if (node->id) {
433
421
                node->id->us--;
434
 
                node->id= NULL;
 
422
                node->id = NULL;
435
423
        }
436
 
        tex= BLI_findlink(&bmain->tex, node->menunr-1);
 
424
        tex = BLI_findlink(&bmain->tex, node->menunr - 1);
437
425
 
438
 
        node->id= &tex->id;
 
426
        node->id = &tex->id;
439
427
        id_us_plus(node->id);
440
 
        BLI_strncpy(node->name, node->id->name+2, sizeof(node->name));
 
428
        BLI_strncpy(node->name, node->id->name + 2, sizeof(node->name));
441
429
        
442
430
        nodeSetActive(ntree, node);
443
431
        
444
 
        if ( ntree->type == NTREE_TEXTURE )
445
 
                ntreeTexCheckCyclics( ntree );
 
432
        if (ntree->type == NTREE_TEXTURE)
 
433
                ntreeTexCheckCyclics(ntree);
446
434
        
447
435
        // allqueue(REDRAWBUTSSHADING, 0);
448
436
        // allqueue(REDRAWNODE, 0);
449
437
        NodeTagChanged(ntree, node); 
450
438
        
451
 
        node->menunr= 0;
 
439
        node->menunr = 0;
452
440
}
453
441
#endif
454
 
static void node_dynamic_update_cb(bContext *C, void *UNUSED(ntree_v), void *node_v)
455
 
{
456
 
        Main *bmain= CTX_data_main(C);
457
 
        Material *ma;
458
 
        bNode *node= (bNode *)node_v;
459
 
        ID *id= node->id;
460
 
        int error= 0;
461
 
 
462
 
        if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) error= 1;
463
 
 
464
 
        /* Users only have to press the "update" button in one pynode
465
 
         * and we also update all others sharing the same script */
466
 
        for (ma= bmain->mat.first; ma; ma= ma->id.next) {
467
 
                if (ma->nodetree) {
468
 
                        bNode *nd;
469
 
                        for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) {
470
 
                                if ((nd->type == NODE_DYNAMIC) && (nd->id == id)) {
471
 
                                        nd->custom1= 0;
472
 
                                        nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_REPARSE);
473
 
                                        nd->menunr= 0;
474
 
                                        if (error)
475
 
                                                nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_ERROR);
476
 
                                }
477
 
                        }
478
 
                }
479
 
        }
480
 
 
481
 
        // allqueue(REDRAWBUTSSHADING, 0);
482
 
        // allqueue(REDRAWNODE, 0);
483
 
        // XXX BIF_preview_changed(ID_MA);
484
 
}
485
442
 
486
443
static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
487
444
{
488
 
        bNode *node= ptr->data;
 
445
        bNode *node = ptr->data;
489
446
 
490
447
        short multi = (
491
 
                node->id &&
492
 
                ((Tex*)node->id)->use_nodes &&
493
 
                (node->type != CMP_NODE_TEXTURE) &&
494
 
                (node->type != TEX_NODE_TEXTURE)
495
 
        );
 
448
            node->id &&
 
449
            ((Tex *)node->id)->use_nodes &&
 
450
            (node->type != CMP_NODE_TEXTURE) &&
 
451
            (node->type != TEX_NODE_TEXTURE)
 
452
            );
496
453
        
497
454
        uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
498
455
        
505
462
static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
506
463
507
464
        uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
 
465
        uiItemR(layout, ptr, "use_clamp", 0, NULL, ICON_NONE);
508
466
}
509
467
 
510
468
static int node_resize_area_default(bNode *node, int x, int y)
511
469
{
512
470
        if (node->flag & NODE_HIDDEN) {
513
 
                rctf totr= node->totr;
 
471
                rctf totr = node->totr;
514
472
                /* right part of node */
515
 
                totr.xmin = node->totr.xmax-20.0f;
516
 
                return BLI_in_rctf(&totr, x, y);
 
473
                totr.xmin = node->totr.xmax - 20.0f;
 
474
                if (BLI_rctf_isect_pt(&totr, x, y))
 
475
                        return NODE_RESIZE_RIGHT;
 
476
                else
 
477
                        return 0;
517
478
        }
518
479
        else {
519
 
                /* rect we're interested in is just the bottom right corner */
520
 
                rctf totr= node->totr;
521
 
                /* bottom right corner */
522
 
                totr.xmin = totr.xmax-10.0f;
523
 
                totr.ymax = totr.ymin+10.0f;
524
 
                return BLI_in_rctf(&totr, x, y);
 
480
                const float size = 10.0f;
 
481
                rctf totr = node->totr;
 
482
                int dir = 0;
 
483
                
 
484
                if (x >= totr.xmax - size && x < totr.xmax && y >= totr.ymin && y < totr.ymax)
 
485
                        dir |= NODE_RESIZE_RIGHT;
 
486
                if (x >= totr.xmin && x < totr.xmin + size && y >= totr.ymin && y < totr.ymax)
 
487
                        dir |= NODE_RESIZE_LEFT;
 
488
                return dir;
525
489
        }
526
490
}
527
491
 
528
492
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
529
493
 
530
494
/* width of socket columns in group display */
531
 
#define NODE_GROUP_FRAME                120
 
495
#define NODE_GROUP_FRAME        120
532
496
 
533
497
/* based on settings in node, sets drawing rect info. each redraw! */
534
498
/* note: this assumes only 1 group at a time is drawn (linked data) */
539
503
                node_update_default(C, ntree, gnode);
540
504
        }
541
505
        else {
542
 
                bNodeTree *ngroup= (bNodeTree *)gnode->id;
 
506
                bNodeTree *ngroup = (bNodeTree *)gnode->id;
543
507
                bNode *node;
544
508
                bNodeSocket *sock, *gsock;
545
509
                float locx, locy;
546
 
                rctf *rect= &gnode->totr;
547
 
                float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
548
 
                float group_header= 26*U.dpi/72;
 
510
                rctf *rect = &gnode->totr;
 
511
                const float dpi_fac = UI_DPI_FAC;
 
512
                const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
 
513
                const float group_header = 26 * dpi_fac;
549
514
                int counter;
550
515
                int dy;
551
516
                
552
517
                /* get "global" coords */
553
 
                nodeSpaceCoords(gnode, &locx, &locy);
 
518
                node_to_view(gnode, 0.0f, 0.0f, &locx, &locy);
554
519
                
555
520
                /* center them, is a bit of abuse of locx and locy though */
556
521
                node_update_nodetree(C, ngroup, locx, locy);
558
523
                rect->xmin = rect->xmax = locx;
559
524
                rect->ymin = rect->ymax = locy;
560
525
                
561
 
                counter= 1;
562
 
                for (node= ngroup->nodes.first; node; node= node->next) {
 
526
                counter = 1;
 
527
                for (node = ngroup->nodes.first; node; node = node->next) {
563
528
                        if (counter) {
564
 
                                *rect= node->totr;
565
 
                                counter= 0;
 
529
                                *rect = node->totr;
 
530
                                counter = 0;
566
531
                        }
567
532
                        else
568
 
                                BLI_union_rctf(rect, &node->totr);
 
533
                                BLI_rctf_union(rect, &node->totr);
569
534
                }
570
535
                
571
536
                /* add some room for links to group sockets */
572
 
                rect->xmin -= 4*NODE_DY;
573
 
                rect->xmax += 4*NODE_DY;
574
 
                rect->ymin-= NODE_DY;
575
 
                rect->ymax+= NODE_DY;
 
537
                rect->xmin -= 4 * NODE_DY;
 
538
                rect->xmax += 4 * NODE_DY;
 
539
                rect->ymin -= NODE_DY;
 
540
                rect->ymax += NODE_DY;
576
541
                
577
542
                /* input sockets */
578
 
                dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->inputs)-1);
579
 
                gsock=ngroup->inputs.first;
580
 
                sock=gnode->inputs.first;
 
543
                dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->inputs) - 1));
 
544
                gsock = ngroup->inputs.first;
 
545
                sock = gnode->inputs.first;
581
546
                while (gsock || sock) {
582
547
                        while (sock && !sock->groupsock) {
583
548
                                sock->locx = rect->xmin - node_group_frame;
584
549
                                sock->locy = dy;
585
550
 
586
551
                                /* prevent long socket lists from growing out of the group box */
587
 
                                if (dy-3*NODE_DYS < rect->ymin)
588
 
                                        rect->ymin = dy-3*NODE_DYS;
589
 
                                if (dy+3*NODE_DYS > rect->ymax)
590
 
                                        rect->ymax = dy+3*NODE_DYS;
591
 
                                dy -= 2*NODE_DY;
 
552
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
553
                                        rect->ymin = dy - 3 * NODE_DYS;
 
554
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
555
                                        rect->ymax = dy + 3 * NODE_DYS;
 
556
                                dy -= 2 * NODE_DY;
592
557
                                
593
558
                                sock = sock->next;
594
559
                        }
595
 
                        while (gsock && (!sock || sock->groupsock!=gsock)) {
 
560
                        while (gsock && (!sock || sock->groupsock != gsock)) {
596
561
                                gsock->locx = rect->xmin;
597
562
                                gsock->locy = dy;
598
563
                                
599
564
                                /* prevent long socket lists from growing out of the group box */
600
 
                                if (dy-3*NODE_DYS < rect->ymin)
601
 
                                        rect->ymin = dy-3*NODE_DYS;
602
 
                                if (dy+3*NODE_DYS > rect->ymax)
603
 
                                        rect->ymax = dy+3*NODE_DYS;
604
 
                                dy -= 2*NODE_DY;
 
565
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
566
                                        rect->ymin = dy - 3 * NODE_DYS;
 
567
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
568
                                        rect->ymax = dy + 3 * NODE_DYS;
 
569
                                dy -= 2 * NODE_DY;
605
570
                                
606
571
                                gsock = gsock->next;
607
572
                        }
608
 
                        while (sock && gsock && sock->groupsock==gsock) {
 
573
                        while (sock && gsock && sock->groupsock == gsock) {
609
574
                                gsock->locx = rect->xmin;
610
575
                                sock->locx = rect->xmin - node_group_frame;
611
576
                                sock->locy = gsock->locy = dy;
612
577
                                
613
578
                                /* prevent long socket lists from growing out of the group box */
614
 
                                if (dy-3*NODE_DYS < rect->ymin)
615
 
                                        rect->ymin = dy-3*NODE_DYS;
616
 
                                if (dy+3*NODE_DYS > rect->ymax)
617
 
                                        rect->ymax = dy+3*NODE_DYS;
618
 
                                dy -= 2*NODE_DY;
 
579
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
580
                                        rect->ymin = dy - 3 * NODE_DYS;
 
581
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
582
                                        rect->ymax = dy + 3 * NODE_DYS;
 
583
                                dy -= 2 * NODE_DY;
619
584
                                
620
585
                                sock = sock->next;
621
586
                                gsock = gsock->next;
623
588
                }
624
589
                
625
590
                /* output sockets */
626
 
                dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->outputs)-1);
627
 
                gsock=ngroup->outputs.first;
628
 
                sock=gnode->outputs.first;
 
591
                dy = BLI_rctf_cent_y(rect) + (NODE_DY * (BLI_countlist(&gnode->outputs) - 1));
 
592
                gsock = ngroup->outputs.first;
 
593
                sock = gnode->outputs.first;
629
594
                while (gsock || sock) {
630
595
                        while (sock && !sock->groupsock) {
631
596
                                sock->locx = rect->xmax + node_group_frame;
632
597
                                sock->locy = dy - NODE_DYS;
633
598
                                
634
599
                                /* prevent long socket lists from growing out of the group box */
635
 
                                if (dy-3*NODE_DYS < rect->ymin)
636
 
                                        rect->ymin = dy-3*NODE_DYS;
637
 
                                if (dy+3*NODE_DYS > rect->ymax)
638
 
                                        rect->ymax = dy+3*NODE_DYS;
639
 
                                dy -= 2*NODE_DY;
 
600
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
601
                                        rect->ymin = dy - 3 * NODE_DYS;
 
602
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
603
                                        rect->ymax = dy + 3 * NODE_DYS;
 
604
                                dy -= 2 * NODE_DY;
640
605
                                
641
606
                                sock = sock->next;
642
607
                        }
643
 
                        while (gsock && (!sock || sock->groupsock!=gsock)) {
 
608
                        while (gsock && (!sock || sock->groupsock != gsock)) {
644
609
                                gsock->locx = rect->xmax;
645
610
                                gsock->locy = dy - NODE_DYS;
646
611
                                
647
612
                                /* prevent long socket lists from growing out of the group box */
648
 
                                if (dy-3*NODE_DYS < rect->ymin)
649
 
                                        rect->ymin = dy-3*NODE_DYS;
650
 
                                if (dy+3*NODE_DYS > rect->ymax)
651
 
                                        rect->ymax = dy+3*NODE_DYS;
652
 
                                dy -= 2*NODE_DY;
 
613
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
614
                                        rect->ymin = dy - 3 * NODE_DYS;
 
615
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
616
                                        rect->ymax = dy + 3 * NODE_DYS;
 
617
                                dy -= 2 * NODE_DY;
653
618
                                
654
619
                                gsock = gsock->next;
655
620
                        }
656
 
                        while (sock && gsock && sock->groupsock==gsock) {
 
621
                        while (sock && gsock && sock->groupsock == gsock) {
657
622
                                gsock->locx = rect->xmax;
658
623
                                sock->locx = rect->xmax + node_group_frame;
659
624
                                sock->locy = gsock->locy = dy - NODE_DYS;
660
625
                                
661
626
                                /* prevent long socket lists from growing out of the group box */
662
 
                                if (dy-3*NODE_DYS < rect->ymin)
663
 
                                        rect->ymin = dy-3*NODE_DYS;
664
 
                                if (dy+3*NODE_DYS > rect->ymax)
665
 
                                        rect->ymax = dy+3*NODE_DYS;
666
 
                                dy -= 2*NODE_DY;
 
627
                                if (dy - 3 * NODE_DYS < rect->ymin)
 
628
                                        rect->ymin = dy - 3 * NODE_DYS;
 
629
                                if (dy + 3 * NODE_DYS > rect->ymax)
 
630
                                        rect->ymax = dy + 3 * NODE_DYS;
 
631
                                dy -= 2 * NODE_DY;
667
632
                                
668
633
                                sock = sock->next;
669
634
                                gsock = gsock->next;
674
639
                 * Add margin for header and input/output columns.
675
640
                 */
676
641
                uiExplicitBoundsBlock(gnode->block,
677
 
                                                          rect->xmin - node_group_frame,
678
 
                                                          rect->ymin,
679
 
                                                          rect->xmax + node_group_frame,
680
 
                                                          rect->ymax + group_header);
 
642
                                      rect->xmin - node_group_frame,
 
643
                                      rect->ymin,
 
644
                                      rect->xmax + node_group_frame,
 
645
                                      rect->ymax + group_header);
681
646
        }
682
647
}
683
648
 
684
649
static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
685
650
{
686
 
        bNodeTree *ngroup= (bNodeTree*)ngroup_v;
 
651
        bNodeTree *ngroup = (bNodeTree *)ngroup_v;
687
652
        
688
653
        ngroup->update |= NTREE_UPDATE_GROUP_IN;
689
654
        ntreeUpdateTree(ngroup);
691
656
 
692
657
static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
693
658
{
694
 
        bNodeTree *ngroup= (bNodeTree*)ngroup_v;
 
659
        bNodeTree *ngroup = (bNodeTree *)ngroup_v;
695
660
        
696
661
        ngroup->update |= NTREE_UPDATE_GROUP_OUT;
697
662
        ntreeUpdateTree(ngroup);
698
663
}
699
664
 
700
 
static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, int in_out, float xoffset, float yoffset)
 
665
static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock,
 
666
                                   int in_out, float xoffset, float yoffset, short width, short height)
701
667
{
702
 
        bNodeTree *ngroup= (bNodeTree*)gnode->id;
703
 
        uiBut *bt;
704
 
        
705
668
        if (sock->flag & SOCK_DYNAMIC) {
706
 
                bt = uiDefBut(gnode->block, TEX, 0, "", 
707
 
                                          sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
708
 
                                          sock->name, 0, sizeof(sock->name), 0, 0, "");
709
 
                if (in_out==SOCK_IN)
710
 
                        uiButSetFunc(bt, update_group_input_cb, snode, ngroup);
 
669
                bNodeTree *ngroup = (bNodeTree *)gnode->id;
 
670
                uiBut *but;
 
671
                but = uiDefBut(gnode->block, TEX, 0, "",
 
672
                               sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
 
673
                               sock->name, 0, sizeof(sock->name), 0, 0, "");
 
674
                if (in_out == SOCK_IN)
 
675
                        uiButSetFunc(but, update_group_input_cb, snode, ngroup);
711
676
                else
712
 
                        uiButSetFunc(bt, update_group_output_cb, snode, ngroup);
 
677
                        uiButSetFunc(but, update_group_output_cb, snode, ngroup);
713
678
        }
714
679
        else {
715
 
                uiDefBut(gnode->block, LABEL, 0, sock->name,
716
 
                         sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
717
 
                         NULL, 0, sizeof(sock->name), 0, 0, "");
 
680
                const char *ui_name = IFACE_(sock->name);
 
681
                uiDefBut(gnode->block, LABEL, 0, ui_name,
 
682
                         sock->locx + xoffset, sock->locy + 1 + yoffset, width, height,
 
683
                         NULL, 0, 0, 0, 0, "");
718
684
        }
719
685
}
720
686
 
721
 
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode, bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
 
687
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode,
 
688
                              bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
722
689
{
723
 
        bNodeTree *ngroup= (bNodeTree*)gnode->id;
724
 
        bNodeSocketType *stype= ntreeGetSocketType(gsock ? gsock->type : sock->type);
 
690
        const float dpi_fac = 1.0f;
 
691
        bNodeTree *ngroup = (bNodeTree *)gnode->id;
 
692
        bNodeSocketType *stype = ntreeGetSocketType(gsock ? gsock->type : sock->type);
725
693
        uiBut *bt;
726
694
        float offset;
727
695
        int draw_value;
728
 
        float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
729
 
        float socket_size= NODE_SOCKSIZE*U.dpi/72;
730
 
        float arrowbutw= 0.8f*UI_UNIT_X;
 
696
        const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
 
697
        const float socket_size      = NODE_SOCKSIZE * dpi_fac;
 
698
        const float arrowbutw        = 0.8f * UI_UNIT_X;
 
699
        const short co_text_w = 72 * dpi_fac;
 
700
        const float co_margin = 6.0f * dpi_fac;
731
701
        /* layout stuff for buttons on group left frame */
732
 
        float colw= 0.6f*node_group_frame;
733
 
        float col1= 6 - node_group_frame;
734
 
        float col2= col1 + colw+6;
735
 
        float col3= - arrowbutw - 6;
 
702
        const float colw = 0.6f * node_group_frame;
 
703
        const float col1 = co_margin - node_group_frame;
 
704
        const float col2 = col1 + colw + co_margin;
 
705
        const float col3 = -arrowbutw - co_margin;
736
706
        /* layout stuff for buttons on group right frame */
737
 
        float cor1= 6;
738
 
        float cor2= cor1 + arrowbutw + 6;
739
 
        float cor3= cor2 + arrowbutw + 6;
 
707
        const float cor1 = co_margin;
 
708
        const float cor2 = cor1 + arrowbutw;
 
709
        const float cor3 = cor2 + arrowbutw + co_margin;
740
710
        
741
711
        /* node and group socket circles */
742
712
        if (sock)
743
 
                node_socket_circle_draw(ntree, sock, socket_size);
 
713
                node_socket_circle_draw(ntree, sock, socket_size, sock->flag & SELECT);
744
714
        if (gsock)
745
 
                node_socket_circle_draw(ngroup, gsock, socket_size);
 
715
                node_socket_circle_draw(ngroup, gsock, socket_size, gsock->flag & SELECT);
746
716
        
747
717
        /* socket name */
748
 
        offset = (in_out==SOCK_IN ? col1 : cor3);
 
718
        offset = (in_out == SOCK_IN ? col1 : cor3);
749
719
        if (!gsock)
750
 
                offset += (in_out==SOCK_IN ? node_group_frame : -node_group_frame);
 
720
                offset += (in_out == SOCK_IN ? node_group_frame : -node_group_frame);
751
721
        
752
722
        /* draw both name and value button if:
753
723
         * 1) input: not internal
755
725
         */
756
726
        draw_value = 0;
757
727
        switch (in_out) {
758
 
        case SOCK_IN:
759
 
                draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
760
 
                break;
761
 
        case SOCK_OUT:
762
 
                if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
763
 
                        draw_value = !(gsock && gsock->link);
764
 
                break;
 
728
                case SOCK_IN:
 
729
                        draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
 
730
                        break;
 
731
                case SOCK_OUT:
 
732
                        if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
 
733
                                draw_value = !(gsock && gsock->link);
 
734
                        break;
765
735
        }
766
736
        if (draw_value) {
767
737
                /* both name and value buttons */
768
738
                if (gsock) {
769
 
                        draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0);
 
739
                        draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0, co_text_w, NODE_DY);
770
740
                        if (stype->buttonfunc)
771
 
                                stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "", gsock->locx+offset, gsock->locy-NODE_DY, colw);
 
741
                                stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "",
 
742
                                                  gsock->locx + offset, gsock->locy - NODE_DY, colw);
772
743
                }
773
744
                else {
774
 
                        draw_group_socket_name(snode, gnode, sock, in_out, offset, 0);
 
745
                        draw_group_socket_name(snode, gnode, sock, in_out, offset, 0, co_text_w, NODE_DY);
775
746
                        if (stype->buttonfunc)
776
 
                                stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "", sock->locx+offset, sock->locy-NODE_DY, colw);
 
747
                                stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "",
 
748
                                                  sock->locx + offset, sock->locy - NODE_DY, colw);
777
749
                }
778
750
        }
779
751
        else {
780
752
                /* only name, no value button */
781
753
                if (gsock)
782
 
                        draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS);
 
754
                        draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
783
755
                else
784
 
                        draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS);
 
756
                        draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS, co_text_w, NODE_DY);
785
757
        }
786
758
        
787
759
        if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
788
760
                /* up/down buttons */
789
 
                offset = (in_out==SOCK_IN ? col2 : cor2);
 
761
                offset = (in_out == SOCK_IN ? col2 : cor2);
790
762
                uiBlockSetDirection(gnode->block, UI_TOP);
791
763
                uiBlockBeginAlign(gnode->block);
792
764
                bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP,
793
 
                                                   gsock->locx+offset, gsock->locy, arrowbutw, arrowbutw, "");
 
765
                                   gsock->locx + offset, gsock->locy, arrowbutw, arrowbutw, "");
794
766
                if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC))
795
767
                        uiButSetFlag(bt, UI_BUT_DISABLED);
796
768
                RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
797
769
                RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
798
770
                bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN,
799
 
                                                   gsock->locx+offset, gsock->locy-arrowbutw, arrowbutw, arrowbutw, "");
 
771
                                   gsock->locx + offset, gsock->locy - arrowbutw, arrowbutw, arrowbutw, "");
800
772
                if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC))
801
773
                        uiButSetFlag(bt, UI_BUT_DISABLED);
802
774
                RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
805
777
                uiBlockSetDirection(gnode->block, 0);
806
778
                
807
779
                /* remove button */
808
 
                offset = (in_out==SOCK_IN ? col3 : cor1);
 
780
                offset = (in_out == SOCK_IN ? col3 : cor1);
809
781
                uiBlockSetEmboss(gnode->block, UI_EMBOSSN);
810
782
                bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X,
811
 
                                                   gsock->locx+offset, gsock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, "");
 
783
                                   gsock->locx + offset, gsock->locy - 0.5f * arrowbutw, arrowbutw, arrowbutw, "");
812
784
                RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
813
785
                RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
814
786
                uiBlockSetEmboss(gnode->block, UI_EMBOSS);
822
794
                node_draw_default(C, ar, snode, ntree, gnode);
823
795
        }
824
796
        else {
825
 
                bNodeTree *ngroup= (bNodeTree *)gnode->id;
 
797
                bNodeTree *ngroup = (bNodeTree *)gnode->id;
826
798
                bNodeSocket *sock, *gsock;
827
799
                uiLayout *layout;
828
800
                PointerRNA ptr;
829
 
                rctf rect= gnode->totr;
830
 
                float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
831
 
                float group_header= 26*U.dpi/72;
 
801
                rctf rect = gnode->totr;
 
802
                const float dpi_fac = 1.0f;
 
803
                const float node_group_frame = NODE_GROUP_FRAME * dpi_fac;
 
804
                const float group_header = 26 * dpi_fac;
832
805
                
833
806
                int index;
834
807
                
836
809
                glEnable(GL_BLEND);
837
810
                uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
838
811
                UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70);
839
 
                uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD);
 
812
                uiDrawBox(GL_POLYGON,
 
813
                          rect.xmin - node_group_frame, rect.ymax,
 
814
                          rect.xmax + node_group_frame, rect.ymax + group_header, BASIS_RAD);
840
815
                
841
816
                /* backdrop body */
842
817
                UI_ThemeColorShadeAlpha(TH_BACK, -8, -70);
846
821
                /* input column */
847
822
                UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
848
823
                uiSetRoundBox(UI_CNR_BOTTOM_LEFT);
849
 
                uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
 
824
                uiDrawBox(GL_POLYGON, rect.xmin - node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
850
825
        
851
826
                /* output column */
852
827
                UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
853
828
                uiSetRoundBox(UI_CNR_BOTTOM_RIGHT);
854
 
                uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD);
 
829
                uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax + node_group_frame, rect.ymax, BASIS_RAD);
855
830
        
856
831
                /* input column separator */
857
832
                glColor4ub(200, 200, 200, 140);
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);
877
854
                
878
855
                /* backdrop title */
879
856
                UI_ThemeColor(TH_TEXT_HI);
880
857
        
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);
886
864
        
887
865
                /* draw the internal tree nodes and links */
888
866
                node_draw_nodetree(C, ar, snode, ngroup);
889
867
        
890
868
                /* group sockets */
891
 
                gsock=ngroup->inputs.first;
892
 
                sock=gnode->inputs.first;
 
869
                gsock = ngroup->inputs.first;
 
870
                sock = gnode->inputs.first;
893
871
                index = 0;
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;
898
876
                        }
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;
902
 
                                ++index;
 
880
                                index++;
903
881
                        }
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;
908
 
                                ++index;
 
886
                                index++;
909
887
                        }
910
888
                }
911
 
                gsock=ngroup->outputs.first;
912
 
                sock=gnode->outputs.first;
 
889
                gsock = ngroup->outputs.first;
 
890
                sock = gnode->outputs.first;
913
891
                index = 0;
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;
918
896
                        }
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;
922
 
                                ++index;
 
900
                                index++;
923
901
                        }
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;
928
 
                                ++index;
 
906
                                index++;
929
907
                        }
930
908
                }
931
909
                
932
910
                uiEndBlock(C, gnode->block);
933
911
                uiDrawBlock(C, gnode->block);
934
 
                gnode->block= NULL;
 
912
                gnode->block = NULL;
935
913
        }
936
914
}
937
915
 
938
 
void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
916
static void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
939
917
{
940
918
        uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
941
919
}
942
920
 
943
 
static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
944
 
{
945
 
        uiItemR(layout, ptr, "max_iterations", 0, NULL, 0);
946
 
}
947
 
 
948
 
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
949
 
{
 
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.
 
924
 */
 
925
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *ntree, bNode *node)
 
926
{
 
927
        const float margin = 1.5f * U.widget_unit;
 
928
        NodeFrame *data = (NodeFrame *)node->storage;
 
929
        int bbinit;
 
930
        bNode *tnode;
 
931
        rctf rect, noderect;
 
932
        float xmax, ymax;
 
933
        
 
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);
 
937
        
 
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)
 
945
                        continue;
 
946
                
 
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;
 
953
                
 
954
                /* first child initializes frame */
 
955
                if (bbinit) {
 
956
                        bbinit = 0;
 
957
                        rect = noderect;
 
958
                        data->flag &= ~NODE_FRAME_RESIZEABLE;
 
959
                }
 
960
                else
 
961
                        BLI_rctf_union(&rect, &noderect);
 
962
        }
 
963
        
 
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;
 
969
        
 
970
        node->totr = rect;
 
971
}
 
972
 
 
973
static void node_draw_frame_label(bNode *node, const float aspect)
 
974
{
 
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;
 
983
        float x, y;
 
984
        const int font_size = data->label_size / aspect;
 
985
 
 
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 */
 
989
        
 
990
        /* title color */
 
991
        UI_ThemeColorBlendShade(TH_TEXT, color_id, 0.8f, 10);
 
992
 
 
993
        width = BLF_width(fontid, label);
 
994
        ascender = BLF_ascender(fontid);
 
995
        
 
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));
 
999
 
 
1000
        BLF_position(fontid, x, y, 0);
 
1001
        BLF_draw(fontid, label, BLF_DRAW_STR_DUMMY_MAX);
 
1002
 
 
1003
        BLF_disable(fontid, BLF_ASPECT);
 
1004
}
 
1005
 
 
1006
static void node_draw_frame(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *UNUSED(ntree), bNode *node)
 
1007
{
 
1008
        rctf *rct = &node->totr;
 
1009
        int color_id = node_get_colorid(node);
 
1010
        unsigned char color[4];
 
1011
        float alpha;
 
1012
        
 
1013
        /* skip if out of view */
 
1014
        if (BLI_rctf_isect(&node->totr, &ar->v2d.cur, NULL) == FALSE) {
 
1015
                uiEndBlock(C, node->block);
 
1016
                node->block = NULL;
 
1017
                return;
 
1018
        }
 
1019
 
 
1020
        UI_GetThemeColor4ubv(TH_NODE_FRAME, color);
 
1021
        alpha = (float)(color[3]) / 255.0f;
 
1022
        
 
1023
        /* shadow */
 
1024
        node_draw_shadow(snode, node, BASIS_RAD, alpha);
 
1025
        
 
1026
        /* body */
 
1027
        if (node->flag & NODE_CUSTOM_COLOR)
 
1028
                glColor4f(node->color[0], node->color[1], node->color[2], alpha);
 
1029
        else
 
1030
                UI_ThemeColor4(TH_NODE_FRAME);
 
1031
        glEnable(GL_BLEND);
 
1032
        uiSetRoundBox(UI_CNR_ALL);
 
1033
        uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);
 
1034
        glDisable(GL_BLEND);
 
1035
 
 
1036
        /* outline active and selected emphasis */
 
1037
        if (node->flag & SELECT) {
 
1038
                glEnable(GL_BLEND);
 
1039
                glEnable(GL_LINE_SMOOTH);
 
1040
                
 
1041
                if (node->flag & NODE_ACTIVE)
 
1042
                        UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
 
1043
                else
 
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);
 
1049
                
 
1050
                glDisable(GL_LINE_SMOOTH);
 
1051
                glDisable(GL_BLEND);
 
1052
        }
 
1053
        
 
1054
        /* label */
 
1055
        node_draw_frame_label(node, snode->aspect);
 
1056
        
 
1057
        UI_ThemeClearColor(color_id);
 
1058
                
 
1059
        uiEndBlock(C, node->block);
 
1060
        uiDrawBlock(C, node->block);
 
1061
        node->block = NULL;
 
1062
}
 
1063
 
 
1064
static int node_resize_area_frame(bNode *node, int x, int y)
 
1065
{
 
1066
        const float size = 10.0f;
 
1067
        NodeFrame *data = (NodeFrame *)node->storage;
 
1068
        rctf totr = node->totr;
 
1069
        int dir = 0;
 
1070
        
 
1071
        /* shrinking frame size is determined by child nodes */
 
1072
        if (!(data->flag & NODE_FRAME_RESIZEABLE))
 
1073
                return 0;
 
1074
        
 
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;
 
1083
        
 
1084
        return dir;
 
1085
}
 
1086
 
 
1087
static void node_buts_frame_details(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1088
{
 
1089
        uiItemR(layout, ptr, "label_size", 0, IFACE_("Label Size"), ICON_NONE);
 
1090
        uiItemR(layout, ptr, "shrink", 0, IFACE_("Shrink"), ICON_NONE);
 
1091
}
 
1092
 
 
1093
 
 
1094
#define NODE_REROUTE_SIZE   8.0f
 
1095
 
 
1096
static void node_update_reroute(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
 
1097
{
 
1098
        bNodeSocket *nsock;
950
1099
        float locx, locy;
951
 
 
 
1100
        float size = NODE_REROUTE_SIZE;
 
1101
        
952
1102
        /* get "global" coords */
953
 
        nodeSpaceCoords(node, &locx, &locy);
954
 
 
955
 
        node->prvr.xmin = locx + NODE_DYS;
956
 
        node->prvr.xmax = locx + node->width- NODE_DYS;
957
 
 
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);
 
1104
        
 
1105
        /* reroute node has exactly one input and one output, both in the same place */
 
1106
        nsock = node->outputs.first;
 
1107
        nsock->locx = locx;
 
1108
        nsock->locy = locy;
 
1109
 
 
1110
        nsock = node->inputs.first;
 
1111
        nsock->locx = locx;
 
1112
        nsock->locy = locy;
 
1113
 
 
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;
 
1119
}
 
1120
 
 
1121
static void node_draw_reroute(const bContext *C, ARegion *ar, SpaceNode *UNUSED(snode),  bNodeTree *ntree, bNode *node)
 
1122
{
 
1123
        bNodeSocket *sock;
 
1124
        char showname[128]; /* 128 used below */
 
1125
        rctf *rct = &node->totr;
 
1126
 
 
1127
#if 0   /* UNUSED */
 
1128
        float size = NODE_REROUTE_SIZE;
 
1129
#endif
 
1130
        float socket_size = NODE_SOCKSIZE;
 
1131
 
 
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) {
 
1135
 
 
1136
                uiEndBlock(C, node->block);
 
1137
                node->block = NULL;
 
1138
                return;
 
1139
        }
 
1140
 
 
1141
        /* XXX only kept for debugging
 
1142
         * selection state is indicated by socket outline below!
 
1143
         */
 
1144
#if 0
 
1145
        /* body */
 
1146
        uiSetRoundBox(15);
 
1147
        UI_ThemeColor4(TH_NODE);
 
1148
        glEnable(GL_BLEND);
 
1149
        uiRoundBox(rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
 
1150
        glDisable(GL_BLEND);
 
1151
 
 
1152
        /* outline active and selected emphasis */
 
1153
        if (node->flag & SELECT) {
 
1154
                glEnable(GL_BLEND);
 
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);
 
1159
                else
 
1160
                        UI_ThemeColorShadeAlpha(TH_TEXT_HI, -20, -120);
 
1161
                uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, size);
 
1162
 
 
1163
                glDisable(GL_LINE_SMOOTH);
 
1164
                glDisable(GL_BLEND);
 
1165
        }
 
1166
#endif
 
1167
 
 
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);
 
1175
        }
 
1176
 
 
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!
 
1179
         */
 
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));
 
1182
        }
 
1183
 
 
1184
        uiEndBlock(C, node->block);
 
1185
        uiDrawBlock(C, node->block);
 
1186
        node->block = NULL;
 
1187
}
 
1188
 
 
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.
 
1191
 */
 
1192
static int node_tweak_area_reroute(bNode *node, int x, int y)
 
1193
{
 
1194
        /* square of tweak radius */
 
1195
        static const float tweak_radius_sq = 576;  /* 24 * 24 */
 
1196
        
 
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);
962
1201
}
963
1202
 
964
1203
static void node_common_set_butfunc(bNodeType *ntype)
965
1204
{
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;
971
 
                        break;
972
 
                case NODE_FORLOOP:
973
 
//                      ntype->uifunc= node_common_buts_group;
974
 
                        ntype->drawfunc= node_draw_group;
975
 
                        ntype->drawupdatefunc= node_update_group;
976
 
                        break;
977
 
                case NODE_WHILELOOP:
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;
981
1210
                        break;
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;
 
1216
                        break;
 
1217
                case NODE_REROUTE:
 
1218
                        ntype->drawfunc = node_draw_reroute;
 
1219
                        ntype->drawupdatefunc = node_update_reroute;
 
1220
                        ntype->tweak_area_func = node_tweak_area_reroute;
984
1221
                        break;
985
1222
        }
986
1223
}
987
1224
 
988
1225
/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
989
1226
 
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)
991
1229
{
992
 
        Main *bmain= CTX_data_main(C);
993
 
        bNodeTree *ntree= ntree_v;
994
 
        bNode *node= node_v;
995
 
        /* ID *oldid; */ /* UNUSED */
996
 
        
997
 
        if (node->menunr<1) return;
998
 
        
999
 
        if (node->id) {
1000
 
                node->id->us--;
1001
 
        }
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));
1006
 
 
1007
 
        node->custom1= BSET(node->custom1, NODE_DYNAMIC_NEW);
1008
 
        
1009
 
        nodeSetActive(ntree, node);
1010
 
 
1011
 
        // allqueue(REDRAWBUTSSHADING, 0);
1012
 
        // allqueue(REDRAWNODE, 0);
1013
 
 
1014
 
        node->menunr= 0;
 
1230
        uiLayout *col;
 
1231
        int source;
 
1232
 
 
1233
        if (!imaptr->data)
 
1234
                return;
 
1235
 
 
1236
        col = uiLayoutColumn(layout, FALSE);
 
1237
        
 
1238
        uiItemR(col, imaptr, "source", 0, "", ICON_NONE);
 
1239
        
 
1240
        source = RNA_enum_get(imaptr, "source");
 
1241
 
 
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;
 
1246
                char numstr[32];
 
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);
 
1250
        }
 
1251
 
 
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);
 
1259
        }
 
1260
 
 
1261
        col = uiLayoutColumn(layout, FALSE);
 
1262
 
 
1263
        if (RNA_enum_get(imaptr, "type") == IMA_TYPE_MULTILAYER)
 
1264
                uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
1015
1265
}
1016
1266
 
1017
1267
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
1018
1268
{
1019
 
        bNode *node= ptr->data;
 
1269
        bNode *node = ptr->data;
1020
1270
        uiLayout *col;
1021
1271
        
1022
1272
        uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
1023
1273
        
1024
1274
        if (!node->id) return;
1025
1275
        
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);
1033
1283
{
1034
1284
        uiLayout *row;
1035
1285
        
1036
 
        uiItemL(layout, "Location:", ICON_NONE);
1037
 
        row= uiLayoutRow(layout, 1);
 
1286
        uiItemL(layout, IFACE_("Location:"), ICON_NONE);
 
1287
        row = uiLayoutRow(layout, TRUE);
1038
1288
        uiItemR(row, ptr, "translation", 0, "", ICON_NONE);
1039
1289
        
1040
 
        uiItemL(layout, "Rotation:", ICON_NONE);
1041
 
        row= uiLayoutRow(layout, 1);
 
1290
        uiItemL(layout, IFACE_("Rotation:"), ICON_NONE);
 
1291
        row = uiLayoutRow(layout, TRUE);
1042
1292
        uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
1043
1293
        
1044
 
        uiItemL(layout, "Scale:", ICON_NONE);
1045
 
        row= uiLayoutRow(layout, 1);
 
1294
        uiItemL(layout, IFACE_("Scale:"), ICON_NONE);
 
1295
        row = uiLayoutRow(layout, TRUE);
1046
1296
        uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
1047
1297
        
1048
 
        row= uiLayoutRow(layout, 1);
 
1298
        row = uiLayoutRow(layout, TRUE);
1049
1299
        uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
1050
1300
        uiItemR(row, ptr, "min", 0, "", ICON_NONE);
1051
1301
        
1052
 
        row= uiLayoutRow(layout, 1);
 
1302
        row = uiLayoutRow(layout, TRUE);
1053
1303
        uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
1054
1304
        uiItemR(row, ptr, "max", 0, "", ICON_NONE);
1055
1305
}
1061
1311
 
1062
1312
static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
1063
1313
{
1064
 
        PointerRNA obptr= CTX_data_pointer_get(C, "active_object");
 
1314
        PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
1065
1315
        uiLayout *col;
1066
1316
 
1067
 
        col= uiLayoutColumn(layout, 0);
 
1317
        col = uiLayoutColumn(layout, FALSE);
1068
1318
 
1069
1319
        if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
1070
 
                PointerRNA dataptr= RNA_pointer_get(&obptr, "data");
 
1320
                PointerRNA dataptr = RNA_pointer_get(&obptr, "data");
1071
1321
 
1072
1322
                uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
1073
1323
                uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
1074
1324
        }
1075
1325
        else {
1076
 
                uiItemR(col, ptr, "uv_layer", 0, "UV", ICON_NONE);
1077
 
                uiItemR(col, ptr, "color_layer", 0, "VCol", ICON_NONE);
 
1326
                uiItemR(col, ptr, "uv_layer", 0, IFACE_("UV"), ICON_NONE);
 
1327
                uiItemR(col, ptr, "color_layer", 0, IFACE_("VCol"), ICON_NONE);
1078
1328
        }
1079
1329
}
1080
1330
 
1081
1331
static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1082
1332
{
1083
 
        uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
 
1333
        uiItemR(layout, ptr, "attribute_name", 0, IFACE_("Name"), ICON_NONE);
1084
1334
}
1085
1335
 
1086
1336
static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1087
1337
{
 
1338
        PointerRNA imaptr = RNA_pointer_get(ptr, "image");
 
1339
        PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
 
1340
 
1088
1341
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1089
1342
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
 
1343
        uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
 
1344
 
 
1345
        if (RNA_enum_get(ptr, "projection") == SHD_PROJ_BOX) {
 
1346
                uiItemR(layout, ptr, "projection_blend", 0, "Blend", ICON_NONE);
 
1347
        }
 
1348
 
 
1349
        /* note: image user properties used directly here, unlike compositor image node,
 
1350
         * which redefines them in the node struct RNA to get proper updates.
 
1351
         */
 
1352
        node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
1090
1353
}
1091
1354
 
1092
 
 
1093
1355
static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
1094
1356
{
 
1357
        PointerRNA imaptr = RNA_pointer_get(ptr, "image");
 
1358
        PointerRNA iuserptr = RNA_pointer_get(ptr, "image_user");
 
1359
 
1095
1360
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1096
1361
        uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
1097
1362
        uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
 
1363
 
 
1364
        node_buts_image_user(layout, C, &iuserptr, &imaptr, &iuserptr);
1098
1365
}
1099
1366
 
1100
1367
static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1113
1380
        uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
1114
1381
}
1115
1382
 
 
1383
static void node_shader_buts_tex_brick(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1384
{
 
1385
        uiLayout *col;
 
1386
        
 
1387
        col = uiLayoutColumn(layout, TRUE);
 
1388
        uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
 
1389
        uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
 
1390
        
 
1391
        col = uiLayoutColumn(layout, TRUE);
 
1392
        uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
 
1393
        uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
 
1394
}
 
1395
 
1116
1396
static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1117
1397
{
1118
1398
        uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
1128
1408
        uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
1129
1409
}
1130
1410
 
 
1411
static void node_shader_buts_tex_coord(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1412
{
 
1413
        uiItemR(layout, ptr, "from_dupli", 0, NULL, 0);
 
1414
}
 
1415
 
 
1416
static void node_shader_buts_normal_map(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1417
{
 
1418
        uiItemR(layout, ptr, "space", 0, "", 0);
 
1419
 
 
1420
        if (RNA_enum_get(ptr, "space") == SHD_NORMAL_MAP_TANGENT) {
 
1421
                PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
 
1422
 
 
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);
 
1426
                }
 
1427
                else
 
1428
                        uiItemR(layout, ptr, "uv_map", 0, "", 0);
 
1429
        }
 
1430
}
 
1431
 
 
1432
static void node_shader_buts_tangent(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1433
{
 
1434
        uiLayout *split, *row;
 
1435
 
 
1436
        split = uiLayoutSplit(layout, 0.0f, FALSE);
 
1437
 
 
1438
        uiItemR(split, ptr, "direction_type", 0, "", 0);
 
1439
 
 
1440
        row = uiLayoutRow(split, FALSE);
 
1441
 
 
1442
        if (RNA_enum_get(ptr, "direction_type") == SHD_TANGENT_UVMAP) {
 
1443
                PointerRNA obptr = CTX_data_pointer_get(C, "active_object");
 
1444
 
 
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);
 
1448
                }
 
1449
                else
 
1450
                        uiItemR(row, ptr, "uv_map", 0, "", 0);
 
1451
        }
 
1452
        else
 
1453
                uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, 0);
 
1454
}
 
1455
 
1131
1456
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1132
1457
{
1133
1458
        uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
1134
1459
}
1135
1460
 
1136
 
static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
1137
 
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;
1143
 
        uiBut *bt;
1144
 
        // XXX SpaceNode *snode= curarea->spacedata.first;
1145
 
        short dy= (short)butr->ymin;
1146
 
        int xoff=0;
1147
 
 
1148
 
        /* B_NODE_EXEC is handled in butspace.c do_node_buts */
1149
 
        if (!node->id) {
1150
 
                        const char *strp;
1151
 
                        IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL);
1152
 
                        node->menunr= 0;
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);
1157
 
                        xoff=19;
1158
 
                        if (strp) MEM_freeN((void *)strp);
1159
 
        }
1160
 
        else {
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);
1165
 
 
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);
1170
 
                        ;
1171
 
                }
1172
 
        }
 
1461
static void node_shader_buts_script(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1462
{
 
1463
        uiLayout *row;
 
1464
 
 
1465
        row = uiLayoutRow(layout, FALSE);
 
1466
        uiItemR(row, ptr, "mode", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
 
1467
 
 
1468
        row = uiLayoutRow(layout, TRUE);
 
1469
 
 
1470
        if (RNA_enum_get(ptr, "mode") == NODE_SCRIPT_INTERNAL)
 
1471
                uiItemR(row, ptr, "script", 0, "", ICON_NONE);
 
1472
        else
 
1473
                uiItemR(row, ptr, "filepath", 0, "", ICON_NONE);
 
1474
 
 
1475
        uiItemO(row, "", ICON_FILE_REFRESH, "node.shader_script_update");
 
1476
}
 
1477
 
 
1478
static void node_shader_buts_script_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1479
{
 
1480
        uiItemS(layout);
 
1481
 
 
1482
        node_shader_buts_script(layout, C, ptr);
 
1483
 
 
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);
 
1487
#endif
1173
1488
}
1174
1489
 
1175
1490
/* only once called */
1176
1491
static void node_shader_set_butfunc(bNodeType *ntype)
1177
1492
{
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" */
1181
1495
 
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;
1185
1499
                        break;
1186
1500
                case SH_NODE_TEXTURE:
1187
 
                        ntype->uifunc= node_buts_texture;
 
1501
                        ntype->uifunc = node_buts_texture;
1188
1502
                        break;
1189
1503
                case SH_NODE_NORMAL:
1190
 
                        ntype->uifunc= node_buts_normal;
 
1504
                        ntype->uifunc = node_buts_normal;
1191
1505
                        break;
1192
1506
                case SH_NODE_CURVE_VEC:
1193
 
                        ntype->uifunc= node_buts_curvevec;
 
1507
                        ntype->uifunc = node_buts_curvevec;
1194
1508
                        break;
1195
1509
                case SH_NODE_CURVE_RGB:
1196
 
                        ntype->uifunc= node_buts_curvecol;
 
1510
                        ntype->uifunc = node_buts_curvecol;
1197
1511
                        break;
1198
1512
                case SH_NODE_MAPPING:
1199
 
                        ntype->uifunc= node_shader_buts_mapping;
 
1513
                        ntype->uifunc = node_shader_buts_mapping;
1200
1514
                        break;
1201
1515
                case SH_NODE_VALUE:
1202
 
                        ntype->uifunc= node_buts_value;
 
1516
                        ntype->uifunc = node_buts_value;
1203
1517
                        break;
1204
1518
                case SH_NODE_RGB:
1205
 
                        ntype->uifunc= node_buts_rgb;
 
1519
                        ntype->uifunc = node_buts_rgb;
1206
1520
                        break;
1207
1521
                case SH_NODE_MIX_RGB:
1208
 
                        ntype->uifunc= node_buts_mix_rgb;
 
1522
                        ntype->uifunc = node_buts_mix_rgb;
1209
1523
                        break;
1210
1524
                case SH_NODE_VALTORGB:
1211
 
                        ntype->uifunc= node_buts_colorramp;
 
1525
                        ntype->uifunc = node_buts_colorramp;
1212
1526
                        break;
1213
1527
                case SH_NODE_MATH: 
1214
 
                        ntype->uifunc= node_buts_math;
 
1528
                        ntype->uifunc = node_buts_math;
1215
1529
                        break; 
1216
1530
                case SH_NODE_VECT_MATH: 
1217
 
                        ntype->uifunc= node_shader_buts_vect_math;
 
1531
                        ntype->uifunc = node_shader_buts_vect_math;
1218
1532
                        break; 
1219
1533
                case SH_NODE_GEOMETRY:
1220
 
                        ntype->uifunc= node_shader_buts_geometry;
 
1534
                        ntype->uifunc = node_shader_buts_geometry;
1221
1535
                        break;
1222
1536
                case SH_NODE_ATTRIBUTE:
1223
 
                        ntype->uifunc= node_shader_buts_attribute;
 
1537
                        ntype->uifunc = node_shader_buts_attribute;
1224
1538
                        break;
1225
1539
                case SH_NODE_TEX_SKY:
1226
 
                        ntype->uifunc= node_shader_buts_tex_sky;
 
1540
                        ntype->uifunc = node_shader_buts_tex_sky;
1227
1541
                        break;
1228
1542
                case SH_NODE_TEX_IMAGE:
1229
 
                        ntype->uifunc= node_shader_buts_tex_image;
 
1543
                        ntype->uifunc = node_shader_buts_tex_image;
1230
1544
                        break;
1231
1545
                case SH_NODE_TEX_ENVIRONMENT:
1232
 
                        ntype->uifunc= node_shader_buts_tex_environment;
 
1546
                        ntype->uifunc = node_shader_buts_tex_environment;
1233
1547
                        break;
1234
1548
                case SH_NODE_TEX_GRADIENT:
1235
 
                        ntype->uifunc= node_shader_buts_tex_gradient;
 
1549
                        ntype->uifunc = node_shader_buts_tex_gradient;
1236
1550
                        break;
1237
1551
                case SH_NODE_TEX_MAGIC:
1238
 
                        ntype->uifunc= node_shader_buts_tex_magic;
 
1552
                        ntype->uifunc = node_shader_buts_tex_magic;
 
1553
                        break;
 
1554
                case SH_NODE_TEX_BRICK:
 
1555
                        ntype->uifunc = node_shader_buts_tex_brick;
1239
1556
                        break;
1240
1557
                case SH_NODE_TEX_WAVE:
1241
 
                        ntype->uifunc= node_shader_buts_tex_wave;
 
1558
                        ntype->uifunc = node_shader_buts_tex_wave;
1242
1559
                        break;
1243
1560
                case SH_NODE_TEX_MUSGRAVE:
1244
 
                        ntype->uifunc= node_shader_buts_tex_musgrave;
 
1561
                        ntype->uifunc = node_shader_buts_tex_musgrave;
1245
1562
                        break;
1246
1563
                case SH_NODE_TEX_VORONOI:
1247
 
                        ntype->uifunc= node_shader_buts_tex_voronoi;
 
1564
                        ntype->uifunc = node_shader_buts_tex_voronoi;
 
1565
                        break;
 
1566
                case SH_NODE_TEX_COORD:
 
1567
                        ntype->uifunc = node_shader_buts_tex_coord;
 
1568
                        break;
 
1569
                case SH_NODE_NORMAL_MAP:
 
1570
                        ntype->uifunc = node_shader_buts_normal_map;
 
1571
                        break;
 
1572
                case SH_NODE_TANGENT:
 
1573
                        ntype->uifunc = node_shader_buts_tangent;
1248
1574
                        break;
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;
1252
1579
                        break;
1253
 
                case NODE_DYNAMIC:
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;
1255
1583
                        break;
1256
1584
        }
1257
 
                if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
1258
1585
}
1259
1586
 
1260
1587
/* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
1261
1588
 
1262
1589
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
1263
1590
{
1264
 
        uiLayout *col;
1265
 
        bNode *node= ptr->data;
 
1591
        bNode *node = ptr->data;
 
1592
        PointerRNA imaptr, iuserptr;
 
1593
        
 
1594
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
 
1595
        
 
1596
        if (!node->id) return;
 
1597
        
 
1598
        imaptr = RNA_pointer_get(ptr, "image");
 
1599
        RNA_pointer_create((ID *)ptr->id.data, &RNA_ImageUser, node->storage, &iuserptr);
 
1600
        
 
1601
        node_buts_image_user(layout, C, ptr, &imaptr, &iuserptr);
 
1602
}
 
1603
 
 
1604
static void node_composit_buts_image_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
1605
{
 
1606
        bNode *node = ptr->data;
1266
1607
        PointerRNA imaptr;
1267
 
        PropertyRNA *prop;
1268
 
        int source;
1269
 
        
1270
 
        uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
1271
 
        
1272
 
        if (!node->id) return;
1273
 
        
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);
1277
 
        
1278
 
        col= uiLayoutColumn(layout, 0);
1279
 
        
1280
 
        uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
1281
 
        
1282
 
        source= RNA_enum_get(&imaptr, "source");
1283
 
 
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;
1288
 
                char numstr[32];
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);
1292
 
        }
1293
 
 
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);
1301
 
        }
1302
 
 
1303
 
        col= uiLayoutColumn(layout, 0);
1304
 
        
1305
 
        if (RNA_enum_get(&imaptr, "type")== IMA_TYPE_MULTILAYER)
1306
 
                uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
 
1608
 
 
1609
        node_composit_buts_image(layout, C, ptr);
 
1610
 
 
1611
        uiItemR(layout, ptr, "use_straight_alpha_output", 0, NULL, 0);
 
1612
 
 
1613
        if (!node->id)
 
1614
                return;
 
1615
 
 
1616
        imaptr = RNA_pointer_get(ptr, "image");
 
1617
 
 
1618
        uiTemplateColorspaceSettings(layout, &imaptr, "colorspace_settings");
 
1619
        uiItemR(layout, &imaptr, "alpha_mode", 0, NULL, 0);
1307
1620
}
1308
1621
 
1309
1622
static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
1310
1623
{
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);
1319
1632
 
1320
1633
        BLI_assert(ot != 0);
1323
1636
        
1324
1637
        if (!node->id) return;
1325
1638
 
1326
 
        col= uiLayoutColumn(layout, 0);
1327
 
        row = uiLayoutRow(col, 0);
 
1639
        col = uiLayoutColumn(layout, FALSE);
 
1640
        row = uiLayoutRow(col, FALSE);
1328
1641
        uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
1329
1642
        
1330
1643
        prop = RNA_struct_find_property(ptr, "layer");
1345
1658
static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1346
1659
{
1347
1660
        uiLayout *col, *row;
1348
 
        
1349
 
        col= uiLayoutColumn(layout, 0);
1350
 
        
 
1661
        int reference;
 
1662
        int filter;
 
1663
        
 
1664
        col = uiLayoutColumn(layout, FALSE);
 
1665
        filter = RNA_enum_get(ptr, "filter_type");
 
1666
        reference = RNA_boolean_get(ptr, "use_variable_size");
 
1667
 
1351
1668
        uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE);
1352
 
        if (RNA_enum_get(ptr, "filter_type")!= R_FILTER_FAST_GAUSS) {
1353
 
                uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
 
1669
        if (filter != R_FILTER_FAST_GAUSS) {
 
1670
                uiItemR(col, ptr, "use_variable_size", 0, NULL, ICON_NONE);
 
1671
                if (!reference) {
 
1672
                        uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
 
1673
                }
1354
1674
                uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1355
1675
        }
1356
1676
        
1357
1677
        uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
1358
1678
        
1359
1679
        if (RNA_boolean_get(ptr, "use_relative")) {
1360
 
                uiItemL(col, "Aspect Correction", 0);
1361
 
                row= uiLayoutRow(layout, 1);
1362
 
                uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0);
 
1680
                uiItemL(col, IFACE_("Aspect Correction"), ICON_NONE);
 
1681
                row = uiLayoutRow(layout, TRUE);
 
1682
                uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1363
1683
                
1364
 
                col= uiLayoutColumn(layout, 1);
1365
 
                uiItemR(col, ptr, "factor_x", 0, "X", ICON_NONE);
1366
 
                uiItemR(col, ptr, "factor_y", 0, "Y", ICON_NONE);
 
1684
                col = uiLayoutColumn(layout, TRUE);
 
1685
                uiItemR(col, ptr, "factor_x", 0, IFACE_("X"), ICON_NONE);
 
1686
                uiItemR(col, ptr, "factor_y", 0, IFACE_("Y"), ICON_NONE);
1367
1687
        }
1368
1688
        else {
1369
 
                col= uiLayoutColumn(layout, 1);
1370
 
                uiItemR(col, ptr, "size_x", 0, "X", ICON_NONE);
1371
 
                uiItemR(col, ptr, "size_y", 0, "Y", ICON_NONE);
 
1689
                col = uiLayoutColumn(layout, TRUE);
 
1690
                uiItemR(col, ptr, "size_x", 0, IFACE_("X"), ICON_NONE);
 
1691
                uiItemR(col, ptr, "size_y", 0, IFACE_("Y"), ICON_NONE);
1372
1692
        }
1373
1693
}
1374
1694
 
1379
1699
        uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1380
1700
        uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
1381
1701
        
1382
 
        col= uiLayoutColumn(layout, 1);
1383
 
        uiItemL(col, "Center:", ICON_NONE);
1384
 
        uiItemR(col, ptr, "center_x", 0, "X", ICON_NONE);
1385
 
        uiItemR(col, ptr, "center_y", 0, "Y", ICON_NONE);
 
1702
        col = uiLayoutColumn(layout, TRUE);
 
1703
        uiItemL(col, IFACE_("Center:"), ICON_NONE);
 
1704
        uiItemR(col, ptr, "center_x", 0, IFACE_("X"), ICON_NONE);
 
1705
        uiItemR(col, ptr, "center_y", 0, IFACE_("Y"), ICON_NONE);
1386
1706
        
1387
1707
        uiItemS(layout);
1388
1708
        
1389
 
        col= uiLayoutColumn(layout, 1);
 
1709
        col = uiLayoutColumn(layout, TRUE);
1390
1710
        uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
1391
1711
        uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1392
1712
        
1400
1720
{       
1401
1721
        uiLayout *col;
1402
1722
        
1403
 
        col= uiLayoutColumn(layout, 1);
 
1723
        col = uiLayoutColumn(layout, TRUE);
1404
1724
        uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
1405
1725
        uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
1406
1726
        uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
1410
1730
{
1411
1731
        uiLayout *sub, *col;
1412
1732
        
1413
 
        col= uiLayoutColumn(layout, 0);
1414
 
        uiItemL(col, "Bokeh Type:", ICON_NONE);
 
1733
        col = uiLayoutColumn(layout, FALSE);
 
1734
        uiItemL(col, IFACE_("Bokeh Type:"), ICON_NONE);
1415
1735
        uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
1416
1736
        uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
1417
1737
 
1418
1738
        uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
1419
1739
 
1420
 
        col = uiLayoutColumn(layout, 0);
1421
 
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer")==1);
 
1740
        col = uiLayoutColumn(layout, FALSE);
 
1741
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer") == TRUE);
1422
1742
        uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE);
1423
1743
 
1424
1744
        uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
1425
1745
        uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1426
1746
 
1427
 
        col = uiLayoutColumn(layout, 0);
 
1747
        col = uiLayoutColumn(layout, FALSE);
1428
1748
        uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
1429
 
        sub = uiLayoutColumn(col, 0);
1430
 
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_preview"));
1431
 
        uiItemR(sub, ptr, "samples", 0, NULL, ICON_NONE);
1432
1749
        
1433
 
        col = uiLayoutColumn(layout, 0);
 
1750
        col = uiLayoutColumn(layout, FALSE);
1434
1751
        uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
1435
 
        sub = uiLayoutColumn(col, 0);
1436
 
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer")==0);
 
1752
        sub = uiLayoutColumn(col, FALSE);
 
1753
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer") == FALSE);
1437
1754
        uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE);
1438
1755
}
1439
1756
 
1443
1760
        uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
1444
1761
        uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
1445
1762
 
1446
 
        if (RNA_enum_get(ptr, "glare_type")!= 1) {
 
1763
        if (RNA_enum_get(ptr, "glare_type") != 1) {
1447
1764
                uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
1448
1765
        
1449
 
                if (RNA_enum_get(ptr, "glare_type")!= 0) 
 
1766
                if (RNA_enum_get(ptr, "glare_type") != 0)
1450
1767
                        uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1451
1768
        }
1452
1769
        
1453
1770
        uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
1454
1771
        uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
1455
1772
 
1456
 
        if (RNA_enum_get(ptr, "glare_type")== 2) {
 
1773
        if (RNA_enum_get(ptr, "glare_type") == 2) {
1457
1774
                uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
1458
1775
                uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
1459
1776
        }
1460
 
        if (RNA_enum_get(ptr, "glare_type")== 0 || RNA_enum_get(ptr, "glare_type")== 2) {
 
1777
        if (RNA_enum_get(ptr, "glare_type") == 0 || RNA_enum_get(ptr, "glare_type") == 2) {
1461
1778
                uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1462
1779
                
1463
 
                if (RNA_enum_get(ptr, "glare_type")== 0) 
 
1780
                if (RNA_enum_get(ptr, "glare_type") == 0)
1464
1781
                        uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
1465
1782
        }
1466
 
        if (RNA_enum_get(ptr, "glare_type")== 1) {
 
1783
        if (RNA_enum_get(ptr, "glare_type") == 1) {
1467
1784
                uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
1468
1785
        }
1469
1786
}
1472
1789
{       
1473
1790
        uiLayout *col;
1474
1791
 
1475
 
        col = uiLayoutColumn(layout, 0);
 
1792
        col = uiLayoutColumn(layout, FALSE);
1476
1793
        uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
1477
 
        if (RNA_enum_get(ptr, "tonemap_type")== 0) {
 
1794
        if (RNA_enum_get(ptr, "tonemap_type") == 0) {
1478
1795
                uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1479
1796
                uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1480
1797
                uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
1491
1808
{
1492
1809
        uiLayout *col;
1493
1810
 
1494
 
        col= uiLayoutColumn(layout, 0);
 
1811
        col = uiLayoutColumn(layout, FALSE);
1495
1812
        uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE);
1496
1813
 
1497
 
        col = uiLayoutColumn(col, 0);
1498
 
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector")==0);
 
1814
        col = uiLayoutColumn(col, FALSE);
 
1815
        uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector") == FALSE);
1499
1816
        uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE);
1500
1817
        uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE);
1501
1818
}
1504
1821
{
1505
1822
        uiLayout *col;
1506
1823
        
1507
 
        col= uiLayoutColumn(layout, 0);
 
1824
        col = uiLayoutColumn(layout, FALSE);
1508
1825
        uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
1509
 
        uiItemR(col, ptr, "factor", 0, "Blur", ICON_NONE);
 
1826
        uiItemR(col, ptr, "factor", 0, IFACE_("Blur"), ICON_NONE);
1510
1827
        
1511
 
        col= uiLayoutColumn(layout, 1);
1512
 
        uiItemL(col, "Speed:", ICON_NONE);
1513
 
        uiItemR(col, ptr, "speed_min", 0, "Min", ICON_NONE);
1514
 
        uiItemR(col, ptr, "speed_max", 0, "Max", ICON_NONE);
 
1828
        col = uiLayoutColumn(layout, TRUE);
 
1829
        uiItemL(col, IFACE_("Speed:"), ICON_NONE);
 
1830
        uiItemR(col, ptr, "speed_min", 0, IFACE_("Min"), ICON_NONE);
 
1831
        uiItemR(col, ptr, "speed_max", 0, IFACE_("Max"), ICON_NONE);
1515
1832
 
1516
1833
        uiItemR(layout, ptr, "use_curved", 0, NULL, ICON_NONE);
1517
1834
}
1533
1850
        uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE);
1534
1851
        uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE);
1535
1852
 
1536
 
        col= uiLayoutColumn(layout, 1);
 
1853
        col = uiLayoutColumn(layout, TRUE);
1537
1854
        if (RNA_boolean_get(ptr, "relative")) {
1538
 
                uiItemR(col, ptr, "rel_min_x", 0, "Left", ICON_NONE);
1539
 
                uiItemR(col, ptr, "rel_max_x", 0, "Right", ICON_NONE);
1540
 
                uiItemR(col, ptr, "rel_min_y", 0, "Up", ICON_NONE);
1541
 
                uiItemR(col, ptr, "rel_max_y", 0, "Down", ICON_NONE);
 
1855
                uiItemR(col, ptr, "rel_min_x", 0, IFACE_("Left"), ICON_NONE);
 
1856
                uiItemR(col, ptr, "rel_max_x", 0, IFACE_("Right"), ICON_NONE);
 
1857
                uiItemR(col, ptr, "rel_min_y", 0, IFACE_("Up"), ICON_NONE);
 
1858
                uiItemR(col, ptr, "rel_max_y", 0, IFACE_("Down"), ICON_NONE);
1542
1859
        }
1543
1860
        else {
1544
 
                uiItemR(col, ptr, "min_x", 0, "Left", ICON_NONE);
1545
 
                uiItemR(col, ptr, "max_x", 0, "Right", ICON_NONE);
1546
 
                uiItemR(col, ptr, "min_y", 0, "Up", ICON_NONE);
1547
 
                uiItemR(col, ptr, "max_y", 0, "Down", ICON_NONE);
 
1861
                uiItemR(col, ptr, "min_x", 0, IFACE_("Left"), ICON_NONE);
 
1862
                uiItemR(col, ptr, "max_x", 0, IFACE_("Right"), ICON_NONE);
 
1863
                uiItemR(col, ptr, "min_y", 0, IFACE_("Up"), ICON_NONE);
 
1864
                uiItemR(col, ptr, "max_y", 0, IFACE_("Down"), ICON_NONE);
1548
1865
        }
1549
1866
}
1550
1867
 
1552
1869
{
1553
1870
        uiLayout *row, *col;
1554
1871
        
1555
 
        col= uiLayoutColumn(layout, 0);
1556
 
        row= uiLayoutRow(col, 0);
 
1872
        col = uiLayoutColumn(layout, FALSE);
 
1873
        row = uiLayoutRow(col, FALSE);
1557
1874
        uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1558
1875
        uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
1559
1876
}
1562
1879
{
1563
1880
        uiLayout *col;
1564
1881
 
1565
 
        col= uiLayoutColumn(layout, 0);
 
1882
        col = uiLayoutColumn(layout, FALSE);
1566
1883
 
1567
 
        uiItemL(col, "Inner Edge:", ICON_NONE);
 
1884
        uiItemL(col, IFACE_("Inner Edge:"), ICON_NONE);
1568
1885
        uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
1569
 
        uiItemL(col, "Buffer Edge:", ICON_NONE);
 
1886
        uiItemL(col, IFACE_("Buffer Edge:"), ICON_NONE);
1570
1887
        uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
1571
1888
}
1572
1889
 
 
1890
static void node_composit_buts_map_range(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1891
{
 
1892
        uiLayout *col;
 
1893
 
 
1894
        col = uiLayoutColumn(layout, TRUE);
 
1895
        uiItemR(col, ptr, "use_clamp", 0, NULL, ICON_NONE);
 
1896
}
 
1897
 
1573
1898
static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1574
1899
{
1575
1900
        uiLayout *sub, *col;
1576
1901
        
1577
 
        col = uiLayoutColumn(layout, 1);
 
1902
        col = uiLayoutColumn(layout, TRUE);
1578
1903
        uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
1579
1904
        uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
1580
1905
        
1581
 
        col = uiLayoutColumn(layout, 1);
 
1906
        col = uiLayoutColumn(layout, TRUE);
1582
1907
        uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
1583
 
        sub = uiLayoutColumn(col, 0);
 
1908
        sub = uiLayoutColumn(col, FALSE);
1584
1909
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
1585
1910
        uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
1586
1911
        
1587
 
        col = uiLayoutColumn(layout, 1);
 
1912
        col = uiLayoutColumn(layout, TRUE);
1588
1913
        uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
1589
 
        sub = uiLayoutColumn(col, 0);
 
1914
        sub = uiLayoutColumn(col, FALSE);
1590
1915
        uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
1591
1916
        uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
1592
1917
}
1595
1920
{       
1596
1921
        uiLayout *col;
1597
1922
        
1598
 
        col = uiLayoutColumn(layout, 1);
 
1923
        col = uiLayoutColumn(layout, TRUE);
1599
1924
        uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
1600
1925
        uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
1601
1926
}
1604
1929
{       
1605
1930
        uiLayout *col;
1606
1931
        
1607
 
        col = uiLayoutColumn(layout, 1);
 
1932
        col = uiLayoutColumn(layout, TRUE);
1608
1933
        uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
1609
1934
}
1610
1935
 
1613
1938
{
1614
1939
        uiLayout *col;
1615
1940
        
1616
 
        col = uiLayoutColumn(layout, 0);
 
1941
        col = uiLayoutColumn(layout, FALSE);
1617
1942
        uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1618
1943
        uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1619
1944
        uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1621
1946
 
1622
1947
static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1623
1948
{
1624
 
        uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
 
1949
        uiItemR(layout, ptr, "mode", 0, NULL, ICON_NONE);
 
1950
        uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
 
1951
        switch (RNA_enum_get(ptr, "mode")) {
 
1952
                case CMP_NODE_DILATEERODE_DISTANCE_THRESH:
 
1953
                        uiItemR(layout, ptr, "edge", 0, NULL, ICON_NONE);
 
1954
                        break;
 
1955
                case CMP_NODE_DILATEERODE_DISTANCE_FEATHER:
 
1956
                        uiItemR(layout, ptr, "falloff", 0, NULL, ICON_NONE);
 
1957
                        break;
 
1958
        }
 
1959
}
 
1960
 
 
1961
static void node_composit_buts_inpaint(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1962
{
 
1963
        uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
 
1964
}
 
1965
 
 
1966
static void node_composit_buts_despeckle(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
1967
{
 
1968
        uiLayout *col;
 
1969
 
 
1970
        col = uiLayoutColumn(layout, FALSE);
 
1971
        uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
 
1972
        uiItemR(col, ptr, "threshold_neighbour", 0, NULL, ICON_NONE);
1625
1973
}
1626
1974
 
1627
1975
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1628
1976
{
1629
1977
        uiLayout *col;
1630
1978
        
1631
 
        col = uiLayoutColumn(layout, 1);
 
1979
        col = uiLayoutColumn(layout, TRUE);
1632
1980
        uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1633
1981
        uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1634
1982
}
1637
1985
{
1638
1986
        uiLayout *col, *row;
1639
1987
        
1640
 
        col = uiLayoutColumn(layout, 1);
1641
 
   
1642
 
         uiItemL(layout, "Color Space:", ICON_NONE);
1643
 
        row= uiLayoutRow(layout, 0);
 
1988
        col = uiLayoutColumn(layout, TRUE);
 
1989
 
 
1990
        uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
 
1991
        row = uiLayoutRow(layout, FALSE);
1644
1992
        uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1645
1993
 
1646
1994
        uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1651
1999
{
1652
2000
        uiLayout *row, *col;
1653
2001
        
1654
 
        uiItemL(layout, "Despill Channel:", ICON_NONE);
1655
 
        row = uiLayoutRow(layout,0);
 
2002
        uiItemL(layout, IFACE_("Despill Channel:"), ICON_NONE);
 
2003
        row = uiLayoutRow(layout, FALSE);
1656
2004
        uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1657
2005
 
1658
 
        col= uiLayoutColumn(layout, 0);
 
2006
        col = uiLayoutColumn(layout, FALSE);
1659
2007
        uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1660
2008
 
1661
 
        if (RNA_enum_get(ptr, "limit_method")==0) {
1662
 
                uiItemL(col, "Limiting Channel:", ICON_NONE);
1663
 
                row=uiLayoutRow(col,0);
 
2009
        if (RNA_enum_get(ptr, "limit_method") == 0) {
 
2010
                uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
 
2011
                row = uiLayoutRow(col, FALSE);
1664
2012
                uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1665
2013
        }
1666
2014
 
1667
2015
        uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1668
2016
        uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE);
1669
 
        if (RNA_boolean_get(ptr, "use_unspill")== 1) {
 
2017
        if (RNA_boolean_get(ptr, "use_unspill") == TRUE) {
1670
2018
                uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1671
2019
                uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1672
2020
                uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1677
2025
{
1678
2026
        uiLayout *col;
1679
2027
        
1680
 
        col= uiLayoutColumn(layout, 0);
 
2028
        col = uiLayoutColumn(layout, FALSE);
1681
2029
        uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
1682
2030
        uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
1683
2031
        
1684
 
        col= uiLayoutColumn(layout, 1);
 
2032
        col = uiLayoutColumn(layout, TRUE);
1685
2033
        /*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE);  Removed for now */
1686
2034
        uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1687
2035
        /*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE);  Removed for now*/
1691
2039
{
1692
2040
        uiLayout *col;
1693
2041
        
1694
 
        col= uiLayoutColumn(layout, 1);
 
2042
        col = uiLayoutColumn(layout, TRUE);
1695
2043
        uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1696
2044
        uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1697
2045
        uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1701
2049
{       
1702
2050
        uiLayout *col, *row;
1703
2051
 
1704
 
        uiItemL(layout, "Color Space:", ICON_NONE);
1705
 
        row= uiLayoutRow(layout, 0);
 
2052
        uiItemL(layout, IFACE_("Color Space:"), ICON_NONE);
 
2053
        row = uiLayoutRow(layout, FALSE);
1706
2054
        uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1707
2055
 
1708
 
        col=uiLayoutColumn(layout, 0);
1709
 
        uiItemL(col, "Key Channel:", ICON_NONE);
1710
 
        row= uiLayoutRow(col, 0);
 
2056
        col = uiLayoutColumn(layout, FALSE);
 
2057
        uiItemL(col, IFACE_("Key Channel:"), ICON_NONE);
 
2058
        row = uiLayoutRow(col, FALSE);
1711
2059
        uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1712
2060
 
1713
 
        col = uiLayoutColumn(layout, 0);
 
2061
        col = uiLayoutColumn(layout, FALSE);
1714
2062
 
1715
2063
        uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
1716
 
        if (RNA_enum_get(ptr, "limit_method")==0) {
1717
 
                uiItemL(col, "Limiting Channel:", ICON_NONE);
1718
 
                row=uiLayoutRow(col,0);
 
2064
        if (RNA_enum_get(ptr, "limit_method") == 0) {
 
2065
                uiItemL(col, IFACE_("Limiting Channel:"), ICON_NONE);
 
2066
                row = uiLayoutRow(col, FALSE);
1719
2067
                uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
1720
2068
        }
1721
2069
 
1727
2075
{
1728
2076
        uiLayout *col;
1729
2077
        
1730
 
        col= uiLayoutColumn(layout, 1);
 
2078
        col = uiLayoutColumn(layout, TRUE);
1731
2079
        uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1732
2080
        uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
1733
2081
}
1740
2088
static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1741
2089
{
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);
1744
2092
}
1745
2093
 
 
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)
 
2098
{
 
2099
        uiLayout *layout, *row;
 
2100
        PointerRNA nodeptr, inputptr, imfptr;
 
2101
        int imtype;
 
2102
        int rx, ry;
 
2103
        RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
 
2104
        
 
2105
        layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y + NODE_DY, width, 20, UI_GetStyle());
 
2106
        row = uiLayoutRow(layout, FALSE);
 
2107
        
 
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);
 
2113
                
 
2114
                uiItemL(row, input->layer, ICON_NONE);
 
2115
        }
 
2116
        else {
 
2117
                NodeImageMultiFileSocket *input = sock->storage;
 
2118
                PropertyRNA *imtype_prop;
 
2119
                const char *imtype_name;
 
2120
                RNA_pointer_create(&ntree->id, &RNA_NodeOutputFileSlotFile, input, &inputptr);
 
2121
                
 
2122
                uiItemL(row, input->path, ICON_NONE);
 
2123
                
 
2124
                if (!RNA_boolean_get(&inputptr, "use_node_format"))
 
2125
                        imfptr = RNA_pointer_get(&inputptr, "format");
 
2126
                
 
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);
 
2133
        }
 
2134
        
 
2135
        uiBlockLayoutResolve(block, &rx, &ry);
 
2136
}
1746
2137
static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1747
2138
{
1748
2139
        PointerRNA imfptr = RNA_pointer_get(ptr, "format");
1749
2140
        int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1750
2141
        
1751
2142
        if (multilayer)
1752
 
                uiItemL(layout, "Path:", 0);
 
2143
                uiItemL(layout, IFACE_("Path:"), ICON_NONE);
1753
2144
        else
1754
 
                uiItemL(layout, "Base Path:", 0);
 
2145
                uiItemL(layout, IFACE_("Base Path:"), ICON_NONE);
1755
2146
        uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
1756
2147
}
1757
2148
static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
1758
2149
{
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;
 
2153
        int active_index;
1761
2154
        int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
1762
2155
        
1763
2156
        node_composit_buts_file_output(layout, C, ptr);
1764
 
        uiTemplateImageSettings(layout, &imfptr);
 
2157
        uiTemplateImageSettings(layout, &imfptr, FALSE);
1765
2158
        
1766
2159
        uiItemS(layout);
1767
2160
        
1768
 
        uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
1769
 
        
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");
 
2162
        
 
2163
        row = uiLayoutRow(layout, FALSE);
 
2164
        col = uiLayoutColumn(row, TRUE);
 
2165
        
 
2166
        active_index = RNA_int_get(ptr, "active_input_index");
 
2167
        /* using different collection properties if multilayer format is enabled */
 
2168
        if (multilayer) {
 
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);
 
2172
        }
 
2173
        else {
 
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);
 
2177
        }
 
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;
 
2180
        
 
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);
1771
2188
        
1772
2189
        if (active_input_ptr.data) {
1773
 
                uiLayout *row, *col;
1774
 
                
1775
 
                col = uiLayoutColumn(layout, 1);
1776
 
                if (multilayer)
1777
 
                        uiItemL(col, "Layer Name:", 0);
1778
 
                else
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);
1783
 
                
1784
 
                /* in multilayer format all socket format details are ignored */
1785
 
                if (!multilayer) {
 
2190
                if (multilayer) {
 
2191
                        col = uiLayoutColumn(layout, TRUE);
 
2192
                        
 
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);
 
2198
                }
 
2199
                else {
 
2200
                        col = uiLayoutColumn(layout, TRUE);
 
2201
                        
 
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);
 
2207
                        
 
2208
                        /* format details for individual files */
1786
2209
                        imfptr = RNA_pointer_get(&active_input_ptr, "format");
1787
2210
                        
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);
1791
2214
                        
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);
1795
2218
                }
1796
2219
        }
1797
2220
}
1799
2222
static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1800
2223
{
1801
2224
        uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
 
2225
 
 
2226
        if (RNA_enum_get(ptr, "space") == CMP_SCALE_RENDERPERCENT) {
 
2227
                uiLayout *row;
 
2228
                uiItemR(layout, ptr, "frame_method", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
 
2229
                row = uiLayoutRow(layout, TRUE);
 
2230
                uiItemR(row, ptr, "offset_x", 0, "X", ICON_NONE);
 
2231
                uiItemR(row, ptr, "offset_y", 0, "Y", ICON_NONE);
 
2232
        }
1802
2233
}
1803
2234
 
1804
2235
static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1810
2241
{
1811
2242
        uiLayout *col;
1812
2243
        
1813
 
        col= uiLayoutColumn(layout, 0);
 
2244
        col = uiLayoutColumn(layout, FALSE);
1814
2245
        uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
1815
2246
        uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
1816
2247
}
1831
2262
        
1832
2263
        uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1833
2264
        
1834
 
        if (RNA_enum_get(ptr, "correction_method")== 0) {
 
2265
        if (RNA_enum_get(ptr, "correction_method") == 0) {
1835
2266
        
1836
 
                split = uiLayoutSplit(layout, 0, 0);
1837
 
                col = uiLayoutColumn(split, 0);
1838
 
                uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1);
1839
 
                row = uiLayoutRow(col, 0);
 
2267
                split = uiLayoutSplit(layout, 0.0f, FALSE);
 
2268
                col = uiLayoutColumn(split, FALSE);
 
2269
                uiTemplateColorPicker(col, ptr, "lift", 1, 1, 0, 1);
 
2270
                row = uiLayoutRow(col, FALSE);
1840
2271
                uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
1841
2272
                
1842
 
                col = uiLayoutColumn(split, 0);
1843
 
                uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1);
1844
 
                row = uiLayoutRow(col, 0);
 
2273
                col = uiLayoutColumn(split, FALSE);
 
2274
                uiTemplateColorPicker(col, ptr, "gamma", 1, 1, 1, 1);
 
2275
                row = uiLayoutRow(col, FALSE);
1845
2276
                uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
1846
2277
                
1847
 
                col = uiLayoutColumn(split, 0);
1848
 
                uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1);
1849
 
                row = uiLayoutRow(col, 0);
 
2278
                col = uiLayoutColumn(split, FALSE);
 
2279
                uiTemplateColorPicker(col, ptr, "gain", 1, 1, 1, 1);
 
2280
                row = uiLayoutRow(col, FALSE);
1850
2281
                uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
1851
2282
 
1852
2283
        }
1853
2284
        else {
1854
2285
                
1855
 
                split = uiLayoutSplit(layout, 0, 0);
1856
 
                col = uiLayoutColumn(split, 0);
1857
 
                uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1);
1858
 
                row = uiLayoutRow(col, 0);
 
2286
                split = uiLayoutSplit(layout, 0.0f, FALSE);
 
2287
                col = uiLayoutColumn(split, FALSE);
 
2288
                uiTemplateColorPicker(col, ptr, "offset", 1, 1, 0, 1);
 
2289
                row = uiLayoutRow(col, FALSE);
1859
2290
                uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
1860
2291
                
1861
 
                col = uiLayoutColumn(split, 0);
1862
 
                uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1);
1863
 
                row = uiLayoutRow(col, 0);
 
2292
                col = uiLayoutColumn(split, FALSE);
 
2293
                uiTemplateColorPicker(col, ptr, "power", 1, 1, 0, 1);
 
2294
                row = uiLayoutRow(col, FALSE);
1864
2295
                uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
1865
2296
                
1866
 
                col = uiLayoutColumn(split, 0);
1867
 
                uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1);
1868
 
                row = uiLayoutRow(col, 0);
 
2297
                col = uiLayoutColumn(split, FALSE);
 
2298
                uiTemplateColorPicker(col, ptr, "slope", 1, 1, 0, 1);
 
2299
                row = uiLayoutRow(col, FALSE);
1869
2300
                uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
1870
2301
        }
1871
2302
 
1874
2305
{
1875
2306
        uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
1876
2307
 
1877
 
        if (RNA_enum_get(ptr, "correction_method")== 0) {
 
2308
        if (RNA_enum_get(ptr, "correction_method") == 0) {
1878
2309
 
1879
 
        uiTemplateColorWheel(layout, ptr, "lift", 1, 1, 0, 1);
 
2310
                uiTemplateColorPicker(layout, ptr, "lift", 1, 1, 0, 1);
1880
2311
                uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
1881
2312
 
1882
 
                uiTemplateColorWheel(layout, ptr, "gamma", 1, 1, 1, 1);
 
2313
                uiTemplateColorPicker(layout, ptr, "gamma", 1, 1, 1, 1);
1883
2314
                uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
1884
2315
 
1885
 
                uiTemplateColorWheel(layout, ptr, "gain", 1, 1, 1, 1);
 
2316
                uiTemplateColorPicker(layout, ptr, "gain", 1, 1, 1, 1);
1886
2317
                uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
1887
2318
        }
1888
2319
        else {
1889
 
                uiTemplateColorWheel(layout, ptr, "offset", 1, 1, 0, 1);
 
2320
                uiTemplateColorPicker(layout, ptr, "offset", 1, 1, 0, 1);
1890
2321
                uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
1891
2322
 
1892
 
                uiTemplateColorWheel(layout, ptr, "power", 1, 1, 0, 1);
 
2323
                uiTemplateColorPicker(layout, ptr, "power", 1, 1, 0, 1);
1893
2324
                uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
1894
2325
 
1895
 
                uiTemplateColorWheel(layout, ptr, "slope", 1, 1, 0, 1);
 
2326
                uiTemplateColorPicker(layout, ptr, "slope", 1, 1, 0, 1);
1896
2327
                uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
1897
2328
        }
1898
2329
}
1900
2331
 
1901
2332
static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1902
2333
{
 
2334
        bNode *node = ptr->data;
 
2335
        CurveMapping *cumap = node->storage;
 
2336
 
 
2337
        if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
 
2338
                cumap->flag |= CUMA_DRAW_SAMPLE;
 
2339
                copy_v3_v3(cumap->sample, _sample_col);
 
2340
        }
 
2341
        else {
 
2342
                cumap->flag &= ~CUMA_DRAW_SAMPLE;
 
2343
        }
 
2344
 
1903
2345
        uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
1904
2346
}
1905
2347
 
1913
2355
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1914
2356
}
1915
2357
 
 
2358
static void node_composit_buts_movieclip_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
2359
{
 
2360
        bNode *node = ptr->data;
 
2361
        PointerRNA clipptr;
 
2362
 
 
2363
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
 
2364
 
 
2365
        if (!node->id)
 
2366
                return;
 
2367
 
 
2368
        clipptr = RNA_pointer_get(ptr, "clip");
 
2369
 
 
2370
        uiTemplateColorspaceSettings(layout, &clipptr, "colorspace_settings");
 
2371
}
 
2372
 
1916
2373
static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
1917
2374
{
1918
 
        bNode *node= ptr->data;
 
2375
        bNode *node = ptr->data;
1919
2376
 
1920
2377
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1921
2378
 
1922
2379
        if (!node->id)
1923
2380
                return;
1924
2381
 
1925
 
        uiItemR(layout, ptr, "filter_type", 0, "", 0);
 
2382
        uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
 
2383
}
 
2384
 
 
2385
static void node_composit_buts_translate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2386
{
 
2387
        uiItemR(layout, ptr, "use_relative", 0, NULL, ICON_NONE);
 
2388
        uiItemR(layout, ptr, "wrap_axis", 0, NULL, ICON_NONE);
1926
2389
}
1927
2390
 
1928
2391
static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
1929
2392
{
1930
 
        uiItemR(layout, ptr, "filter_type", 0, "", 0);
 
2393
        uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
1931
2394
}
1932
2395
 
1933
2396
static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
1934
2397
{
1935
 
        bNode *node= ptr->data;
 
2398
        bNode *node = ptr->data;
1936
2399
 
1937
2400
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
1938
2401
 
1939
2402
        if (!node->id)
1940
2403
                return;
1941
2404
 
1942
 
        uiItemR(layout, ptr, "distortion_type", 0, "", 0);
 
2405
        uiItemR(layout, ptr, "distortion_type", 0, "", ICON_NONE);
 
2406
}
 
2407
 
 
2408
static void node_composit_buts_colorcorrection(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2409
{
 
2410
        uiLayout *row;
 
2411
        
 
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);
 
2416
 
 
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);
 
2424
 
 
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);
 
2432
 
 
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);
 
2440
 
 
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);
 
2448
 
 
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);
 
2456
 
 
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);
 
2460
}
 
2461
 
 
2462
static void node_composit_buts_colorcorrection_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2463
{
 
2464
        uiLayout *row;
 
2465
        
 
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);
 
2470
        row = layout;
 
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);
 
2476
 
 
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);
 
2482
 
 
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);
 
2488
 
 
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);
 
2494
        
 
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);
 
2500
 
 
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);
 
2504
}
 
2505
 
 
2506
static void node_composit_buts_switch(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2507
{
 
2508
        uiItemR(layout, ptr, "check", 0, NULL, ICON_NONE);
 
2509
}
 
2510
 
 
2511
static void node_composit_buts_boxmask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2512
{
 
2513
        uiLayout *row;
 
2514
        
 
2515
        row = uiLayoutRow(layout, TRUE);
 
2516
        uiItemR(row, ptr, "x", 0, NULL, ICON_NONE);
 
2517
        uiItemR(row, ptr, "y", 0, NULL, ICON_NONE);
 
2518
        
 
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);
 
2522
 
 
2523
        uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
 
2524
        uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
 
2525
}
 
2526
 
 
2527
static void node_composit_buts_bokehimage(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2528
{
 
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);
 
2534
}
 
2535
 
 
2536
static void node_composit_buts_bokehblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2537
{
 
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);
 
2541
}
 
2542
 
 
2543
static void node_composit_backdrop_viewer(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
 
2544
{
 
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;
 
2551
 
 
2552
                glColor3f(1.0, 1.0, 1.0);
 
2553
 
 
2554
                glBegin(GL_LINES);
 
2555
                glVertex2f(cx - 25, cy - 25);
 
2556
                glVertex2f(cx + 25, cy + 25);
 
2557
                glVertex2f(cx + 25, cy - 25);
 
2558
                glVertex2f(cx - 25, cy + 25);
 
2559
                glEnd();
 
2560
        }
 
2561
}
 
2562
 
 
2563
static void node_composit_backdrop_boxmask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
 
2564
{
 
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;
 
2574
 
 
2575
        float cx, cy, x1, x2, x3, x4;
 
2576
        float y1, y2, y3, y4;
 
2577
 
 
2578
 
 
2579
        /* keep this, saves us from a version patch */
 
2580
        if (snode->zoom == 0.0f) snode->zoom = 1.0f;
 
2581
 
 
2582
        glColor3f(1.0, 1.0, 1.0);
 
2583
 
 
2584
        cx  = x + snode->zoom * backdropWidth * boxmask->x;
 
2585
        cy = y + snode->zoom * backdropHeight * boxmask->y;
 
2586
 
 
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;
 
2595
 
 
2596
        glBegin(GL_LINE_LOOP);
 
2597
        glVertex2f(x1, y1);
 
2598
        glVertex2f(x2, y2);
 
2599
        glVertex2f(x3, y3);
 
2600
        glVertex2f(x4, y4);
 
2601
        glEnd();
 
2602
}
 
2603
 
 
2604
static void node_composit_backdrop_ellipsemask(SpaceNode *snode, ImBuf *backdrop, bNode *node, int x, int y)
 
2605
{
 
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;
 
2615
 
 
2616
        float cx, cy, x1, x2, x3, x4;
 
2617
        float y1, y2, y3, y4;
 
2618
 
 
2619
 
 
2620
        /* keep this, saves us from a version patch */
 
2621
        if (snode->zoom == 0.0f) snode->zoom = 1.0f;
 
2622
 
 
2623
        glColor3f(1.0, 1.0, 1.0);
 
2624
 
 
2625
        cx  = x + snode->zoom * backdropWidth * ellipsemask->x;
 
2626
        cy = y + snode->zoom * backdropHeight * ellipsemask->y;
 
2627
 
 
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;
 
2636
 
 
2637
        glBegin(GL_LINE_LOOP);
 
2638
 
 
2639
        glVertex2f(x1, y1);
 
2640
        glVertex2f(x2, y2);
 
2641
        glVertex2f(x3, y3);
 
2642
        glVertex2f(x4, y4);
 
2643
        glEnd();
 
2644
}
 
2645
 
 
2646
static void node_composit_buts_ellipsemask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2647
{
 
2648
        uiLayout *row;
 
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);
 
2655
 
 
2656
        uiItemR(layout, ptr, "rotation", 0, NULL, ICON_NONE);
 
2657
        uiItemR(layout, ptr, "mask_type", 0, NULL, ICON_NONE);
 
2658
}
 
2659
 
 
2660
static void node_composit_buts_composite(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2661
{
 
2662
        uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
 
2663
}
 
2664
 
 
2665
static void node_composit_buts_viewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2666
{
 
2667
        uiItemR(layout, ptr, "use_alpha", 0, NULL, ICON_NONE);
 
2668
}
 
2669
 
 
2670
static void node_composit_buts_viewer_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2671
{
 
2672
        uiLayout *col;
 
2673
        
 
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);
 
2680
        }
 
2681
}
 
2682
 
 
2683
static void node_composit_buts_mask(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
2684
{
 
2685
        bNode *node = ptr->data;
 
2686
 
 
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);
 
2690
 
 
2691
        uiItemR(layout, ptr, "size_source", 0, "", ICON_NONE);
 
2692
 
 
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);
 
2696
        }
 
2697
 
 
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);
 
2702
        }
 
2703
}
 
2704
 
 
2705
static void node_composit_buts_keyingscreen(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
2706
{
 
2707
        bNode *node = ptr->data;
 
2708
 
 
2709
        uiTemplateID(layout, C, ptr, "clip", NULL, NULL, NULL);
 
2710
 
 
2711
        if (node->id) {
 
2712
                MovieClip *clip = (MovieClip *) node->id;
 
2713
                uiLayout *col;
 
2714
                PointerRNA tracking_ptr;
 
2715
 
 
2716
                RNA_pointer_create(&clip->id, &RNA_MovieTracking, &clip->tracking, &tracking_ptr);
 
2717
 
 
2718
                col = uiLayoutColumn(layout, TRUE);
 
2719
                uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
 
2720
        }
 
2721
}
 
2722
 
 
2723
static void node_composit_buts_keying(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
 
2724
{
 
2725
        /* bNode *node = ptr->data; */ /* UNUSED */
 
2726
 
 
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);
 
2739
}
 
2740
 
 
2741
static void node_composit_buts_trackpos(uiLayout *layout, bContext *C, PointerRNA *ptr)
 
2742
{
 
2743
        bNode *node = ptr->data;
 
2744
 
 
2745
        uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
 
2746
 
 
2747
        if (node->id) {
 
2748
                MovieClip *clip = (MovieClip *) node->id;
 
2749
                MovieTracking *tracking = &clip->tracking;
 
2750
                MovieTrackingObject *object;
 
2751
                uiLayout *col;
 
2752
                PointerRNA tracking_ptr;
 
2753
                NodeTrackPosData *data = node->storage;
 
2754
 
 
2755
                RNA_pointer_create(&clip->id, &RNA_MovieTracking, tracking, &tracking_ptr);
 
2756
 
 
2757
                col = uiLayoutColumn(layout, FALSE);
 
2758
                uiItemPointerR(col, ptr, "tracking_object", &tracking_ptr, "objects", "", ICON_OBJECT_DATA);
 
2759
 
 
2760
                object = BKE_tracking_object_get_named(tracking, data->tracking_object);
 
2761
                if (object) {
 
2762
                        PointerRNA object_ptr;
 
2763
 
 
2764
                        RNA_pointer_create(&clip->id, &RNA_MovieTrackingObject, object, &object_ptr);
 
2765
 
 
2766
                        uiItemPointerR(col, ptr, "track_name", &object_ptr, "tracks", "", ICON_ANIM_DATA);
 
2767
                }
 
2768
                else {
 
2769
                        uiItemR(layout, ptr, "track_name", 0, "", ICON_ANIM_DATA);
 
2770
                }
 
2771
 
 
2772
                uiItemR(layout, ptr, "position", 0, NULL, ICON_NONE);
 
2773
 
 
2774
                if (node->custom1 == 2) {
 
2775
                        uiItemR(layout, ptr, "frame_relative", 0, NULL, ICON_NONE);
 
2776
                }
 
2777
        }
1943
2778
}
1944
2779
 
1945
2780
/* only once called */
1946
2781
static void node_composit_set_butfunc(bNodeType *ntype)
1947
2782
{
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" */
1951
2785
 
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;
1954
2789
                        break;
1955
2790
                case CMP_NODE_R_LAYERS:
1956
 
                        ntype->uifunc= node_composit_buts_renderlayers;
 
2791
                        ntype->uifunc = node_composit_buts_renderlayers;
1957
2792
                        break;
1958
2793
                case CMP_NODE_NORMAL:
1959
 
                        ntype->uifunc= node_buts_normal;
 
2794
                        ntype->uifunc = node_buts_normal;
1960
2795
                        break;
1961
2796
                case CMP_NODE_CURVE_VEC:
1962
 
                        ntype->uifunc= node_buts_curvevec;
 
2797
                        ntype->uifunc = node_buts_curvevec;
1963
2798
                        break;
1964
2799
                case CMP_NODE_CURVE_RGB:
1965
 
                        ntype->uifunc= node_buts_curvecol;
 
2800
                        ntype->uifunc = node_buts_curvecol;
1966
2801
                        break;
1967
2802
                case CMP_NODE_VALUE:
1968
 
                        ntype->uifunc= node_buts_value;
 
2803
                        ntype->uifunc = node_buts_value;
1969
2804
                        break;
1970
2805
                case CMP_NODE_RGB:
1971
 
                        ntype->uifunc= node_buts_rgb;
 
2806
                        ntype->uifunc = node_buts_rgb;
1972
2807
                        break;
1973
2808
                case CMP_NODE_FLIP:
1974
 
                        ntype->uifunc= node_composit_buts_flip;
 
2809
                        ntype->uifunc = node_composit_buts_flip;
1975
2810
                        break;
1976
2811
                case CMP_NODE_SPLITVIEWER:
1977
 
                        ntype->uifunc= node_composit_buts_splitviewer;
 
2812
                        ntype->uifunc = node_composit_buts_splitviewer;
1978
2813
                        break;
1979
2814
                case CMP_NODE_MIX_RGB:
1980
 
                        ntype->uifunc= node_buts_mix_rgb;
 
2815
                        ntype->uifunc = node_buts_mix_rgb;
1981
2816
                        break;
1982
2817
                case CMP_NODE_VALTORGB:
1983
 
                        ntype->uifunc= node_buts_colorramp;
 
2818
                        ntype->uifunc = node_buts_colorramp;
1984
2819
                        break;
1985
2820
                case CMP_NODE_CROP:
1986
 
                        ntype->uifunc= node_composit_buts_crop;
 
2821
                        ntype->uifunc = node_composit_buts_crop;
1987
2822
                        break;
1988
2823
                case CMP_NODE_BLUR:
1989
 
                        ntype->uifunc= node_composit_buts_blur;
 
2824
                        ntype->uifunc = node_composit_buts_blur;
1990
2825
                        break;
1991
2826
                case CMP_NODE_DBLUR:
1992
 
                        ntype->uifunc= node_composit_buts_dblur;
 
2827
                        ntype->uifunc = node_composit_buts_dblur;
1993
2828
                        break;
1994
2829
                case CMP_NODE_BILATERALBLUR:
1995
 
                        ntype->uifunc= node_composit_buts_bilateralblur;
 
2830
                        ntype->uifunc = node_composit_buts_bilateralblur;
1996
2831
                        break;
1997
2832
                case CMP_NODE_DEFOCUS:
1998
2833
                        ntype->uifunc = node_composit_buts_defocus;
2007
2842
                        ntype->uifunc = node_composit_buts_lensdist;
2008
2843
                        break;
2009
2844
                case CMP_NODE_VECBLUR:
2010
 
                        ntype->uifunc= node_composit_buts_vecblur;
 
2845
                        ntype->uifunc = node_composit_buts_vecblur;
2011
2846
                        break;
2012
2847
                case CMP_NODE_FILTER:
2013
 
                        ntype->uifunc= node_composit_buts_filter;
 
2848
                        ntype->uifunc = node_composit_buts_filter;
2014
2849
                        break;
2015
2850
                case CMP_NODE_MAP_VALUE:
2016
 
                        ntype->uifunc= node_composit_buts_map_value;
 
2851
                        ntype->uifunc = node_composit_buts_map_value;
 
2852
                        break;
 
2853
                case CMP_NODE_MAP_RANGE:
 
2854
                        ntype->uifunc = node_composit_buts_map_range;
2017
2855
                        break;
2018
2856
                case CMP_NODE_TIME:
2019
 
                        ntype->uifunc= node_buts_time;
 
2857
                        ntype->uifunc = node_buts_time;
2020
2858
                        break;
2021
2859
                case CMP_NODE_ALPHAOVER:
2022
 
                        ntype->uifunc= node_composit_buts_alphaover;
 
2860
                        ntype->uifunc = node_composit_buts_alphaover;
2023
2861
                        break;
2024
2862
                case CMP_NODE_HUE_SAT:
2025
 
                        ntype->uifunc= node_composit_buts_hue_sat;
 
2863
                        ntype->uifunc = node_composit_buts_hue_sat;
2026
2864
                        break;
2027
2865
                case CMP_NODE_TEXTURE:
2028
 
                        ntype->uifunc= node_buts_texture;
 
2866
                        ntype->uifunc = node_buts_texture;
2029
2867
                        break;
2030
2868
                case CMP_NODE_DILATEERODE:
2031
 
                        ntype->uifunc= node_composit_buts_dilateerode;
 
2869
                        ntype->uifunc = node_composit_buts_dilateerode;
 
2870
                        break;
 
2871
                case CMP_NODE_INPAINT:
 
2872
                        ntype->uifunc = node_composit_buts_inpaint;
 
2873
                        break;
 
2874
                case CMP_NODE_DESPECKLE:
 
2875
                        ntype->uifunc = node_composit_buts_despeckle;
2032
2876
                        break;
2033
2877
                case CMP_NODE_OUTPUT_FILE:
2034
 
                        ntype->uifunc= node_composit_buts_file_output;
2035
 
                        ntype->uifuncbut= node_composit_buts_file_output_details;
 
2878
                        ntype->uifunc = node_composit_buts_file_output;
 
2879
                        ntype->uifuncbut = node_composit_buts_file_output_details;
 
2880
                        ntype->drawinputfunc = node_draw_input_file_output;
2036
2881
                        break;
2037
2882
                case CMP_NODE_DIFF_MATTE:
2038
 
                        ntype->uifunc=node_composit_buts_diff_matte;
 
2883
                        ntype->uifunc = node_composit_buts_diff_matte;
2039
2884
                        break;
2040
2885
                case CMP_NODE_DIST_MATTE:
2041
 
                        ntype->uifunc=node_composit_buts_distance_matte;
 
2886
                        ntype->uifunc = node_composit_buts_distance_matte;
2042
2887
                        break;
2043
2888
                case CMP_NODE_COLOR_SPILL:
2044
 
                        ntype->uifunc=node_composit_buts_color_spill;
 
2889
                        ntype->uifunc = node_composit_buts_color_spill;
2045
2890
                        break;
2046
2891
                case CMP_NODE_CHROMA_MATTE:
2047
 
                        ntype->uifunc=node_composit_buts_chroma_matte;
 
2892
                        ntype->uifunc = node_composit_buts_chroma_matte;
2048
2893
                        break;
2049
2894
                case CMP_NODE_COLOR_MATTE:
2050
 
                        ntype->uifunc=node_composit_buts_color_matte;
 
2895
                        ntype->uifunc = node_composit_buts_color_matte;
2051
2896
                        break;
2052
2897
                case CMP_NODE_SCALE:
2053
 
                        ntype->uifunc= node_composit_buts_scale;
 
2898
                        ntype->uifunc = node_composit_buts_scale;
2054
2899
                        break;
2055
2900
                case CMP_NODE_ROTATE:
2056
 
                        ntype->uifunc=node_composit_buts_rotate;
 
2901
                        ntype->uifunc = node_composit_buts_rotate;
2057
2902
                        break;
2058
2903
                case CMP_NODE_CHANNEL_MATTE:
2059
 
                        ntype->uifunc= node_composit_buts_channel_matte;
 
2904
                        ntype->uifunc = node_composit_buts_channel_matte;
2060
2905
                        break;
2061
2906
                case CMP_NODE_LUMA_MATTE:
2062
 
                        ntype->uifunc= node_composit_buts_luma_matte;
 
2907
                        ntype->uifunc = node_composit_buts_luma_matte;
2063
2908
                        break;
2064
2909
                case CMP_NODE_MAP_UV:
2065
 
                        ntype->uifunc= node_composit_buts_map_uv;
 
2910
                        ntype->uifunc = node_composit_buts_map_uv;
2066
2911
                        break;
2067
2912
                case CMP_NODE_ID_MASK:
2068
 
                        ntype->uifunc= node_composit_buts_id_mask;
 
2913
                        ntype->uifunc = node_composit_buts_id_mask;
2069
2914
                        break;
2070
2915
                case CMP_NODE_DOUBLEEDGEMASK:
2071
 
                        ntype->uifunc= node_composit_buts_double_edge_mask;
 
2916
                        ntype->uifunc = node_composit_buts_double_edge_mask;
2072
2917
                        break;
2073
2918
                case CMP_NODE_MATH:
2074
 
                        ntype->uifunc= node_buts_math;
 
2919
                        ntype->uifunc = node_buts_math;
2075
2920
                        break;
2076
2921
                case CMP_NODE_INVERT:
2077
 
                        ntype->uifunc= node_composit_buts_invert;
 
2922
                        ntype->uifunc = node_composit_buts_invert;
2078
2923
                        break;
2079
2924
                case CMP_NODE_PREMULKEY:
2080
 
                        ntype->uifunc= node_composit_buts_premulkey;
 
2925
                        ntype->uifunc = node_composit_buts_premulkey;
2081
2926
                        break;
2082
2927
                case CMP_NODE_VIEW_LEVELS:
2083
 
                        ntype->uifunc=node_composit_buts_view_levels;
 
2928
                        ntype->uifunc = node_composit_buts_view_levels;
2084
2929
                        break;
2085
2930
                case CMP_NODE_COLORBALANCE:
2086
 
                        ntype->uifunc=node_composit_buts_colorbalance;
2087
 
                        ntype->uifuncbut=node_composit_buts_colorbalance_but;
 
2931
                        ntype->uifunc = node_composit_buts_colorbalance;
 
2932
                        ntype->uifuncbut = node_composit_buts_colorbalance_but;
2088
2933
                        break;
2089
2934
                case CMP_NODE_HUECORRECT:
2090
 
                        ntype->uifunc=node_composit_buts_huecorrect;
 
2935
                        ntype->uifunc = node_composit_buts_huecorrect;
2091
2936
                        break;
2092
2937
                case CMP_NODE_ZCOMBINE:
2093
 
                        ntype->uifunc=node_composit_buts_zcombine;
 
2938
                        ntype->uifunc = node_composit_buts_zcombine;
2094
2939
                        break;
2095
2940
                case CMP_NODE_COMBYCCA:
2096
2941
                case CMP_NODE_SEPYCCA:
2097
 
                        ntype->uifunc=node_composit_buts_ycc;
 
2942
                        ntype->uifunc = node_composit_buts_ycc;
2098
2943
                        break;
2099
2944
                case CMP_NODE_MOVIECLIP:
2100
 
                        ntype->uifunc= node_composit_buts_movieclip;
 
2945
                        ntype->uifunc = node_composit_buts_movieclip;
 
2946
                        ntype->uifuncbut = node_composit_buts_movieclip_details;
2101
2947
                        break;
2102
2948
                case CMP_NODE_STABILIZE2D:
2103
 
                        ntype->uifunc= node_composit_buts_stabilize2d;
 
2949
                        ntype->uifunc = node_composit_buts_stabilize2d;
2104
2950
                        break;
2105
2951
                case CMP_NODE_TRANSFORM:
2106
 
                        ntype->uifunc= node_composit_buts_transform;
 
2952
                        ntype->uifunc = node_composit_buts_transform;
 
2953
                        break;
 
2954
                case CMP_NODE_TRANSLATE:
 
2955
                        ntype->uifunc = node_composit_buts_translate;
2107
2956
                        break;
2108
2957
                case CMP_NODE_MOVIEDISTORTION:
2109
 
                        ntype->uifunc= node_composit_buts_moviedistortion;
 
2958
                        ntype->uifunc = node_composit_buts_moviedistortion;
 
2959
                        break;
 
2960
                case CMP_NODE_COLORCORRECTION:
 
2961
                        ntype->uifunc = node_composit_buts_colorcorrection;
 
2962
                        ntype->uifuncbut = node_composit_buts_colorcorrection_but;
 
2963
                        break;
 
2964
                case CMP_NODE_SWITCH:
 
2965
                        ntype->uifunc = node_composit_buts_switch;
 
2966
                        break;
 
2967
                case CMP_NODE_MASK_BOX:
 
2968
                        ntype->uifunc = node_composit_buts_boxmask;
 
2969
                        ntype->uibackdropfunc = node_composit_backdrop_boxmask;
 
2970
                        break;
 
2971
                case CMP_NODE_MASK_ELLIPSE:
 
2972
                        ntype->uifunc = node_composit_buts_ellipsemask;
 
2973
                        ntype->uibackdropfunc = node_composit_backdrop_ellipsemask;
 
2974
                        break;
 
2975
                case CMP_NODE_BOKEHIMAGE:
 
2976
                        ntype->uifunc = node_composit_buts_bokehimage;
 
2977
                        break;
 
2978
                case CMP_NODE_BOKEHBLUR:
 
2979
                        ntype->uifunc = node_composit_buts_bokehblur;
 
2980
                        break;
 
2981
                case CMP_NODE_VIEWER:
 
2982
                        ntype->uifunc = node_composit_buts_viewer;
 
2983
                        ntype->uifuncbut = node_composit_buts_viewer_but;
 
2984
                        ntype->uibackdropfunc = node_composit_backdrop_viewer;
 
2985
                        break;
 
2986
                case CMP_NODE_COMPOSITE:
 
2987
                        ntype->uifunc = node_composit_buts_composite;
 
2988
                        break;
 
2989
                case CMP_NODE_MASK:
 
2990
                        ntype->uifunc = node_composit_buts_mask;
 
2991
                        break;
 
2992
                case CMP_NODE_KEYINGSCREEN:
 
2993
                        ntype->uifunc = node_composit_buts_keyingscreen;
 
2994
                        break;
 
2995
                case CMP_NODE_KEYING:
 
2996
                        ntype->uifunc = node_composit_buts_keying;
 
2997
                        break;
 
2998
                case CMP_NODE_TRACKPOS:
 
2999
                        ntype->uifunc = node_composit_buts_trackpos;
2110
3000
                        break;
2111
3001
                default:
2112
 
                        ntype->uifunc= NULL;
 
3002
                        ntype->uifunc = NULL;
2113
3003
        }
2114
 
        if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
2115
 
 
2116
3004
}
2117
3005
 
2118
3006
/* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
2121
3009
{
2122
3010
        uiLayout *col;
2123
3011
        
2124
 
        col= uiLayoutColumn(layout, 1);
2125
 
        uiItemR(col, ptr, "offset", 0, "Offset", ICON_NONE);
2126
 
        uiItemR(col, ptr, "offset_frequency", 0, "Frequency", ICON_NONE);
 
3012
        col = uiLayoutColumn(layout, TRUE);
 
3013
        uiItemR(col, ptr, "offset", 0, IFACE_("Offset"), ICON_NONE);
 
3014
        uiItemR(col, ptr, "offset_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2127
3015
        
2128
 
        col= uiLayoutColumn(layout, 1);
2129
 
        uiItemR(col, ptr, "squash", 0, "Squash", ICON_NONE);
2130
 
        uiItemR(col, ptr, "squash_frequency", 0, "Frequency", ICON_NONE);
 
3016
        col = uiLayoutColumn(layout, TRUE);
 
3017
        uiItemR(col, ptr, "squash", 0, IFACE_("Squash"), ICON_NONE);
 
3018
        uiItemR(col, ptr, "squash_frequency", 0, IFACE_("Frequency"), ICON_NONE);
2131
3019
}
2132
3020
 
2133
3021
static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
2134
3022
{
2135
3023
        PointerRNA tex_ptr;
2136
 
        bNode *node= ptr->data;
2137
 
        ID *id= ptr->id.data;
 
3024
        bNode *node = ptr->data;
 
3025
        ID *id = ptr->id.data;
2138
3026
        Tex *tex = (Tex *)node->storage;
2139
3027
        uiLayout *col, *row;
2140
3028
        
2141
3029
        RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
2142
3030
 
2143
 
        col= uiLayoutColumn(layout, 0);
 
3031
        col = uiLayoutColumn(layout, FALSE);
2144
3032
 
2145
 
        switch( tex->type ) {
 
3033
        switch (tex->type) {
2146
3034
                case TEX_BLEND:
2147
3035
                        uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
2148
 
                        row= uiLayoutRow(col, 0);
 
3036
                        row = uiLayoutRow(col, FALSE);
2149
3037
                        uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2150
3038
                        break;
2151
3039
 
2152
3040
                case TEX_MARBLE:
2153
 
                        row= uiLayoutRow(col, 0);
 
3041
                        row = uiLayoutRow(col, FALSE);
2154
3042
                        uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2155
 
                        row= uiLayoutRow(col, 0);
 
3043
                        row = uiLayoutRow(col, FALSE);
2156
3044
                        uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2157
 
                        row= uiLayoutRow(col, 0);
 
3045
                        row = uiLayoutRow(col, FALSE);
2158
3046
                        uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2159
 
                        row= uiLayoutRow(col, 0);
 
3047
                        row = uiLayoutRow(col, FALSE);
2160
3048
                        uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2161
3049
                        break;
2162
3050
 
2165
3053
                        break;
2166
3054
 
2167
3055
                case TEX_STUCCI:
2168
 
                        row= uiLayoutRow(col, 0);
 
3056
                        row = uiLayoutRow(col, FALSE);
2169
3057
                        uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2170
 
                        row= uiLayoutRow(col, 0);
 
3058
                        row = uiLayoutRow(col, FALSE);
2171
3059
                        uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2172
3060
                        uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2173
3061
                        break;
2175
3063
                case TEX_WOOD:
2176
3064
                        uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2177
3065
                        uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE);
2178
 
                        row= uiLayoutRow(col, 0);
 
3066
                        row = uiLayoutRow(col, FALSE);
2179
3067
                        uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2180
 
                        row= uiLayoutRow(col, 0);
2181
 
                        uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type")==TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type")==TEX_RING)); 
 
3068
                        row = uiLayoutRow(col, FALSE);
 
3069
                        uiLayoutSetActive(row, !(ELEM(tex->stype, TEX_BAND, TEX_RING)));
2182
3070
                        uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2183
3071
                        break;
2184
3072
                        
2185
3073
                case TEX_CLOUDS:
2186
3074
                        uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
2187
 
                        row= uiLayoutRow(col, 0);
 
3075
                        row = uiLayoutRow(col, FALSE);
2188
3076
                        uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2189
 
                        row= uiLayoutRow(col, 0);
 
3077
                        row = uiLayoutRow(col, FALSE);
2190
3078
                        uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
2191
 
                        uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, "Depth", ICON_NONE);
 
3079
                        uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, IFACE_("Depth"), ICON_NONE);
2192
3080
                        break;
2193
3081
                        
2194
3082
                case TEX_DISTNOISE:
2223
3111
/* only once called */
2224
3112
static void node_texture_set_butfunc(bNodeType *ntype)
2225
3113
{
2226
 
        ntype->uifuncbut = NULL;
2227
 
        if ( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) {
 
3114
        if (ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX) {
2228
3115
                ntype->uifunc = node_texture_buts_proc;
2229
3116
        }
2230
 
        else switch(ntype->type) {
2231
 
                
2232
 
                case TEX_NODE_MATH:
2233
 
                        ntype->uifunc = node_buts_math;
2234
 
                        break;
2235
 
                
2236
 
                case TEX_NODE_MIX_RGB:
2237
 
                        ntype->uifunc = node_buts_mix_rgb;
2238
 
                        break;
2239
 
                        
2240
 
                case TEX_NODE_VALTORGB:
2241
 
                        ntype->uifunc = node_buts_colorramp;
2242
 
                        break;
2243
 
                        
2244
 
                case TEX_NODE_CURVE_RGB:
2245
 
                        ntype->uifunc= node_buts_curvecol;
2246
 
                        break;
2247
 
                        
2248
 
                case TEX_NODE_CURVE_TIME:
2249
 
                        ntype->uifunc = node_buts_time;
2250
 
                        break;
2251
 
                        
2252
 
                case TEX_NODE_TEXTURE:
2253
 
                        ntype->uifunc = node_buts_texture;
2254
 
                        break;
2255
 
                        
2256
 
                case TEX_NODE_BRICKS:
2257
 
                        ntype->uifunc = node_texture_buts_bricks;
2258
 
                        break;
2259
 
                        
2260
 
                case TEX_NODE_IMAGE:
2261
 
                        ntype->uifunc = node_texture_buts_image;
2262
 
                        break;
2263
 
                        
2264
 
                case TEX_NODE_OUTPUT:
2265
 
                        ntype->uifunc = node_texture_buts_output;
2266
 
                        break;
 
3117
        else {
 
3118
                switch (ntype->type) {
 
3119
 
 
3120
                        case TEX_NODE_MATH:
 
3121
                                ntype->uifunc = node_buts_math;
 
3122
                                break;
 
3123
 
 
3124
                        case TEX_NODE_MIX_RGB:
 
3125
                                ntype->uifunc = node_buts_mix_rgb;
 
3126
                                break;
 
3127
 
 
3128
                        case TEX_NODE_VALTORGB:
 
3129
                                ntype->uifunc = node_buts_colorramp;
 
3130
                                break;
 
3131
 
 
3132
                        case TEX_NODE_CURVE_RGB:
 
3133
                                ntype->uifunc = node_buts_curvecol;
 
3134
                                break;
 
3135
 
 
3136
                        case TEX_NODE_CURVE_TIME:
 
3137
                                ntype->uifunc = node_buts_time;
 
3138
                                break;
 
3139
 
 
3140
                        case TEX_NODE_TEXTURE:
 
3141
                                ntype->uifunc = node_buts_texture;
 
3142
                                break;
 
3143
 
 
3144
                        case TEX_NODE_BRICKS:
 
3145
                                ntype->uifunc = node_texture_buts_bricks;
 
3146
                                break;
 
3147
 
 
3148
                        case TEX_NODE_IMAGE:
 
3149
                                ntype->uifunc = node_texture_buts_image;
 
3150
                                break;
 
3151
 
 
3152
                        case TEX_NODE_OUTPUT:
 
3153
                                ntype->uifunc = node_texture_buts_output;
 
3154
                                break;
 
3155
                }
2267
3156
        }
2268
 
        if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
2269
3157
}
2270
3158
 
2271
3159
/* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
2272
3160
 
2273
 
void ED_init_node_butfuncs(void)
 
3161
void ED_node_init_butfuncs(void)
2274
3162
{
2275
3163
        bNodeTreeType *treetype;
2276
3164
        bNodeType *ntype;
2278
3166
        int i;
2279
3167
        
2280
3168
        /* node type ui functions */
2281
 
        for (i=0; i < NUM_NTREE_TYPES; ++i) {
 
3169
        for (i = 0; i < NUM_NTREE_TYPES; ++i) {
2282
3170
                treetype = ntreeGetType(i);
2283
3171
                if (treetype) {
2284
 
                        for (ntype= treetype->node_types.first; ntype; ntype= ntype->next) {
 
3172
                        for (ntype = treetype->node_types.first; ntype; ntype = ntype->next) {
2285
3173
                                /* default ui functions */
2286
3174
                                ntype->drawfunc = node_draw_default;
2287
3175
                                ntype->drawupdatefunc = node_update_default;
 
3176
                                ntype->select_area_func = node_select_area_default;
 
3177
                                ntype->tweak_area_func = node_tweak_area_default;
2288
3178
                                ntype->uifunc = NULL;
2289
3179
                                ntype->uifuncbut = NULL;
 
3180
                                ntype->drawinputfunc = node_draw_input_default;
 
3181
                                ntype->drawoutputfunc = node_draw_output_default;
2290
3182
                                ntype->resize_area_func = node_resize_area_default;
2291
3183
                                
2292
3184
                                node_common_set_butfunc(ntype);
2293
3185
                                
2294
3186
                                switch (i) {
2295
 
                                case NTREE_COMPOSIT:
2296
 
                                        node_composit_set_butfunc(ntype);
2297
 
                                        break;
2298
 
                                case NTREE_SHADER:
2299
 
                                        node_shader_set_butfunc(ntype);
2300
 
                                        break;
2301
 
                                case NTREE_TEXTURE:
2302
 
                                        node_texture_set_butfunc(ntype);
2303
 
                                        break;
 
3187
                                        case NTREE_COMPOSIT:
 
3188
                                                node_composit_set_butfunc(ntype);
 
3189
                                                break;
 
3190
                                        case NTREE_SHADER:
 
3191
                                                node_shader_set_butfunc(ntype);
 
3192
                                                break;
 
3193
                                        case NTREE_TEXTURE:
 
3194
                                                node_texture_set_butfunc(ntype);
 
3195
                                                break;
2304
3196
                                }
2305
3197
                        }
2306
3198
                }
2307
3199
        }
2308
3200
        
2309
3201
        /* socket type ui functions */
2310
 
        for (i=0; i < NUM_SOCKET_TYPES; ++i) {
 
3202
        for (i = 0; i < NUM_SOCKET_TYPES; ++i) {
2311
3203
                stype = ntreeGetSocketType(i);
2312
3204
                if (stype) {
2313
 
                        switch(stype->type) {
2314
 
                        case SOCK_FLOAT:
2315
 
                        case SOCK_INT:
2316
 
                        case SOCK_BOOLEAN:
2317
 
                                stype->buttonfunc = node_socket_button_default;
2318
 
                                break;
2319
 
                        case SOCK_VECTOR:
2320
 
                                stype->buttonfunc = node_socket_button_components;
2321
 
                                break;
2322
 
                        case SOCK_RGBA:
2323
 
                                stype->buttonfunc = node_socket_button_color;
2324
 
                                break;
2325
 
                        case SOCK_SHADER:
2326
 
                                stype->buttonfunc = node_socket_button_label;
2327
 
                                break;
2328
 
                        default:
2329
 
                                stype->buttonfunc = NULL;
 
3205
                        switch (stype->type) {
 
3206
                                case SOCK_FLOAT:
 
3207
                                case SOCK_INT:
 
3208
                                case SOCK_BOOLEAN:
 
3209
                                        stype->buttonfunc = node_socket_button_default;
 
3210
                                        break;
 
3211
                                case SOCK_STRING:
 
3212
                                        stype->buttonfunc = node_socket_button_string;
 
3213
                                        break;
 
3214
                                case SOCK_VECTOR:
 
3215
                                        stype->buttonfunc = node_socket_button_components;
 
3216
                                        break;
 
3217
                                case SOCK_RGBA:
 
3218
                                        stype->buttonfunc = node_socket_button_color;
 
3219
                                        break;
 
3220
                                case SOCK_SHADER:
 
3221
                                        stype->buttonfunc = node_socket_button_label;
 
3222
                                        break;
 
3223
                                default:
 
3224
                                        stype->buttonfunc = NULL;
2330
3225
                        }
2331
3226
                }
2332
3227
        }
2334
3229
 
2335
3230
/* ************** Generic drawing ************** */
2336
3231
 
2337
 
void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
 
3232
void draw_nodespace_back_pix(const bContext *C, ARegion *ar, SpaceNode *snode)
2338
3233
{
2339
3234
        
2340
 
        if ((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) {
2341
 
                Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 
3235
        if ((snode->flag & SNODE_BACKDRAW) && snode->treetype == NTREE_COMPOSIT) {
 
3236
                Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
2342
3237
                void *lock;
2343
 
                ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
 
3238
                ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
2344
3239
                if (ibuf) {
2345
3240
                        float x, y; 
 
3241
                        unsigned char *display_buffer;
 
3242
                        void *cache_handle;
2346
3243
                        
2347
3244
                        glMatrixMode(GL_PROJECTION);
2348
3245
                        glPushMatrix();
2350
3247
                        glPushMatrix();
2351
3248
 
2352
3249
                        /* keep this, saves us from a version patch */
2353
 
                        if (snode->zoom==0.0f) snode->zoom= 1.0f;
 
3250
                        if (snode->zoom == 0.0f) snode->zoom = 1.0f;
2354
3251
                        
2355
3252
                        /* somehow the offset has to be calculated inverse */
2356
3253
                        
2357
3254
                        glaDefine2DArea(&ar->winrct);
2358
3255
                        /* ortho at pixel level curarea */
2359
 
                        wmOrtho2(-0.375, ar->winx-0.375, -0.375, ar->winy-0.375);
2360
 
                        
2361
 
                        x = (ar->winx-snode->zoom*ibuf->x)/2 + snode->xof;
2362
 
                        y = (ar->winy-snode->zoom*ibuf->y)/2 + snode->yof;
2363
 
                        
2364
 
                        if (!ibuf->rect) {
2365
 
                                if (color_manage)
2366
 
                                        ibuf->profile = IB_PROFILE_LINEAR_RGB;
2367
 
                                else
2368
 
                                        ibuf->profile = IB_PROFILE_NONE;
2369
 
                                IMB_rect_from_float(ibuf);
2370
 
                        }
2371
 
 
2372
 
                        if (ibuf->rect) {
2373
 
                                if (snode->flag & SNODE_SHOW_ALPHA) {
2374
 
                                        glPixelZoom(snode->zoom, snode->zoom);
2375
 
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
2376
 
                                        if (ENDIAN_ORDER == B_ENDIAN)
2377
 
                                                glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
2378
 
                                        
2379
 
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
2380
 
                                        
 
3256
                        wmOrtho2(-GLA_PIXEL_OFS, ar->winx - GLA_PIXEL_OFS, -GLA_PIXEL_OFS, ar->winy - GLA_PIXEL_OFS);
 
3257
                        
 
3258
                        x = (ar->winx - snode->zoom * ibuf->x) / 2 + snode->xof;
 
3259
                        y = (ar->winy - snode->zoom * ibuf->y) / 2 + snode->yof;
 
3260
                        
 
3261
 
 
3262
                        display_buffer = IMB_display_buffer_acquire_ctx(C, ibuf, &cache_handle);
 
3263
 
 
3264
                        if (display_buffer) {
 
3265
                                if (snode->flag & (SNODE_SHOW_R | SNODE_SHOW_G | SNODE_SHOW_B)) {
 
3266
                                        int ofs;
 
3267
 
 
3268
#ifdef __BIG_ENDIAN__
 
3269
                                        if      (snode->flag & SNODE_SHOW_R) ofs = 2;
 
3270
                                        else if (snode->flag & SNODE_SHOW_G) ofs = 1;
 
3271
                                        else                                 ofs = 0;
 
3272
#else
 
3273
                                        if      (snode->flag & SNODE_SHOW_R) ofs = 1;
 
3274
                                        else if (snode->flag & SNODE_SHOW_G) ofs = 2;
 
3275
                                        else                                 ofs = 3;
 
3276
#endif
 
3277
 
 
3278
                                        glPixelZoom(snode->zoom, snode->zoom);
 
3279
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
 
3280
 
 
3281
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT,
 
3282
                                                          display_buffer + ofs);
 
3283
 
 
3284
                                        glPixelZoom(1.0f, 1.0f);
 
3285
                                }
 
3286
                                else if (snode->flag & SNODE_SHOW_ALPHA) {
 
3287
                                        glPixelZoom(snode->zoom, snode->zoom);
 
3288
                                        /* swap bytes, so alpha is most significant one, then just draw it as luminance int */
 
3289
#ifdef __BIG_ENDIAN__
 
3290
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
 
3291
#endif
 
3292
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, display_buffer);
 
3293
 
 
3294
#ifdef __BIG_ENDIAN__
2381
3295
                                        glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
 
3296
#endif
2382
3297
                                        glPixelZoom(1.0f, 1.0f);
2383
3298
                                }
2384
3299
                                else if (snode->flag & SNODE_USE_ALPHA) {
2386
3301
                                        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
2387
3302
                                        glPixelZoom(snode->zoom, snode->zoom);
2388
3303
                                        
2389
 
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 
3304
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
2390
3305
                                        
2391
3306
                                        glPixelZoom(1.0f, 1.0f);
2392
3307
                                        glDisable(GL_BLEND);
2393
3308
                                }
2394
3309
                                else {
2395
3310
                                        glPixelZoom(snode->zoom, snode->zoom);
2396
 
                                        
2397
 
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
 
3311
 
 
3312
                                        glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, display_buffer);
2398
3313
                                        
2399
3314
                                        glPixelZoom(1.0f, 1.0f);
2400
3315
                                }
2401
3316
                        }
 
3317
 
 
3318
                        IMB_display_buffer_release(cache_handle);
 
3319
 
 
3320
                        /** @note draw selected info on backdrop */
 
3321
                        if (snode->edittree) {
 
3322
                                bNode *node = snode->edittree->nodes.first;
 
3323
                                while (node) {
 
3324
                                        if (node->flag & NODE_SELECT) {
 
3325
                                                if (node->typeinfo->uibackdropfunc) {
 
3326
                                                        node->typeinfo->uibackdropfunc(snode, ibuf, node, x, y);
 
3327
                                                }
 
3328
                                        }
 
3329
                                        node = node->next;
 
3330
                                }
 
3331
                        }
2402
3332
                        
2403
3333
                        glMatrixMode(GL_PROJECTION);
2404
3334
                        glPopMatrix();
2406
3336
                        glPopMatrix();
2407
3337
                }
2408
3338
 
2409
 
                BKE_image_release_ibuf(ima, lock);
 
3339
                BKE_image_release_ibuf(ima, ibuf, lock);
2410
3340
        }
2411
3341
}
2412
3342
 
2418
3348
        draw_nodespace_grid(snode);
2419
3349
        
2420
3350
        if (snode->flag & SNODE_BACKDRAW) {
2421
 
                Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
2422
 
                ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
 
3351
                Image *ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 
3352
                ImBuf *ibuf = BKE_image_acquire_ibuf(ima, NULL, NULL);
2423
3353
                if (ibuf) {
2424
3354
                        int x, y;
2425
3355
                        float zoom = 1.0;
2433
3363
 
2434
3364
                        if (ibuf->x > sa->winx || ibuf->y > sa->winy) {
2435
3365
                                float zoomx, zoomy;
2436
 
                                zoomx= (float)sa->winx/ibuf->x;
2437
 
                                zoomy= (float)sa->winy/ibuf->y;
2438
 
                                zoom = MIN2(zoomx, zoomy);
 
3366
                                zoomx = (float)sa->winx / ibuf->x;
 
3367
                                zoomy = (float)sa->winy / ibuf->y;
 
3368
                                zoom = min_ff(zoomx, zoomy);
2439
3369
                        }
2440
3370
                        
2441
 
                        x = (sa->winx-zoom*ibuf->x)/2 + snode->xof;
2442
 
                        y = (sa->winy-zoom*ibuf->y)/2 + snode->yof;
 
3371
                        x = (sa->winx - zoom * ibuf->x) / 2 + snode->xof;
 
3372
                        y = (sa->winy - zoom * ibuf->y) / 2 + snode->yof;
2443
3373
 
2444
3374
                        glPixelZoom(zoom, zoom);
2445
3375
 
2446
3376
                        glColor4f(1.0, 1.0, 1.0, 1.0);
2447
3377
                        if (ibuf->rect)
2448
3378
                                glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
2449
 
                        else if (ibuf->channels==4)
 
3379
                        else if (ibuf->channels == 4)
2450
3380
                                glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_FLOAT, ibuf->rect_float);
2451
3381
 
2452
3382
                        glPixelZoom(1.0, 1.0);
2455
3385
                        glPopMatrix();
2456
3386
                        glMatrixMode(GL_MODELVIEW);
2457
3387
                        glPopMatrix();
 
3388
 
 
3389
                        BKE_image_release_ibuf(ima, ibuf, NULL);
2458
3390
                }
2459
3391
        }
2460
3392
}
2464
3396
int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
2465
3397
{
2466
3398
        float dist, vec[4][2];
2467
 
        
 
3399
        float deltax, deltay;
 
3400
        int toreroute, fromreroute;
2468
3401
        /* in v0 and v3 we put begin/end points */
2469
3402
        if (link->fromsock) {
2470
 
                vec[0][0]= link->fromsock->locx;
2471
 
                vec[0][1]= link->fromsock->locy;
 
3403
                vec[0][0] = link->fromsock->locx;
 
3404
                vec[0][1] = link->fromsock->locy;
 
3405
                fromreroute = (link->fromnode && link->fromnode->type == NODE_REROUTE);
2472
3406
        }
2473
3407
        else {
2474
 
                if (snode==NULL) return 0;
2475
 
                vec[0][0]= snode->mx;
2476
 
                vec[0][1]= snode->my;
 
3408
                if (snode == NULL) return 0;
 
3409
                copy_v2_v2(vec[0], snode->cursor);
 
3410
                fromreroute = 0;
2477
3411
        }
2478
3412
        if (link->tosock) {
2479
 
                vec[3][0]= link->tosock->locx;
2480
 
                vec[3][1]= link->tosock->locy;
 
3413
                vec[3][0] = link->tosock->locx;
 
3414
                vec[3][1] = link->tosock->locy;
 
3415
                toreroute = (link->tonode && link->tonode->type == NODE_REROUTE);
2481
3416
        }
2482
3417
        else {
2483
 
                if (snode==NULL) return 0;
2484
 
                vec[3][0]= snode->mx;
2485
 
                vec[3][1]= snode->my;
 
3418
                if (snode == NULL) return 0;
 
3419
                copy_v2_v2(vec[3], snode->cursor);
 
3420
                toreroute = 0;
2486
3421
        }
2487
3422
 
2488
 
        dist= UI_GetThemeValue(TH_NODE_CURVING)*0.10f*ABS(vec[0][0] - vec[3][0]);
2489
 
        
 
3423
        dist = UI_GetThemeValue(TH_NODE_CURVING) * 0.10f * ABS(vec[0][0] - vec[3][0]);
 
3424
        deltax = vec[3][0] - vec[0][0];
 
3425
        deltay = vec[3][1] - vec[0][1];
2490
3426
        /* check direction later, for top sockets */
2491
 
        vec[1][0]= vec[0][0]+dist;
2492
 
        vec[1][1]= vec[0][1];
2493
 
        
2494
 
        vec[2][0]= vec[3][0]-dist;
2495
 
        vec[2][1]= vec[3][1];
2496
 
        
2497
 
        if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */
2498
 
        else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin); /* clipped */
2499
 
        else {
2500
 
                
 
3427
        if (fromreroute) {
 
3428
                if (ABS(deltax) > ABS(deltay)) {
 
3429
                        vec[1][1] = vec[0][1];
 
3430
                        vec[1][0] = vec[0][0] + (deltax > 0 ? dist : -dist);
 
3431
                }
 
3432
                else {
 
3433
                        vec[1][0] = vec[0][0];
 
3434
                        vec[1][1] = vec[0][1] + (deltay > 0 ? dist : -dist);
 
3435
                }
 
3436
        }
 
3437
        else {
 
3438
                vec[1][0] = vec[0][0] + dist;
 
3439
                vec[1][1] = vec[0][1];
 
3440
        }
 
3441
        if (toreroute) {
 
3442
                if (ABS(deltax) > ABS(deltay)) {
 
3443
                        vec[2][1] = vec[3][1];
 
3444
                        vec[2][0] = vec[3][0] + (deltax > 0 ? -dist : dist);
 
3445
                }
 
3446
                else {
 
3447
                        vec[2][0] = vec[3][0];
 
3448
                        vec[2][1] = vec[3][1] + (deltay > 0 ? -dist : dist);
 
3449
                }
 
3450
 
 
3451
        }
 
3452
        else {
 
3453
                vec[2][0] = vec[3][0] - dist;
 
3454
                vec[2][1] = vec[3][1];
 
3455
        }
 
3456
        if (v2d && min_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax) {
 
3457
                /* clipped */
 
3458
        }
 
3459
        else if (v2d && max_ffff(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin) {
 
3460
                /* clipped */
 
3461
        }
 
3462
        else {
2501
3463
                /* always do all three, to prevent data hanging around */
2502
 
                forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, sizeof(float)*2);
2503
 
                forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0]+1, resol, sizeof(float)*2);
 
3464
                BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0],
 
3465
                                              coord_array[0] + 0, resol, sizeof(float) * 2);
 
3466
                BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1],
 
3467
                                              coord_array[0] + 1, resol, sizeof(float) * 2);
2504
3468
                
2505
3469
                return 1;
2506
3470
        }
2507
3471
        return 0;
2508
3472
}
2509
3473
 
2510
 
#define LINK_RESOL      24
2511
 
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 )
 
3474
#define LINK_RESOL  24
 
3475
#define LINK_ARROW  12  /* position of arrow on the link, LINK_RESOL/2 */
 
3476
#define ARROW_SIZE 7
 
3477
void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link,
 
3478
                           int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
2512
3479
{
2513
 
        float coord_array[LINK_RESOL+1][2];
 
3480
        float coord_array[LINK_RESOL + 1][2];
2514
3481
        
2515
3482
        if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) {
2516
3483
                float dist, spline_step = 0.0f;
2517
3484
                int i;
2518
 
                
 
3485
                int drawarrow;
2519
3486
                /* store current linewidth */
2520
3487
                float linew;
 
3488
                float arrow[2], arrow1[2], arrow2[2];
2521
3489
                glGetFloatv(GL_LINE_WIDTH, &linew);
2522
3490
                
2523
3491
                /* we can reuse the dist variable here to increment the GL curve eval amount*/
2524
 
                dist = 1.0f/(float)LINK_RESOL;
 
3492
                dist = 1.0f / (float)LINK_RESOL;
2525
3493
                
2526
3494
                glEnable(GL_LINE_SMOOTH);
2527
3495
                
 
3496
                drawarrow = ((link->tonode && (link->tonode->type == NODE_REROUTE)) &&
 
3497
                             (link->fromnode && (link->fromnode->type == NODE_REROUTE)));
 
3498
 
 
3499
                if (drawarrow) {
 
3500
                        /* draw arrow in line segment LINK_ARROW */
 
3501
                        float d_xy[2], len;
 
3502
 
 
3503
                        sub_v2_v2v2(d_xy, coord_array[LINK_ARROW], coord_array[LINK_ARROW - 1]);
 
3504
                        len = len_v2(d_xy);
 
3505
                        mul_v2_fl(d_xy, ARROW_SIZE / len);
 
3506
                        arrow1[0] = coord_array[LINK_ARROW][0] - d_xy[0] + d_xy[1];
 
3507
                        arrow1[1] = coord_array[LINK_ARROW][1] - d_xy[1] - d_xy[0];
 
3508
                        arrow2[0] = coord_array[LINK_ARROW][0] - d_xy[0] - d_xy[1];
 
3509
                        arrow2[1] = coord_array[LINK_ARROW][1] - d_xy[1] + d_xy[0];
 
3510
                        arrow[0] = coord_array[LINK_ARROW][0];
 
3511
                        arrow[1] = coord_array[LINK_ARROW][1];
 
3512
                }
2528
3513
                if (do_triple) {
2529
3514
                        UI_ThemeColorShadeAlpha(th_col3, -80, -120);
2530
3515
                        glLineWidth(4.0f);
2531
3516
                        
2532
3517
                        glBegin(GL_LINE_STRIP);
2533
 
                        for (i=0; i<=LINK_RESOL; i++) {
 
3518
                        for (i = 0; i <= LINK_RESOL; i++) {
2534
3519
                                glVertex2fv(coord_array[i]);
2535
3520
                        }
2536
3521
                        glEnd();
 
3522
                        if (drawarrow) {
 
3523
                                glBegin(GL_LINE_STRIP);
 
3524
                                glVertex2fv(arrow1);
 
3525
                                glVertex2fv(arrow);
 
3526
                                glVertex2fv(arrow);
 
3527
                                glVertex2fv(arrow2);
 
3528
                                glEnd();
 
3529
                        }
2537
3530
                }
2538
3531
                
2539
3532
                /* XXX using GL_LINES for shaded node lines is a workaround
2543
3536
                glLineWidth(1.5f);
2544
3537
                if (do_shaded) {
2545
3538
                        glBegin(GL_LINES);
2546
 
                        for (i=0; i<LINK_RESOL; i++) {
 
3539
                        for (i = 0; i < LINK_RESOL; i++) {
2547
3540
                                UI_ThemeColorBlend(th_col1, th_col2, spline_step);
2548
3541
                                glVertex2fv(coord_array[i]);
2549
3542
                                
2550
 
                                UI_ThemeColorBlend(th_col1, th_col2, spline_step+dist);
2551
 
                                glVertex2fv(coord_array[i+1]);
 
3543
                                UI_ThemeColorBlend(th_col1, th_col2, spline_step + dist);
 
3544
                                glVertex2fv(coord_array[i + 1]);
2552
3545
                                
2553
3546
                                spline_step += dist;
2554
3547
                        }
2557
3550
                else {
2558
3551
                        UI_ThemeColor(th_col1);
2559
3552
                        glBegin(GL_LINE_STRIP);
2560
 
                        for (i=0; i<=LINK_RESOL; i++) {
 
3553
                        for (i = 0; i <= LINK_RESOL; i++) {
2561
3554
                                glVertex2fv(coord_array[i]);
2562
3555
                        }
2563
3556
                        glEnd();
2564
3557
                }
2565
3558
                
 
3559
                if (drawarrow) {
 
3560
                        glBegin(GL_LINE_STRIP);
 
3561
                        glVertex2fv(arrow1);
 
3562
                        glVertex2fv(arrow);
 
3563
                        glVertex2fv(arrow);
 
3564
                        glVertex2fv(arrow2);
 
3565
                        glEnd();
 
3566
                }
 
3567
                
2566
3568
                glDisable(GL_LINE_SMOOTH);
2567
3569
                
2568
3570
                /* restore previuos linewidth */
2569
 
                glLineWidth(linew);
 
3571
                glLineWidth(1.0f);
2570
3572
        }
2571
3573
}
2572
3574
 
 
3575
#if 0 /* not used in 2.5x yet */
2573
3576
static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2])
2574
3577
{
2575
3578
        if (link->fromsock) {
2576
 
                coord_array[0][0]= link->fromsock->locx;
2577
 
                coord_array[0][1]= link->fromsock->locy;
 
3579
                coord_array[0][0] = link->fromsock->locx;
 
3580
                coord_array[0][1] = link->fromsock->locy;
2578
3581
        }
2579
3582
        else {
2580
 
                if (snode==NULL) return;
2581
 
                coord_array[0][0]= snode->mx;
2582
 
                coord_array[0][1]= snode->my;
 
3583
                if (snode == NULL) return;
 
3584
                coord_array[0][0] = snode->mx;
 
3585
                coord_array[0][1] = snode->my;
2583
3586
        }
2584
3587
        if (link->tosock) {
2585
 
                coord_array[1][0]= link->tosock->locx;
2586
 
                coord_array[1][1]= link->tosock->locy;
 
3588
                coord_array[1][0] = link->tosock->locx;
 
3589
                coord_array[1][1] = link->tosock->locy;
2587
3590
        }
2588
3591
        else {
2589
 
                if (snode==NULL) return;
2590
 
                coord_array[1][0]= snode->mx;
2591
 
                coord_array[1][1]= snode->my;
 
3592
                if (snode == NULL) return;
 
3593
                coord_array[1][0] = snode->mx;
 
3594
                coord_array[1][1] = snode->my;
2592
3595
        }
2593
3596
}
2594
3597
 
2595
 
void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3 )
 
3598
void node_draw_link_straight(View2D *v2d, SpaceNode *snode, bNodeLink *link,
 
3599
                             int th_col1, int do_shaded, int th_col2, int do_triple, int th_col3)
2596
3600
{
2597
3601
        float coord_array[2][2];
2598
3602
        float linew;
2624
3628
         */
2625
3629
        if (do_shaded) {
2626
3630
                glBegin(GL_LINES);
2627
 
                for (i=0; i < LINK_RESOL-1; ++i) {
2628
 
                        float t= (float)i/(float)(LINK_RESOL-1);
 
3631
                for (i = 0; i < LINK_RESOL - 1; ++i) {
 
3632
                        float t = (float)i / (float)(LINK_RESOL - 1);
2629
3633
                        UI_ThemeColorBlend(th_col1, th_col2, t);
2630
 
                        glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
 
3634
                        glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 
3635
                                   (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
2631
3636
                        
2632
 
                        t= (float)(i+1)/(float)(LINK_RESOL-1);
 
3637
                        t = (float)(i + 1) / (float)(LINK_RESOL - 1);
2633
3638
                        UI_ThemeColorBlend(th_col1, th_col2, t);
2634
 
                        glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
 
3639
                        glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 
3640
                                   (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
2635
3641
                }
2636
3642
                glEnd();
2637
3643
        }
2638
3644
        else {
2639
3645
                glBegin(GL_LINE_STRIP);
2640
 
                for (i=0; i < LINK_RESOL; ++i) {
2641
 
                        float t= (float)i/(float)(LINK_RESOL-1);
2642
 
                        glVertex2f((1.0f-t)*coord_array[0][0]+t*coord_array[1][0], (1.0f-t)*coord_array[0][1]+t*coord_array[1][1]);
 
3646
                for (i = 0; i < LINK_RESOL; ++i) {
 
3647
                        float t = (float)i / (float)(LINK_RESOL - 1);
 
3648
                        glVertex2f((1.0f - t) * coord_array[0][0] + t * coord_array[1][0],
 
3649
                                   (1.0f - t) * coord_array[0][1] + t * coord_array[1][1]);
2643
3650
                }
2644
3651
                glEnd();
2645
3652
        }
2647
3654
        glDisable(GL_LINE_SMOOTH);
2648
3655
        
2649
3656
        /* restore previuos linewidth */
2650
 
        glLineWidth(linew);
 
3657
        glLineWidth(1.0f);
2651
3658
}
 
3659
#endif
2652
3660
 
2653
3661
/* note; this is used for fake links in groups too */
2654
3662
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
2655
3663
{
2656
 
        int do_shaded= 0, th_col1= TH_HEADER, th_col2= TH_HEADER;
2657
 
        int do_triple= 0, th_col3= TH_WIRE;
 
3664
        int do_shaded = FALSE, th_col1 = TH_HEADER, th_col2 = TH_HEADER;
 
3665
        int do_triple = FALSE, th_col3 = TH_WIRE;
2658
3666
        
2659
 
        if (link->fromsock==NULL && link->tosock==NULL)
 
3667
        if (link->fromsock == NULL && link->tosock == NULL)
2660
3668
                return;
2661
3669
        
2662
3670
        /* new connection */
2663
3671
        if (!link->fromsock || !link->tosock) {
2664
3672
                th_col1 = TH_ACTIVE;
2665
 
                do_triple = 1;
 
3673
                do_triple = TRUE;
2666
3674
        }
2667
3675
        else {
 
3676
                int cycle = 0;
 
3677
                
2668
3678
                /* going to give issues once... */
2669
3679
                if (link->tosock->flag & SOCK_UNAVAIL)
2670
3680
                        return;
2671
3681
                if (link->fromsock->flag & SOCK_UNAVAIL)
2672
3682
                        return;
2673
3683
                
2674
 
                /* a bit ugly... but thats how we detect the internal group links */
2675
 
                if (!link->fromnode || !link->tonode) {
2676
 
                        UI_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5f);
2677
 
                        do_shaded= 0;
2678
 
                }
2679
 
                else {
2680
 
                        /* check cyclic */
2681
 
                        if ((link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) && (link->flag & NODE_LINK_VALID)) {
2682
 
                                /* special indicated link, on drop-node */
2683
 
                                if (link->flag & NODE_LINKFLAG_HILITE) {
2684
 
                                        th_col1= th_col2= TH_ACTIVE;
2685
 
                                }
2686
 
                                else {
2687
 
                                        /* regular link */
2688
 
                                        if (link->fromnode->flag & SELECT)
2689
 
                                                th_col1= TH_EDGE_SELECT;
2690
 
                                        if (link->tonode->flag & SELECT)
2691
 
                                                th_col2= TH_EDGE_SELECT;
2692
 
                                }
2693
 
                                do_shaded= 1;
2694
 
                                do_triple= 1;
2695
 
                        }                               
 
3684
                /* check cyclic */
 
3685
                if (link->fromnode && link->tonode)
 
3686
                        cycle = (link->fromnode->level < link->tonode->level || link->tonode->level == 0xFFF);
 
3687
                if (!cycle && (link->flag & NODE_LINK_VALID)) {
 
3688
                        /* special indicated link, on drop-node */
 
3689
                        if (link->flag & NODE_LINKFLAG_HILITE) {
 
3690
                                th_col1 = th_col2 = TH_ACTIVE;
 
3691
                        }
2696
3692
                        else {
2697
 
                                th_col1 = TH_REDALERT;
 
3693
                                /* regular link */
 
3694
                                if (link->fromnode && link->fromnode->flag & SELECT)
 
3695
                                        th_col1 = TH_EDGE_SELECT;
 
3696
                                if (link->tonode && link->tonode->flag & SELECT)
 
3697
                                        th_col2 = TH_EDGE_SELECT;
2698
3698
                        }
 
3699
                        do_shaded = TRUE;
 
3700
                        do_triple = TRUE;
 
3701
                }
 
3702
                else {
 
3703
                        th_col1 = TH_REDALERT;
2699
3704
                }
2700
3705
        }
2701
3706
        
2702
3707
        node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
2703
3708
//      node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
2704
3709
}
 
3710
 
 
3711
void ED_node_draw_snap(View2D *v2d, const float cent[2], float size, NodeBorder border)
 
3712
{
 
3713
        glBegin(GL_LINES);
 
3714
        
 
3715
        if (border & (NODE_LEFT | NODE_RIGHT)) {
 
3716
                glVertex2f(cent[0], v2d->cur.ymin);
 
3717
                glVertex2f(cent[0], v2d->cur.ymax);
 
3718
        }
 
3719
        else {
 
3720
                glVertex2f(cent[0], cent[1] - size);
 
3721
                glVertex2f(cent[0], cent[1] + size);
 
3722
        }
 
3723
        
 
3724
        if (border & (NODE_TOP | NODE_BOTTOM)) {
 
3725
                glVertex2f(v2d->cur.xmin, cent[1]);
 
3726
                glVertex2f(v2d->cur.xmax, cent[1]);
 
3727
        }
 
3728
        else {
 
3729
                glVertex2f(cent[0] - size, cent[1]);
 
3730
                glVertex2f(cent[0] + size, cent[1]);
 
3731
        }
 
3732
        
 
3733
        glEnd();
 
3734
}