2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2008-12-24 10:33:10 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2008-12-24 10:33:10 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
2009-09-18 21:04:54 +00:00
|
|
|
* Contributor(s): David Millan Escriva, Juho Vepsäläinen, Bob Holcomb, Thomas Dinges
|
2008-12-24 10:33:10 +00:00
|
|
|
*
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
*/
|
|
|
|
|
2011-02-27 20:29:51 +00:00
|
|
|
/** \file blender/editors/space_node/drawnode.c
|
|
|
|
* \ingroup spnode
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include <math.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "BLI_blenlib.h"
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_space_types.h"
|
|
|
|
#include "DNA_screen_types.h"
|
|
|
|
|
2008-12-29 00:55:23 +00:00
|
|
|
#include "BKE_context.h"
|
2009-02-07 14:03:34 +00:00
|
|
|
#include "BKE_curve.h"
|
2011-01-31 11:17:50 +00:00
|
|
|
#include "BKE_global.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_library.h"
|
|
|
|
#include "BKE_main.h"
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "BKE_node.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "NOD_composite.h"
|
|
|
|
#include "NOD_shader.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
#include "BIF_gl.h"
|
|
|
|
#include "BIF_glutil.h"
|
|
|
|
|
2011-01-31 14:42:55 +00:00
|
|
|
#include "BLF_api.h"
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
2008-12-29 00:55:23 +00:00
|
|
|
|
|
|
|
#include "RNA_access.h"
|
|
|
|
|
2010-11-06 17:55:43 +00:00
|
|
|
#include "ED_node.h"
|
|
|
|
|
2008-12-29 00:55:23 +00:00
|
|
|
#include "WM_api.h"
|
|
|
|
#include "WM_types.h"
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
#include "UI_interface.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
|
2009-10-07 22:05:30 +00:00
|
|
|
#include "IMB_imbuf.h"
|
2008-12-26 18:00:38 +00:00
|
|
|
#include "IMB_imbuf_types.h"
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2008-12-29 00:55:23 +00:00
|
|
|
#include "node_intern.h"
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
/* ****************** SOCKET BUTTON DRAW FUNCTIONS ***************** */
|
|
|
|
|
|
|
|
static void node_sync_cb(bContext *UNUSED(C), void *snode_v, void *node_v)
|
|
|
|
{
|
|
|
|
SpaceNode *snode= snode_v;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode->treetype==NTREE_SHADER) {
|
2011-09-05 21:01:50 +00:00
|
|
|
nodeShaderSynchronizeID(node_v, 1);
|
|
|
|
// allqueue(REDRAWBUTSSHADING, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-07 17:35:20 +00:00
|
|
|
static void node_socket_button_label(const bContext *UNUSED(C), uiBlock *block,
|
|
|
|
bNodeTree *UNUSED(ntree), bNode *UNUSED(node), bNodeSocket *sock,
|
|
|
|
const char *UNUSED(name), int x, int y, int width)
|
|
|
|
{
|
|
|
|
uiDefBut(block, LABEL, 0, sock->name, x, y, width, NODE_DY, NULL, 0, 0, 0, 0, "");
|
|
|
|
}
|
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
/* draw function for file output node sockets.
|
|
|
|
* XXX a bit ugly use atm, called from datatype button functions,
|
|
|
|
* since all node types and callbacks only use data type without struct_type.
|
|
|
|
*/
|
|
|
|
static void node_socket_button_output_file(const bContext *C, uiBlock *block,
|
|
|
|
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
|
|
|
|
const char *UNUSED(name), int x, int y, int width)
|
|
|
|
{
|
|
|
|
uiLayout *layout, *row;
|
|
|
|
PointerRNA nodeptr, sockptr, imfptr;
|
|
|
|
int imtype;
|
|
|
|
int rx, ry;
|
|
|
|
RNA_pointer_create(&ntree->id, &RNA_Node, node, &nodeptr);
|
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &sockptr);
|
|
|
|
|
|
|
|
layout = uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, x, y+NODE_DY, width, 20, UI_GetStyle());
|
|
|
|
row = uiLayoutRow(layout, 0);
|
|
|
|
|
|
|
|
uiItemL(row, sock->name, 0);
|
|
|
|
|
|
|
|
imfptr = RNA_pointer_get(&nodeptr, "format");
|
|
|
|
imtype = RNA_enum_get(&imfptr, "file_format");
|
|
|
|
/* in multilayer format all socket format details are ignored */
|
|
|
|
if (imtype != R_IMF_IMTYPE_MULTILAYER) {
|
|
|
|
PropertyRNA *imtype_prop;
|
|
|
|
const char *imtype_name;
|
|
|
|
|
|
|
|
if (!RNA_boolean_get(&sockptr, "use_node_format"))
|
|
|
|
imfptr = RNA_pointer_get(&sockptr, "format");
|
|
|
|
|
|
|
|
imtype_prop = RNA_struct_find_property(&imfptr, "file_format");
|
|
|
|
RNA_property_enum_name((bContext*)C, &imfptr, imtype_prop, RNA_property_enum_get(&imfptr, imtype_prop), &imtype_name);
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSSP);
|
|
|
|
uiItemL(row, imtype_name, 0);
|
|
|
|
uiBlockSetEmboss(block, UI_EMBOSSN);
|
|
|
|
}
|
|
|
|
|
|
|
|
uiBlockLayoutResolve(block, &rx, &ry);
|
|
|
|
}
|
2011-11-07 17:35:20 +00:00
|
|
|
|
2011-09-16 08:20:21 +00:00
|
|
|
static void node_socket_button_default(const bContext *C, uiBlock *block,
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
|
|
|
|
const char *name, int x, int y, int width)
|
|
|
|
{
|
2012-03-01 07:56:15 +00:00
|
|
|
switch (sock->struct_type) {
|
|
|
|
case SOCK_STRUCT_NONE: {
|
|
|
|
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
|
|
|
|
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
|
|
|
|
else {
|
|
|
|
PointerRNA ptr;
|
|
|
|
uiBut *bt;
|
|
|
|
|
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
|
|
|
|
|
|
|
|
bt = uiDefButR(block, NUM, B_NODE_EXEC, name,
|
|
|
|
x, y+1, width, NODE_DY-2,
|
|
|
|
&ptr, "default_value", 0, 0, 0, -1, -1, NULL);
|
|
|
|
if (node)
|
|
|
|
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SOCK_STRUCT_OUTPUT_FILE:
|
|
|
|
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
|
|
|
|
break;
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
typedef struct SocketComponentMenuArgs {
|
|
|
|
PointerRNA ptr;
|
|
|
|
int x, y, width;
|
|
|
|
uiButHandleFunc cb;
|
|
|
|
void *arg1, *arg2;
|
|
|
|
} SocketComponentMenuArgs;
|
|
|
|
/* NOTE: this is a block-menu, needs 0 events, otherwise the menu closes */
|
|
|
|
static uiBlock *socket_component_menu(bContext *C, ARegion *ar, void *args_v)
|
|
|
|
{
|
|
|
|
SocketComponentMenuArgs *args= (SocketComponentMenuArgs*)args_v;
|
|
|
|
uiBlock *block;
|
|
|
|
uiLayout *layout;
|
|
|
|
|
2012-01-11 09:33:44 +00:00
|
|
|
block= uiBeginBlock(C, ar, __func__, UI_EMBOSS);
|
2011-09-05 21:01:50 +00:00
|
|
|
uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN);
|
|
|
|
|
2011-09-21 15:15:30 +00:00
|
|
|
layout= uiLayoutColumn(uiBlockLayout(block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, args->x, args->y+2, args->width, NODE_DY, UI_GetStyle()), 0);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
uiItemR(layout, &args->ptr, "default_value", UI_ITEM_R_EXPAND, "", ICON_NONE);
|
|
|
|
|
|
|
|
return block;
|
|
|
|
}
|
2011-09-16 08:20:21 +00:00
|
|
|
static void node_socket_button_components(const bContext *C, uiBlock *block,
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
|
|
|
|
const char *name, int x, int y, int width)
|
|
|
|
{
|
2012-03-01 07:56:15 +00:00
|
|
|
switch (sock->struct_type) {
|
|
|
|
case SOCK_STRUCT_NONE: {
|
|
|
|
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
|
|
|
|
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
|
|
|
|
else {
|
|
|
|
PointerRNA ptr;
|
|
|
|
SocketComponentMenuArgs *args;
|
|
|
|
|
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
|
|
|
|
|
|
|
|
args= MEM_callocN(sizeof(SocketComponentMenuArgs), "SocketComponentMenuArgs");
|
|
|
|
|
|
|
|
args->ptr = ptr;
|
|
|
|
args->x = x;
|
|
|
|
args->y = y;
|
|
|
|
args->width = width;
|
|
|
|
args->cb = node_sync_cb;
|
|
|
|
args->arg1 = CTX_wm_space_node(C);
|
|
|
|
args->arg2 = node;
|
|
|
|
|
|
|
|
uiDefBlockButN(block, socket_component_menu, args, name, x, y+1, width, NODE_DY-2, "");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case SOCK_STRUCT_OUTPUT_FILE:
|
|
|
|
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
|
|
|
|
break;
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
2011-09-16 08:20:21 +00:00
|
|
|
static void node_socket_button_color(const bContext *C, uiBlock *block,
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTree *ntree, bNode *node, bNodeSocket *sock,
|
|
|
|
const char *name, int x, int y, int width)
|
|
|
|
{
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
/* XXX would be nicer to have draw function based on sock->struct_type as well,
|
|
|
|
* but currently socket types are completely identified by data type only.
|
|
|
|
*/
|
2011-09-05 21:01:50 +00:00
|
|
|
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
switch (sock->struct_type) {
|
|
|
|
case SOCK_STRUCT_NONE: {
|
|
|
|
if (sock->link || (sock->flag & SOCK_HIDE_VALUE))
|
|
|
|
node_socket_button_label(C, block, ntree, node, sock, name, x, y, width);
|
|
|
|
else {
|
|
|
|
PointerRNA ptr;
|
|
|
|
uiBut *bt;
|
|
|
|
int labelw= width - 40;
|
|
|
|
RNA_pointer_create(&ntree->id, &RNA_NodeSocket, sock, &ptr);
|
|
|
|
|
|
|
|
bt=uiDefButR(block, COL, B_NODE_EXEC, "",
|
|
|
|
x, y+2, (labelw>0 ? 40 : width), NODE_DY-2,
|
|
|
|
&ptr, "default_value", 0, 0, 0, -1, -1, NULL);
|
|
|
|
if (node)
|
|
|
|
uiButSetFunc(bt, node_sync_cb, CTX_wm_space_node(C), node);
|
|
|
|
|
|
|
|
if (name[0]!='\0' && labelw>0)
|
|
|
|
uiDefBut(block, LABEL, 0, name, x + 40, y+2, labelw, NODE_DY-2, NULL, 0, 0, 0, 0, "");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2012-03-01 07:56:15 +00:00
|
|
|
case SOCK_STRUCT_OUTPUT_FILE:
|
|
|
|
node_socket_button_output_file(C, block, ntree, node, sock, name, x, y, width);
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** BASE DRAW FUNCTIONS FOR NEW OPERATOR NODES ***************** */
|
|
|
|
|
2011-09-20 08:48:48 +00:00
|
|
|
#if 0 /* UNUSED */
|
2011-09-16 08:20:21 +00:00
|
|
|
static void node_draw_socket_new(bNodeSocket *sock, float size)
|
2011-09-05 21:01:50 +00:00
|
|
|
{
|
|
|
|
float x=sock->locx, y=sock->locy;
|
|
|
|
|
|
|
|
/* 16 values of sin function */
|
|
|
|
static float si[16] = {
|
2012-04-29 15:47:02 +00:00
|
|
|
0.00000000f, 0.39435585f, 0.72479278f,0.93775213f,
|
2011-09-05 21:01:50 +00:00
|
|
|
0.99871650f,0.89780453f,0.65137248f,0.29936312f,
|
|
|
|
-0.10116832f,-0.48530196f,-0.79077573f,-0.96807711f,
|
|
|
|
-0.98846832f,-0.84864425f,-0.57126821f,-0.20129852f
|
|
|
|
};
|
|
|
|
/* 16 values of cos function */
|
|
|
|
static float co[16] ={
|
|
|
|
1.00000000f,0.91895781f,0.68896691f,0.34730525f,
|
|
|
|
-0.05064916f,-0.44039415f,-0.75875812f,-0.95413925f,
|
|
|
|
-0.99486932f,-0.87434661f,-0.61210598f,-0.25065253f,
|
|
|
|
0.15142777f,0.52896401f,0.82076344f,0.97952994f,
|
|
|
|
};
|
|
|
|
int a;
|
|
|
|
|
|
|
|
glColor3ub(180, 180, 180);
|
|
|
|
|
|
|
|
glBegin(GL_POLYGON);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (a=0; a<16; a++)
|
2011-09-05 21:01:50 +00:00
|
|
|
glVertex2f(x+size*si[a], y+size*co[a]);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
glColor4ub(0, 0, 0, 150);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glEnable( GL_LINE_SMOOTH );
|
|
|
|
glBegin(GL_LINE_LOOP);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (a=0; a<16; a++)
|
2011-09-05 21:01:50 +00:00
|
|
|
glVertex2f(x+size*si[a], y+size*co[a]);
|
|
|
|
glEnd();
|
|
|
|
glDisable( GL_LINE_SMOOTH );
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
}
|
2011-09-20 08:48:48 +00:00
|
|
|
#endif
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* ****************** BUTTON CALLBACKS FOR ALL TREES ***************** */
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-11 02:15:09 +00:00
|
|
|
PointerRNA sockptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
/* first socket stores value */
|
|
|
|
prop = RNA_struct_find_property(ptr, "outputs");
|
|
|
|
RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, &sockptr, "default_value", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-11 02:15:09 +00:00
|
|
|
uiLayout *col;
|
|
|
|
PointerRNA sockptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
|
|
|
|
/* first socket stores value */
|
|
|
|
prop = RNA_struct_find_property(ptr, "outputs");
|
|
|
|
RNA_property_collection_lookup_int(ptr, prop, 0, &sockptr);
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, &sockptr, "default_value", 1, 0, 0, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &sockptr, "default_value", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_mix_rgb(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-27 11:00:35 +00:00
|
|
|
{
|
2009-09-16 18:59:13 +00:00
|
|
|
uiLayout *row;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-09-27 11:00:35 +00:00
|
|
|
bNodeTree *ntree= (bNodeTree*)ptr->id.data;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-09-27 11:00:35 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "blend_type", 0, "", ICON_NONE);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ntree->type == NTREE_COMPOSIT)
|
2010-08-21 04:51:00 +00:00
|
|
|
uiItemR(row, ptr, "use_alpha", 0, "", ICON_IMAGE_RGB_ALPHA);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_time(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
|
|
|
uiLayout *row;
|
|
|
|
#if 0
|
|
|
|
/* XXX no context access here .. */
|
|
|
|
bNode *node= ptr->data;
|
|
|
|
CurveMapping *cumap= node->storage;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (cumap) {
|
2009-09-16 18:59:13 +00:00
|
|
|
cumap->flag |= CUMA_DRAW_CFRA;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->custom1<node->custom2)
|
2009-09-16 18:59:13 +00:00
|
|
|
cumap->sample[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-01-04 17:28:37 +00:00
|
|
|
uiTemplateCurveMapping(layout, ptr, "curve", 's', 0, 0);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "frame_start", 0, "Sta", ICON_NONE);
|
|
|
|
uiItemR(row, ptr, "frame_end", 0, "End", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_colorramp(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-10 04:01:44 +00:00
|
|
|
uiTemplateColorRamp(layout, ptr, "color_ramp", 0);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-01-04 17:28:37 +00:00
|
|
|
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static float *_sample_col= NULL; // bad bad, 2.5 will do better?
|
2011-02-17 12:05:09 +00:00
|
|
|
#if 0
|
2011-02-14 17:55:27 +00:00
|
|
|
static void node_curvemap_sample(float *col)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
_sample_col= col;
|
|
|
|
}
|
2011-02-17 12:05:09 +00:00
|
|
|
#endif
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-09-16 18:59:13 +00:00
|
|
|
bNode *node= ptr->data;
|
|
|
|
CurveMapping *cumap= node->storage;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (_sample_col) {
|
2009-09-16 18:59:13 +00:00
|
|
|
cumap->flag |= CUMA_DRAW_SAMPLE;
|
2011-09-11 02:50:01 +00:00
|
|
|
copy_v3_v3(cumap->sample, _sample_col);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
cumap->flag &= ~CUMA_DRAW_SAMPLE;
|
|
|
|
|
2010-01-04 17:28:37 +00:00
|
|
|
uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-11-06 17:55:43 +00:00
|
|
|
static void node_normal_cb(bContext *C, void *ntree_v, void *node_v)
|
|
|
|
{
|
|
|
|
Main *bmain = CTX_data_main(C);
|
|
|
|
|
|
|
|
ED_node_generic_update(bmain, ntree_v, node_v);
|
|
|
|
WM_event_add_notifier(C, NC_NODE|NA_EDITED, ntree_v);
|
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_normal(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-10-09 10:45:11 +00:00
|
|
|
uiBlock *block= uiLayoutAbsoluteBlock(layout);
|
2010-11-06 17:55:43 +00:00
|
|
|
bNodeTree *ntree= ptr->id.data;
|
2009-09-16 18:59:13 +00:00
|
|
|
bNode *node= ptr->data;
|
|
|
|
rctf *butr= &node->butr;
|
|
|
|
bNodeSocket *sock= node->outputs.first; /* first socket stores normal */
|
2011-09-05 21:01:50 +00:00
|
|
|
float *nor= ((bNodeSocketValueVector*)sock->default_value)->value;
|
2010-11-06 17:55:43 +00:00
|
|
|
uiBut *bt;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2010-11-06 17:55:43 +00:00
|
|
|
bt= uiDefButF(block, BUT_NORMAL, B_NODE_EXEC, "",
|
2011-11-11 13:09:14 +00:00
|
|
|
(short)butr->xmin, (short)butr->xmin,
|
|
|
|
butr->xmax-butr->xmin, butr->xmax-butr->xmin,
|
|
|
|
nor, 0.0f, 1.0f, 0, 0, "");
|
2010-11-06 17:55:43 +00:00
|
|
|
uiButSetFunc(bt, node_normal_cb, ntree, node);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2009-11-06 22:51:08 +00:00
|
|
|
#if 0 // not used in 2.5x yet
|
2008-12-29 00:55:23 +00:00
|
|
|
static void node_browse_tex_cb(bContext *C, void *ntree_v, void *node_v)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2008-12-24 10:33:10 +00:00
|
|
|
bNodeTree *ntree= ntree_v;
|
|
|
|
bNode *node= node_v;
|
|
|
|
Tex *tex;
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->menunr<1) return;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->id) {
|
2008-12-24 10:33:10 +00:00
|
|
|
node->id->us--;
|
|
|
|
node->id= NULL;
|
|
|
|
}
|
2010-08-01 12:47:49 +00:00
|
|
|
tex= BLI_findlink(&bmain->tex, node->menunr-1);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
node->id= &tex->id;
|
|
|
|
id_us_plus(node->id);
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(node->name, node->id->name+2, sizeof(node->name));
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
nodeSetActive(ntree, node);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( ntree->type == NTREE_TEXTURE )
|
2008-12-24 10:33:10 +00:00
|
|
|
ntreeTexCheckCyclics( ntree );
|
|
|
|
|
|
|
|
// allqueue(REDRAWBUTSSHADING, 0);
|
|
|
|
// allqueue(REDRAWNODE, 0);
|
|
|
|
NodeTagChanged(ntree, node);
|
|
|
|
|
|
|
|
node->menunr= 0;
|
|
|
|
}
|
2009-11-06 22:51:08 +00:00
|
|
|
#endif
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_dynamic_update_cb(bContext *C, void *UNUSED(ntree_v), void *node_v)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2008-12-24 10:33:10 +00:00
|
|
|
Material *ma;
|
|
|
|
bNode *node= (bNode *)node_v;
|
|
|
|
ID *id= node->id;
|
|
|
|
int error= 0;
|
|
|
|
|
|
|
|
if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) error= 1;
|
|
|
|
|
|
|
|
/* Users only have to press the "update" button in one pynode
|
|
|
|
* and we also update all others sharing the same script */
|
2010-08-01 12:47:49 +00:00
|
|
|
for (ma= bmain->mat.first; ma; ma= ma->id.next) {
|
2008-12-24 10:33:10 +00:00
|
|
|
if (ma->nodetree) {
|
|
|
|
bNode *nd;
|
|
|
|
for (nd= ma->nodetree->nodes.first; nd; nd= nd->next) {
|
|
|
|
if ((nd->type == NODE_DYNAMIC) && (nd->id == id)) {
|
|
|
|
nd->custom1= 0;
|
|
|
|
nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_REPARSE);
|
|
|
|
nd->menunr= 0;
|
|
|
|
if (error)
|
|
|
|
nd->custom1= BSET(nd->custom1, NODE_DYNAMIC_ERROR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// allqueue(REDRAWBUTSSHADING, 0);
|
|
|
|
// allqueue(REDRAWNODE, 0);
|
2008-12-29 00:55:23 +00:00
|
|
|
// XXX BIF_preview_changed(ID_MA);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_texture(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-09-16 18:59:13 +00:00
|
|
|
bNode *node= ptr->data;
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
short multi = (
|
|
|
|
node->id &&
|
|
|
|
((Tex*)node->id)->use_nodes &&
|
|
|
|
(node->type != CMP_NODE_TEXTURE) &&
|
|
|
|
(node->type != TEX_NODE_TEXTURE)
|
|
|
|
);
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "texture", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (multi) {
|
2009-10-30 19:31:44 +00:00
|
|
|
/* Number Drawing not optimal here, better have a list*/
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "node_output", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_buts_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static int node_resize_area_default(bNode *node, int x, int y)
|
|
|
|
{
|
|
|
|
if (node->flag & NODE_HIDDEN) {
|
|
|
|
rctf totr= node->totr;
|
|
|
|
/* right part of node */
|
2012-03-24 02:51:46 +00:00
|
|
|
totr.xmin = node->totr.xmax-20.0f;
|
2011-09-05 21:01:50 +00:00
|
|
|
return BLI_in_rctf(&totr, x, y);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* rect we're interested in is just the bottom right corner */
|
|
|
|
rctf totr= node->totr;
|
|
|
|
/* bottom right corner */
|
2012-03-24 02:51:46 +00:00
|
|
|
totr.xmin = totr.xmax-10.0f;
|
|
|
|
totr.ymax = totr.ymin+10.0f;
|
2011-09-05 21:01:50 +00:00
|
|
|
return BLI_in_rctf(&totr, x, y);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** BUTTON CALLBACKS FOR COMMON NODES ***************** */
|
|
|
|
|
|
|
|
/* width of socket columns in group display */
|
|
|
|
#define NODE_GROUP_FRAME 120
|
|
|
|
|
|
|
|
/* based on settings in node, sets drawing rect info. each redraw! */
|
|
|
|
/* note: this assumes only 1 group at a time is drawn (linked data) */
|
|
|
|
/* in node->totr the entire boundbox for the group is stored */
|
|
|
|
static void node_update_group(const bContext *C, bNodeTree *ntree, bNode *gnode)
|
|
|
|
{
|
|
|
|
if (!(gnode->flag & NODE_GROUP_EDIT)) {
|
|
|
|
node_update_default(C, ntree, gnode);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNodeTree *ngroup= (bNodeTree *)gnode->id;
|
|
|
|
bNode *node;
|
|
|
|
bNodeSocket *sock, *gsock;
|
|
|
|
float locx, locy;
|
|
|
|
rctf *rect= &gnode->totr;
|
|
|
|
float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
|
2011-11-22 17:49:06 +00:00
|
|
|
float group_header= 26*U.dpi/72;
|
2011-09-05 21:01:50 +00:00
|
|
|
int counter;
|
|
|
|
int dy;
|
|
|
|
|
|
|
|
/* get "global" coords */
|
|
|
|
nodeSpaceCoords(gnode, &locx, &locy);
|
|
|
|
|
|
|
|
/* center them, is a bit of abuse of locx and locy though */
|
|
|
|
node_update_nodetree(C, ngroup, locx, locy);
|
|
|
|
|
|
|
|
rect->xmin = rect->xmax = locx;
|
|
|
|
rect->ymin = rect->ymax = locy;
|
|
|
|
|
|
|
|
counter= 1;
|
2012-03-24 06:38:07 +00:00
|
|
|
for (node= ngroup->nodes.first; node; node= node->next) {
|
|
|
|
if (counter) {
|
2011-09-05 21:01:50 +00:00
|
|
|
*rect= node->totr;
|
|
|
|
counter= 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
BLI_union_rctf(rect, &node->totr);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* add some room for links to group sockets */
|
|
|
|
rect->xmin -= 4*NODE_DY;
|
|
|
|
rect->xmax += 4*NODE_DY;
|
|
|
|
rect->ymin-= NODE_DY;
|
|
|
|
rect->ymax+= NODE_DY;
|
|
|
|
|
|
|
|
/* input sockets */
|
|
|
|
dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->inputs)-1);
|
|
|
|
gsock=ngroup->inputs.first;
|
|
|
|
sock=gnode->inputs.first;
|
|
|
|
while (gsock || sock) {
|
|
|
|
while (sock && !sock->groupsock) {
|
|
|
|
sock->locx = rect->xmin - node_group_frame;
|
|
|
|
sock->locy = dy;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
sock = sock->next;
|
|
|
|
}
|
|
|
|
while (gsock && (!sock || sock->groupsock!=gsock)) {
|
|
|
|
gsock->locx = rect->xmin;
|
|
|
|
gsock->locy = dy;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
gsock = gsock->next;
|
|
|
|
}
|
|
|
|
while (sock && gsock && sock->groupsock==gsock) {
|
|
|
|
gsock->locx = rect->xmin;
|
|
|
|
sock->locx = rect->xmin - node_group_frame;
|
|
|
|
sock->locy = gsock->locy = dy;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
sock = sock->next;
|
|
|
|
gsock = gsock->next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* output sockets */
|
|
|
|
dy = 0.5f*(rect->ymin+rect->ymax) + NODE_DY*(BLI_countlist(&gnode->outputs)-1);
|
|
|
|
gsock=ngroup->outputs.first;
|
|
|
|
sock=gnode->outputs.first;
|
|
|
|
while (gsock || sock) {
|
|
|
|
while (sock && !sock->groupsock) {
|
|
|
|
sock->locx = rect->xmax + node_group_frame;
|
|
|
|
sock->locy = dy - NODE_DYS;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
sock = sock->next;
|
|
|
|
}
|
|
|
|
while (gsock && (!sock || sock->groupsock!=gsock)) {
|
|
|
|
gsock->locx = rect->xmax;
|
|
|
|
gsock->locy = dy - NODE_DYS;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
gsock = gsock->next;
|
|
|
|
}
|
|
|
|
while (sock && gsock && sock->groupsock==gsock) {
|
|
|
|
gsock->locx = rect->xmax;
|
|
|
|
sock->locx = rect->xmax + node_group_frame;
|
|
|
|
sock->locy = gsock->locy = dy - NODE_DYS;
|
|
|
|
|
|
|
|
/* prevent long socket lists from growing out of the group box */
|
|
|
|
if (dy-3*NODE_DYS < rect->ymin)
|
|
|
|
rect->ymin = dy-3*NODE_DYS;
|
|
|
|
if (dy+3*NODE_DYS > rect->ymax)
|
|
|
|
rect->ymax = dy+3*NODE_DYS;
|
|
|
|
dy -= 2*NODE_DY;
|
|
|
|
|
|
|
|
sock = sock->next;
|
|
|
|
gsock = gsock->next;
|
|
|
|
}
|
|
|
|
}
|
2011-11-22 17:49:06 +00:00
|
|
|
|
|
|
|
/* Set the block bounds to clip mouse events from underlying nodes.
|
|
|
|
* Add margin for header and input/output columns.
|
|
|
|
*/
|
|
|
|
uiExplicitBoundsBlock(gnode->block,
|
|
|
|
rect->xmin - node_group_frame,
|
|
|
|
rect->ymin,
|
|
|
|
rect->xmax + node_group_frame,
|
|
|
|
rect->ymax + group_header);
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_group_input_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
|
|
|
|
{
|
|
|
|
bNodeTree *ngroup= (bNodeTree*)ngroup_v;
|
|
|
|
|
|
|
|
ngroup->update |= NTREE_UPDATE_GROUP_IN;
|
|
|
|
ntreeUpdateTree(ngroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void update_group_output_cb(bContext *UNUSED(C), void *UNUSED(snode_v), void *ngroup_v)
|
|
|
|
{
|
|
|
|
bNodeTree *ngroup= (bNodeTree*)ngroup_v;
|
|
|
|
|
|
|
|
ngroup->update |= NTREE_UPDATE_GROUP_OUT;
|
|
|
|
ntreeUpdateTree(ngroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_group_socket_name(SpaceNode *snode, bNode *gnode, bNodeSocket *sock, int in_out, float xoffset, float yoffset)
|
|
|
|
{
|
|
|
|
bNodeTree *ngroup= (bNodeTree*)gnode->id;
|
|
|
|
uiBut *bt;
|
|
|
|
|
|
|
|
if (sock->flag & SOCK_DYNAMIC) {
|
|
|
|
bt = uiDefBut(gnode->block, TEX, 0, "",
|
|
|
|
sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
|
2012-01-11 08:51:06 +00:00
|
|
|
sock->name, 0, sizeof(sock->name), 0, 0, "");
|
2011-09-05 21:01:50 +00:00
|
|
|
if (in_out==SOCK_IN)
|
|
|
|
uiButSetFunc(bt, update_group_input_cb, snode, ngroup);
|
|
|
|
else
|
|
|
|
uiButSetFunc(bt, update_group_output_cb, snode, ngroup);
|
|
|
|
}
|
|
|
|
else {
|
2011-11-11 13:09:14 +00:00
|
|
|
uiDefBut(gnode->block, LABEL, 0, sock->name,
|
|
|
|
sock->locx+xoffset, sock->locy+1+yoffset, 72, NODE_DY,
|
2012-01-11 08:51:06 +00:00
|
|
|
NULL, 0, sizeof(sock->name), 0, 0, "");
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void draw_group_socket(const bContext *C, SpaceNode *snode, bNodeTree *ntree, bNode *gnode, bNodeSocket *sock, bNodeSocket *gsock, int index, int in_out)
|
|
|
|
{
|
|
|
|
bNodeTree *ngroup= (bNodeTree*)gnode->id;
|
|
|
|
bNodeSocketType *stype= ntreeGetSocketType(gsock ? gsock->type : sock->type);
|
|
|
|
uiBut *bt;
|
|
|
|
float offset;
|
|
|
|
int draw_value;
|
|
|
|
float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
|
|
|
|
float socket_size= NODE_SOCKSIZE*U.dpi/72;
|
|
|
|
float arrowbutw= 0.8f*UI_UNIT_X;
|
|
|
|
/* layout stuff for buttons on group left frame */
|
|
|
|
float colw= 0.6f*node_group_frame;
|
2011-09-06 11:42:20 +00:00
|
|
|
float col1= 6 - node_group_frame;
|
2011-09-05 21:01:50 +00:00
|
|
|
float col2= col1 + colw+6;
|
2011-09-07 10:48:33 +00:00
|
|
|
float col3= - arrowbutw - 6;
|
2011-09-05 21:01:50 +00:00
|
|
|
/* layout stuff for buttons on group right frame */
|
|
|
|
float cor1= 6;
|
|
|
|
float cor2= cor1 + arrowbutw + 6;
|
|
|
|
float cor3= cor2 + arrowbutw + 6;
|
|
|
|
|
|
|
|
/* node and group socket circles */
|
|
|
|
if (sock)
|
|
|
|
node_socket_circle_draw(ntree, sock, socket_size);
|
|
|
|
if (gsock)
|
|
|
|
node_socket_circle_draw(ngroup, gsock, socket_size);
|
|
|
|
|
|
|
|
/* socket name */
|
|
|
|
offset = (in_out==SOCK_IN ? col1 : cor3);
|
|
|
|
if (!gsock)
|
|
|
|
offset += (in_out==SOCK_IN ? node_group_frame : -node_group_frame);
|
|
|
|
|
|
|
|
/* draw both name and value button if:
|
|
|
|
* 1) input: not internal
|
|
|
|
* 2) output: (node type uses const outputs) and (group output is unlinked)
|
|
|
|
*/
|
2011-09-08 07:01:29 +00:00
|
|
|
draw_value = 0;
|
2011-09-05 21:01:50 +00:00
|
|
|
switch (in_out) {
|
|
|
|
case SOCK_IN:
|
|
|
|
draw_value = !(gsock && (gsock->flag & SOCK_INTERNAL));
|
|
|
|
break;
|
|
|
|
case SOCK_OUT:
|
|
|
|
if (gnode->typeinfo->flag & NODE_CONST_OUTPUT)
|
|
|
|
draw_value = !(gsock && gsock->link);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (draw_value) {
|
|
|
|
/* both name and value buttons */
|
|
|
|
if (gsock) {
|
|
|
|
draw_group_socket_name(snode, gnode, gsock, in_out, offset, 0);
|
|
|
|
if (stype->buttonfunc)
|
|
|
|
stype->buttonfunc(C, gnode->block, ngroup, NULL, gsock, "", gsock->locx+offset, gsock->locy-NODE_DY, colw);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
draw_group_socket_name(snode, gnode, sock, in_out, offset, 0);
|
|
|
|
if (stype->buttonfunc)
|
|
|
|
stype->buttonfunc(C, gnode->block, ngroup, NULL, sock, "", sock->locx+offset, sock->locy-NODE_DY, colw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* only name, no value button */
|
|
|
|
if (gsock)
|
|
|
|
draw_group_socket_name(snode, gnode, gsock, in_out, offset, -NODE_DYS);
|
|
|
|
else
|
|
|
|
draw_group_socket_name(snode, gnode, sock, in_out, offset, -NODE_DYS);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (gsock && (gsock->flag & SOCK_DYNAMIC)) {
|
|
|
|
/* up/down buttons */
|
|
|
|
offset = (in_out==SOCK_IN ? col2 : cor2);
|
|
|
|
uiBlockSetDirection(gnode->block, UI_TOP);
|
|
|
|
uiBlockBeginAlign(gnode->block);
|
|
|
|
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_up", 0, ICON_TRIA_UP,
|
|
|
|
gsock->locx+offset, gsock->locy, arrowbutw, arrowbutw, "");
|
|
|
|
if (!gsock->prev || !(gsock->prev->flag & SOCK_DYNAMIC))
|
|
|
|
uiButSetFlag(bt, UI_BUT_DISABLED);
|
|
|
|
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
|
|
|
|
RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
|
|
|
|
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_move_down", 0, ICON_TRIA_DOWN,
|
|
|
|
gsock->locx+offset, gsock->locy-arrowbutw, arrowbutw, arrowbutw, "");
|
|
|
|
if (!gsock->next || !(gsock->next->flag & SOCK_DYNAMIC))
|
|
|
|
uiButSetFlag(bt, UI_BUT_DISABLED);
|
|
|
|
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
|
|
|
|
RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
|
|
|
|
uiBlockEndAlign(gnode->block);
|
|
|
|
uiBlockSetDirection(gnode->block, 0);
|
|
|
|
|
|
|
|
/* remove button */
|
2011-09-07 10:48:33 +00:00
|
|
|
offset = (in_out==SOCK_IN ? col3 : cor1);
|
2011-09-05 21:01:50 +00:00
|
|
|
uiBlockSetEmboss(gnode->block, UI_EMBOSSN);
|
|
|
|
bt = uiDefIconButO(gnode->block, BUT, "NODE_OT_group_socket_remove", 0, ICON_X,
|
|
|
|
gsock->locx+offset, gsock->locy-0.5f*arrowbutw, arrowbutw, arrowbutw, "");
|
|
|
|
RNA_int_set(uiButGetOperatorPtrRNA(bt), "index", index);
|
|
|
|
RNA_enum_set(uiButGetOperatorPtrRNA(bt), "in_out", in_out);
|
|
|
|
uiBlockSetEmboss(gnode->block, UI_EMBOSS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* groups are, on creation, centered around 0,0 */
|
|
|
|
static void node_draw_group(const bContext *C, ARegion *ar, SpaceNode *snode, bNodeTree *ntree, bNode *gnode)
|
|
|
|
{
|
|
|
|
if (!(gnode->flag & NODE_GROUP_EDIT)) {
|
|
|
|
node_draw_default(C, ar, snode, ntree, gnode);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bNodeTree *ngroup= (bNodeTree *)gnode->id;
|
|
|
|
bNodeSocket *sock, *gsock;
|
|
|
|
uiLayout *layout;
|
|
|
|
PointerRNA ptr;
|
|
|
|
rctf rect= gnode->totr;
|
|
|
|
float node_group_frame= U.dpi*NODE_GROUP_FRAME/72;
|
|
|
|
float group_header= 26*U.dpi/72;
|
|
|
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
/* backdrop header */
|
|
|
|
glEnable(GL_BLEND);
|
2011-09-11 06:41:09 +00:00
|
|
|
uiSetRoundBox(UI_CNR_TOP_LEFT | UI_CNR_TOP_RIGHT);
|
2011-09-05 21:01:50 +00:00
|
|
|
UI_ThemeColorShadeAlpha(TH_NODE_GROUP, 0, -70);
|
|
|
|
uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymax, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD);
|
|
|
|
|
|
|
|
/* backdrop body */
|
|
|
|
UI_ThemeColorShadeAlpha(TH_BACK, -8, -70);
|
2011-09-11 06:41:09 +00:00
|
|
|
uiSetRoundBox(UI_CNR_NONE);
|
2011-09-05 21:01:50 +00:00
|
|
|
uiDrawBox(GL_POLYGON, rect.xmin, rect.ymin, rect.xmax, rect.ymax, BASIS_RAD);
|
|
|
|
|
|
|
|
/* input column */
|
|
|
|
UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
|
2011-09-11 06:41:09 +00:00
|
|
|
uiSetRoundBox(UI_CNR_BOTTOM_LEFT);
|
2011-09-05 21:01:50 +00:00
|
|
|
uiDrawBox(GL_POLYGON, rect.xmin-node_group_frame, rect.ymin, rect.xmin, rect.ymax, BASIS_RAD);
|
|
|
|
|
|
|
|
/* output column */
|
|
|
|
UI_ThemeColorShadeAlpha(TH_BACK, 10, -50);
|
2011-09-11 06:41:09 +00:00
|
|
|
uiSetRoundBox(UI_CNR_BOTTOM_RIGHT);
|
2011-09-05 21:01:50 +00:00
|
|
|
uiDrawBox(GL_POLYGON, rect.xmax, rect.ymin, rect.xmax+node_group_frame, rect.ymax, BASIS_RAD);
|
|
|
|
|
|
|
|
/* input column separator */
|
|
|
|
glColor4ub(200, 200, 200, 140);
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex2f(rect.xmin, rect.ymin);
|
|
|
|
glVertex2f(rect.xmin, rect.ymax);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
/* output column separator */
|
|
|
|
glColor4ub(200, 200, 200, 140);
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex2f(rect.xmax, rect.ymin);
|
|
|
|
glVertex2f(rect.xmax, rect.ymax);
|
|
|
|
glEnd();
|
|
|
|
|
|
|
|
/* group node outline */
|
2011-09-11 06:41:09 +00:00
|
|
|
uiSetRoundBox(UI_CNR_ALL);
|
2011-09-05 21:01:50 +00:00
|
|
|
glColor4ub(200, 200, 200, 140);
|
|
|
|
glEnable( GL_LINE_SMOOTH );
|
|
|
|
uiDrawBox(GL_LINE_LOOP, rect.xmin-node_group_frame, rect.ymin, rect.xmax+node_group_frame, rect.ymax+group_header, BASIS_RAD);
|
|
|
|
glDisable( GL_LINE_SMOOTH );
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
|
|
|
|
/* backdrop title */
|
|
|
|
UI_ThemeColor(TH_TEXT_HI);
|
|
|
|
|
|
|
|
layout = uiBlockLayout(gnode->block, UI_LAYOUT_VERTICAL, UI_LAYOUT_PANEL, (short)(rect.xmin+15), (short)(rect.ymax+group_header),
|
2011-09-21 15:15:30 +00:00
|
|
|
MIN2((int)(rect.xmax - rect.xmin-18.0f), node_group_frame+20), group_header, UI_GetStyle());
|
2011-09-05 21:01:50 +00:00
|
|
|
RNA_pointer_create(&ntree->id, &RNA_Node, gnode, &ptr);
|
|
|
|
uiTemplateIDBrowse(layout, (bContext*)C, &ptr, "node_tree", NULL, NULL, NULL);
|
|
|
|
uiBlockLayoutResolve(gnode->block, NULL, NULL);
|
|
|
|
|
|
|
|
/* draw the internal tree nodes and links */
|
|
|
|
node_draw_nodetree(C, ar, snode, ngroup);
|
|
|
|
|
|
|
|
/* group sockets */
|
|
|
|
gsock=ngroup->inputs.first;
|
|
|
|
sock=gnode->inputs.first;
|
|
|
|
index = 0;
|
|
|
|
while (gsock || sock) {
|
|
|
|
while (sock && !sock->groupsock) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_IN);
|
|
|
|
sock = sock->next;
|
|
|
|
}
|
|
|
|
while (gsock && (!sock || sock->groupsock!=gsock)) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_IN);
|
|
|
|
gsock = gsock->next;
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
while (sock && gsock && sock->groupsock==gsock) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_IN);
|
|
|
|
sock = sock->next;
|
|
|
|
gsock = gsock->next;
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
gsock=ngroup->outputs.first;
|
|
|
|
sock=gnode->outputs.first;
|
|
|
|
index = 0;
|
|
|
|
while (gsock || sock) {
|
|
|
|
while (sock && !sock->groupsock) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, sock, NULL, index, SOCK_OUT);
|
|
|
|
sock = sock->next;
|
|
|
|
}
|
|
|
|
while (gsock && (!sock || sock->groupsock!=gsock)) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, NULL, gsock, index, SOCK_OUT);
|
|
|
|
gsock = gsock->next;
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
while (sock && gsock && sock->groupsock==gsock) {
|
|
|
|
draw_group_socket(C, snode, ntree, gnode, sock, gsock, index, SOCK_OUT);
|
|
|
|
sock = sock->next;
|
|
|
|
gsock = gsock->next;
|
|
|
|
++index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uiEndBlock(C, gnode->block);
|
|
|
|
uiDrawBlock(C, gnode->block);
|
|
|
|
gnode->block= NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-04 13:31:15 +00:00
|
|
|
void node_uifunc_group(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiTemplateIDBrowse(layout, C, ptr, "node_tree", NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void node_common_buts_whileloop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "max_iterations", 0, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_update_frame(const bContext *UNUSED(C), bNodeTree *UNUSED(ntree), bNode *node)
|
|
|
|
{
|
|
|
|
float locx, locy;
|
|
|
|
|
|
|
|
/* get "global" coords */
|
|
|
|
nodeSpaceCoords(node, &locx, &locy);
|
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
node->prvr.xmin = locx + NODE_DYS;
|
|
|
|
node->prvr.xmax = locx + node->width- NODE_DYS;
|
2011-09-05 21:01:50 +00:00
|
|
|
|
2012-03-24 02:51:46 +00:00
|
|
|
node->totr.xmin = locx;
|
|
|
|
node->totr.xmax = locx + node->width;
|
|
|
|
node->totr.ymax = locy;
|
|
|
|
node->totr.ymin = locy - node->height;
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void node_common_set_butfunc(bNodeType *ntype)
|
|
|
|
{
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ntype->type) {
|
2011-09-05 21:01:50 +00:00
|
|
|
case NODE_GROUP:
|
2011-11-04 13:31:15 +00:00
|
|
|
ntype->uifunc= node_uifunc_group;
|
2011-09-05 21:01:50 +00:00
|
|
|
ntype->drawfunc= node_draw_group;
|
|
|
|
ntype->drawupdatefunc= node_update_group;
|
|
|
|
break;
|
|
|
|
case NODE_FORLOOP:
|
|
|
|
// ntype->uifunc= node_common_buts_group;
|
|
|
|
ntype->drawfunc= node_draw_group;
|
|
|
|
ntype->drawupdatefunc= node_update_group;
|
|
|
|
break;
|
|
|
|
case NODE_WHILELOOP:
|
|
|
|
ntype->uifunc= node_common_buts_whileloop;
|
|
|
|
ntype->drawfunc= node_draw_group;
|
|
|
|
ntype->drawupdatefunc= node_update_group;
|
|
|
|
break;
|
|
|
|
case NODE_FRAME:
|
|
|
|
ntype->drawupdatefunc= node_update_frame;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* ****************** BUTTON CALLBACKS FOR SHADER NODES ***************** */
|
|
|
|
|
2008-12-29 00:55:23 +00:00
|
|
|
static void node_browse_text_cb(bContext *C, void *ntree_v, void *node_v)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2008-12-24 10:33:10 +00:00
|
|
|
bNodeTree *ntree= ntree_v;
|
|
|
|
bNode *node= node_v;
|
2011-09-20 08:48:48 +00:00
|
|
|
/* ID *oldid; */ /* UNUSED */
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->menunr<1) return;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node->id) {
|
2008-12-24 10:33:10 +00:00
|
|
|
node->id->us--;
|
|
|
|
}
|
2011-09-20 08:48:48 +00:00
|
|
|
/* oldid= node->id; */ /* UNUSED */
|
2010-08-01 12:47:49 +00:00
|
|
|
node->id= BLI_findlink(&bmain->text, node->menunr-1);
|
2008-12-24 10:33:10 +00:00
|
|
|
id_us_plus(node->id);
|
2010-11-05 07:35:21 +00:00
|
|
|
BLI_strncpy(node->name, node->id->name+2, sizeof(node->name));
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
node->custom1= BSET(node->custom1, NODE_DYNAMIC_NEW);
|
|
|
|
|
|
|
|
nodeSetActive(ntree, node);
|
|
|
|
|
|
|
|
// allqueue(REDRAWBUTSSHADING, 0);
|
|
|
|
// allqueue(REDRAWNODE, 0);
|
|
|
|
|
|
|
|
node->menunr= 0;
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_shader_buts_material(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-10 04:01:44 +00:00
|
|
|
bNode *node= ptr->data;
|
|
|
|
uiLayout *col;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-08-04 12:18:07 +00:00
|
|
|
uiTemplateID(layout, C, ptr, "material", "MATERIAL_OT_new", NULL, NULL);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id) return;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_diffuse", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_specular", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "invert_normal", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_shader_buts_mapping(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-10 04:01:44 +00:00
|
|
|
uiLayout *row;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(layout, "Location:", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2012-04-04 16:11:39 +00:00
|
|
|
uiItemR(row, ptr, "translation", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(layout, "Rotation:", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-11-14 20:39:53 +00:00
|
|
|
uiItemR(row, ptr, "rotation", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(layout, "Scale:", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-11-14 20:39:53 +00:00
|
|
|
uiItemR(row, ptr, "scale", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-11-14 20:39:53 +00:00
|
|
|
uiItemR(row, ptr, "use_min", 0, "Min", ICON_NONE);
|
|
|
|
uiItemR(row, ptr, "min", 0, "", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
|
|
|
|
row= uiLayoutRow(layout, 1);
|
2011-11-14 20:39:53 +00:00
|
|
|
uiItemR(row, ptr, "use_max", 0, "Max", ICON_NONE);
|
|
|
|
uiItemR(row, ptr, "max", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_shader_buts_vect_math(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "operation", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_shader_buts_geometry(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-04-15 10:28:32 +00:00
|
|
|
PointerRNA obptr= CTX_data_pointer_get(C, "active_object");
|
2009-11-10 04:01:44 +00:00
|
|
|
uiLayout *col;
|
2010-04-15 10:28:32 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2010-04-15 10:28:32 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (obptr.data && RNA_enum_get(&obptr, "type") == OB_MESH) {
|
2010-04-15 10:28:32 +00:00
|
|
|
PointerRNA dataptr= RNA_pointer_get(&obptr, "data");
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemPointerR(col, ptr, "uv_layer", &dataptr, "uv_textures", "", ICON_NONE);
|
|
|
|
uiItemPointerR(col, ptr, "color_layer", &dataptr, "vertex_colors", "", ICON_NONE);
|
2010-04-15 10:28:32 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "uv_layer", 0, "UV", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "color_layer", 0, "VCol", ICON_NONE);
|
2010-04-15 10:28:32 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
static void node_shader_buts_attribute(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "attribute_name", 0, "Name", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
|
|
|
|
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
2012-03-08 19:52:58 +00:00
|
|
|
|
|
|
|
static void node_shader_buts_tex_environment(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
|
|
|
|
uiItemR(layout, ptr, "color_space", 0, "", ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "projection", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
2011-11-08 11:38:16 +00:00
|
|
|
static void node_shader_buts_tex_sky(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "sun_direction", 0, "", ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "turbidity", 0, NULL, ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_gradient(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "gradient_type", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_magic(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "turbulence_depth", 0, NULL, ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_wave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "wave_type", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_musgrave(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "musgrave_type", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_tex_voronoi(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "coloring", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_shader_buts_glossy(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "distribution", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_shader_buts_dynamic(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-08-01 12:47:49 +00:00
|
|
|
Main *bmain= CTX_data_main(C);
|
2009-10-09 10:45:11 +00:00
|
|
|
uiBlock *block= uiLayoutAbsoluteBlock(layout);
|
2009-09-16 18:59:13 +00:00
|
|
|
bNode *node= ptr->data;
|
|
|
|
bNodeTree *ntree= ptr->id.data;
|
|
|
|
rctf *butr= &node->butr;
|
|
|
|
uiBut *bt;
|
|
|
|
// XXX SpaceNode *snode= curarea->spacedata.first;
|
|
|
|
short dy= (short)butr->ymin;
|
|
|
|
int xoff=0;
|
|
|
|
|
|
|
|
/* B_NODE_EXEC is handled in butspace.c do_node_buts */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id) {
|
2010-12-03 17:05:21 +00:00
|
|
|
const char *strp;
|
2010-08-01 12:47:49 +00:00
|
|
|
IDnames_to_pupstring(&strp, NULL, "", &(bmain->text), NULL, NULL);
|
2009-09-16 18:59:13 +00:00
|
|
|
node->menunr= 0;
|
|
|
|
bt= uiDefButS(block, MENU, B_NODE_EXEC/*+node->nr*/, strp,
|
|
|
|
butr->xmin, dy, 19, 19,
|
|
|
|
&node->menunr, 0, 0, 0, 0, "Browses existing choices");
|
|
|
|
uiButSetFunc(bt, node_browse_text_cb, ntree, node);
|
|
|
|
xoff=19;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (strp) MEM_freeN((void *)strp);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
bt = uiDefBut(block, BUT, B_NOP, "Update",
|
|
|
|
butr->xmin+xoff, butr->ymin+20, 50, 19,
|
|
|
|
&node->menunr, 0.0, 19.0, 0, 0, "Refresh this node (and all others that use the same script)");
|
|
|
|
uiButSetFunc(bt, node_dynamic_update_cb, ntree, node);
|
|
|
|
|
|
|
|
if (BTST(node->custom1, NODE_DYNAMIC_ERROR)) {
|
|
|
|
// UI_ThemeColor(TH_REDALERT);
|
|
|
|
// XXX ui_rasterpos_safe(butr->xmin + xoff, butr->ymin + 5, snode->aspect);
|
|
|
|
// XXX snode_drawstring(snode, "Error! Check console...", butr->xmax - butr->xmin);
|
|
|
|
;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* only once called */
|
|
|
|
static void node_shader_set_butfunc(bNodeType *ntype)
|
|
|
|
{
|
2011-07-04 19:22:37 +00:00
|
|
|
ntype->uifuncbut = NULL;
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ntype->type) {
|
2008-12-24 10:33:10 +00:00
|
|
|
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
|
|
|
|
|
|
|
|
case SH_NODE_MATERIAL:
|
|
|
|
case SH_NODE_MATERIAL_EXT:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_shader_buts_material;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_TEXTURE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_texture;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_NORMAL:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_normal;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_CURVE_VEC:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_curvevec;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_CURVE_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_curvecol;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_MAPPING:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_shader_buts_mapping;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_VALUE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_value;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_rgb;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_MIX_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_mix_rgb;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_VALTORGB:
|
2009-11-10 04:01:44 +00:00
|
|
|
ntype->uifunc= node_buts_colorramp;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_MATH:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_math;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_VECT_MATH:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_shader_buts_vect_math;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_GEOMETRY:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_shader_buts_geometry;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2011-11-08 11:38:16 +00:00
|
|
|
case SH_NODE_ATTRIBUTE:
|
|
|
|
ntype->uifunc= node_shader_buts_attribute;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_SKY:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_sky;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_IMAGE:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_image;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_ENVIRONMENT:
|
2012-03-08 19:52:58 +00:00
|
|
|
ntype->uifunc= node_shader_buts_tex_environment;
|
2011-11-08 11:38:16 +00:00
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_GRADIENT:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_gradient;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_MAGIC:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_magic;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_WAVE:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_wave;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_MUSGRAVE:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_musgrave;
|
|
|
|
break;
|
|
|
|
case SH_NODE_TEX_VORONOI:
|
|
|
|
ntype->uifunc= node_shader_buts_tex_voronoi;
|
|
|
|
break;
|
|
|
|
case SH_NODE_BSDF_GLOSSY:
|
|
|
|
case SH_NODE_BSDF_GLASS:
|
|
|
|
ntype->uifunc= node_shader_buts_glossy;
|
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case NODE_DYNAMIC:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_shader_buts_dynamic;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-07-04 19:22:37 +00:00
|
|
|
if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** BUTTON CALLBACKS FOR COMPOSITE NODES ***************** */
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_composit_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-10 04:01:44 +00:00
|
|
|
uiLayout *col;
|
|
|
|
bNode *node= ptr->data;
|
|
|
|
PointerRNA imaptr;
|
|
|
|
PropertyRNA *prop;
|
2011-05-01 14:02:40 +00:00
|
|
|
int source;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-08-04 12:18:07 +00:00
|
|
|
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id) return;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, "image");
|
|
|
|
if (!prop || RNA_property_type(prop) != PROP_POINTER) return;
|
|
|
|
imaptr= RNA_property_pointer_get(ptr, prop);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &imaptr, "source", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2011-05-01 14:02:40 +00:00
|
|
|
source= RNA_enum_get(&imaptr, "source");
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (source == IMA_SRC_SEQUENCE) {
|
2011-05-01 14:02:40 +00:00
|
|
|
/* don't use iuser->framenr directly because it may not be updated if auto-refresh is off */
|
|
|
|
Scene *scene= CTX_data_scene(C);
|
|
|
|
ImageUser *iuser= node->storage;
|
2012-01-11 09:33:44 +00:00
|
|
|
char numstr[32];
|
2011-05-01 14:02:40 +00:00
|
|
|
const int framenr= BKE_image_user_get_frame(iuser, CFRA, 0);
|
2012-01-11 09:33:44 +00:00
|
|
|
BLI_snprintf(numstr, sizeof(numstr), "Frame: %d", framenr);
|
|
|
|
uiItemL(layout, numstr, ICON_NONE);
|
2011-05-01 14:02:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ELEM(source, IMA_SRC_SEQUENCE, IMA_SRC_MOVIE)) {
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "frame_duration", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "frame_start", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "frame_offset", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_cyclic", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_auto_refresh", UI_ITEM_R_ICON_ONLY, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
if (RNA_enum_get(&imaptr, "type")== IMA_TYPE_MULTILAYER)
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "layer", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_composit_buts_renderlayers(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-11-10 04:01:44 +00:00
|
|
|
bNode *node= ptr->data;
|
2010-01-06 00:09:07 +00:00
|
|
|
uiLayout *col, *row;
|
|
|
|
PointerRNA op_ptr;
|
|
|
|
PointerRNA scn_ptr;
|
|
|
|
PropertyRNA *prop;
|
|
|
|
const char *layer_name;
|
2011-04-19 06:59:49 +00:00
|
|
|
char scene_name[MAX_ID_NAME-2];
|
2012-01-22 03:30:07 +00:00
|
|
|
wmOperatorType *ot = WM_operatortype_find("RENDER_OT_render", 1);
|
|
|
|
|
|
|
|
BLI_assert(ot != 0);
|
|
|
|
|
2010-08-04 12:18:07 +00:00
|
|
|
uiTemplateID(layout, C, ptr, "scene", NULL, NULL, NULL);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id) return;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-11-10 04:01:44 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2010-01-06 00:09:07 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "layer", 0, "", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
|
2010-01-06 00:09:07 +00:00
|
|
|
prop = RNA_struct_find_property(ptr, "layer");
|
|
|
|
if (!(RNA_property_enum_identifier(C, ptr, prop, RNA_property_enum_get(ptr, prop), &layer_name)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
scn_ptr = RNA_pointer_get(ptr, "scene");
|
|
|
|
RNA_string_get(&scn_ptr, "name", scene_name);
|
|
|
|
|
2012-01-22 03:30:07 +00:00
|
|
|
WM_operator_properties_create_ptr(&op_ptr, ot);
|
2010-01-06 00:09:07 +00:00
|
|
|
RNA_string_set(&op_ptr, "layer", layer_name);
|
|
|
|
RNA_string_set(&op_ptr, "scene", scene_name);
|
2012-01-22 03:30:07 +00:00
|
|
|
uiItemFullO_ptr(row, ot, "", ICON_RENDER_STILL, op_ptr.data, WM_OP_INVOKE_DEFAULT, 0);
|
2010-01-06 00:09:07 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_blur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-10 20:54:02 +00:00
|
|
|
uiLayout *col, *row;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-09-21 16:21:54 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "filter_type", 0, "", ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
if (RNA_enum_get(ptr, "filter_type")!= R_FILTER_FAST_GAUSS) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_bokeh", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2009-09-21 16:21:54 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_relative", 0, NULL, ICON_NONE);
|
2011-02-10 20:54:02 +00:00
|
|
|
|
|
|
|
if (RNA_boolean_get(ptr, "use_relative")) {
|
|
|
|
uiItemL(col, "Aspect Correction", 0);
|
|
|
|
row= uiLayoutRow(layout, 1);
|
|
|
|
uiItemR(row, ptr, "aspect_correction", UI_ITEM_R_EXPAND, NULL, 0);
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "factor_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "factor_y", 0, "Y", ICON_NONE);
|
2011-02-10 20:54:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "size_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "size_y", 0, "Y", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_dblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-27 11:00:35 +00:00
|
|
|
uiLayout *col;
|
2009-09-18 21:04:54 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "use_wrap", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(col, "Center:", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "center_x", 0, "X", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "center_y", 0, "Y", ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "distance", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
uiItemS(layout);
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "spin", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "zoom", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_bilateralblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-18 21:04:54 +00:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-09-18 21:04:54 +00:00
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "iterations", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "sigma_color", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "sigma_space", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_defocus(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-18 21:04:54 +00:00
|
|
|
uiLayout *sub, *col;
|
|
|
|
|
2009-09-26 16:43:20 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(col, "Bokeh Type:", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "bokeh", 0, "", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "angle", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "use_gamma_correction", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, 0);
|
2009-12-02 18:35:44 +00:00
|
|
|
uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_zbuffer")==1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "f_stop", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "blur_max", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
|
2009-09-18 21:04:54 +00:00
|
|
|
col = uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_preview", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
sub = uiLayoutColumn(col, 0);
|
2010-08-25 16:11:58 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_preview"));
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(sub, ptr, "samples", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_zbuffer", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
sub = uiLayoutColumn(col, 0);
|
2009-12-02 18:35:44 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_zbuffer")==0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(sub, ptr, "z_scale", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* qdn: glare node */
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_glare(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-18 21:04:54 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "glare_type", 0, "", ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "quality", 0, "", ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")!= 1) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "iterations", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")!= 0)
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "color_modulation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2009-09-18 21:04:54 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "mix", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "threshold", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")== 2) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "streaks", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(layout, ptr, "angle_offset", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
}
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")== 0 || RNA_enum_get(ptr, "glare_type")== 2) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "fade", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")== 0)
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "use_rotate_45", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
}
|
|
|
|
if (RNA_enum_get(ptr, "glare_type")== 1) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "size", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_tonemap(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-18 21:04:54 +00:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
|
2009-09-26 16:43:20 +00:00
|
|
|
col = uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "tonemap_type", 0, "", ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
if (RNA_enum_get(ptr, "tonemap_type")== 0) {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "key", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "gamma", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
else {
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "intensity", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "contrast", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "adaptation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "correction", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_lensdist(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-17 17:31:50 +00:00
|
|
|
uiLayout *col;
|
2009-09-17 15:06:03 +00:00
|
|
|
|
2009-09-17 16:47:04 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_projector", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-09-18 21:04:54 +00:00
|
|
|
col = uiLayoutColumn(col, 0);
|
2010-08-20 06:09:58 +00:00
|
|
|
uiLayoutSetActive(col, RNA_boolean_get(ptr, "use_projector")==0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_jitter", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_fit", 0, NULL, ICON_NONE);
|
2009-09-18 21:04:54 +00:00
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_vecblur(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
|
2009-09-26 16:43:20 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "samples", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "factor", 0, "Blur", ICON_NONE);
|
2009-09-17 16:47:04 +00:00
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemL(col, "Speed:", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "speed_min", 0, "Min", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "speed_max", 0, "Max", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "use_curved", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_filter(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_flip(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "axis", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_crop(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-09-17 17:31:50 +00:00
|
|
|
uiLayout *col;
|
2011-04-21 13:11:51 +00:00
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "use_crop_size", 0, NULL, ICON_NONE);
|
2011-04-21 13:11:51 +00:00
|
|
|
uiItemR(layout, ptr, "relative", 0, NULL, ICON_NONE);
|
2010-08-25 02:18:37 +00:00
|
|
|
|
2009-09-17 16:47:04 +00:00
|
|
|
col= uiLayoutColumn(layout, 1);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_boolean_get(ptr, "relative")) {
|
2011-04-21 13:11:51 +00:00
|
|
|
uiItemR(col, ptr, "rel_min_x", 0, "Left", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "rel_max_x", 0, "Right", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "rel_min_y", 0, "Up", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "rel_max_y", 0, "Down", ICON_NONE);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-04-21 13:11:51 +00:00
|
|
|
uiItemR(col, ptr, "min_x", 0, "Left", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "max_x", 0, "Right", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "min_y", 0, "Up", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "max_y", 0, "Down", ICON_NONE);
|
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_splitviewer(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-09-18 21:04:54 +00:00
|
|
|
uiLayout *row, *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-09-26 16:43:20 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
2009-09-18 21:04:54 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "factor", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2012-01-10 19:08:08 +00:00
|
|
|
static void node_composit_buts_double_edge_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
|
|
|
|
uiItemL(col, "Inner Edge:", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "inner_mode", 0, "", ICON_NONE);
|
|
|
|
uiItemL(col, "Buffer Edge:", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "edge_mode", 0, "", ICON_NONE);
|
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_map_value(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-19 19:57:30 +00:00
|
|
|
uiLayout *sub, *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "offset", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "size", 0, NULL, ICON_NONE);
|
2009-09-19 19:57:30 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_min", 0, NULL, ICON_NONE);
|
2012-02-23 02:23:42 +00:00
|
|
|
sub = uiLayoutColumn(col, 0);
|
2009-09-19 19:57:30 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_min"));
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(sub, ptr, "min", 0, "", ICON_NONE);
|
2009-09-19 19:57:30 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_max", 0, NULL, ICON_NONE);
|
2012-02-23 02:23:42 +00:00
|
|
|
sub = uiLayoutColumn(col, 0);
|
2009-09-19 19:57:30 +00:00
|
|
|
uiLayoutSetActive(sub, RNA_boolean_get(ptr, "use_max"));
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(sub, ptr, "max", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_alphaover(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-19 19:57:30 +00:00
|
|
|
{
|
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_premultiply", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "premul", 0, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-11-12 14:59:01 +00:00
|
|
|
static void node_composit_buts_zcombine(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiLayout *col;
|
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "use_alpha", 0, NULL, ICON_NONE);
|
2010-11-12 14:59:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_hue_sat(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-19 19:57:30 +00:00
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_dilateerode(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "distance", 0, NULL, ICON_NONE);
|
2009-09-10 04:12:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_diff_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-10 04:12:22 +00:00
|
|
|
{
|
2009-09-20 13:34:54 +00:00
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_distance_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-20 13:34:54 +00:00
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "tolerance", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "falloff", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_color_spill(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-20 13:34:54 +00:00
|
|
|
uiLayout *row, *col;
|
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemL(layout, "Despill Channel:", ICON_NONE);
|
2012-04-29 15:47:02 +00:00
|
|
|
row = uiLayoutRow(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2010-03-12 18:47:35 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
|
2010-03-12 18:47:35 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_enum_get(ptr, "limit_method")==0) {
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemL(col, "Limiting Channel:", ICON_NONE);
|
2012-04-29 15:47:02 +00:00
|
|
|
row=uiLayoutRow(col, 0);
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
}
|
2010-03-12 18:47:35 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(col, ptr, "ratio", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "use_unspill", 0, NULL, ICON_NONE);
|
2011-05-28 12:04:56 +00:00
|
|
|
if (RNA_boolean_get(ptr, "use_unspill")== 1) {
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(col, ptr, "unspill_red", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "unspill_green", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "unspill_blue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
}
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_chroma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-26 16:43:20 +00:00
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "tolerance", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "threshold", 0, NULL, ICON_NONE);
|
2009-09-26 16:43:20 +00:00
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-04-21 15:53:30 +00:00
|
|
|
/*uiItemR(col, ptr, "lift", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now */
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "gain", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2011-04-21 15:53:30 +00:00
|
|
|
/*uiItemR(col, ptr, "shadow_adjust", UI_ITEM_R_SLIDER, NULL, ICON_NONE); Removed for now*/
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_color_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-16 18:59:13 +00:00
|
|
|
{
|
2009-09-21 16:21:54 +00:00
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "color_hue", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "color_saturation", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "color_value", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_channel_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-10-27 13:46:02 +00:00
|
|
|
{
|
|
|
|
uiLayout *col, *row;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemL(layout, "Color Space:", ICON_NONE);
|
2009-10-27 13:46:02 +00:00
|
|
|
row= uiLayoutRow(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "color_space", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
col=uiLayoutColumn(layout, 0);
|
|
|
|
uiItemL(col, "Key Channel:", ICON_NONE);
|
2010-03-13 14:47:26 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "matte_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-11-10 04:01:44 +00:00
|
|
|
|
2012-02-23 02:23:42 +00:00
|
|
|
col = uiLayoutColumn(layout, 0);
|
2010-03-13 14:47:26 +00:00
|
|
|
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(col, ptr, "limit_method", 0, NULL, ICON_NONE);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (RNA_enum_get(ptr, "limit_method")==0) {
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemL(col, "Limiting Channel:", ICON_NONE);
|
2012-04-29 15:47:02 +00:00
|
|
|
row=uiLayoutRow(col, 0);
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(row, ptr, "limit_channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
}
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_luma_matte(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-10 04:12:22 +00:00
|
|
|
{
|
2009-10-27 13:46:02 +00:00
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "limit_max", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "limit_min", UI_ITEM_R_SLIDER, NULL, ICON_NONE);
|
2009-09-10 04:12:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_map_uv(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "alpha", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_id_mask(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "index", 0, NULL, ICON_NONE);
|
2011-10-02 20:09:45 +00:00
|
|
|
uiItemR(layout, ptr, "use_smooth_mask", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_file_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2012-03-01 07:56:15 +00:00
|
|
|
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
|
|
|
|
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
|
|
|
|
|
|
|
|
if (multilayer)
|
|
|
|
uiItemL(layout, "Path:", 0);
|
|
|
|
else
|
|
|
|
uiItemL(layout, "Base Path:", 0);
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
uiItemR(layout, ptr, "base_path", 0, "", ICON_NONE);
|
|
|
|
}
|
2012-03-01 07:56:15 +00:00
|
|
|
static void node_composit_buts_file_output_details(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
{
|
2012-03-01 07:56:15 +00:00
|
|
|
PointerRNA imfptr = RNA_pointer_get(ptr, "format");
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
PointerRNA active_input_ptr = RNA_pointer_get(ptr, "active_input");
|
2012-03-01 07:56:15 +00:00
|
|
|
int multilayer = (RNA_enum_get(&imfptr, "file_format") == R_IMF_IMTYPE_MULTILAYER);
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
node_composit_buts_file_output(layout, C, ptr);
|
|
|
|
uiTemplateImageSettings(layout, &imfptr);
|
|
|
|
|
|
|
|
uiItemS(layout);
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
uiItemO(layout, "Add Input", ICON_ZOOMIN, "NODE_OT_output_file_add_socket");
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
|
|
|
|
uiTemplateList(layout, C, ptr, "inputs", ptr, "active_input_index", NULL, 0, 0, 0);
|
|
|
|
|
|
|
|
if (active_input_ptr.data) {
|
|
|
|
uiLayout *row, *col;
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, 1);
|
2012-03-01 07:56:15 +00:00
|
|
|
if (multilayer)
|
|
|
|
uiItemL(col, "Layer Name:", 0);
|
|
|
|
else
|
|
|
|
uiItemL(col, "File Path:", 0);
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
|
|
|
uiItemR(row, &active_input_ptr, "name", 0, "", 0);
|
2012-03-01 07:56:15 +00:00
|
|
|
uiItemFullO(row, "NODE_OT_output_file_remove_active_socket", "", ICON_X, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_R_ICON_ONLY);
|
2012-02-22 14:19:39 +00:00
|
|
|
|
2012-03-01 07:56:15 +00:00
|
|
|
/* in multilayer format all socket format details are ignored */
|
|
|
|
if (!multilayer) {
|
|
|
|
imfptr = RNA_pointer_get(&active_input_ptr, "format");
|
|
|
|
|
|
|
|
col = uiLayoutColumn(layout, 1);
|
|
|
|
uiItemL(col, "Format:", 0);
|
|
|
|
uiItemR(col, &active_input_ptr, "use_node_format", 0, NULL, 0);
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
uiLayoutSetActive(col, RNA_boolean_get(&active_input_ptr, "use_node_format")==0);
|
|
|
|
uiTemplateImageSettings(col, &imfptr);
|
|
|
|
}
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_scale(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "space", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_rotate(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2010-03-15 22:36:39 +00:00
|
|
|
{
|
2011-04-21 15:53:30 +00:00
|
|
|
uiItemR(layout, ptr, "filter_type", 0, "", ICON_NONE);
|
2010-03-15 22:36:39 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_invert(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-09-20 13:34:54 +00:00
|
|
|
uiLayout *col;
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "invert_rgb", 0, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "invert_alpha", 0, NULL, ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_premulkey(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "mapping", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_view_levels(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2009-09-10 04:12:22 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "channel", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-09-10 04:12:22 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_colorbalance(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2010-01-20 04:19:55 +00:00
|
|
|
{
|
|
|
|
uiLayout *split, *col, *row;
|
|
|
|
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2010-08-20 06:09:58 +00:00
|
|
|
if (RNA_enum_get(ptr, "correction_method")== 0) {
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2010-01-27 00:22:29 +00:00
|
|
|
split = uiLayoutSplit(layout, 0, 0);
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "lift", 1, 1, 0, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "lift", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "gamma", 1, 1, 1, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "gamma", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "gain", 1, 1, 1, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "gain", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2010-01-27 00:22:29 +00:00
|
|
|
|
|
|
|
split = uiLayoutSplit(layout, 0, 0);
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "offset", 1, 1, 0, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "offset", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "power", 1, 1, 0, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "power", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
|
|
|
|
col = uiLayoutColumn(split, 0);
|
2010-07-05 15:52:25 +00:00
|
|
|
uiTemplateColorWheel(col, ptr, "slope", 1, 1, 0, 1);
|
2010-01-27 00:22:29 +00:00
|
|
|
row = uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, ptr, "slope", 0, NULL, ICON_NONE);
|
2010-01-27 00:22:29 +00:00
|
|
|
}
|
2010-01-20 04:19:55 +00:00
|
|
|
|
|
|
|
}
|
2011-07-04 18:48:36 +00:00
|
|
|
static void node_composit_buts_colorbalance_but(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
2011-07-04 19:22:37 +00:00
|
|
|
uiItemR(layout, ptr, "correction_method", 0, NULL, ICON_NONE);
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
if (RNA_enum_get(ptr, "correction_method")== 0) {
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "lift", 1, 1, 0, 1);
|
|
|
|
uiItemR(layout, ptr, "lift", 0, NULL, ICON_NONE);
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "gamma", 1, 1, 1, 1);
|
|
|
|
uiItemR(layout, ptr, "gamma", 0, NULL, ICON_NONE);
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "gain", 1, 1, 1, 1);
|
|
|
|
uiItemR(layout, ptr, "gain", 0, NULL, ICON_NONE);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "offset", 1, 1, 0, 1);
|
|
|
|
uiItemR(layout, ptr, "offset", 0, NULL, ICON_NONE);
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "power", 1, 1, 0, 1);
|
|
|
|
uiItemR(layout, ptr, "power", 0, NULL, ICON_NONE);
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2011-07-04 19:22:37 +00:00
|
|
|
uiTemplateColorWheel(layout, ptr, "slope", 1, 1, 0, 1);
|
|
|
|
uiItemR(layout, ptr, "slope", 0, NULL, ICON_NONE);
|
|
|
|
}
|
2011-07-04 18:48:36 +00:00
|
|
|
}
|
|
|
|
|
2010-01-20 04:19:55 +00:00
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_composit_buts_huecorrect(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2010-01-21 00:00:45 +00:00
|
|
|
{
|
|
|
|
uiTemplateCurveMapping(layout, ptr, "mapping", 'h', 0, 0);
|
|
|
|
}
|
|
|
|
|
2010-12-13 21:17:00 +00:00
|
|
|
static void node_composit_buts_ycc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "mode", 0, "", ICON_NONE);
|
2010-12-13 21:17:00 +00:00
|
|
|
}
|
|
|
|
|
2011-11-07 12:56:05 +00:00
|
|
|
static void node_composit_buts_movieclip(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_composit_buts_stabilize2d(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
bNode *node= ptr->data;
|
|
|
|
|
|
|
|
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id)
|
2011-11-07 12:56:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
uiItemR(layout, ptr, "filter_type", 0, "", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_composit_buts_transform(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
uiItemR(layout, ptr, "filter_type", 0, "", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void node_composit_buts_moviedistortion(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
|
|
|
{
|
|
|
|
bNode *node= ptr->data;
|
|
|
|
|
|
|
|
uiTemplateID(layout, C, ptr, "clip", NULL, "CLIP_OT_open", NULL);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!node->id)
|
2011-11-07 12:56:05 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
uiItemR(layout, ptr, "distortion_type", 0, "", 0);
|
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* only once called */
|
|
|
|
static void node_composit_set_butfunc(bNodeType *ntype)
|
|
|
|
{
|
2011-07-04 19:22:37 +00:00
|
|
|
ntype->uifuncbut = NULL;
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (ntype->type) {
|
2008-12-24 10:33:10 +00:00
|
|
|
/* case NODE_GROUP: note, typeinfo for group is generated... see "XXX ugly hack" */
|
|
|
|
|
|
|
|
case CMP_NODE_IMAGE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_image;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_R_LAYERS:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_renderlayers;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_NORMAL:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_normal;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_CURVE_VEC:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_curvevec;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_CURVE_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_curvecol;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_VALUE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_value;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_rgb;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_FLIP:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_flip;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_SPLITVIEWER:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_splitviewer;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_MIX_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_mix_rgb;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_VALTORGB:
|
2009-11-10 04:01:44 +00:00
|
|
|
ntype->uifunc= node_buts_colorramp;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_CROP:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_crop;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_BLUR:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_blur;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_DBLUR:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_dblur;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_BILATERALBLUR:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_bilateralblur;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_DEFOCUS:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_composit_buts_defocus;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_GLARE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_composit_buts_glare;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_TONEMAP:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_composit_buts_tonemap;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_LENSDIST:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_composit_buts_lensdist;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_VECBLUR:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_vecblur;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_FILTER:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_filter;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_MAP_VALUE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_map_value;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_TIME:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_time;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_ALPHAOVER:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_alphaover;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_HUE_SAT:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_hue_sat;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_TEXTURE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_texture;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_DILATEERODE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_dilateerode;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_OUTPUT_FILE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_file_output;
|
2012-03-01 07:56:15 +00:00
|
|
|
ntype->uifuncbut= node_composit_buts_file_output_details;
|
Adds a new node type for saving multiple image files from a single node.
Unlike the existing file output node this node has an arbitrary number of
possible input slots. It has a base path string that can be set to a general
base folder. Every input socket then uses its name as an extension of the base
path for file organization. This can include further subfolders on top of the
base path. Example:
Base path: '/home/user/myproject'
Input 1: 'Compo'
Input 2: 'Diffuse/'
Input 3: 'details/Normals'
would create output files
in /home/user/myproject: Compo0001.png, Compo0002.png, ...
in /home/user/myproject/Diffuse: 0001.png, 0002.png, ... (no filename base
given)
in /home/user/myproject/details: Normals0001.png, Normals0002.png, ...
Most settings for the node can be found in the sidebar (NKEY). New input sockets
can be added with the "Add Input" button. There is a list of input sockets and
below that the details for each socket can be changed, including the sub-path
and filename. Sockets can be removed here as well. By default each socket uses
the render settings file output format, but each can use its own format if
necessary.
To my knowledge this is the first node making use of such dynamic sockets in
trunk. So this is also a design test, other nodes might use this in the future.
Adding operator buttons on top of a node is a bit unwieldy atm, because all node
operators generally work on selected and/or active node(s). The operator button
would therefore either have to make sure the node is activated before the
operator is called (block callback maybe?) OR it has to store the node name
(risky, weak reference). For now it is only used in the sidebar, where only the
active node's buttons are displayed.
Also adds a new struct_type value to bNodeSocket, in order to distinguish
different socket types with the same data type (file inputs are SOCK_RGBA color
sockets). Would be nicer to use data type only for actual data evaluation, but
used in too many places, this works ok for now.
2012-02-22 12:24:04 +00:00
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case CMP_NODE_DIFF_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_diff_matte;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2009-09-10 04:12:22 +00:00
|
|
|
case CMP_NODE_DIST_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_distance_matte;
|
2009-09-10 04:12:22 +00:00
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case CMP_NODE_COLOR_SPILL:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_color_spill;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2009-09-10 04:12:22 +00:00
|
|
|
case CMP_NODE_CHROMA_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_chroma_matte;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2009-09-10 04:12:22 +00:00
|
|
|
case CMP_NODE_COLOR_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_color_matte;
|
2009-09-10 04:12:22 +00:00
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case CMP_NODE_SCALE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_scale;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2011-04-21 15:53:30 +00:00
|
|
|
case CMP_NODE_ROTATE:
|
|
|
|
ntype->uifunc=node_composit_buts_rotate;
|
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case CMP_NODE_CHANNEL_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_channel_matte;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_LUMA_MATTE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_luma_matte;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_MAP_UV:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_map_uv;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_ID_MASK:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_id_mask;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-01-10 19:08:08 +00:00
|
|
|
case CMP_NODE_DOUBLEEDGEMASK:
|
|
|
|
ntype->uifunc= node_composit_buts_double_edge_mask;
|
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
case CMP_NODE_MATH:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_math;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_INVERT:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_invert;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
|
|
|
case CMP_NODE_PREMULKEY:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_composit_buts_premulkey;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2010-01-20 04:19:55 +00:00
|
|
|
case CMP_NODE_VIEW_LEVELS:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc=node_composit_buts_view_levels;
|
2011-04-21 15:53:30 +00:00
|
|
|
break;
|
2010-01-20 04:19:55 +00:00
|
|
|
case CMP_NODE_COLORBALANCE:
|
2011-07-04 19:22:37 +00:00
|
|
|
ntype->uifunc=node_composit_buts_colorbalance;
|
|
|
|
ntype->uifuncbut=node_composit_buts_colorbalance_but;
|
|
|
|
break;
|
2010-01-21 00:00:45 +00:00
|
|
|
case CMP_NODE_HUECORRECT:
|
|
|
|
ntype->uifunc=node_composit_buts_huecorrect;
|
2011-04-21 15:53:30 +00:00
|
|
|
break;
|
2010-11-12 14:59:01 +00:00
|
|
|
case CMP_NODE_ZCOMBINE:
|
|
|
|
ntype->uifunc=node_composit_buts_zcombine;
|
2011-04-21 15:53:30 +00:00
|
|
|
break;
|
2010-12-13 21:17:00 +00:00
|
|
|
case CMP_NODE_COMBYCCA:
|
|
|
|
case CMP_NODE_SEPYCCA:
|
|
|
|
ntype->uifunc=node_composit_buts_ycc;
|
|
|
|
break;
|
2011-11-07 12:56:05 +00:00
|
|
|
case CMP_NODE_MOVIECLIP:
|
|
|
|
ntype->uifunc= node_composit_buts_movieclip;
|
|
|
|
break;
|
|
|
|
case CMP_NODE_STABILIZE2D:
|
|
|
|
ntype->uifunc= node_composit_buts_stabilize2d;
|
|
|
|
break;
|
|
|
|
case CMP_NODE_TRANSFORM:
|
|
|
|
ntype->uifunc= node_composit_buts_transform;
|
|
|
|
break;
|
|
|
|
case CMP_NODE_MOVIEDISTORTION:
|
|
|
|
ntype->uifunc= node_composit_buts_moviedistortion;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ntype->uifunc= NULL;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2011-07-04 19:22:37 +00:00
|
|
|
if (ntype->uifuncbut == NULL) ntype->uifuncbut = ntype->uifunc;
|
2011-07-04 18:48:36 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ****************** BUTTON CALLBACKS FOR TEXTURE NODES ***************** */
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_texture_buts_bricks(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-10-28 22:14:31 +00:00
|
|
|
uiLayout *col;
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-10-28 22:14:31 +00:00
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "offset", 0, "Offset", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "offset_frequency", 0, "Frequency", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
|
2009-10-28 22:14:31 +00:00
|
|
|
col= uiLayoutColumn(layout, 1);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, ptr, "squash", 0, "Squash", ICON_NONE);
|
|
|
|
uiItemR(col, ptr, "squash_frequency", 0, "Frequency", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_texture_buts_proc(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-12-05 21:14:31 +00:00
|
|
|
PointerRNA tex_ptr;
|
2009-09-16 18:59:13 +00:00
|
|
|
bNode *node= ptr->data;
|
2009-12-05 21:14:31 +00:00
|
|
|
ID *id= ptr->id.data;
|
2008-12-24 10:33:10 +00:00
|
|
|
Tex *tex = (Tex *)node->storage;
|
2009-12-05 21:14:31 +00:00
|
|
|
uiLayout *col, *row;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-12-05 21:14:31 +00:00
|
|
|
RNA_pointer_create(id, &RNA_Texture, tex, &tex_ptr);
|
|
|
|
|
|
|
|
col= uiLayoutColumn(layout, 0);
|
|
|
|
|
2012-04-28 06:31:57 +00:00
|
|
|
switch ( tex->type ) {
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_BLEND:
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &tex_ptr, "progression", 0, "", ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "use_flip_axis", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
break;
|
2009-12-05 21:14:31 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_MARBLE:
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "marble_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-04-05 06:05:55 +00:00
|
|
|
uiItemR(row, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
|
|
|
row= uiLayoutRow(col, 0);
|
|
|
|
uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEX_MAGIC:
|
|
|
|
uiItemR(col, &tex_ptr, "noise_depth", 0, NULL, ICON_NONE);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEX_STUCCI:
|
|
|
|
row= uiLayoutRow(col, 0);
|
|
|
|
uiItemR(row, &tex_ptr, "stucci_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
row= uiLayoutRow(col, 0);
|
|
|
|
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
break;
|
2009-12-05 21:14:31 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_WOOD:
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
|
|
|
uiItemR(col, &tex_ptr, "wood_type", 0, "", ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-04-05 06:05:55 +00:00
|
|
|
uiItemR(row, &tex_ptr, "noise_basis_2", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2010-11-03 15:30:24 +00:00
|
|
|
uiLayoutSetActive(row, !(RNA_enum_get(&tex_ptr, "wood_type")==TEX_BAND || RNA_enum_get(&tex_ptr, "wood_type")==TEX_RING));
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
case TEX_CLOUDS:
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "cloud_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
2009-12-05 21:14:31 +00:00
|
|
|
row= uiLayoutRow(col, 0);
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(row, &tex_ptr, "noise_type", UI_ITEM_R_EXPAND, NULL, ICON_NONE);
|
|
|
|
uiItemR(col, &tex_ptr, "noise_depth", UI_ITEM_R_EXPAND, "Depth", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
case TEX_DISTNOISE:
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
|
|
|
uiItemR(col, &tex_ptr, "noise_distortion", 0, "", ICON_NONE);
|
2009-09-16 18:59:13 +00:00
|
|
|
break;
|
2011-04-05 06:05:55 +00:00
|
|
|
|
|
|
|
case TEX_MUSGRAVE:
|
|
|
|
uiItemR(col, &tex_ptr, "musgrave_type", 0, "", ICON_NONE);
|
|
|
|
uiItemR(col, &tex_ptr, "noise_basis", 0, "", ICON_NONE);
|
|
|
|
break;
|
|
|
|
case TEX_VORONOI:
|
|
|
|
uiItemR(col, &tex_ptr, "distance_metric", 0, "", ICON_NONE);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (tex->vn_distm == TEX_MINKOVSKY) {
|
2011-04-05 06:05:55 +00:00
|
|
|
uiItemR(col, &tex_ptr, "minkovsky_exponent", 0, NULL, ICON_NONE);
|
|
|
|
}
|
|
|
|
uiItemR(col, &tex_ptr, "color_mode", 0, "", ICON_NONE);
|
|
|
|
break;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-16 02:40:31 +00:00
|
|
|
static void node_texture_buts_image(uiLayout *layout, bContext *C, PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2010-08-04 12:18:07 +00:00
|
|
|
uiTemplateID(layout, C, ptr, "image", NULL, "IMAGE_OT_open", NULL);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
2010-10-14 01:22:14 +00:00
|
|
|
static void node_texture_buts_output(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-02-27 18:03:19 +00:00
|
|
|
uiItemR(layout, ptr, "filepath", 0, "", ICON_NONE);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* only once called */
|
|
|
|
static void node_texture_set_butfunc(bNodeType *ntype)
|
|
|
|
{
|
2011-10-06 22:04:01 +00:00
|
|
|
ntype->uifuncbut = NULL;
|
2012-03-24 06:38:07 +00:00
|
|
|
if ( ntype->type >= TEX_NODE_PROC && ntype->type < TEX_NODE_PROC_MAX ) {
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_texture_buts_proc;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2012-04-28 06:31:57 +00:00
|
|
|
else {
|
|
|
|
switch (ntype->type) {
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_MATH:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_buts_math;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_MIX_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_buts_mix_rgb;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_VALTORGB:
|
2009-11-10 04:01:44 +00:00
|
|
|
ntype->uifunc = node_buts_colorramp;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_CURVE_RGB:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc= node_buts_curvecol;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_CURVE_TIME:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_buts_time;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_TEXTURE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_buts_texture;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_BRICKS:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_texture_buts_bricks;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_IMAGE:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_texture_buts_image;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
case TEX_NODE_OUTPUT:
|
2009-09-16 18:59:13 +00:00
|
|
|
ntype->uifunc = node_texture_buts_output;
|
2008-12-24 10:33:10 +00:00
|
|
|
break;
|
2012-04-28 06:31:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ntype->uifuncbut == NULL) {
|
|
|
|
ntype->uifuncbut = ntype->uifunc;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ******* init draw callbacks for all tree types, only called in usiblender.c, once ************* */
|
|
|
|
|
2009-01-27 17:12:40 +00:00
|
|
|
void ED_init_node_butfuncs(void)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeTreeType *treetype;
|
2008-12-24 10:33:10 +00:00
|
|
|
bNodeType *ntype;
|
2011-09-05 21:01:50 +00:00
|
|
|
bNodeSocketType *stype;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* node type ui functions */
|
|
|
|
for (i=0; i < NUM_NTREE_TYPES; ++i) {
|
|
|
|
treetype = ntreeGetType(i);
|
|
|
|
if (treetype) {
|
|
|
|
for (ntype= treetype->node_types.first; ntype; ntype= ntype->next) {
|
|
|
|
/* default ui functions */
|
|
|
|
ntype->drawfunc = node_draw_default;
|
|
|
|
ntype->drawupdatefunc = node_update_default;
|
|
|
|
ntype->uifunc = NULL;
|
|
|
|
ntype->uifuncbut = NULL;
|
|
|
|
ntype->resize_area_func = node_resize_area_default;
|
|
|
|
|
|
|
|
node_common_set_butfunc(ntype);
|
|
|
|
|
|
|
|
switch (i) {
|
|
|
|
case NTREE_COMPOSIT:
|
|
|
|
node_composit_set_butfunc(ntype);
|
|
|
|
break;
|
|
|
|
case NTREE_SHADER:
|
|
|
|
node_shader_set_butfunc(ntype);
|
|
|
|
break;
|
|
|
|
case NTREE_TEXTURE:
|
|
|
|
node_texture_set_butfunc(ntype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
/* socket type ui functions */
|
|
|
|
for (i=0; i < NUM_SOCKET_TYPES; ++i) {
|
|
|
|
stype = ntreeGetSocketType(i);
|
|
|
|
if (stype) {
|
2012-04-28 06:31:57 +00:00
|
|
|
switch (stype->type) {
|
2011-09-05 21:01:50 +00:00
|
|
|
case SOCK_FLOAT:
|
|
|
|
case SOCK_INT:
|
|
|
|
case SOCK_BOOLEAN:
|
|
|
|
stype->buttonfunc = node_socket_button_default;
|
|
|
|
break;
|
|
|
|
case SOCK_VECTOR:
|
|
|
|
stype->buttonfunc = node_socket_button_components;
|
|
|
|
break;
|
|
|
|
case SOCK_RGBA:
|
|
|
|
stype->buttonfunc = node_socket_button_color;
|
|
|
|
break;
|
2011-11-07 17:35:20 +00:00
|
|
|
case SOCK_SHADER:
|
|
|
|
stype->buttonfunc = node_socket_button_label;
|
|
|
|
break;
|
2011-09-05 21:01:50 +00:00
|
|
|
default:
|
|
|
|
stype->buttonfunc = NULL;
|
|
|
|
}
|
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ************** Generic drawing ************** */
|
|
|
|
|
2009-10-07 22:05:30 +00:00
|
|
|
void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode, int color_manage)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) {
|
2008-12-24 10:33:10 +00:00
|
|
|
Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
|
2009-10-07 22:05:30 +00:00
|
|
|
void *lock;
|
|
|
|
ImBuf *ibuf= BKE_image_acquire_ibuf(ima, NULL, &lock);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2008-12-26 20:39:29 +00:00
|
|
|
float x, y;
|
2009-05-20 11:07:34 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
|
2010-04-08 16:36:50 +00:00
|
|
|
/* keep this, saves us from a version patch */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode->zoom==0.0f) snode->zoom= 1.0f;
|
2010-04-08 16:36:50 +00:00
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* somehow the offset has to be calculated inverse */
|
|
|
|
|
2009-02-17 13:37:06 +00:00
|
|
|
glaDefine2DArea(&ar->winrct);
|
2008-12-24 10:33:10 +00:00
|
|
|
/* ortho at pixel level curarea */
|
2009-02-17 13:37:06 +00:00
|
|
|
wmOrtho2(-0.375, ar->winx-0.375, -0.375, ar->winy-0.375);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-04-08 16:36:50 +00:00
|
|
|
x = (ar->winx-snode->zoom*ibuf->x)/2 + snode->xof;
|
|
|
|
y = (ar->winy-snode->zoom*ibuf->y)/2 + snode->yof;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!ibuf->rect) {
|
|
|
|
if (color_manage)
|
2010-01-09 00:16:35 +00:00
|
|
|
ibuf->profile = IB_PROFILE_LINEAR_RGB;
|
2009-10-07 22:05:30 +00:00
|
|
|
else
|
|
|
|
ibuf->profile = IB_PROFILE_NONE;
|
|
|
|
IMB_rect_from_float(ibuf);
|
|
|
|
}
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf->rect) {
|
2011-01-31 11:17:50 +00:00
|
|
|
if (snode->flag & SNODE_SHOW_ALPHA) {
|
|
|
|
glPixelZoom(snode->zoom, snode->zoom);
|
|
|
|
/* swap bytes, so alpha is most significant one, then just draw it as luminance int */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ENDIAN_ORDER == B_ENDIAN)
|
2011-01-31 11:17:50 +00:00
|
|
|
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
|
|
|
|
|
|
|
|
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_LUMINANCE, GL_UNSIGNED_INT, ibuf->rect);
|
|
|
|
|
|
|
|
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
|
|
|
|
glPixelZoom(1.0f, 1.0f);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else if (snode->flag & SNODE_USE_ALPHA) {
|
2011-01-31 11:17:50 +00:00
|
|
|
glEnable(GL_BLEND);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glPixelZoom(snode->zoom, snode->zoom);
|
|
|
|
|
|
|
|
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
|
|
|
|
glPixelZoom(1.0f, 1.0f);
|
|
|
|
glDisable(GL_BLEND);
|
2012-03-24 06:38:07 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-01-31 11:17:50 +00:00
|
|
|
glPixelZoom(snode->zoom, snode->zoom);
|
|
|
|
|
|
|
|
glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect);
|
|
|
|
|
|
|
|
glPixelZoom(1.0f, 1.0f);
|
|
|
|
}
|
2010-04-08 16:36:50 +00:00
|
|
|
}
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2010-02-01 15:32:55 +00:00
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPopMatrix();
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2009-10-07 22:05:30 +00:00
|
|
|
|
|
|
|
BKE_image_release_ibuf(ima, lock);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
/* note: needs to be userpref or opengl profile option */
|
|
|
|
static void draw_nodespace_back_tex(ScrArea *sa, SpaceNode *snode)
|
|
|
|
{
|
|
|
|
|
|
|
|
draw_nodespace_grid(snode);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode->flag & SNODE_BACKDRAW) {
|
2008-12-24 10:33:10 +00:00
|
|
|
Image *ima= BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
|
|
|
|
ImBuf *ibuf= BKE_image_get_ibuf(ima, NULL);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf) {
|
2008-12-24 10:33:10 +00:00
|
|
|
int x, y;
|
|
|
|
float zoom = 1.0;
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPushMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPushMatrix();
|
|
|
|
|
|
|
|
glaDefine2DArea(&sa->winrct);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf->x > sa->winx || ibuf->y > sa->winy) {
|
2008-12-24 10:33:10 +00:00
|
|
|
float zoomx, zoomy;
|
|
|
|
zoomx= (float)sa->winx/ibuf->x;
|
|
|
|
zoomy= (float)sa->winy/ibuf->y;
|
|
|
|
zoom = MIN2(zoomx, zoomy);
|
|
|
|
}
|
|
|
|
|
|
|
|
x = (sa->winx-zoom*ibuf->x)/2 + snode->xof;
|
|
|
|
y = (sa->winy-zoom*ibuf->y)/2 + snode->yof;
|
|
|
|
|
|
|
|
glPixelZoom(zoom, zoom);
|
|
|
|
|
|
|
|
glColor4f(1.0, 1.0, 1.0, 1.0);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (ibuf->rect)
|
2008-12-24 10:33:10 +00:00
|
|
|
glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_UNSIGNED_BYTE, ibuf->rect);
|
2012-03-24 06:38:07 +00:00
|
|
|
else if (ibuf->channels==4)
|
2008-12-24 10:33:10 +00:00
|
|
|
glaDrawPixelsTex(x, y, ibuf->x, ibuf->y, GL_FLOAT, ibuf->rect_float);
|
|
|
|
|
|
|
|
glPixelZoom(1.0, 1.0);
|
|
|
|
|
|
|
|
glMatrixMode(GL_PROJECTION);
|
|
|
|
glPopMatrix();
|
|
|
|
glMatrixMode(GL_MODELVIEW);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-02-07 14:03:34 +00:00
|
|
|
/* if v2d not NULL, it clips and returns 0 if not visible */
|
|
|
|
int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol)
|
2008-12-24 10:33:10 +00:00
|
|
|
{
|
2009-02-07 14:03:34 +00:00
|
|
|
float dist, vec[4][2];
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2009-02-07 14:03:34 +00:00
|
|
|
/* in v0 and v3 we put begin/end points */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->fromsock) {
|
2009-02-07 14:03:34 +00:00
|
|
|
vec[0][0]= link->fromsock->locx;
|
|
|
|
vec[0][1]= link->fromsock->locy;
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode==NULL) return 0;
|
2009-02-07 14:03:34 +00:00
|
|
|
vec[0][0]= snode->mx;
|
|
|
|
vec[0][1]= snode->my;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->tosock) {
|
2009-02-07 14:03:34 +00:00
|
|
|
vec[3][0]= link->tosock->locx;
|
|
|
|
vec[3][1]= link->tosock->locy;
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode==NULL) return 0;
|
2009-02-07 14:03:34 +00:00
|
|
|
vec[3][0]= snode->mx;
|
|
|
|
vec[3][1]= snode->my;
|
|
|
|
}
|
2011-08-04 10:05:14 +00:00
|
|
|
|
|
|
|
dist= UI_GetThemeValue(TH_NODE_CURVING)*0.10f*ABS(vec[0][0] - vec[3][0]);
|
2008-12-24 10:33:10 +00:00
|
|
|
|
|
|
|
/* check direction later, for top sockets */
|
|
|
|
vec[1][0]= vec[0][0]+dist;
|
|
|
|
vec[1][1]= vec[0][1];
|
|
|
|
|
|
|
|
vec[2][0]= vec[3][0]-dist;
|
|
|
|
vec[2][1]= vec[3][1];
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (v2d && MIN4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) > v2d->cur.xmax); /* clipped */
|
2009-02-07 14:03:34 +00:00
|
|
|
else if (v2d && MAX4(vec[0][0], vec[1][0], vec[2][0], vec[3][0]) < v2d->cur.xmin); /* clipped */
|
2008-12-24 10:33:10 +00:00
|
|
|
else {
|
2009-02-07 14:03:34 +00:00
|
|
|
|
|
|
|
/* always do all three, to prevent data hanging around */
|
2012-04-28 16:49:00 +00:00
|
|
|
BKE_curve_forward_diff_bezier(vec[0][0], vec[1][0], vec[2][0], vec[3][0], coord_array[0], resol, sizeof(float)*2);
|
|
|
|
BKE_curve_forward_diff_bezier(vec[0][1], vec[1][1], vec[2][1], vec[3][1], coord_array[0]+1, resol, sizeof(float)*2);
|
2009-02-07 14:03:34 +00:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define LINK_RESOL 24
|
2011-01-09 18:59:35 +00:00
|
|
|
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 )
|
2009-02-07 14:03:34 +00:00
|
|
|
{
|
|
|
|
float coord_array[LINK_RESOL+1][2];
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (node_link_bezier_points(v2d, snode, link, coord_array, LINK_RESOL)) {
|
2009-02-07 14:03:34 +00:00
|
|
|
float dist, spline_step = 0.0f;
|
|
|
|
int i;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
/* store current linewidth */
|
|
|
|
float linew;
|
|
|
|
glGetFloatv(GL_LINE_WIDTH, &linew);
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* we can reuse the dist variable here to increment the GL curve eval amount*/
|
2009-02-07 14:03:34 +00:00
|
|
|
dist = 1.0f/(float)LINK_RESOL;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_triple) {
|
2011-01-09 18:59:35 +00:00
|
|
|
UI_ThemeColorShadeAlpha(th_col3, -80, -120);
|
|
|
|
glLineWidth(4.0f);
|
|
|
|
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i=0; i<=LINK_RESOL; i++) {
|
2011-01-09 18:59:35 +00:00
|
|
|
glVertex2fv(coord_array[i]);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
2011-11-29 20:35:30 +00:00
|
|
|
/* XXX using GL_LINES for shaded node lines is a workaround
|
|
|
|
* for Intel hardware, this breaks with GL_LINE_STRIP and
|
|
|
|
* changing color in begin/end blocks.
|
|
|
|
*/
|
2011-01-09 18:59:35 +00:00
|
|
|
glLineWidth(1.5f);
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_shaded) {
|
2011-11-29 19:50:34 +00:00
|
|
|
glBegin(GL_LINES);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i=0; i<LINK_RESOL; i++) {
|
2008-12-24 10:33:10 +00:00
|
|
|
UI_ThemeColorBlend(th_col1, th_col2, spline_step);
|
2011-11-29 19:50:34 +00:00
|
|
|
glVertex2fv(coord_array[i]);
|
|
|
|
|
|
|
|
UI_ThemeColorBlend(th_col1, th_col2, spline_step+dist);
|
|
|
|
glVertex2fv(coord_array[i+1]);
|
|
|
|
|
2009-02-07 14:03:34 +00:00
|
|
|
spline_step += dist;
|
2011-01-09 18:59:35 +00:00
|
|
|
}
|
2011-11-29 19:50:34 +00:00
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
UI_ThemeColor(th_col1);
|
|
|
|
glBegin(GL_LINE_STRIP);
|
2012-03-24 06:38:07 +00:00
|
|
|
for (i=0; i<=LINK_RESOL; i++) {
|
2011-11-29 19:50:34 +00:00
|
|
|
glVertex2fv(coord_array[i]);
|
|
|
|
}
|
|
|
|
glEnd();
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
2011-01-09 18:59:35 +00:00
|
|
|
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
|
|
|
|
/* restore previuos linewidth */
|
|
|
|
glLineWidth(linew);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
static void node_link_straight_points(View2D *UNUSED(v2d), SpaceNode *snode, bNodeLink *link, float coord_array[][2])
|
|
|
|
{
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->fromsock) {
|
2011-09-05 21:01:50 +00:00
|
|
|
coord_array[0][0]= link->fromsock->locx;
|
|
|
|
coord_array[0][1]= link->fromsock->locy;
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode==NULL) return;
|
2011-09-05 21:01:50 +00:00
|
|
|
coord_array[0][0]= snode->mx;
|
|
|
|
coord_array[0][1]= snode->my;
|
|
|
|
}
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->tosock) {
|
2011-09-05 21:01:50 +00:00
|
|
|
coord_array[1][0]= link->tosock->locx;
|
|
|
|
coord_array[1][1]= link->tosock->locy;
|
|
|
|
}
|
|
|
|
else {
|
2012-03-24 06:38:07 +00:00
|
|
|
if (snode==NULL) return;
|
2011-09-05 21:01:50 +00:00
|
|
|
coord_array[1][0]= snode->mx;
|
|
|
|
coord_array[1][1]= snode->my;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
float coord_array[2][2];
|
|
|
|
float linew;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
node_link_straight_points(v2d, snode, link, coord_array);
|
|
|
|
|
|
|
|
/* store current linewidth */
|
|
|
|
glGetFloatv(GL_LINE_WIDTH, &linew);
|
|
|
|
|
|
|
|
glEnable(GL_LINE_SMOOTH);
|
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_triple) {
|
2011-09-05 21:01:50 +00:00
|
|
|
UI_ThemeColorShadeAlpha(th_col3, -80, -120);
|
|
|
|
glLineWidth(4.0f);
|
|
|
|
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex2fv(coord_array[0]);
|
|
|
|
glVertex2fv(coord_array[1]);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
UI_ThemeColor(th_col1);
|
|
|
|
glLineWidth(1.5f);
|
|
|
|
|
2011-11-29 20:35:30 +00:00
|
|
|
/* XXX using GL_LINES for shaded node lines is a workaround
|
|
|
|
* for Intel hardware, this breaks with GL_LINE_STRIP and
|
|
|
|
* changing color in begin/end blocks.
|
|
|
|
*/
|
2012-03-24 06:38:07 +00:00
|
|
|
if (do_shaded) {
|
2011-11-29 20:35:30 +00:00
|
|
|
glBegin(GL_LINES);
|
|
|
|
for (i=0; i < LINK_RESOL-1; ++i) {
|
|
|
|
float t= (float)i/(float)(LINK_RESOL-1);
|
2011-09-05 21:01:50 +00:00
|
|
|
UI_ThemeColorBlend(th_col1, th_col2, t);
|
2011-11-29 20:35:30 +00:00
|
|
|
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]);
|
|
|
|
|
|
|
|
t= (float)(i+1)/(float)(LINK_RESOL-1);
|
|
|
|
UI_ThemeColorBlend(th_col1, th_col2, t);
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
glBegin(GL_LINE_STRIP);
|
|
|
|
for (i=0; i < LINK_RESOL; ++i) {
|
|
|
|
float t= (float)i/(float)(LINK_RESOL-1);
|
|
|
|
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]);
|
|
|
|
}
|
|
|
|
glEnd();
|
2011-09-05 21:01:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
glDisable(GL_LINE_SMOOTH);
|
|
|
|
|
|
|
|
/* restore previuos linewidth */
|
|
|
|
glLineWidth(linew);
|
|
|
|
}
|
|
|
|
|
2008-12-24 10:33:10 +00:00
|
|
|
/* note; this is used for fake links in groups too */
|
|
|
|
void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link)
|
|
|
|
{
|
2011-01-09 18:59:35 +00:00
|
|
|
int do_shaded= 0, th_col1= TH_HEADER, th_col2= TH_HEADER;
|
|
|
|
int do_triple= 0, th_col3= TH_WIRE;
|
2008-12-24 10:33:10 +00:00
|
|
|
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->fromsock==NULL && link->tosock==NULL)
|
2008-12-24 10:33:10 +00:00
|
|
|
return;
|
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
/* new connection */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!link->fromsock || !link->tosock) {
|
2011-01-09 18:59:35 +00:00
|
|
|
th_col1 = TH_ACTIVE;
|
|
|
|
do_triple = 1;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* going to give issues once... */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->tosock->flag & SOCK_UNAVAIL)
|
2008-12-24 10:33:10 +00:00
|
|
|
return;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->fromsock->flag & SOCK_UNAVAIL)
|
2008-12-24 10:33:10 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
/* a bit ugly... but thats how we detect the internal group links */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (!link->fromnode || !link->tonode) {
|
2011-02-21 13:47:49 +00:00
|
|
|
UI_ThemeColorBlend(TH_BACK, TH_WIRE, 0.5f);
|
|
|
|
do_shaded= 0;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* check cyclic */
|
2012-03-24 06:38:07 +00:00
|
|
|
if ((link->fromnode->level >= link->tonode->level && link->tonode->level!=0xFFF) && (link->flag & NODE_LINK_VALID)) {
|
2011-07-22 15:28:50 +00:00
|
|
|
/* special indicated link, on drop-node */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->flag & NODE_LINKFLAG_HILITE) {
|
2011-07-22 15:28:50 +00:00
|
|
|
th_col1= th_col2= TH_ACTIVE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* regular link */
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->fromnode->flag & SELECT)
|
2011-07-22 15:28:50 +00:00
|
|
|
th_col1= TH_EDGE_SELECT;
|
2012-03-24 06:38:07 +00:00
|
|
|
if (link->tonode->flag & SELECT)
|
2011-07-22 15:28:50 +00:00
|
|
|
th_col2= TH_EDGE_SELECT;
|
|
|
|
}
|
2011-01-09 18:59:35 +00:00
|
|
|
do_shaded= 1;
|
|
|
|
do_triple= 1;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
else {
|
2011-01-09 18:59:35 +00:00
|
|
|
th_col1 = TH_REDALERT;
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-09 18:59:35 +00:00
|
|
|
node_draw_link_bezier(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
|
2011-09-05 21:01:50 +00:00
|
|
|
// node_draw_link_straight(v2d, snode, link, th_col1, do_shaded, th_col2, do_triple, th_col3);
|
2008-12-24 10:33:10 +00:00
|
|
|
}
|