Revision: 18140
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=18140
Author:   aligorith
Date:     2008-12-29 07:06:59 +0100 (Mon, 29 Dec 2008)

Log Message:
-----------
2.5 Transform Code - Preparing for Action Editor Support

* Fixed up most of the relevant Fixme's for Action Editor and/or some animation 
stuff

* Added keymap for action editor transforms to transform keymap.

* Added context pointer to TransInfo struct. This was needed to avoid passing 
context to everything. As such, renamed the old 'context' setting to options. 

Modified Paths:
--------------
    
branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.c
    branches/blender2.5/blender/source/blender/editors/transform/transform.h
    
branches/blender2.5/blender/source/blender/editors/transform/transform_conversions.c
    
branches/blender2.5/blender/source/blender/editors/transform/transform_generics.c
    branches/blender2.5/blender/source/blender/editors/transform/transform_ops.c

Modified: 
branches/blender2.5/blender/source/blender/editors/space_action/action_header.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_action/action_header.c 
    2008-12-29 04:23:41 UTC (rev 18139)
+++ 
branches/blender2.5/blender/source/blender/editors/space_action/action_header.c 
    2008-12-29 06:06:59 UTC (rev 18140)
@@ -488,12 +488,12 @@
                
                xmax= GetButStringLength("View");
                uiDefPulldownBut(block, action_viewmenu, CTX_wm_area(C), 
-                                         "View", xco, yco, xmax-3, 24, "");
+                                         "View", xco, yco-2, xmax-3, 24, "");
                xco+= xmax;
                
                xmax= GetButStringLength("Select");
                uiDefPulldownBut(block, action_selectmenu, CTX_wm_area(C), 
-                                         "Select", xco, yco, xmax-3, 24, "");
+                                         "Select", xco, yco-2, xmax-3, 24, "");
                xco+= xmax;
                
                if ( (saction->mode == SACTCONT_DOPESHEET) ||
@@ -501,31 +501,31 @@
                {
                        xmax= GetButStringLength("Channel");
                        uiDefPulldownBut(block, action_channelmenu, 
CTX_wm_area(C), 
-                                                 "Channel", xco, yco, xmax-3, 
24, "");
+                                                 "Channel", xco, yco-2, 
xmax-3, 24, "");
                        xco+= xmax;
                }
                else if (saction->mode==SACTCONT_GPENCIL) {
                        xmax= GetButStringLength("Channel");
                        uiDefPulldownBut(block, action_gplayermenu, 
CTX_wm_area(C), 
-                                                 "Channel", xco, yco, xmax-3, 
24, "");
+                                                 "Channel", xco, yco-2, 
xmax-3, 24, "");
                        xco+= xmax;
                }
                
                xmax= GetButStringLength("Marker");
                uiDefPulldownBut(block, action_markermenu, CTX_wm_area(C), 
-                                         "Marker", xco, yco, xmax-3, 24, "");
+                                         "Marker", xco, yco-2, xmax-3, 24, "");
                xco+= xmax;
                
                if (saction->mode == SACTCONT_GPENCIL) {
                        xmax= GetButStringLength("Frame");
                        uiDefPulldownBut(block, action_framemenu, 
CTX_wm_area(C), 
-                                                 "Frame", xco, yco, xmax-3, 
24, "");
+                                                 "Frame", xco, yco-2, xmax-3, 
24, "");
                        xco+= xmax;
                }
                else {
                        xmax= GetButStringLength("Key");
                        uiDefPulldownBut(block, action_keymenu, CTX_wm_area(C), 
-                                                 "Key", xco, yco, xmax-3, 24, 
"");
+                                                 "Key", xco, yco-2, xmax-3, 
24, "");
                        xco+= xmax;
                }
        }

Modified: 
branches/blender2.5/blender/source/blender/editors/transform/transform.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2008-12-29 04:23:41 UTC (rev 18139)
+++ branches/blender2.5/blender/source/blender/editors/transform/transform.c    
2008-12-29 06:06:59 UTC (rev 18140)
@@ -467,6 +467,16 @@
                // need to redraw ALL 3d view
                ED_area_tag_redraw(t->sa);
        }
