From 7a66002753e8da11e53cb8cdad28bde606847758 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Tue, 17 Feb 2009 13:37:06 +0000 Subject: 2.5 Node/Composite tinkering: - titles in headers and on collapsed nodes back - backdrop option draws again (no scroll operator yet) - added preview option in blur, filter and mix nodes. Just for fun while working :) Probably every node should get this... --- source/blender/editors/space_node/drawnode.c | 15 +++++++------- source/blender/editors/space_node/node_draw.c | 24 ++++++---------------- source/blender/editors/space_node/node_intern.h | 2 +- source/blender/nodes/intern/CMP_nodes/CMP_blur.c | 4 +++- source/blender/nodes/intern/CMP_nodes/CMP_filter.c | 4 +++- source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c | 4 +++- 6 files changed, 23 insertions(+), 30 deletions(-) diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index cc6fe4e9ebd..841600d7262 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -2443,7 +2443,7 @@ void node_rename_but(char *s) #endif -void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode) +void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode) { if((snode->flag & SNODE_BACKDRAW) && snode->treetype==NTREE_COMPOSIT) { @@ -2453,12 +2453,12 @@ void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode) float x, y; /* somehow the offset has to be calculated inverse */ - //glaDefine2DArea(&sa->winrct); + glaDefine2DArea(&ar->winrct); /* ortho at pixel level curarea */ - //myortho2(-0.375, sa->winx-0.375, -0.375, sa->winy-0.375); + wmOrtho2(-0.375, ar->winx-0.375, -0.375, ar->winy-0.375); - x = (sa->winx-ibuf->x)/2 + snode->xof; - y = (sa->winy-ibuf->y)/2 + snode->yof; + x = (ar->winx-ibuf->x)/2 + snode->xof; + y = (ar->winy-ibuf->y)/2 + snode->yof; if(ibuf->rect) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_UNSIGNED_BYTE, ibuf->rect); @@ -2466,9 +2466,8 @@ void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode) glaDrawPixelsSafe(x, y, ibuf->x, ibuf->y, ibuf->x, GL_RGBA, GL_FLOAT, ibuf->rect_float); /* sort this out, this should not be needed */ - //myortho2(snode->v2d.cur.xmin, snode->v2d.cur.xmax, snode->v2d.cur.ymin, snode->v2d.cur.ymax); - //bwin_clear_viewmat(sa->win); /* clear buttons view */ - // glLoadIdentity(); + wmOrtho2(ar->v2d.cur.xmin, ar->v2d.cur.xmax, ar->v2d.cur.ymin, ar->v2d.cur.ymax); + glLoadIdentity(); } } } diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c index 39a2144e867..8c9d2d12c86 100644 --- a/source/blender/editors/space_node/node_draw.c +++ b/source/blender/editors/space_node/node_draw.c @@ -94,7 +94,7 @@ extern void ui_rasterpos_safe(float x, float y, float aspect); extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad); extern void ui_draw_tria_icon(float x, float y, float aspect, char dir); -#if 0 // XXX + static void snode_drawstring(void *curfont, SpaceNode *snode, char *str, int okwidth) { char drawstr[NODE_MAXSTR]; @@ -118,7 +118,7 @@ static void snode_drawstring(void *curfont, SpaceNode *snode, char *str, int okw } UI_DrawString(curfont, drawstr, 0); } -#endif + static void node_scaling_widget(int color_id, float aspect, float xmin, float ymin, float xmax, float ymax) { @@ -730,7 +730,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else UI_ThemeColor(TH_TEXT); - // ui_rasterpos_safe(rct->xmin+19.0f, rct->ymax-NODE_DY+5.0f, snode->aspect); + ui_rasterpos_safe(rct->xmin+19.0f, rct->ymax-NODE_DY+5.0f, snode->aspect); if(node->flag & NODE_MUTED) sprintf(showname, "[%s]", node->name); @@ -739,11 +739,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN else BLI_strncpy(showname, node->name, 128); - block= uiBeginBlock(C, ar, "snode_drawstring_hack", UI_EMBOSSN, UI_HELV); - // snode_drawstring(block->curfont, snode, showname, (int)(iconofs - rct->xmin-18.0f)); - bt= uiDefBut(block, LABEL, 0, showname, (int)rct->xmin+19, (int)rct->ymax-NODE_DY+5, 100, 20, NULL, 0, 0, 0, 0, ""); - uiEndBlock(C, block); - block= NULL; + snode_drawstring(snode->curfont, snode, showname, (int)(iconofs - rct->xmin-18.0f)); /* body */ UI_ThemeColor4(TH_NODE); @@ -871,7 +867,6 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN static void node_draw_hidden(View2D *v2d, SpaceNode *snode, bNode *node) { -// uiBlock *block; // XXX HACK bNodeSocket *sock; rctf *rct= &node->totr; float dx, centy= 0.5f*(rct->ymax+rct->ymin); @@ -923,13 +918,7 @@ static void node_draw_hidden(View2D *v2d, SpaceNode *snode, bNode *node) else BLI_strncpy(showname, node->name, 128); - /* XXX - block= uiBeginBlock(C, ar, "snode_drawstring_hack", UI_EMBOSSN, UI_HELV); - // snode_drawstring(block->curfont, snode, showname, (int)(iconofs - rct->xmin-18.0f)); - bt= uiDefBut(block, LABEL, 0, showname, rct->xmin+21, centy-4, 100, 20, NULL, 0, 0, 0, 0, ""); - uiEndBlock(C, block); - */ - + snode_drawstring(snode->curfont, snode, showname, (int)(rct->xmax - rct->xmin-18.0f -12.0f)); } /* scale widget thing */ @@ -1092,7 +1081,6 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) float col[3]; View2DScrollers *scrollers; SpaceNode *snode= (SpaceNode*)CTX_wm_space_data(C); - ScrArea *sa= CTX_wm_area(C); UI_GetThemeColor3fv(TH_BACK, col); glClearColor(col[0], col[1], col[2], 0); @@ -1112,7 +1100,7 @@ void drawnodespace(const bContext *C, ARegion *ar, View2D *v2d) UI_view2d_constant_grid_draw(C, v2d); /* backdrop */ - draw_nodespace_back_pix(sa, snode); + draw_nodespace_back_pix(ar, snode); /* nodes */ snode_set_context(snode, CTX_data_scene(C)); diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h index b8fbed6db16..de3999ae5cb 100644 --- a/source/blender/editors/space_node/node_intern.h +++ b/source/blender/editors/space_node/node_intern.h @@ -64,7 +64,7 @@ void NODE_OT_border_select(struct wmOperatorType *ot); void node_draw_link(View2D *v2d, SpaceNode *snode, bNodeLink *link); void node_draw_link_bezier(View2D *v2d, SpaceNode *snode, bNodeLink *link, int th_col1, int th_col2, int do_shaded); int node_link_bezier_points(View2D *v2d, SpaceNode *snode, bNodeLink *link, float coord_array[][2], int resol); -void draw_nodespace_back_pix(ScrArea *sa, SpaceNode *snode); +void draw_nodespace_back_pix(ARegion *ar, SpaceNode *snode); /* node_edit.c */ void snode_handle_recalc(bContext *C, SpaceNode *snode); diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c index e7e799b6e76..2c7974d129d 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_blur.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_blur.c @@ -665,6 +665,8 @@ static void node_composit_exec_blur(void *data, bNode *node, bNodeStack **in, bN if(img!=in[0]->data) free_compbuf(img); } + + generate_preview(node, out[0]->data); } static void node_composit_init_blur(bNode* node) @@ -677,7 +679,7 @@ bNodeType cmp_node_blur= { /* type code */ CMP_NODE_BLUR, /* name */ "Blur", /* width+range */ 120, 80, 200, - /* class+opts */ NODE_CLASS_OP_FILTER, NODE_OPTIONS, + /* class+opts */ NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS, /* input sock */ cmp_node_blur_in, /* output sock */ cmp_node_blur_out, /* storage */ "NodeBlurData", diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c index 6011ac3b58a..2c3b78e13a3 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_filter.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_filter.c @@ -211,6 +211,8 @@ static void node_composit_exec_filter(void *data, bNode *node, bNodeStack **in, } out[0]->data= stackbuf; + + generate_preview(node, out[0]->data); } } @@ -220,7 +222,7 @@ bNodeType cmp_node_filter= { /* type code */ CMP_NODE_FILTER, /* name */ "Filter", /* width+range */ 80, 40, 120, - /* class+opts */ NODE_CLASS_OP_FILTER, NODE_OPTIONS, + /* class+opts */ NODE_CLASS_OP_FILTER, NODE_PREVIEW|NODE_OPTIONS, /* input sock */ cmp_node_filter_in, /* output sock */ cmp_node_filter_out, /* storage */ "", diff --git a/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c b/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c index 6a4916b3fac..ca6de027b1d 100644 --- a/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c +++ b/source/blender/nodes/intern/CMP_nodes/CMP_mixrgb.c @@ -73,6 +73,8 @@ static void node_composit_exec_mix_rgb(void *data, bNode *node, bNodeStack **in, composit3_pixel_processor(node, stackbuf, in[1]->data, in[1]->vec, in[2]->data, in[2]->vec, in[0]->data, fac, do_mix_rgb, CB_RGBA, CB_RGBA, CB_VAL); out[0]->data= stackbuf; + + generate_preview(node, out[0]->data); } } @@ -82,7 +84,7 @@ bNodeType cmp_node_mix_rgb= { /* type code */ CMP_NODE_MIX_RGB, /* name */ "Mix", /* width+range */ 110, 60, 120, - /* class+opts */ NODE_CLASS_OP_COLOR, NODE_OPTIONS, + /* class+opts */ NODE_CLASS_OP_COLOR, NODE_PREVIEW|NODE_OPTIONS, /* input sock */ cmp_node_mix_rgb_in, /* output sock */ cmp_node_mix_rgb_out, /* storage */ "", -- cgit v1.2.3