RNA
[blender-staging.git] / source / blender / editors / screen / screen_ops.c
index 6cd06faab68d879333ba494625ad1a3d0bf828be..dae7a7cedd5e76627b0c99d5b12fc8c890f62ae0 100644 (file)
@@ -24,6 +24,8 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <math.h>
+
 #include "MEM_guardedalloc.h"
 
 #include "BLI_arithb.h"
@@ -45,6 +47,7 @@
 #include "BKE_idprop.h"
 #include "BKE_library.h"
 #include "BKE_main.h"
+#include "BKE_mesh.h"
 #include "BKE_multires.h"
 #include "BKE_report.h"
 #include "BKE_screen.h"
@@ -55,6 +58,7 @@
 
 #include "ED_util.h"
 #include "ED_screen.h"
+#include "ED_mesh.h"
 #include "ED_screen_types.h"
 
 #include "RE_pipeline.h"
 
 /* ************** Exported Poll tests ********************** */
 
+int ED_operator_regionactive(bContext *C)
+{
+       if(CTX_wm_window(C)==NULL) return 0;
+       if(CTX_wm_screen(C)==NULL) return 0;
+       if(CTX_wm_region(C)==NULL) return 0;
+       return 1;
+}
+
 int ED_operator_areaactive(bContext *C)
 {
        if(CTX_wm_window(C)==NULL) return 0;
@@ -124,11 +136,7 @@ int ED_operator_timeline_active(bContext *C)
 
 int ED_operator_outliner_active(bContext *C)
 {
-       if(ed_spacetype_test(C, SPACE_OOPS)) {
-               SpaceOops *so= (SpaceOops *)CTX_wm_space_data(C);
-               return (so->type == SO_OUTLINER);
-       }
-       return 0;
+       return ed_spacetype_test(C, SPACE_OUTLINER);
 }
 
 int ED_operator_file_active(bContext *C)
@@ -210,11 +218,15 @@ int ED_operator_uvedit(bContext *C)
        EditMesh *em= NULL;
 
        if(obedit && obedit->type==OB_MESH)
-               em= ((Mesh *)obedit->data)->edit_mesh;
+               em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
 
-    if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE)))
+       if(em && (em->faces.first) && (CustomData_has_layer(&em->fdata, CD_MTFACE))) {
+               BKE_mesh_end_editmesh(obedit->data, em);
                return 1;
+       }
 
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
 }
 
@@ -224,22 +236,50 @@ int ED_operator_uvmap(bContext *C)
        EditMesh *em= NULL;
 
        if(obedit && obedit->type==OB_MESH)
-               em= ((Mesh *)obedit->data)->edit_mesh;
+               em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
 
-    if(em && (em->faces.first))
+       if(em && (em->faces.first)) {
+               BKE_mesh_end_editmesh(obedit->data, em);
                return 1;
+       }
+
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
+       return 0;
+}
 
+int ED_operator_editsurfcurve(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && ELEM(obedit->type, OB_CURVE, OB_SURF))
+               return NULL != ((Curve *)obedit->data)->editnurb;
        return 0;
 }
 
+
 int ED_operator_editcurve(bContext *C)
 {
        Object *obedit= CTX_data_edit_object(C);
        if(obedit && obedit->type==OB_CURVE)
-               return NULL != ((Mesh *)obedit->data)->edit_mesh;
+               return NULL != ((Curve *)obedit->data)->editnurb;
        return 0;
 }
 
+int ED_operator_editsurf(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_SURF)
+               return NULL != ((Curve *)obedit->data)->editnurb;
+       return 0;
+}
+
+int ED_operator_editfont(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_FONT)
+               return NULL != ((Curve *)obedit->data)->editfont;
+       return 0;
+}
 
 /* *************************** action zone operator ************************** */
 
@@ -269,7 +309,7 @@ callbacks:
 typedef struct sActionzoneData {
        ScrArea *sa1, *sa2;
        AZone *az;
-       int x, y, gesture_dir;
+       int x, y, gesture_dir, modifier;
 } sActionzoneData;
 
 /* used by other operators too */
@@ -285,46 +325,51 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y)
        return sa;
 }
 
