From c3adb61dcc6b550efa1df0eb5c8a4729bd47350a Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 24 Nov 2006 16:56:02 +0000 Subject: Composite Time node usablity improvement: - now draws green 'current frame' line - when Time Node is active, hotkey I will allow inserting a value on current frame. --- source/blender/makesdna/DNA_color_types.h | 3 ++- source/blender/src/drawnode.c | 6 ++++++ source/blender/src/editnode.c | 28 ++++++++++++++++++++++++++++ source/blender/src/interface_draw.c | 9 +++++++++ source/blender/src/toets.c | 2 +- 5 files changed, 46 insertions(+), 2 deletions(-) diff --git a/source/blender/makesdna/DNA_color_types.h b/source/blender/makesdna/DNA_color_types.h index 32cbc39523b..a4224976f5f 100644 --- a/source/blender/makesdna/DNA_color_types.h +++ b/source/blender/makesdna/DNA_color_types.h @@ -68,13 +68,14 @@ typedef struct CurveMapping { rctf curr, clipr; /* current rect, clip rect (is default rect too) */ CurveMap cm[4]; /* max 4 builtin curves per mapping struct now */ - float black[3], white[3]; /* black/white point */ + float black[3], white[3]; /* black/white point (black[0] abused for current frame) */ float bwmul[3], padf; /* black/white point multiply value, for speed */ } CurveMapping; /* cumapping->flag */ #define CUMA_DO_CLIP 1 #define CUMA_PREMULLED 2 +#define CUMA_DRAW_CFRA 4 #endif diff --git a/source/blender/src/drawnode.c b/source/blender/src/drawnode.c index a42ae4e722d..f1e9f70b5aa 100644 --- a/source/blender/src/drawnode.c +++ b/source/blender/src/drawnode.c @@ -35,6 +35,7 @@ #include "BLI_arithb.h" #include "DNA_action_types.h" +#include "DNA_color_types.h" #include "DNA_ipo_types.h" #include "DNA_ID.h" #include "DNA_image_types.h" @@ -981,8 +982,13 @@ static int node_composit_buts_map_value(uiBlock *block, bNodeTree *ntree, bNode static int node_composit_buts_time(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr) { if(block) { + CurveMapping *cumap= node->storage; short dx= (butr->xmax-butr->xmin)/2; + cumap->flag |= CUMA_DRAW_CFRA; + if(node->custom1custom2) + cumap->black[0]= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1); + uiDefBut(block, BUT_CURVE, B_NODE_EXEC+node->nr, "", butr->xmin, butr->ymin+24, butr->xmax-butr->xmin, butr->ymax-butr->ymin-24, node->storage, 0.0f, 1.0f, 0, 0, ""); diff --git a/source/blender/src/editnode.c b/source/blender/src/editnode.c index 9f37248783e..1d290644148 100644 --- a/source/blender/src/editnode.c +++ b/source/blender/src/editnode.c @@ -35,6 +35,7 @@ #include "MEM_guardedalloc.h" #include "DNA_action_types.h" +#include "DNA_color_types.h" #include "DNA_image_types.h" #include "DNA_ipo_types.h" #include "DNA_object_types.h" @@ -45,6 +46,7 @@ #include "DNA_scene_types.h" #include "DNA_userdef_types.h" +#include "BKE_colortools.h" #include "BKE_global.h" #include "BKE_image.h" #include "BKE_library.h" @@ -1674,7 +1676,30 @@ void node_hide(SpaceNode *snode) BIF_undo_push("Hide nodes"); allqueue(REDRAWNODE, 1); } + +void node_insert_key(SpaceNode *snode) +{ + bNode *node= editnode_get_active(snode->edittree); + + if(node->type==CMP_NODE_TIME) { + if(node->custom1custom2) { + + CurveMapping *cumap= node->storage; + float fval, curval; + + curval= (float)(CFRA - node->custom1)/(float)(node->custom2-node->custom1); + fval= curvemapping_evaluateF(cumap, 0, curval); + if(fbutton(&fval, 0.0f, 1.0f, 10, 10, "Insert Value")) { + curvemap_insert(cumap->cm, curval, fval); + + BIF_undo_push("Insert key in Time node"); + allqueue(REDRAWNODE, 1); + } + } + } +} + static void node_border_link_delete(SpaceNode *snode) { @@ -1998,6 +2023,9 @@ void winqreadnodespace(ScrArea *sa, void *spacedata, BWinEvent *evt) case HKEY: node_hide(snode); break; + case IKEY: + node_insert_key(snode); + break; case RKEY: if(okee("Read saved Render Layers")) node_read_renderlayers(snode); diff --git a/source/blender/src/interface_draw.c b/source/blender/src/interface_draw.c index 84ae130110a..de95b1264b4 100644 --- a/source/blender/src/interface_draw.c +++ b/source/blender/src/interface_draw.c @@ -2191,6 +2191,15 @@ static void ui_draw_but_CURVE(uiBut *but) glVertex2f(but->x1 + zoomx*(-offsx), but->y2); glEnd(); + /* cfra option */ + if(cumap->flag & CUMA_DRAW_CFRA) { + glColor3ub(0x60, 0xc0, 0x40); + glBegin(GL_LINES); + glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y1); + glVertex2f(but->x1 + zoomx*(cumap->black[0]-offsx), but->y2); + glEnd(); + } + /* the curve */ BIF_ThemeColor(TH_TEXT); glBegin(GL_LINE_STRIP); diff --git a/source/blender/src/toets.c b/source/blender/src/toets.c index 4f47206006e..b6f0e90ad1a 100644 --- a/source/blender/src/toets.c +++ b/source/blender/src/toets.c @@ -729,7 +729,7 @@ int blenderqread(unsigned short event, short val) } break; case IKEY: - if(textediting==0 && textspace==0 && curarea->spacetype!=SPACE_FILE && curarea->spacetype!=SPACE_IMASEL) { + if(textediting==0 && textspace==0 && !ELEM3(curarea->spacetype, SPACE_FILE, SPACE_IMASEL, SPACE_NODE)) { if(G.qual==0) { common_insertkey(); return 0; -- cgit v1.2.3