+       else if (t->spacetype == SPACE_ACTION) {
+               SpaceAction *saction= CTX_wm_space_data(t->context);
+               
+               // TRANSFORM_FIX_ME
+               if (saction->lock) {
+                       // whole window...
+               }
+               else 
+                       ED_area_tag_redraw(t->sa);
+       }
 #if 0 // TRANSFORM_FIX_ME
        else if (t->spacetype==SPACE_IMAGE) {
                if (G.sima->lock) force_draw_plus(SPACE_VIEW3D, 0);
@@ -961,14 +971,14 @@
                switch(handleNDofInput(&(t->ndof), event))
                {
                        case NDOF_CONFIRM:
-                               if ((t->context & CTX_NDOF) == 0)
+                               if ((t->options & CTX_NDOF) == 0)
                                {
                                        /* Confirm on normal transform only */
                                        t->state = TRANS_CONFIRM;
                                }
                                break;
                        case NDOF_CANCEL:
-                               if (t->context & CTX_NDOF)
+                               if (t->options & CTX_NDOF)
                                {
                                        /* Cancel on pure NDOF transform */
                                        t->state = TRANS_CANCEL; 
@@ -980,7 +990,7 @@
                                }
                                break;
                        case NDOF_NOMOVE:
-                               if (t->context & CTX_NDOF)
+                               if (t->options & CTX_NDOF)
                                {
                                        /* Confirm on pure NDOF transform */
                                        t->state = TRANS_CONFIRM;
@@ -1010,7 +1020,7 @@
                        break;
                case LEFTMOUSE:
                case RIGHTMOUSE:
-                       if (t->context & CTX_TWEAK)
+                       if (t->options & CTX_TWEAK)
                                t->state = TRANS_CONFIRM;
                        break;
                case LEFTSHIFTKEY:
@@ -1033,7 +1043,7 @@
 
        t->state = TRANS_RUNNING;
 
-       t->context = CTX_NONE;
+       t->options = CTX_NONE;
        
        t->mode = TFM_DUMMY;
 
@@ -1065,13 +1075,13 @@
        return success;
 }
 
-void initTransform(bContext *C, TransInfo *t, int mode, int context, wmEvent 
*event)
+void initTransform(bContext *C, TransInfo *t, int mode, int options, wmEvent 
*event)
 {
        /* added initialize, for external calls to set stuff in TransInfo, like 
undo string */
 
        t->state = TRANS_RUNNING;
 
-       t->context = context;
+       t->options = options;
        
        t->mode = mode;
 
@@ -1207,7 +1217,7 @@
        }
 
        /* If auto confirm is on, break after one pass */               
-       if (t->context & CTX_AUTOCONFIRM)
+       if (t->options & CTX_AUTOCONFIRM)
        {
                t->state = TRANS_CONFIRM;
        }
@@ -1250,7 +1260,8 @@
 #endif
                return 1;
        }
-
+       
+       t->context= NULL;
        t->event = NULL;
        
        return 0;
@@ -1263,7 +1274,7 @@
 #if 0 // TRANSFORM_FIX_ME
        Trans.state = TRANS_RUNNING;
 
-       Trans.context = CTX_NONE;
+       Trans.options = CTX_NONE;
        
        Trans.mode = mode;
        
@@ -4244,68 +4255,77 @@
 /* This function returns the snapping 'mode' for Animation Editors only 
  * We cannot use the standard snapping due to NLA-strip scaling complexities.
  */
+// XXX these modifier checks should be keymappable
 static short getAnimEdit_SnapMode(TransInfo *t)
 {
        short autosnap= SACTSNAP_OFF;
-#if 0 // TRANSFORM_FIX_ME      
+       
        /* currently, some of these are only for the action editor */
-       if (t->spacetype == SPACE_ACTION && G.saction) {
-               switch (G.saction->autosnap) {
-               case SACTSNAP_OFF:
-                       if (G.qual == LR_CTRLKEY) 
-                               autosnap= SACTSNAP_STEP;
-                       else if (G.qual == LR_SHIFTKEY)
-                               autosnap= SACTSNAP_FRAME;
-                       else if (G.qual == LR_ALTKEY)
-                               autosnap= SACTSNAP_MARKER;
-                       else
-                               autosnap= SACTSNAP_OFF;
-                       break;
-               case SACTSNAP_STEP:
-                       autosnap= (G.qual==LR_CTRLKEY)? SACTSNAP_OFF: 
SACTSNAP_STEP;
-                       break;
-               case SACTSNAP_FRAME:
-                       autosnap= (G.qual==LR_SHIFTKEY)? SACTSNAP_OFF: 
SACTSNAP_FRAME;
-                       break;
-               case SACTSNAP_MARKER:
-                       autosnap= (G.qual==LR_ALTKEY)? SACTSNAP_OFF: 
SACTSNAP_MARKER;
-                       break;
+       if (t->spacetype == SPACE_ACTION) {
+               SpaceAction *saction= CTX_wm_space_data(t->context);
+               
+               if (saction) {
+                       switch (saction->autosnap) {
+                       case SACTSNAP_OFF:
+                               if (t->event->ctrl) 
+                                       autosnap= SACTSNAP_STEP;
+                               else if (t->event->shift)
+                                       autosnap= SACTSNAP_FRAME;
+                               else if (t->event->alt)
+                                       autosnap= SACTSNAP_MARKER;
+                               else
+                                       autosnap= SACTSNAP_OFF;
+                               break;
+                       case SACTSNAP_STEP:
+                               autosnap= (t->event->ctrl)? SACTSNAP_OFF: 
SACTSNAP_STEP;
+                               break;
+                       case SACTSNAP_FRAME:
+                               autosnap= (t->event->shift)? SACTSNAP_OFF: 
SACTSNAP_FRAME;
+                               break;
+                       case SACTSNAP_MARKER:
+                               autosnap= (t->event->alt)? SACTSNAP_OFF: 
SACTSNAP_MARKER;
+                               break;
+                       }
                }
        }
-       else if (t->spacetype == SPACE_NLA && G.snla) {
-               switch (G.snla->autosnap) {
-               case SACTSNAP_OFF:
-                       if (G.qual == LR_CTRLKEY) 
-                               autosnap= SACTSNAP_STEP;
-                       else if (G.qual == LR_SHIFTKEY)
-                               autosnap= SACTSNAP_FRAME;
-                       else if (G.qual == LR_ALTKEY)
-                               autosnap= SACTSNAP_MARKER;
-                       else
-                               autosnap= SACTSNAP_OFF;
-                       break;
-               case SACTSNAP_STEP:
-                       autosnap= (G.qual==LR_CTRLKEY)? SACTSNAP_OFF: 
SACTSNAP_STEP;
-                       break;
-               case SACTSNAP_FRAME:
-                       autosnap= (G.qual==LR_SHIFTKEY)? SACTSNAP_OFF: 
SACTSNAP_FRAME;
-                       break;
-               case SACTSNAP_MARKER:
-                       autosnap= (G.qual==LR_ALTKEY)? SACTSNAP_OFF: 
SACTSNAP_MARKER;
-                       break;
+       else if (t->spacetype == SPACE_NLA) {
+               SpaceAction *snla= CTX_wm_space_data(t->context);
+               
+               if (snla) {
+                       switch (snla->autosnap) {
+                       case SACTSNAP_OFF:
+                               if (t->event->ctrl) 
+                                       autosnap= SACTSNAP_STEP;
+                               else if (t->event->shift)
+                                       autosnap= SACTSNAP_FRAME;
+                               else if (t->event->alt)
+                                       autosnap= SACTSNAP_MARKER;
+                               else
+                                       autosnap= SACTSNAP_OFF;
+                               break;
+                       case SACTSNAP_STEP:
+                               autosnap= (t->event->ctrl)? SACTSNAP_OFF: 
SACTSNAP_STEP;
+                               break;
+                       case SACTSNAP_FRAME:
+                               autosnap= (t->event->shift)? SACTSNAP_OFF: 
SACTSNAP_FRAME;
+                               break;
+                       case SACTSNAP_MARKER:
+                               autosnap= (t->event->alt)? SACTSNAP_OFF: 
SACTSNAP_MARKER;
+                               break;
+                       }
                }
        }
        else {
-               if (G.qual == LR_CTRLKEY) 
+               if (t->event->ctrl) 
                        autosnap= SACTSNAP_STEP;
-               else if (G.qual == LR_SHIFTKEY)
+               else if (t->event->shift)
                        autosnap= SACTSNAP_FRAME;
-               else if (G.qual == LR_ALTKEY)
+               else if (t->event->alt)
                        autosnap= SACTSNAP_MARKER;
                else
                        autosnap= SACTSNAP_OFF;
        }
-#endif 
+       
        return autosnap;
 }
 
@@ -4315,23 +4335,24 @@
  */
 static short getAnimEdit_DrawTime(TransInfo *t)
 {
-#if 0 // TRANSFORM_FIX_ME      
        short drawtime;
        
        /* currently, some of these are only for the action editor */
-       if (t->spacetype == SPACE_ACTION && G.saction) {
-               drawtime = (G.saction->flag & SACTION_DRAWTIME)? 1 : 0;
+       if (t->spacetype == SPACE_ACTION) {
+               SpaceAction *saction= CTX_wm_space_data(t->context);
+               
+               drawtime = (saction->flag & SACTION_DRAWTIME)? 1 : 0;
        }
-       else if (t->spacetype == SPACE_NLA && G.snla) {
-               drawtime = (G.snla->flag & SNLA_DRAWTIME)? 1 : 0;
+       else if (t->spacetype == SPACE_NLA) {
+               SpaceAction *snla= CTX_wm_space_data(t->context);
+               
+               drawtime = (snla->flag & SNLA_DRAWTIME)? 1 : 0;
        }
        else {
                drawtime = 0;
        }
        
        return drawtime;
-#endif
-return 0;
 }      
 
 
@@ -4340,11 +4361,11 @@
  */
 static void doAnimEdit_SnapFrame(TransInfo *t, TransData *td, Object *ob, 
short autosnap)
 {
-#if 0 // TRANSFORM_FIX_ME      
        /* snap key to nearest frame? */
        if (autosnap == SACTSNAP_FRAME) {
-               short doTime= getAnimEdit_DrawTime(t);
-               double secf= FPS;
+               const Scene *scene= t->scene;
+               const short doTime= getAnimEdit_DrawTime(t);
+               const double secf= FPS;
                double val;
                
                /* convert frame to nla-action time (if needed) */
@@ -4376,15 +4397,15 @@
                        val= *(td->val);
                
                /* snap to nearest marker */
-               val= (float)find_nearest_marker_time(val);
-                       
+               // XXX missing function!
+               //val= (float)find_nearest_marker_time(val);
+               
                /* convert frame out of nla-action time */
                if (ob)
                        *(td->val)= get_action_frame(ob, val);
                else
                        *(td->val)= val;
        }
-#endif
 }
 
 /* ----------------- Translation ----------------------- */
@@ -4413,10 +4434,10 @@
                outputNumInput(&(t->num), tvec);
        }
        else {
-               Scene *scene = t->scene;
-               short autosnap= getAnimEdit_SnapMode(t);
-               short doTime = getAnimEdit_DrawTime(t);
-               double secf= FPS;
+               const Scene *scene = t->scene;
+               const short autosnap= getAnimEdit_SnapMode(t);
+               const short doTime = getAnimEdit_DrawTime(t);
+               const double secf= FPS;
                float val= t->fac;
                
                /* apply snapping + frame->seconds conversions */
@@ -4443,10 +4464,10 @@
        Scene *scene = t->scene;
        int i;
        
-       short doTime= getAnimEdit_DrawTime(t);
-       double secf= FPS;
+       const short doTime= getAnimEdit_DrawTime(t);
+       const double secf= FPS;
        

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to