+/* quick poll to save operators to be created and handled */
+static int actionzone_area_poll(bContext *C)
+{
+       wmWindow *win= CTX_wm_window(C);
+       ScrArea *sa= CTX_wm_area(C);
+       
+       if(sa && win) {
+               AZone *az;
+               int x= win->eventstate->x;
+               int y= win->eventstate->y;
+               
+               for(az= sa->actionzones.first; az; az= az->next)
+                       if(BLI_in_rcti(&az->rect, x, y))
+                          return 1;
+       }       
+       return 0;
+}
 
 AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
 {
        AZone *az= NULL;
-       int i= 0;
        
-       for(az= sa->actionzones.first, i= 0; az; az= az->next, i++) {
-               if(az->type == AZONE_TRI) {
-                       if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) 
-                               break;
-               }
-               if(az->type == AZONE_QUAD) {
-                       if(az->x1 < x && x < az->x2 && az->y1 < y && y < az->y2) 
-                               break;
+       for(az= sa->actionzones.first; az; az= az->next) {
+               if(BLI_in_rcti(&az->rect, x, y)) {
+                       if(az->type == AZONE_AREA) {
+                               if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) 
+                                       break;
+                       }
+                       else if(az->type == AZONE_REGION) {
+                               float v1[2], v2[2], v3[2], pt[2];
+                               
+                               v1[0]= az->x1; v1[1]= az->y1;
+                               v2[0]= az->x2; v2[1]= az->y2;
+                               v3[0]= az->x3; v3[1]= az->y3;
+                               pt[0]= x; pt[1]=y;
+
+                               if(IsPointInTri2D(v1, v2, v3, pt)) 
+                                       break;
+                       }
                }
        }
        
        return az;
 }
 
-static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
-       sActionzoneData *sad;
-       
-       /* quick escape */
-       if(az==NULL)
-               return OPERATOR_PASS_THROUGH;
-       
-       /* ok we do the actionzone */
-       sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
-       sad->sa1= CTX_wm_area(C);
-       sad->az= az;
-       sad->x= event->x; sad->y= event->y;
-       
-       /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
-       
-       return OPERATOR_RUNNING_MODAL;
-}
 
 static void actionzone_exit(bContext *C, wmOperator *op)
 {
@@ -334,13 +379,19 @@ static void actionzone_exit(bContext *C, wmOperator *op)
 }
 
 /* send EVT_ACTIONZONE event */
-static void actionzone_apply(bContext *C, wmOperator *op)
+static void actionzone_apply(bContext *C, wmOperator *op, int type)
 {
        wmEvent event;
        wmWindow *win= CTX_wm_window(C);
+       sActionzoneData *sad= op->customdata;
+       
+       sad->modifier= RNA_int_get(op->ptr, "modifier");
        
        event= *(win->eventstate);      /* XXX huh huh? make api call */
-       event.type= EVT_ACTIONZONE;
+       if(type==AZONE_AREA)
+               event.type= EVT_ACTIONZONE_AREA;
+       else
+               event.type= EVT_ACTIONZONE_REGION;
        event.customdata= op->customdata;
        event.customdatafree= TRUE;
        op->customdata= NULL;
@@ -348,10 +399,41 @@ static void actionzone_apply(bContext *C, wmOperator *op)
        wm_event_add(win, &event);
 }
 
+static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
+       sActionzoneData *sad;
+       
+       /* quick escape */
+       if(az==NULL)
+               return OPERATOR_PASS_THROUGH;
+       
+       /* ok we do the actionzone */
+       sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
+       sad->sa1= CTX_wm_area(C);
+       sad->az= az;
+       sad->x= event->x; sad->y= event->y;
+       
+       /* region azone directly reacts on mouse clicks */
+       if(sad->az->type==AZONE_REGION) {
+               actionzone_apply(C, op, AZONE_REGION);
+               actionzone_exit(C, op);
+               return OPERATOR_FINISHED;
+       }
+       else {
+               /* add modal handler */
+               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               
+               return OPERATOR_RUNNING_MODAL;
+       }
+}
+
+
 static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        sActionzoneData *sad= op->customdata;
        int deltax, deltay;
