Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuho Vepsalainen <bebraw@gmail.com>2007-10-29 17:37:19 +0300
committerJuho Vepsalainen <bebraw@gmail.com>2007-10-29 17:37:19 +0300
commitd6db819a8366c515b30378b46a77f7341fc9fc67 (patch)
treeda09f318128c817c6335ebe5f026b0e36be6d60e /source/blender/src/drawnode.c
parent8a3f92693843445c877f14e08a25394e720519fa (diff)
Crop Compositing Node:
This commit adds a new node, crop, to the compositor. This node can be used to crop input image. It has two modes of operation. It can either crop image size (Crop Image Size option) or crop while retaining original size of the image. This latter mode can be used to preview the crop. Use X1, Y1, X2, Y2 controls to manage the area to be cropped. Note that I added a check for image preview min and max values to node_update. This is because it could give inappropriate values in certain cases when Crop Image Size option was toggled (values such as x1=0, y1=0, x2=60, y2=0 would result in eternal loop due to bad min and max (min bigger than max!)). The check makes sure that min and max values are always valid.
Diffstat (limited to 'source/blender/src/drawnode.c')
-rw-r--r--source/blender/src/drawnode.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c
index 78c36d97746..256633524e4 100644
--- a/source/blender/src/drawnode.c
+++ b/source/blender/src/drawnode.c
@@ -1330,6 +1330,50 @@ static int node_composit_buts_flip(uiBlock *block, bNodeTree *ntree, bNode *node
return 20;
}
+static int node_composit_buts_crop(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
+{
+ if(block) {
+ NodeTwoXYs *ntxy= node->storage;
+ uiBut *bt;
+ char elementheight = 19;
+ short dx= (butr->xmax-butr->xmin)/2;
+ short dy= butr->ymax - elementheight;
+ short xymin= 0, xymax= 10000;
+
+ uiBlockBeginAlign(block);
+
+ /* crop image size toggle */
+ uiDefButS(block, TOG, B_NODE_EXEC+node->nr, "Crop Image Size",
+ butr->xmin, dy, dx*2, elementheight,
+ &node->custom1, 0, 0, 0, 0, "Crop the size of the input image.");
+
+ dy-=elementheight;
+
+ /* x1 */
+ bt=uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "X1:",
+ butr->xmin, dy, dx, elementheight,
+ &ntxy->x1, xymin, xymax, 0, 0, "");
+ /* y1 */
+ bt=uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Y1:",
+ butr->xmin+dx, dy, dx, elementheight,
+ &ntxy->y1, xymin, xymax, 0, 0, "");
+
+ dy-=elementheight;
+
+ /* x2 */
+ bt=uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "X2:",
+ butr->xmin, dy, dx, elementheight,
+ &ntxy->x2, xymin, xymax, 0, 0, "");
+ /* y2 */
+ bt=uiDefButS(block, NUM, B_NODE_EXEC+node->nr, "Y2:",
+ butr->xmin+dx, dy, dx, elementheight,
+ &ntxy->y2, xymin, xymax, 0, 0, "");
+
+ uiBlockEndAlign(block);
+ }
+ return 60;
+}
+
static int node_composit_buts_splitviewer(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
@@ -1758,6 +1802,9 @@ static void node_composit_set_butfunc(bNodeType *ntype)
case CMP_NODE_VALTORGB:
ntype->butfunc= node_buts_valtorgb;
break;
+ case CMP_NODE_CROP:
+ ntype->butfunc= node_composit_buts_crop;
+ break;
case CMP_NODE_BLUR:
ntype->butfunc= node_composit_buts_blur;
break;
@@ -2132,8 +2179,12 @@ static void node_update(bNode *node)
node->prvr.xmin+= 0.5*dx;
node->prvr.xmax-= 0.5*dx;
}
-
+
dy= node->prvr.ymin - NODE_DYS/2;
+
+ /* make sure that maximums are bigger or equal to minimums */
+ if(node->prvr.xmax < node->prvr.xmin) SWAP(float, node->prvr.xmax, node->prvr.xmin);
+ if(node->prvr.ymax < node->prvr.ymin) SWAP(float, node->prvr.ymax, node->prvr.ymin);
}
else {
float oldh= node->prvr.ymax - node->prvr.ymin;
@@ -2145,7 +2196,7 @@ static void node_update(bNode *node)
dy= node->prvr.ymin - NODE_DYS/2;
}
}
-
+
/* XXX ugly hack, typeinfo for group is generated */
if(node->type == NODE_GROUP)
node->typeinfo->butfunc= node_buts_group;