Composite Time node usablity improvement:
authorTon Roosendaal <ton@blender.org>
Fri, 24 Nov 2006 16:56:02 +0000 (16:56 +0000)
committerTon Roosendaal <ton@blender.org>
Fri, 24 Nov 2006 16:56:02 +0000 (16:56 +0000)
- 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
source/blender/src/drawnode.c
source/blender/src/editnode.c
source/blender/src/interface_draw.c
source/blender/src/toets.c

index 32cbc39523b64a0540359fac39b067298bdae83e..a4224976f5fabb8fe2290c37b35615aaa4c3b2b2 100644 (file)
@@ -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
 
index a42ae4e722de5230aadc20e6a704b950833ca561..f1e9f70b5aa5d57a342126785da8348c611b29e3 100644 (file)
@@ -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->custom1<node->custom2)
+                       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, "");
index 9f37248783e33ba8b72ae361bade7485a2b8c05b..1d290644148f38cf92758f29b15cf17ce87c5dbd 100644 (file)
@@ -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->custom1<node->custom2) {
+
+                       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);
index 84ae130110ade22b9471dabbd2c1ce202e8a6f45..de95b1264b4b97b0919bf96d4717e149f5d08e02 100644 (file)
@@ -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);
index 4f47206006e0012c6773a3024a7f5bd0a4043ec3..b6f0e90ad1af5993c75b33d17bf07f79d73b7479 100644 (file)
@@ -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;