+       int mindelta= sad->az->type==AZONE_REGION?1:12;
        
        switch(event->type) {
                case MOUSEMOVE:
@@ -360,30 +442,33 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
                        deltay= (event->y - sad->y);
                        
                        if(deltay > ABS(deltax))
-                               sad->gesture_dir= AZONE_N;
+                               sad->gesture_dir= 'n';
                        else if(deltax > ABS(deltay))
-                               sad->gesture_dir= AZONE_E;
+                               sad->gesture_dir= 'e';
                        else if(deltay < -ABS(deltax))
-                               sad->gesture_dir= AZONE_S;
+                               sad->gesture_dir= 's';
                        else
-                               sad->gesture_dir= AZONE_W;
+                               sad->gesture_dir= 'w';
                        
                        /* gesture is large enough? */
-                       if(ABS(deltax) > 12 || ABS(deltay) > 12) {
+                       if(ABS(deltax) > mindelta || ABS(deltay) > mindelta) {
                                
                                /* second area, for join */
                                sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
                                /* apply sends event */
-                               actionzone_apply(C, op);
+                               actionzone_apply(C, op, sad->az->type);
                                actionzone_exit(C, op);
                                
                                return OPERATOR_FINISHED;
                        }
                                break;
                case ESCKEY:
-               case LEFTMOUSE:
                        actionzone_exit(C, op);
                        return OPERATOR_CANCELLED;
+               case LEFTMOUSE:                         
+                       actionzone_exit(C, op);
+                       return OPERATOR_CANCELLED;
+
        }
        
        return OPERATOR_RUNNING_MODAL;
@@ -398,17 +483,126 @@ void SCREEN_OT_actionzone(wmOperatorType *ot)
        ot->invoke= actionzone_invoke;
        ot->modal= actionzone_modal;
        
-       ot->poll= ED_operator_areaactive;
+       ot->poll= actionzone_area_poll;
+       RNA_def_int(ot->srna, "modifier", 0, 0, 2, "modifier", "modifier state", 0, 2);
+}
+
+/* ************** swap area operator *********************************** */
+
+/* operator state vars used:  
+                                       sa1             start area
+                                       sa2             area to swap with
+
+       functions:
+
+       init()   set custom data for operator, based on actionzone event custom data
+
+       cancel()        cancel the operator
+
+       exit()  cleanup, send notifier
+
+       callbacks:
+
+       invoke() gets called on shift+lmb drag in actionzone
+            call init(), add handler
+
+       modal()  accept modal events while doing it
+
+*/
+
+typedef struct sAreaSwapData {
+       ScrArea *sa1, *sa2;
+} sAreaSwapData;
+
+static int area_swap_init(bContext *C, wmOperator *op, wmEvent *event)
+{
+       sAreaSwapData *sd= NULL;
+       sActionzoneData *sad= event->customdata;
+
+       if(sad==NULL || sad->sa1==NULL)
+                                       return 0;
+       
+       sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
+       sd->sa1= sad->sa1;
+       sd->sa2= sad->sa2;
+       op->customdata= sd;
+
+       return 1;
+}
+
+
+static void area_swap_exit(bContext *C, wmOperator *op)
+{
+       if(op->customdata)
+               MEM_freeN(op->customdata);
+       op->customdata= NULL;
+}
+
+static int area_swap_cancel(bContext *C, wmOperator *op)
+{
+       area_swap_exit(C, op);
+       return OPERATOR_CANCELLED;
+}
+
+static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+
+       if(!area_swap_init(C, op, event))
+               return OPERATOR_PASS_THROUGH;
+
+       /* add modal handler */
+       WM_cursor_modal(CTX_wm_window(C), BC_SWAPAREA_CURSOR);
+       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       
+       return OPERATOR_RUNNING_MODAL;
+
+}
+
+static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+       sActionzoneData *sad= op->customdata;
+
+       switch(event->type) {
+               case MOUSEMOVE:
+                       /* second area, for join */
+                       sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
+                       break;
+               case LEFTMOUSE: /* release LMB */
+                       if(event->val==0) {
+                               if(sad->sa1 == sad->sa2) {
+
+                                       return area_swap_cancel(C, op);
+                               }
+                               ED_area_swapspace(C, sad->sa1, sad->sa2);
+
+                               area_swap_exit(C, op);
+
+                               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+
+                               return OPERATOR_FINISHED;
+                       }
+                       break;
+
+               case ESCKEY:
+                       return area_swap_cancel(C, op);
+       }
+       return OPERATOR_RUNNING_MODAL;
 }
 
+static void SCREEN_OT_area_swap(wmOperatorType *ot)
+{
+       ot->name= "Swap areas";
+       ot->idname= "SCREEN_OT_area_swap";
 
-/* *********** Rip area operator ****************** */
+       ot->invoke= area_swap_invoke;
+       ot->modal= area_swap_modal;
+       ot->poll= ED_operator_areaactive;
+}
 
+/* *********** Duplicate area as new window operator ****************** */
 
 /* operator callback */
-/* (ton) removed attempt to merge ripped area with another, don't think this is desired functionality.
-conventions: 'atomic' and 'dont think for user' :) */
-static int screen_area_rip_op(bContext *C, wmOperator *op)
+static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        wmWindow *newwin, *win;
        bScreen *newsc, *sc;
@@ -418,10 +612,23 @@ static int screen_area_rip_op(bContext *C, wmOperator *op)
        win= CTX_wm_window(C);
        sc= CTX_wm_screen(C);
        sa= CTX_wm_area(C);
+       
+       /* XXX hrmf! */
+       if(event->type==EVT_ACTIONZONE_AREA) {
+               sActionzoneData *sad= event->customdata;
 
+               if(sad==NULL)
+                       return OPERATOR_PASS_THROUGH;
+       
+               sa= sad->sa1;
+       }
+       
        /*  poll() checks area context, but we don't accept full-area windows */
-       if(sc->full != SCREENNORMAL) 
+       if(sc->full != SCREENNORMAL) {
+               if(event->type==EVT_ACTIONZONE_AREA)
+                       actionzone_exit(C, op);
                return OPERATOR_CANCELLED;
+       }
        
        /* adds window to WM */
        rect= sa->totrct;
@@ -437,17 +644,19 @@ static int screen_area_rip_op(bContext *C, wmOperator *op)
        
        /* screen, areas init */
        WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+
+       if(event->type==EVT_ACTIONZONE_AREA)
+               actionzone_exit(C, op);
        
        return OPERATOR_FINISHED;
 }
 
-void SCREEN_OT_area_rip(wmOperatorType *ot)
+static void SCREEN_OT_area_dupli(wmOperatorType *ot)
 {
-       ot->name= "Rip Area into New Window";
-       ot->idname= "SCREEN_OT_area_rip";
+       ot->name= "Duplicate Area into New Window";
+       ot->idname= "SCREEN_OT_area_dupli";
        
-       ot->invoke= WM_operator_confirm;
-       ot->exec= screen_area_rip_op;
+       ot->invoke= area_dupli_invoke;
        ot->poll= ED_operator_areaactive;
 }
 
@@ -859,9 +1068,17 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        sAreaSplitData *sd;
        
-       if(event->type==EVT_ACTIONZONE) {
+       if(event->type==EVT_ACTIONZONE_AREA) {
                sActionzoneData *sad= event->customdata;
                int dir;
+
+               if(sad->modifier>0) {
+                       return OPERATOR_PASS_THROUGH;
+               }
+               
+               /* no full window splitting allowed */
+               if(CTX_wm_area(C)->full)
+                       return OPERATOR_PASS_THROUGH;
                
                /* verify *sad itself */
                if(sad==NULL || sad->sa1==NULL || sad->az==NULL)
@@ -872,7 +1089,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        return OPERATOR_PASS_THROUGH;
                
                /* prepare operator state vars */
-               if(sad->gesture_dir==AZONE_N || sad->gesture_dir==AZONE_S) {
+               if(sad->gesture_dir=='n' || sad->gesture_dir=='s') {
                        dir= 'h';
                        RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
                }
@@ -975,9 +1192,9 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
 }
 
 static EnumPropertyItem prop_direction_items[] = {
-       {'h', "HORIZONTAL", "Horizontal", ""},
-       {'v', "VERTICAL", "Vertical", ""},
-       {0, NULL, NULL, NULL}};
+       {'h', "HORIZONTAL", 0, "Horizontal", ""},
+       {'v', "VERTICAL", 0, "Vertical", ""},
+       {0, NULL, 0, NULL, NULL}};
 
 void SCREEN_OT_area_split(wmOperatorType *ot)
 {
@@ -996,6 +1213,119 @@ void SCREEN_OT_area_split(wmOperatorType *ot)
        RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
 }
 
+
+
+/* ************** scale region edge operator *********************************** */
+
+typedef struct RegionMoveData {
+       ARegion *ar;
+       int bigger, smaller, origval;
+       int origx, origy;
+       char edge;
+       
+} RegionMoveData;
+
+static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       sActionzoneData *sad= event->customdata;
+       AZone *az= sad->az;
+       
+       if(az->ar) {
+               RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
+               
+               op->customdata= rmd;
+               
+               rmd->ar= az->ar;
+               rmd->edge= az->edge;
+               rmd->origx= event->x;
+               rmd->origy= event->y;
+               if(rmd->edge=='l' || rmd->edge=='r') 
+                       rmd->origval= rmd->ar->type->minsizex;
+               else
+                       rmd->origval= rmd->ar->type->minsizey;
+               
+               /* add temp handler */
+               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               
+               return OPERATOR_RUNNING_MODAL;
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+       RegionMoveData *rmd= op->customdata;
+       int delta;
+       
+       /* execute the events */
+       switch(event->type) {
+               case MOUSEMOVE:
+                       
+                       if(rmd->edge=='l' || rmd->edge=='r') {
+                               delta= event->x - rmd->origx;
+                               if(rmd->edge=='l') delta= -delta;
+                               rmd->ar->type->minsizex= rmd->origval + delta;
+                               CLAMP(rmd->ar->type->minsizex, 0, 1000);
+                               if(rmd->ar->type->minsizex < 10) {
+                                       rmd->ar->type->minsizex= 10;
+                                       rmd->ar->flag |= RGN_FLAG_HIDDEN;
+                               }
+                               else
+                                       rmd->ar->flag &= ~RGN_FLAG_HIDDEN;
+                       }
+                       else {
+                               delta= event->y - rmd->origy;
+                               if(rmd->edge=='b') delta= -delta;
+                               rmd->ar->type->minsizey= rmd->origval + delta;
+                               CLAMP(rmd->ar->type->minsizey, 0, 1000);
+                               if(rmd->ar->type->minsizey < 10) {
+                                       rmd->ar->type->minsizey= 10;
+                                       rmd->ar->flag |= RGN_FLAG_HIDDEN;
+                               }
+                               else
+                                       rmd->ar->flag &= ~RGN_FLAG_HIDDEN;
+                       }
+                       
+                       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+                                       
+                       break;
+                       
+               case LEFTMOUSE:
+                       if(event->val==0) {
+                               
+                               if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
+                                       rmd->ar->flag ^= RGN_FLAG_HIDDEN;
+                                       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+                               }                               
+                               MEM_freeN(op->customdata);
+                               op->customdata = NULL;
+
+                               return OPERATOR_FINISHED;
+                       }
+                       break;
+                       
+               case ESCKEY:
+                       ;
+       }
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+
+static void SCREEN_OT_region_scale(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Scale Region Size";
+       ot->idname= "SCREEN_OT_region_scale";
+       
+       ot->invoke= region_scale_invoke;
+       ot->modal= region_scale_modal;
+       
+       ot->poll= ED_operator_areaactive;
+}
+
+
 /* ************** frame change operator ***************************** */
 
 
@@ -1021,7 +1351,7 @@ void SCREEN_OT_frame_offset(wmOperatorType *ot)
        ot->exec= frame_offset_exec;
 
        ot->poll= ED_operator_screenactive;
-       ot->flag= OPTYPE_REGISTER;
+       ot->flag= 0;
 
        /* rna */
        RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
@@ -1099,7 +1429,7 @@ void SCREEN_OT_screen_full_area(wmOperatorType *ot)
        
        ot->exec= screen_full_area_exec;
        ot->poll= ED_operator_areaactive;
-       ot->flag= OPTYPE_REGISTER;
+       ot->flag= 0;
 
 }
 
@@ -1223,8 +1553,12 @@ static int area_join_exec(bContext *C, wmOperator *op)
 static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
 
-       if(event->type==EVT_ACTIONZONE) {
+       if(event->type==EVT_ACTIONZONE_AREA) {
                sActionzoneData *sad= event->customdata;
+
+               if(sad->modifier>0) {
+                       return OPERATOR_PASS_THROUGH;
+               }
                
                /* verify *sad itself */
                if(sad==NULL || sad->sa1==NULL || sad->sa2==NULL)
@@ -1409,19 +1743,21 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
        wmOperator *lastop;
-       uiMenuItem *head;
+       uiPopupMenu *pup;
+       uiLayout *layout;
        int items, i;
        
        items= BLI_countlist(&wm->operators);
        if(items==0)
                return OPERATOR_CANCELLED;
        
-       head= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
+       layout= uiPupMenuLayout(pup);
 
        for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
-               uiMenuItemIntO(head, lastop->type->name, 0, op->type->idname, "index", i);
+               uiItemIntO(layout, lastop->type->name, 0, op->type->idname, "index", i);
 
-       uiPupMenuEnd(C, head);
+       uiPupMenuEnd(C, pup);
        
        return OPERATOR_CANCELLED;
 }
@@ -1459,71 +1795,18 @@ void SCREEN_OT_repeat_history(wmOperatorType *ot)
 
 /* ********************** redo operator ***************************** */
 
-static int redo_last_exec(bContext *C, wmOperator *op)
-{
-#if 0
-       /* XXX context is not correct after popup menu */
-       wmOperator *lastop= CTX_wm_manager(C)->operators.last;
-       
-       if(lastop) {
-               ED_undo_pop(C);
-               WM_operator_repeat(C, lastop);
-       }
-#endif
-       
-       return OPERATOR_CANCELLED;
-}
-
-static void redo_last_cb(bContext *C, void *arg1, void *arg2)
-{
-       wmOperator *lastop= CTX_wm_manager(C)->operators.last;
-       
-       if(lastop) {
-               ED_undo_pop(C);
-               WM_operator_repeat(C, lastop);
-       }
-       
-}
-
-static uiBlock *ui_block_create_redo_last(bContext *C, ARegion *ar, void *arg_op)
-{
-       wmWindowManager *wm= CTX_wm_manager(C);
-       wmOperator *op= arg_op;
-       PointerRNA ptr;
-       uiBlock *block;
-       int height;
-       
-       block= uiBeginBlock(C, ar, "redo_last_popup", UI_EMBOSS, UI_HELV);
-       uiBlockSetFlag(block, UI_BLOCK_KEEP_OPEN|UI_BLOCK_RET_1);
-       uiBlockSetFunc(block, redo_last_cb, NULL, NULL);
-
-       if(!op->properties) {
-               IDPropertyTemplate val = {0};
-               op->properties= IDP_New(IDP_GROUP, val, "wmOperatorProperties");
-       }
-
-       RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr);
-       height= uiDefAutoButsRNA(block, &ptr);
-
-       uiPopupBoundsBlock(block, 4.0f, 0, 0);
-       uiEndBlock(C, block);
-
-       return block;
-}
-
 static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        wmWindowManager *wm= CTX_wm_manager(C);
-       wmOperator *lastop= wm->operators.last;
-
-       if(!lastop)
-               return OPERATOR_CANCELLED;
+       wmOperator *lastop;
 
        /* only for operators that are registered and did an undo push */
-       if(!(lastop->type->flag & OPTYPE_REGISTER) || !(lastop->type->flag & OPTYPE_UNDO))
-               return OPERATOR_CANCELLED;
-
-       uiPupBlockO(C, ui_block_create_redo_last, lastop, op->type->idname, WM_OP_EXEC_DEFAULT);
+       for(lastop= wm->operators.last; lastop; lastop= lastop->prev)
+               if((lastop->type->flag & OPTYPE_REGISTER) && (lastop->type->flag & OPTYPE_UNDO))
+                       break;
+       
+       if(lastop)
+               WM_operator_redo_popup(C, lastop);
 
        return OPERATOR_CANCELLED;
 }
@@ -1536,7 +1819,6 @@ void SCREEN_OT_redo_last(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke= redo_last_invoke;
-       ot->exec= redo_last_exec;
        
        ot->poll= ED_operator_screenactive;
 }
@@ -1606,6 +1888,7 @@ static int region_foursplit_exec(bContext *C, wmOperator *op)
                if(sa->spacetype==SPACE_VIEW3D) {
                        RegionView3D *rv3d= ar->regiondata;
                        rv3d->viewlock= 0;
+                       rv3d->rflag &= ~RV3D_CLIPPING;
                }
                
                for(ar= sa->regionbase.first; ar; ar= arn) {
@@ -1697,37 +1980,6 @@ static int region_flip_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static void testfunc(bContext *C, void *argv, int arg)
-{
-       printf("arg %d\n", arg);
-}
-
-static void newlevel1(bContext *C, uiMenuItem *head, void *arg)
-{
-       uiMenuFunc(head, testfunc, NULL);
-       
-       uiMenuItemVal(head, "First", ICON_PROP_ON, 1);
-       uiMenuItemVal(head, "Second", ICON_PROP_CON, 2);
-       uiMenuItemVal(head, "Third", ICON_SMOOTHCURVE, 3);
-       uiMenuItemVal(head, "Fourth", ICON_SHARPCURVE, 4);      
-}
-
-static int testing123(bContext *C, wmOperator *op, wmEvent *event)
-{
-       uiMenuItem *head= uiPupMenuBegin("Hello world", 0);
-       
-       uiMenuContext(head, WM_OP_EXEC_DEFAULT);
-       uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_region_flip");
-       uiMenuItemO(head, ICON_PROP_CON, "SCREEN_OT_screen_full_area");
-       uiMenuItemO(head, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit");
-       uiMenuLevel(head, "Submenu", newlevel1);
-       uiMenuItemO(head, ICON_PROP_ON, "SCREEN_OT_area_rip");
-       
-       uiPupMenuEnd(C, head);
-       
-       /* this operator is only for a menu, not used further */
-       return OPERATOR_CANCELLED;
-}
 
 void SCREEN_OT_region_flip(wmOperatorType *ot)
 {
@@ -1736,26 +1988,78 @@ void SCREEN_OT_region_flip(wmOperatorType *ot)
        ot->idname= "SCREEN_OT_region_flip";
        
        /* api callbacks */
-       ot->invoke= testing123; // XXX WM_operator_confirm;
        ot->exec= region_flip_exec;
        
        ot->poll= ED_operator_areaactive;
        ot->flag= OPTYPE_REGISTER;
-       
-       RNA_def_int(ot->srna, "test", 0, INT_MIN, INT_MAX, "test", "", INT_MIN, INT_MAX);
 
 }
 
-/* ****************** anim player, typically with timer ***************** */
+/* ****************** anim player, with timer ***************** */
 
-static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
+static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
+{
+       if(regiontype==RGN_TYPE_WINDOW) {
+
+               switch (spacetype) {
+                       case SPACE_VIEW3D:
+                               if(redraws & TIME_ALL_3D_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_IPO:
+                       case SPACE_ACTION:
+                       case SPACE_NLA:
+                               if(redraws & TIME_ALL_ANIM_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_TIME:
+                               /* if only 1 window or 3d windows, we do timeline too */
+                               if(redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN))
+                                       return 1;
+                               break;
+                       case SPACE_BUTS:
+                               if(redraws & TIME_ALL_BUTS_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_SEQ:
+                               if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN))
+                                       return 1;
+                               break;
+                       case SPACE_IMAGE:
+                               if(redraws & TIME_ALL_IMAGE_WIN)
+                                       return 1;
+                               break;
+                               
+               }
+       }
+       else if(regiontype==RGN_TYPE_UI) {
+               if(redraws & TIME_ALL_BUTS_WIN)
+                       return 1;
+       }
+       else if(regiontype==RGN_TYPE_HEADER) {
+               if(spacetype==SPACE_TIME)
+                       return 1;
+       }
+       return 0;
+}
+
+static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
 {
        bScreen *screen= CTX_wm_screen(C);
        
        if(screen->animtimer==event->customdata) {
                Scene *scene= CTX_data_scene(C);
+               wmTimer *wt= screen->animtimer;
+               ScreenAnimData *sad= wt->customdata;
+               ScrArea *sa;
                
-               scene->r.cfra++;
+               if(scene->audio.flag & AUDIO_SYNC) {
+                       int step = floor(wt->duration * FPS);
+                       scene->r.cfra += step;
+                       wt->duration -= ((float)step)/FPS;
+               }
+               else
+                       scene->r.cfra++;
                
                if (scene->r.psfra) {
                        if(scene->r.cfra > scene->r.pefra)
@@ -1766,13 +2070,65 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
                                scene->r.cfra= scene->r.sfra;
                }
 
-               WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+               /* since we follow drawflags, we can't send notifier but tag regions ourselves */
+               ED_update_for_newframe(C, 1);
+               
+               for(sa= screen->areabase.first; sa; sa= sa->next) {
+                       ARegion *ar;
+                       for(ar= sa->regionbase.first; ar; ar= ar->next) {
+                               if(ar==sad->ar)
+                                       ED_region_tag_redraw(ar);
+                               else
+                                       if(match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
+                                               ED_region_tag_redraw(ar);
+                       }
+               }
+               
+               //WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
                
                return OPERATOR_FINISHED;
        }
        return OPERATOR_PASS_THROUGH;
 }
 
+static void SCREEN_OT_animation_step(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Animation Step";
+       ot->idname= "SCREEN_OT_animation_step";
+       
+       /* api callbacks */
+       ot->invoke= screen_animation_step;
+       
+       ot->poll= ED_operator_screenactive;
+       
+}
+
+/* ****************** anim player, starts or ends timer ***************** */
+
+/* toggle operator */
+static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
+{
+       bScreen *screen= CTX_wm_screen(C);
+       
+       if(screen->animtimer) {
+               ED_screen_animation_timer(C, 0, 0);
+       }
+       else {
+               /* todo: RNA properties to define play types */
+               ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, 1);
+               
+               if(screen->animtimer) {
+                       wmTimer *wt= screen->animtimer;
+                       ScreenAnimData *sad= wt->customdata;
+                       
+                       sad->ar= CTX_wm_region(C);
+               }
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
 void SCREEN_OT_animation_play(wmOperatorType *ot)
 {
        /* identifiers */
@@ -1784,6 +2140,7 @@ void SCREEN_OT_animation_play(wmOperatorType *ot)
        
        ot->poll= ED_operator_screenactive;
        
+       
 }
 
 /* ************** border select operator (template) ***************************** */
@@ -1859,7 +2216,7 @@ static ScrArea *biggest_non_image_area(bContext *C)
        short foundwin= 0;
        
        for(sa= sc->areabase.first; sa; sa= sa->next) {
-               if(sa->winx > 10 && sa->winy > 10) {
+               if(sa->winx > 30 && sa->winy > 30) {
                        size= sa->winx*sa->winy;
                        if(sa->spacetype == SPACE_BUTS) {
                                if(foundwin == 0 && size > bwmaxsize) {
@@ -2019,15 +2376,16 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
                        return;
                
                /* xmin here is first subrect x coord, xmax defines subrect width */
-               xmin = renrect->xmin;
-               xmax = renrect->xmax - xmin;
+               xmin = renrect->xmin + rr->crop;
+               xmax = renrect->xmax - xmin - rr->crop;
                if (xmax<2) return;
                
-               ymin= renrect->ymin;
-               ymax= renrect->ymax - ymin;
+               ymin= renrect->ymin + rr->crop;
+               ymax= renrect->ymax - ymin - rr->crop;
                if(ymax<2)
                        return;
                renrect->ymin= renrect->ymax;
+               
        }
        else {
                xmin = ymin = rr->crop;
@@ -2045,6 +2403,7 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
                xmax= ibuf->x - rxmin;
        if(rymin + ymax > ibuf->y)
                ymax= ibuf->y - rymin;
+       
        if(xmax < 1 || ymax < 1) return;
        
        /* find current float rect for display, first case is after composit... still weak */
@@ -2067,11 +2426,14 @@ static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrec
                float *rf= rectf;
                char *rc= rectc;
                
-               for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
-                       rc[0]= FTOCHAR(rf[0]);
-                       rc[1]= FTOCHAR(rf[1]);
-                       rc[2]= FTOCHAR(rf[2]);
-                       rc[3]= FTOCHAR(rf[3]);
+               /* XXX temp. because crop offset */
+               if( rectc >= (char *)(ibuf->rect)) {
+                       for(x1= 0; x1<xmax; x1++, rf += 4, rc+=4) {
+                               rc[0]= FTOCHAR(rf[0]);
+                               rc[1]= FTOCHAR(rf[1]);
+                               rc[2]= FTOCHAR(rf[2]);
+                               rc[3]= FTOCHAR(rf[3]);
+                       }
                }
                rectf += 4*rr->rectx;
                rectc += 4*ibuf->x;
@@ -2106,6 +2468,22 @@ static int render_breakjob(void *rjv)
        return 0;
 }
 
+/* catch esc */
+static int screen_render_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+       /* no running blender, remove handler and pass through */
+       if(0==WM_jobs_test(CTX_wm_manager(C), CTX_data_scene(C)))
+          return OPERATOR_FINISHED|OPERATOR_PASS_THROUGH;
+       
+       /* running render */
+       switch (event->type) {
+               case ESCKEY:
+                       return OPERATOR_RUNNING_MODAL;
+                       break;
+       }
+       return OPERATOR_PASS_THROUGH;
+}
+
 /* using context, starts job */
 static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
@@ -2163,14 +2541,17 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        //      BKE_report in render!
        //      RE_error_cb(re, error_cb);
 
-       WM_jobs_start(steve);
+       WM_jobs_start(CTX_wm_manager(C), steve);
        
        G.afbreek= 0;
        
        WM_cursor_wait(0);
        WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
 
-       return OPERATOR_FINISHED;
+       /* add modal handler for ESC */
+       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       
+       return OPERATOR_RUNNING_MODAL;
 }
 
 
@@ -2183,6 +2564,7 @@ void SCREEN_OT_render(wmOperatorType *ot)
        
        /* api callbacks */
        ot->invoke= screen_render_invoke;
+       ot->modal= screen_render_modal;
        ot->exec= screen_render_exec;
        
        ot->poll= ED_operator_screenactive;
@@ -2200,12 +2582,18 @@ static int render_view_cancel_exec(bContext *C, wmOperator *unused)
        
        if(sima->flag & SI_PREVSPACE) {
                sima->flag &= ~SI_PREVSPACE;
-               ED_area_prevspace(C);
+               
+               if(sima->flag & SI_FULLWINDOW) {
+                       sima->flag &= ~SI_FULLWINDOW;
+                       ED_screen_full_prevspace(C);
+               }
+               else
+                       ED_area_prevspace(C);
        }
        else if(sima->flag & SI_FULLWINDOW) {
                sima->flag &= ~SI_FULLWINDOW;
-               ED_screen_full_prevspace(C);
-       }
+               ed_screen_fullarea(C, sa);
+       }               
        
        return OPERATOR_FINISHED;
 }
@@ -2237,15 +2625,20 @@ void ED_operatortypes_screen(void)
        WM_operatortype_append(SCREEN_OT_area_move);
        WM_operatortype_append(SCREEN_OT_area_split);
        WM_operatortype_append(SCREEN_OT_area_join);
-       WM_operatortype_append(SCREEN_OT_area_rip);
+       WM_operatortype_append(SCREEN_OT_area_dupli);
+       WM_operatortype_append(SCREEN_OT_area_swap);
        WM_operatortype_append(SCREEN_OT_region_split);
        WM_operatortype_append(SCREEN_OT_region_foursplit);
        WM_operatortype_append(SCREEN_OT_region_flip);
+       WM_operatortype_append(SCREEN_OT_region_scale);
        WM_operatortype_append(SCREEN_OT_screen_set);
        WM_operatortype_append(SCREEN_OT_screen_full_area);
+       WM_operatortype_append(SCREEN_OT_screenshot);
+       WM_operatortype_append(SCREEN_OT_screencast);
        
        /*frame changes*/
        WM_operatortype_append(SCREEN_OT_frame_offset);
+       WM_operatortype_append(SCREEN_OT_animation_step);
        WM_operatortype_append(SCREEN_OT_animation_play);
        
        /* render */
@@ -2264,19 +2657,28 @@ void ED_keymap_screen(wmWindowManager *wm)
        ListBase *keymap= WM_keymap_listbase(wm, "Screen", 0, 0);
        
        /* standard timers */
-       WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", TIMER0, KM_ANY, KM_ANY, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
        
-       WM_keymap_verify_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0);
+       RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0);
+       RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1);
+       RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "modifier", 2);
        
+       /* screen tools */
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_dupli", EVT_ACTIONZONE_AREA, 0, KM_SHIFT, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_swap", EVT_ACTIONZONE_AREA, 0, KM_ALT, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_region_scale", EVT_ACTIONZONE_REGION, 0, 0, 0);
+                       /* area move after action zones */
        WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE, 0, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE, 0, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_rip", RKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
        WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", DOWNARROWKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", SPACEKEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_screenshot", F3KEY, KM_PRESS, KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_screencast", F3KEY, KM_PRESS, KM_ALT, 0);
 
         /* tests */
        WM_keymap_add_item(keymap, "SCREEN_OT_region_split", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
@@ -2286,10 +2688,13 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
+       
+       RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", F7KEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
+       WM_keymap_verify_item(keymap, "SCRIPT_OT_python_run_ui_scripts", F8KEY, KM_PRESS, 0, 0);
 
        /* files */
-       WM_keymap_add_item(keymap, "ED_FILE_OT_load", RETKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "ED_FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "FILE_OT_exec", RETKEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "FILE_OT_cancel", ESCKEY, KM_PRESS, 0, 0);
        
        /* undo */
        WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_CTRL, 0);
@@ -2301,12 +2706,13 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0);
        
-       /* frame offsets */
+       /* frame offsets & play */
        keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
        
 }