RNA
[blender-staging.git] / source / blender / editors / screen / screen_ops.c
index cb45f1a2680216b08d45b0271598adfa3ced77f5..dae7a7cedd5e76627b0c99d5b12fc8c890f62ae0 100644 (file)
  * ***** END GPL LICENSE BLOCK *****
  */
 
+#include <math.h>
+
 #include "MEM_guardedalloc.h"
 
-#include "BLI_blenlib.h"
 #include "BLI_arithb.h"
-
+#include "BLI_blenlib.h"
+#include "BLI_editVert.h"
+
+#include "DNA_armature_types.h"
+#include "DNA_image_types.h"
+#include "DNA_object_types.h"
+#include "DNA_mesh_types.h"
+#include "DNA_curve_types.h"
+#include "DNA_scene_types.h"
+
+#include "BKE_blender.h"
+#include "BKE_context.h"
+#include "BKE_customdata.h"
 #include "BKE_global.h"
+#include "BKE_image.h"
+#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"
 #include "BKE_utildefines.h"
 
 #include "WM_api.h"
 #include "WM_types.h"
 
-#include "ED_markers.h"
+#include "ED_util.h"
 #include "ED_screen.h"
+#include "ED_mesh.h"
 #include "ED_screen_types.h"
 
+#include "RE_pipeline.h"
+#include "IMB_imbuf.h"
+#include "IMB_imbuf_types.h"
+
 #include "RNA_access.h"
 #include "RNA_define.h"
 
+#include "UI_interface.h"
+#include "UI_resources.h"
+
 #include "screen_intern.h"     /* own module include */
 
 /* ************** 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(C->window==NULL) return 0;
-       if(C->screen==NULL) return 0;
-       if(C->area==NULL) return 0;
+       if(CTX_wm_window(C)==NULL) return 0;
+       if(CTX_wm_screen(C)==NULL) return 0;
+       if(CTX_wm_area(C)==NULL) return 0;
        return 1;
 }
 
 int ED_operator_screenactive(bContext *C)
 {
-       if(C->window==NULL) return 0;
-       if(C->screen==NULL) return 0;
+       if(CTX_wm_window(C)==NULL) return 0;
+       if(CTX_wm_screen(C)==NULL) return 0;
        return 1;
 }
 
 /* when mouse is over area-edge */
 int ED_operator_screen_mainwinactive(bContext *C)
 {
-       if(C->window==NULL) return 0;
-       if(C->screen==NULL) return 0;
-       if (C->screen->subwinactive!=C->screen->mainwin) return 0;
+       if(CTX_wm_window(C)==NULL) return 0;
+       if(CTX_wm_screen(C)==NULL) return 0;
+       if (CTX_wm_screen(C)->subwinactive!=CTX_wm_screen(C)->mainwin) return 0;
        return 1;
 }
 
+int ED_operator_scene_editable(bContext *C)
+{
+       Scene *scene= CTX_data_scene(C);
+       if(scene && scene->id.lib==NULL)
+               return 1;
+       return 0;
+}
+
+static int ed_spacetype_test(bContext *C, int type)
+{
+       if(ED_operator_areaactive(C)) {
+               SpaceLink *sl= (SpaceLink *)CTX_wm_space_data(C);
+               return sl && (sl->spacetype == type);
+       }
+       return 0;
+}
+
+int ED_operator_view3d_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_VIEW3D);
+}
+
+int ED_operator_timeline_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_TIME);
+}
+
+int ED_operator_outliner_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_OUTLINER);
+}
+
+int ED_operator_file_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_FILE);
+}
+
+int ED_operator_action_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_ACTION);
+}
+
+int ED_operator_buttons_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_BUTS);
+}
+
+int ED_operator_node_active(bContext *C)
+{
+       if(ed_spacetype_test(C, SPACE_NODE)) {
+               SpaceNode *snode= (SpaceNode *)CTX_wm_space_data(C);
+               if(snode->edittree)
+                       return 1;
+       }
+       return 0;
+}
+
+int ED_operator_ipo_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_IPO);
+}
+
+int ED_operator_sequencer_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_SEQ);
+}
+
+int ED_operator_image_active(bContext *C)
+{
+       return ed_spacetype_test(C, SPACE_IMAGE);
+}
+
+int ED_operator_object_active(bContext *C)
+{
+       return NULL != CTX_data_active_object(C);
+}
+
+int ED_operator_editmesh(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_MESH)
+               return NULL != ((Mesh *)obedit->data)->edit_mesh;
+       return 0;
+}
+
+int ED_operator_editarmature(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       if(obedit && obedit->type==OB_ARMATURE)
+               return NULL != ((bArmature *)obedit->data)->edbo;
+       return 0;
+}
+
+int ED_operator_posemode(bContext *C)
+{
+       Object *obact= CTX_data_active_object(C);
+       Object *obedit= CTX_data_edit_object(C);
+       
+       if ((obact != obedit) && (obact) && (obact->type==OB_ARMATURE))
+               return (obact->flag & OB_POSEMODE)!=0;
+               
+       return 0;
+}
+
+
+int ED_operator_uvedit(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= NULL;
+
+       if(obedit && obedit->type==OB_MESH)
+               em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+
+       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;
+}
+
+int ED_operator_uvmap(bContext *C)
+{
+       Object *obedit= CTX_data_edit_object(C);
+       EditMesh *em= NULL;
+
+       if(obedit && obedit->type==OB_MESH)
+               em= BKE_mesh_get_editmesh((Mesh *)obedit->data);
+
+       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 != ((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 ************************** */
 
 /* operator state vars used:  
@@ -101,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 */
@@ -117,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;
+}
 
-static AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
+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(C->area, 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= C->area;
-       sad->az= az;
-       sad->x= event->x; sad->y= event->y;
-       
-       /* add modal handler */
-       WM_event_add_modal_handler(C, &C->window->handlers, op);
-       
-       return OPERATOR_RUNNING_MODAL;
-}
 
 static void actionzone_exit(bContext *C, wmOperator *op)
 {
@@ -166,23 +379,61 @@ 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= *(C->window->eventstate);        /* XXX huh huh? make api call */
-       event.type= EVT_ACTIONZONE;
+       event= *(win->eventstate);      /* XXX huh huh? make api call */
+       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;
        
-       wm_event_add(C->window, &event);
+       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:
@@ -191,160 +442,221 @@ 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(C->screen, event->x, event->y);
+                               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;
 }
 
-void ED_SCR_OT_actionzone(wmOperatorType *ot)
+void SCREEN_OT_actionzone(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Handle area action zones";
-       ot->idname= "ED_SCR_OT_actionzone";
+       ot->idname= "SCREEN_OT_actionzone";
        
        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);
 }
 
-/* ****************** cursor near edge operator ********************************* */
+/* ************** swap area operator *********************************** */
 
-static int scredge_is_horizontal(ScrEdge *se)
-{
-       return (se->v1->vec.y == se->v2->vec.y);
-}
+/* 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
 
-static ScrEdge *screen_find_active_scredge(bScreen *sc, int mx, int my)
+       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)
 {
-       ScrEdge *se;
-       
-       for (se= sc->edgebase.first; se; se= se->next) {
-               if (scredge_is_horizontal(se)) {
-                       short min, max;
-                       min= MIN2(se->v1->vec.x, se->v2->vec.x);
-                       max= MAX2(se->v1->vec.x, se->v2->vec.x);
-                       
-                       if (abs(my-se->v1->vec.y)<=2 && mx>=min && mx<=max)
-                               return se;
-               } 
-               else {
-                       short min, max;
-                       min= MIN2(se->v1->vec.y, se->v2->vec.y);
-                       max= MAX2(se->v1->vec.y, se->v2->vec.y);
-                       
-                       if (abs(mx-se->v1->vec.x)<=2 && my>=min && my<=max)
-                               return se;
-               }
-       }
+       sAreaSwapData *sd= NULL;
+       sActionzoneData *sad= event->customdata;
+
+       if(sad==NULL || sad->sa1==NULL)
+                                       return 0;
        
-       return NULL;
+       sd= MEM_callocN(sizeof(sAreaSwapData), "sAreaSwapData");
+       sd->sa1= sad->sa1;
+       sd->sa2= sad->sa2;
+       op->customdata= sd;
+
+       return 1;
 }
 
 
-/* operator cb */
-static int screen_cursor_test(bContext *C, wmOperator *op, wmEvent *event)
+static void area_swap_exit(bContext *C, wmOperator *op)
 {
-       if (C->screen->subwinactive==C->screen->mainwin) {
-               ScrEdge *actedge= screen_find_active_scredge(C->screen, event->x, event->y);
-               
-               if (actedge && scredge_is_horizontal(actedge)) {
-                       WM_set_cursor(C, CURSOR_Y_MOVE);
-               } else {
-                       WM_set_cursor(C, CURSOR_X_MOVE);
-               }
-       } 
-       else {
-               ScrArea *sa= NULL;
-               AZone *az= NULL;
-               
-               for(sa= C->screen->areabase.first; sa; sa= sa->next) {
-                       az= is_in_area_actionzone(sa, event->x, event->y);
-                       if(az!=NULL) break;
-               }
-               
-               if(az!=NULL) WM_set_cursor(C, CURSOR_EDIT);
-               else WM_set_cursor(C, CURSOR_STD);
-       }
-       
-       return OPERATOR_PASS_THROUGH;
+       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 void ED_SCR_OT_cursor_type(wmOperatorType *ot)
+static int area_swap_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-    ot->name= "Cursor type";
-    ot->idname= "ED_SCR_OT_cursor_type";
+
+       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);
        
-    ot->invoke= screen_cursor_test;
-    ot->poll= ED_operator_screenactive;
+       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 *win;
-       bScreen *newsc;
+       wmWindow *newwin, *win;
+       bScreen *newsc, *sc;
+       ScrArea *sa;
        rcti rect;
        
+       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(C->screen->full != SCREENNORMAL) 
+       if(sc->full != SCREENNORMAL) {
+               if(event->type==EVT_ACTIONZONE_AREA)
+                       actionzone_exit(C, op);
                return OPERATOR_CANCELLED;
+       }
        
        /* adds window to WM */
-       rect= C->area->totrct;
-       BLI_translate_rcti(&rect, C->window->posx, C->window->posy);
-       win= WM_window_open(C, &rect);
+       rect= sa->totrct;
+       BLI_translate_rcti(&rect, win->posx, win->posy);
+       newwin= WM_window_open(C, &rect);
        
        /* allocs new screen and adds to newly created window, using window size */
-       newsc= screen_add(win, C->screen->id.name+2);
+       newsc= screen_add(newwin, CTX_data_scene(C), sc->id.name+2);
+       newwin->screen= newsc;
        
        /* copy area to new screen */
-       area_copy_data((ScrArea *)newsc->areabase.first, C->area, 0);
+       area_copy_data((ScrArea *)newsc->areabase.first, sa, 0);
        
        /* screen, areas init */
-       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+
+       if(event->type==EVT_ACTIONZONE_AREA)
+               actionzone_exit(C, op);
        
        return OPERATOR_FINISHED;
 }
 
-void ED_SCR_OT_area_rip(wmOperatorType *ot)
+static void SCREEN_OT_area_dupli(wmOperatorType *ot)
 {
-       ot->name= "Rip Area into New Window";
-       ot->idname= "ED_SCR_OT_area_rip";
+       ot->name= "Duplicate Area into New Window";
+       ot->idname= "SCREEN_OT_area_dupli";
        
-       ot->invoke= NULL; //WM_operator_confirm;
-       ot->exec= screen_area_rip_op;
+       ot->invoke= area_dupli_invoke;
        ot->poll= ED_operator_areaactive;
 }
 
@@ -419,6 +731,7 @@ static void area_move_set_limits(bScreen *sc, int dir, int *bigger, int *smaller
 /* return 0: init failed */
 static int area_move_init (bContext *C, wmOperator *op)
 {
+       bScreen *sc= CTX_wm_screen(C);
        ScrEdge *actedge;
        sAreaMoveData *md;
        int x, y;
@@ -428,7 +741,7 @@ static int area_move_init (bContext *C, wmOperator *op)
        y= RNA_int_get(op->ptr, "y");
 
        /* setup */
-       actedge= screen_find_active_scredge(C->screen, x, y);
+       actedge= screen_find_active_scredge(sc, x, y);
        if(actedge==NULL) return 0;
 
        md= MEM_callocN(sizeof(sAreaMoveData), "sAreaMoveData");
@@ -438,10 +751,10 @@ static int area_move_init (bContext *C, wmOperator *op)
        if(md->dir=='h') md->origval= actedge->v1->vec.y;
        else md->origval= actedge->v1->vec.x;
        
-       select_connected_scredge(C->screen, actedge);
+       select_connected_scredge(sc, actedge);
        /* now all vertices with 'flag==1' are the ones that can be moved. */
 
-       area_move_set_limits(C->screen, md->dir, &md->bigger, &md->smaller);
+       area_move_set_limits(sc, md->dir, &md->bigger, &md->smaller);
        
        return 1;
 }
@@ -449,31 +762,33 @@ static int area_move_init (bContext *C, wmOperator *op)
 /* moves selected screen edge amount of delta, used by split & move */
 static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int bigger, int smaller)
 {
+       wmWindow *win= CTX_wm_window(C);
+       bScreen *sc= CTX_wm_screen(C);
        ScrVert *v1;
        
        delta= CLAMPIS(delta, -smaller, bigger);
        
-       for (v1= C->screen->vertbase.first; v1; v1= v1->next) {
+       for (v1= sc->vertbase.first; v1; v1= v1->next) {
                if (v1->flag) {
                        /* that way a nice AREAGRID  */
-                       if((dir=='v') && v1->vec.x>0 && v1->vec.x<C->window->sizex-1) {
+                       if((dir=='v') && v1->vec.x>0 && v1->vec.x<win->sizex-1) {
                                v1->vec.x= origval + delta;
                                if(delta != bigger && delta != -smaller) v1->vec.x-= (v1->vec.x % AREAGRID);
                        }
-                       if((dir=='h') && v1->vec.y>0 && v1->vec.y<C->window->sizey-1) {
+                       if((dir=='h') && v1->vec.y>0 && v1->vec.y<win->sizey-1) {
                                v1->vec.y= origval + delta;
 
                                v1->vec.y+= AREAGRID-1;
                                v1->vec.y-= (v1->vec.y % AREAGRID);
                                
                                /* prevent too small top header */
-                               if(v1->vec.y > C->window->sizey-AREAMINY)
-                                       v1->vec.y= C->window->sizey-AREAMINY;
+                               if(v1->vec.y > win->sizey-AREAMINY)
+                                       v1->vec.y= win->sizey-AREAMINY;
                        }
                }
        }
 
-       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
 }
 
 static void area_move_apply(bContext *C, wmOperator *op)
@@ -492,8 +807,8 @@ static void area_move_exit(bContext *C, wmOperator *op)
        op->customdata= NULL;
        
        /* this makes sure aligned edges will result in aligned grabbing */
-       removedouble_scrverts(C->screen);
-       removedouble_scredges(C->screen);
+       removedouble_scrverts(CTX_wm_screen(C));
+       removedouble_scredges(CTX_wm_screen(C));
 }
 
 static int area_move_exec(bContext *C, wmOperator *op)
@@ -517,7 +832,7 @@ static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event)
                return OPERATOR_PASS_THROUGH;
        
        /* add temp handler */
-       WM_event_add_modal_handler(C, &C->window->handlers, op);
+       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
        
        return OPERATOR_RUNNING_MODAL;
 }
@@ -566,13 +881,11 @@ static int area_move_modal(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
-void ED_SCR_OT_area_move(wmOperatorType *ot)
+void SCREEN_OT_area_move(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
-
        /* identifiers */
        ot->name= "Move area edges";
-       ot->idname= "ED_SCR_OT_area_move";
+       ot->idname= "SCREEN_OT_area_move";
 
        ot->exec= area_move_exec;
        ot->invoke= area_move_invoke;
@@ -582,9 +895,9 @@ void ED_SCR_OT_area_move(wmOperatorType *ot)
        ot->poll= ED_operator_screen_mainwinactive; /* when mouse is over area-edge */
 
        /* rna */
-       prop= RNA_def_property(ot->srna, "x", PROP_INT, PROP_NONE);
-       prop= RNA_def_property(ot->srna, "y", PROP_INT, PROP_NONE);
-       prop= RNA_def_property(ot->srna, "delta", PROP_INT, PROP_NONE);
+       RNA_def_int(ot->srna, "x", 0, INT_MIN, INT_MAX, "X", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "y", 0, INT_MIN, INT_MAX, "Y", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
 }
 
 /* ************** split area operator *********************************** */
@@ -644,26 +957,27 @@ typedef struct sAreaSplitData
 /* generic init, no UI stuff here */
 static int area_split_init(bContext *C, wmOperator *op)
 {
+       ScrArea *sa= CTX_wm_area(C);
        sAreaSplitData *sd;
        int dir;
        
        /* required context */
-       if(C->area==NULL) return 0;
+       if(sa==NULL) return 0;
        
        /* required properties */
-       dir= RNA_enum_get(op->ptr, "dir");
+       dir= RNA_enum_get(op->ptr, "direction");
        
        /* minimal size */
-       if(dir=='v' && C->area->winx < 2*AREAMINX) return 0;
-       if(dir=='h' && C->area->winy < 2*AREAMINY) return 0;
+       if(dir=='v' && sa->winx < 2*AREAMINX) return 0;
+       if(dir=='h' && sa->winy < 2*AREAMINY) return 0;
           
        /* custom data */
        sd= (sAreaSplitData*)MEM_callocN(sizeof (sAreaSplitData), "op_area_split");
        op->customdata= sd;
        
-       sd->sarea= C->area;
-       sd->origsize= dir=='v' ? C->area->winx:C->area->winy;
-       sd->origmin = dir=='v' ? C->area->totrct.xmin:C->area->totrct.ymin;
+       sd->sarea= sa;
+       sd->origsize= dir=='v' ? sa->winx:sa->winy;
+       sd->origmin = dir=='v' ? sa->totrct.xmin:sa->totrct.ymin;
        
        return 1;
 }
@@ -701,22 +1015,23 @@ static ScrEdge *area_findsharededge(bScreen *screen, ScrArea *sa, ScrArea *sb)
 /* do the split, return success */
 static int area_split_apply(bContext *C, wmOperator *op)
 {
+       bScreen *sc= CTX_wm_screen(C);
        sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
        float fac;
        int dir;
        
-       fac= RNA_float_get(op->ptr, "fac");
-       dir= RNA_enum_get(op->ptr, "dir");
+       fac= RNA_float_get(op->ptr, "factor");
+       dir= RNA_enum_get(op->ptr, "direction");
 
-       sd->narea= area_split(C->window, C->screen, sd->sarea, dir, fac);
+       sd->narea= area_split(CTX_wm_window(C), sc, sd->sarea, dir, fac);
        
        if(sd->narea) {
                ScrVert *sv;
                
-               sd->nedge= area_findsharededge(C->screen, sd->sarea, sd->narea);
+               sd->nedge= area_findsharededge(sc, sd->sarea, sd->narea);
        
                /* select newly created edge, prepare for moving edge */
-               for(sv= C->screen->vertbase.first; sv; sv= sv->next)
+               for(sv= sc->vertbase.first; sv; sv= sv->next)
                        sv->flag = 0;
                
                sd->nedge->v1->flag= 1;
@@ -725,7 +1040,7 @@ static int area_split_apply(bContext *C, wmOperator *op)
                if(dir=='h') sd->origval= sd->nedge->v1->vec.y;
                else sd->origval= sd->nedge->v1->vec.x;
 
-               WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
                
                return 1;
        }               
@@ -740,11 +1055,11 @@ static void area_split_exit(bContext *C, wmOperator *op)
                op->customdata = NULL;
        }
        
-       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
 
        /* this makes sure aligned edges will result in aligned grabbing */
-       removedouble_scrverts(C->screen);
-       removedouble_scredges(C->screen);
+       removedouble_scrverts(CTX_wm_screen(C));
+       removedouble_scredges(CTX_wm_screen(C));
 }
 
 
@@ -753,28 +1068,36 @@ 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)
                        return OPERATOR_PASS_THROUGH;
                
                /* is this our *sad? if areas not equal it should be passed on */
-               if(C->area!=sad->sa1 || sad->sa1!=sad->sa2)
+               if(CTX_wm_area(C)!=sad->sa1 || sad->sa1!=sad->sa2)
                        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, "fac", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
+                       RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
                }
                else {
                        dir= 'v';
-                       RNA_float_set(op->ptr, "fac", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
+                       RNA_float_set(op->ptr, "factor", ((float)(event->y - sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
                }
-               RNA_enum_set(op->ptr, "dir", dir);
+               RNA_enum_set(op->ptr, "direction", dir);
 
                /* general init, also non-UI case, adds customdata, sets area and defaults */
                if(!area_split_init(C, op))
@@ -787,10 +1110,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
                
                /* do the split */
                if(area_split_apply(C, op)) {
-                       area_move_set_limits(C->screen, dir, &sd->bigger, &sd->smaller);
+                       area_move_set_limits(CTX_wm_screen(C), dir, &sd->bigger, &sd->smaller);
                        
                        /* add temp handler for edge move or cancel */
-                       WM_event_add_modal_handler(C, &C->window->handlers, op);
+                       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
                        
                        return OPERATOR_RUNNING_MODAL;
                }
@@ -822,9 +1145,10 @@ static int area_split_cancel(bContext *C, wmOperator *op)
 {
        sAreaSplitData *sd= (sAreaSplitData *)op->customdata;
 
-       if (screen_area_join(C, C->screen, sd->sarea, sd->narea)) {
-               if (C->area == sd->narea) {
-                       C->area = NULL;
+       if (screen_area_join(C, CTX_wm_screen(C), sd->sarea, sd->narea)) {
+               if (CTX_wm_area(C) == sd->narea) {
+                       CTX_wm_area_set(C, NULL);
+                       CTX_wm_region_set(C, NULL);
                }
                sd->narea = NULL;
        }
@@ -842,15 +1166,15 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
        /* execute the events */
        switch(event->type) {
                case MOUSEMOVE:
-                       dir= RNA_enum_get(op->ptr, "dir");
+                       dir= RNA_enum_get(op->ptr, "direction");
                        
                        sd->delta= (dir == 'v')? event->x - sd->origval: event->y - sd->origval;
                        area_move_apply_do(C, sd->origval, sd->delta, dir, sd->bigger, sd->smaller);
                        
                        fac= (dir == 'v') ? event->x-sd->origmin : event->y-sd->origmin;
-                       RNA_float_set(op->ptr, "fac", fac / (float)sd->origsize);
+                       RNA_float_set(op->ptr, "factor", fac / (float)sd->origsize);
                        
-                       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+                       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
                        break;
                        
                case LEFTMOUSE:
@@ -868,16 +1192,14 @@ 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 ED_SCR_OT_area_split(wmOperatorType *ot)
+void SCREEN_OT_area_split(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
-
        ot->name = "Split area";
-       ot->idname = "ED_SCR_OT_area_split";
+       ot->idname = "SCREEN_OT_area_split";
        
        ot->exec= area_split_exec;
        ot->invoke= area_split_invoke;
@@ -887,15 +1209,232 @@ void ED_SCR_OT_area_split(wmOperatorType *ot)
        ot->flag= OPTYPE_REGISTER;
        
        /* rna */
-       prop= RNA_def_property(ot->srna, "dir", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_items(prop, prop_direction_items);
-       RNA_def_property_enum_default(prop, 'h');
+       RNA_def_enum(ot->srna, "direction", prop_direction_items, 'h', "Direction", "");
+       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;
 
-       prop= RNA_def_property(ot->srna, "fac", PROP_FLOAT, PROP_NONE);
-       RNA_def_property_range(prop, 0.0, 1.0);
-       RNA_def_property_float_default(prop, 0.5f);
+                               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 ***************************** */
+
+
+/* function to be called outside UI context, or for redo */
+static int frame_offset_exec(bContext *C, wmOperator *op)
+{
+       int delta;
+
+       delta = RNA_int_get(op->ptr, "delta");
+
+       CTX_data_scene(C)->r.cfra += delta;
+
+       WM_event_add_notifier(C, NC_SCENE|ND_FRAME, CTX_data_scene(C));
+
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_frame_offset(wmOperatorType *ot)
+{
+       ot->name = "Frame Offset";
+       ot->idname = "SCREEN_OT_frame_offset";
+
+       ot->exec= frame_offset_exec;
+
+       ot->poll= ED_operator_screenactive;
+       ot->flag= 0;
+
+       /* rna */
+       RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
+}
+
+/* ************** switch screen operator ***************************** */
+
+
+/* function to be called outside UI context, or for redo */
+static int screen_set_exec(bContext *C, wmOperator *op)
+{
+       bScreen *screen= CTX_wm_screen(C);
+       ScrArea *sa= CTX_wm_area(C);
+       int tot= BLI_countlist(&CTX_data_main(C)->screen);
+       int delta= RNA_int_get(op->ptr, "delta");
+       
+       /* this screen is 'fake', solve later XXX */
+       if(sa && sa->full)
+               return OPERATOR_CANCELLED;
+       
+       if(delta==1) {
+               while(tot--) {
+                       screen= screen->id.next;
+                       if(screen==NULL) screen= CTX_data_main(C)->screen.first;
+                       if(screen->winid==0 && screen->full==0)
+                               break;
+               }
+       }
+       else if(delta== -1) {
+               while(tot--) {
+                       screen= screen->id.prev;
+                       if(screen==NULL) screen= CTX_data_main(C)->screen.last;
+                       if(screen->winid==0 && screen->full==0)
+                               break;
+               }
+       }
+       else {
+               screen= NULL;
+       }
+       
+       if(screen) {
+               ED_screen_set(C, screen);
+               return OPERATOR_FINISHED;
+       }
+       return OPERATOR_CANCELLED;
+}
+
+void SCREEN_OT_screen_set(wmOperatorType *ot)
+{
+       ot->name = "Set Screen";
+       ot->idname = "SCREEN_OT_screen_set";
+       
+       ot->exec= screen_set_exec;
+       ot->poll= ED_operator_screenactive;
+       
+       /* rna */
+       RNA_def_pointer_runtime(ot->srna, "screen", &RNA_Screen, "Screen", "");
+       RNA_def_int(ot->srna, "delta", 0, INT_MIN, INT_MAX, "Delta", "", INT_MIN, INT_MAX);
+}
+
+/* ************** screen full-area operator ***************************** */
+
+
+/* function to be called outside UI context, or for redo */
+static int screen_full_area_exec(bContext *C, wmOperator *op)
+{
+       ed_screen_fullarea(C, CTX_wm_area(C));
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_screen_full_area(wmOperatorType *ot)
+{
+       ot->name = "Toggle Make Area Fullscreen";
+       ot->idname = "SCREEN_OT_screen_full_area";
+       
+       ot->exec= screen_full_area_exec;
+       ot->poll= ED_operator_areaactive;
+       ot->flag= 0;
+
+}
+
+
+
 /* ************** join area operator ********************************************** */
 
 /* operator state vars used:  
@@ -951,8 +1490,8 @@ static int area_join_init(bContext *C, wmOperator *op)
        x2= RNA_int_get(op->ptr, "x2");
        y2= RNA_int_get(op->ptr, "y2");
        
-       sa1 = screen_areahascursor(C->screen, x1, y1);
-       sa2 = screen_areahascursor(C->screen, x2, y2);
+       sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1);
+       sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2);
        if(sa1==NULL || sa2==NULL || sa1==sa2)
                return 0;
 
@@ -974,11 +1513,12 @@ static int area_join_apply(bContext *C, wmOperator *op)
        sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
        if (!jd) return 0;
 
-       if(!screen_area_join(C, C->screen, jd->sa1, jd->sa2)){
+       if(!screen_area_join(C, CTX_wm_screen(C), jd->sa1, jd->sa2)){
                return 0;
        }
-       if (C->area == jd->sa2) {
-               C->area = NULL;
+       if (CTX_wm_area(C) == jd->sa2) {
+               CTX_wm_area_set(C, NULL);
+               CTX_wm_region_set(C, NULL);
        }
 
        return 1;
@@ -993,9 +1533,9 @@ static void area_join_exit(bContext *C, wmOperator *op)
        }
 
        /* this makes sure aligned edges will result in aligned grabbing */
-       removedouble_scredges(C->screen);
-       removenotused_scredges(C->screen);
-       removenotused_scrverts(C->screen);
+       removedouble_scredges(CTX_wm_screen(C));
+       removenotused_scredges(CTX_wm_screen(C));
+       removenotused_scrverts(CTX_wm_screen(C));
 }
 
 static int area_join_exec(bContext *C, wmOperator *op)
@@ -1013,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)
@@ -1034,7 +1578,7 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        return OPERATOR_PASS_THROUGH;
        
                /* add temp handler */
-               WM_event_add_modal_handler(C, &C->window->handlers, op);
+               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
        
                return OPERATOR_RUNNING_MODAL;
        }
@@ -1055,7 +1599,7 @@ static int area_join_cancel(bContext *C, wmOperator *op)
                jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
        }
 
-       WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+       WM_event_add_notifier(C, NC_WINDOW, NULL);
        
        area_join_exit(C, op);
 
@@ -1065,6 +1609,7 @@ static int area_join_cancel(bContext *C, wmOperator *op)
 /* modal callback while selecting area (space) that will be removed */
 static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
+       bScreen *sc= CTX_wm_screen(C);
        sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
        
        /* execute the events */
@@ -1072,12 +1617,12 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                        
                case MOUSEMOVE: 
                        {
-                               ScrArea *sa = screen_areahascursor(C->screen, event->x, event->y);
+                               ScrArea *sa = screen_areahascursor(sc, event->x, event->y);
                                int dir;
                                
                                if (sa) {                                       
                                        if (jd->sa1 != sa) {
-                                               dir = area_getorientation(C->screen, jd->sa1, sa);
+                                               dir = area_getorientation(sc, jd->sa1, sa);
                                                if (dir >= 0) {
                                                        if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
                                                        jd->sa2 = sa;
@@ -1088,7 +1633,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                                                           we check if area has common border with the one marked for removal
                                                           in this case we can swap areas.
                                                        */
-                                                       dir = area_getorientation(C->screen, sa, jd->sa2);
+                                                       dir = area_getorientation(sc, sa, jd->sa2);
                                                        if (dir >= 0) {
                                                                if (jd->sa1) jd->sa1->flag &= ~AREA_FLAG_DRAWJOINFROM;
                                                                if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
@@ -1102,7 +1647,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                                                                jd->sa2 = NULL;
                                                        }
                                                }
-                                               WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+                                               WM_event_add_notifier(C, NC_WINDOW, NULL);
                                        } 
                                        else {
                                                /* we are back in the area previously selected for keeping 
@@ -1114,20 +1659,20 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                                                        jd->sa2 = sa;
                                                        if (jd->sa1) jd->sa1->flag |= AREA_FLAG_DRAWJOINFROM;
                                                        if (jd->sa2) jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
-                                                       dir = area_getorientation(C->screen, jd->sa1, jd->sa2);
+                                                       dir = area_getorientation(sc, jd->sa1, jd->sa2);
                                                        if (dir < 0) {
                                                                printf("oops, didn't expect that!\n");
                                                        }
                                                } 
                                                else {
-                                                       dir = area_getorientation(C->screen, jd->sa1, sa);
+                                                       dir = area_getorientation(sc, jd->sa1, sa);
                                                        if (dir >= 0) {
                                                                if (jd->sa2) jd->sa2->flag &= ~AREA_FLAG_DRAWJOINTO;
                                                                jd->sa2 = sa;
                                                                jd->sa2->flag |= AREA_FLAG_DRAWJOINTO;
                                                        }
                                                }
-                                               WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
+                                               WM_event_add_notifier(C, NC_WINDOW, NULL);
                                        }
                                }
                        }
@@ -1135,7 +1680,7 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
                case LEFTMOUSE:
                        if(event->val==0) {
                                area_join_apply(C, op);
-                               WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
+                               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
                                area_join_exit(C, op);
                                return OPERATOR_FINISHED;
                        }
@@ -1149,51 +1694,43 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event)
 }
 
 /* Operator for joining two areas (space types) */
-void ED_SCR_OT_area_join(wmOperatorType *ot)
+void SCREEN_OT_area_join(wmOperatorType *ot)
 {
-       PropertyRNA *prop;
-
        /* identifiers */
        ot->name= "Join area";
-       ot->idname= "ED_SCR_OT_area_join";
+       ot->idname= "SCREEN_OT_area_join";
        
        /* api callbacks */
        ot->exec= area_join_exec;
        ot->invoke= area_join_invoke;
        ot->modal= area_join_modal;
 
-       ot->poll= ED_operator_screenactive;
+       ot->poll= ED_operator_areaactive;
 
        /* rna */
-       prop= RNA_def_property(ot->srna, "x1", PROP_INT, PROP_NONE);
-       RNA_def_property_int_default(prop, -100);
-       prop= RNA_def_property(ot->srna, "y1", PROP_INT, PROP_NONE);
-       RNA_def_property_int_default(prop, -100);
-       prop= RNA_def_property(ot->srna, "x2", PROP_INT, PROP_NONE);
-       RNA_def_property_int_default(prop, -100);
-       prop= RNA_def_property(ot->srna, "y2", PROP_INT, PROP_NONE);
-       RNA_def_property_int_default(prop, -100);
+       RNA_def_int(ot->srna, "x1", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "y1", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "x2", -100, INT_MIN, INT_MAX, "X 2", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "y2", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX);
 }
 
 /* ************** repeat last operator ***************************** */
 
 static int repeat_last_exec(bContext *C, wmOperator *op)
 {
-       wmOperator *lastop= C->wm->operators.last;
+       wmOperator *lastop= CTX_wm_manager(C)->operators.last;
        
-       if(lastop) {
-               printf("repeat %s\n", lastop->type->idname);
-               lastop->type->exec(C, lastop);
-       }
+       if(lastop)
+               WM_operator_repeat(C, lastop);
        
-       return OPERATOR_FINISHED;
+       return OPERATOR_CANCELLED;
 }
 
-void ED_SCR_OT_repeat_last(wmOperatorType *ot)
+void SCREEN_OT_repeat_last(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Repeat Last";
-       ot->idname= "ED_SCR_OT_repeat_last";
+       ot->idname= "SCREEN_OT_repeat_last";
        
        /* api callbacks */
        ot->exec= repeat_last_exec;
@@ -1202,60 +1739,409 @@ void ED_SCR_OT_repeat_last(wmOperatorType *ot)
        
 }
 
+static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       wmOperator *lastop;
+       uiPopupMenu *pup;
+       uiLayout *layout;
+       int items, i;
+       
+       items= BLI_countlist(&wm->operators);
+       if(items==0)
+               return OPERATOR_CANCELLED;
+       
+       pup= uiPupMenuBegin(C, op->type->name, 0);
+       layout= uiPupMenuLayout(pup);
+
+       for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
+               uiItemIntO(layout, lastop->type->name, 0, op->type->idname, "index", i);
+
+       uiPupMenuEnd(C, pup);
+       
+       return OPERATOR_CANCELLED;
+}
+
+static int repeat_history_exec(bContext *C, wmOperator *op)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       
+       op= BLI_findlink(&wm->operators, RNA_int_get(op->ptr, "index"));
+       if(op) {
+               /* let's put it as last operator in list */
+               BLI_remlink(&wm->operators, op);
+               BLI_addtail(&wm->operators, op);
+               
+               WM_operator_repeat(C, op);
+       }
+                                        
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_repeat_history(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Repeat History";
+       ot->idname= "SCREEN_OT_repeat_history";
+       
+       /* api callbacks */
+       ot->invoke= repeat_history_invoke;
+       ot->exec= repeat_history_exec;
+       
+       ot->poll= ED_operator_screenactive;
+       
+       RNA_def_int(ot->srna, "index", 0, 0, INT_MAX, "Index", "", 0, 1000);
+}
+
+/* ********************** redo operator ***************************** */
+
+static int redo_last_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       wmWindowManager *wm= CTX_wm_manager(C);
+       wmOperator *lastop;
+
+       /* only for operators that are registered and did an undo push */
+       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;
+}
+
+void SCREEN_OT_redo_last(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Redo Last";
+       ot->idname= "SCREEN_OT_redo_last";
+       
+       /* api callbacks */
+       ot->invoke= redo_last_invoke;
+       
+       ot->poll= ED_operator_screenactive;
+}
+
 /* ************** region split operator ***************************** */
 
 /* insert a region in the area region list */
 static int region_split_exec(bContext *C, wmOperator *op)
 {
-       ARegion *newar= BKE_area_region_copy(C->region);
-       int dir= RNA_enum_get(op->ptr, "dir");
+       ARegion *ar= CTX_wm_region(C);
+       
+       if(ar->regiontype==RGN_TYPE_HEADER)
+               BKE_report(op->reports, RPT_ERROR, "Cannot split header");
+       else if(ar->alignment==RGN_ALIGN_QSPLIT)
+               BKE_report(op->reports, RPT_ERROR, "Cannot split further");
+       else {
+               ScrArea *sa= CTX_wm_area(C);
+               ARegion *newar= BKE_area_region_copy(sa->type, ar);
+               int dir= RNA_enum_get(op->ptr, "type");
+       
+               BLI_insertlinkafter(&sa->regionbase, ar, newar);
+               
+               newar->alignment= ar->alignment;
+               
+               if(dir=='h')
+                       ar->alignment= RGN_ALIGN_HSPLIT;
+               else
+                       ar->alignment= RGN_ALIGN_VSPLIT;
+               
+               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+       }
        
-       BLI_insertlinkafter(&C->area->regionbase, C->region, newar);
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_region_split(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Split Region";
+       ot->idname= "SCREEN_OT_region_split";
        
-       newar->alignment= C->region->alignment;
+       /* api callbacks */
+       ot->invoke= WM_menu_invoke;
+       ot->exec= region_split_exec;
+       ot->poll= ED_operator_areaactive;
        
-       if(dir=='h')
-               C->region->alignment= RGN_ALIGN_HSPLIT;
-       else
-               C->region->alignment= RGN_ALIGN_VSPLIT;
+       RNA_def_enum(ot->srna, "type", prop_direction_items, 'h', "Direction", "");
+}
+
+/* ************** region four-split operator ***************************** */
+
+/* insert a region in the area region list */
+static int region_foursplit_exec(bContext *C, wmOperator *op)
+{
+       ARegion *ar= CTX_wm_region(C);
+       
+       /* some rules... */
+       if(ar->regiontype!=RGN_TYPE_WINDOW)
+               BKE_report(op->reports, RPT_ERROR, "Only window region can be 4-splitted");
+       else if(ar->alignment==RGN_ALIGN_QSPLIT) {
+               ScrArea *sa= CTX_wm_area(C);
+               ARegion *arn;
+               
+               /* keep current region */
+               ar->alignment= 0;
+               
+               if(sa->spacetype==SPACE_VIEW3D) {
+                       RegionView3D *rv3d= ar->regiondata;
+                       rv3d->viewlock= 0;
+                       rv3d->rflag &= ~RV3D_CLIPPING;
+               }
+               
+               for(ar= sa->regionbase.first; ar; ar= arn) {
+                       arn= ar->next;
+                       if(ar->alignment==RGN_ALIGN_QSPLIT) {
+                               ED_region_exit(C, ar);
+                               BKE_area_region_free(sa->type, ar);
+                               BLI_remlink(&sa->regionbase, ar);
+                               MEM_freeN(ar);
+                       }
+               }
+               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+       }
+       else if(ar->next)
+               BKE_report(op->reports, RPT_ERROR, "Only last region can be 4-splitted");
+       else {
+               ScrArea *sa= CTX_wm_area(C);
+               ARegion *newar;
+               int count;
+               
+               ar->alignment= RGN_ALIGN_QSPLIT;
+               
+               for(count=0; count<3; count++) {
+                       newar= BKE_area_region_copy(sa->type, ar);
+                       BLI_addtail(&sa->regionbase, newar);
+               }
+               
+               /* lock views and set them */
+               if(sa->spacetype==SPACE_VIEW3D) {
+                       RegionView3D *rv3d;
+                       
+                       rv3d= ar->regiondata;
+                       rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_FRONT; rv3d->persp= V3D_ORTHO;
+                       
+                       ar= ar->next;
+                       rv3d= ar->regiondata;
+                       rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_TOP; rv3d->persp= V3D_ORTHO;
+                       
+                       ar= ar->next;
+                       rv3d= ar->regiondata;
+                       rv3d->viewlock= RV3D_LOCKED; rv3d->view= V3D_VIEW_RIGHT; rv3d->persp= V3D_ORTHO;
+                       
+                       ar= ar->next;
+                       rv3d= ar->regiondata;
+                       rv3d->view= V3D_VIEW_CAMERA; rv3d->persp= V3D_CAMOB;
+               }
+               
+               WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+       }
        
-       WM_event_add_notifier(C, WM_NOTE_SCREEN_CHANGED, 0, NULL);
        
        return OPERATOR_FINISHED;
 }
 
-static int region_split_invoke(bContext *C, wmOperator *op, wmEvent *evt)
+void SCREEN_OT_region_foursplit(wmOperatorType *ot)
 {
+       /* identifiers */
+       ot->name= "Split Region in 4 Parts";
+       ot->idname= "SCREEN_OT_region_foursplit";
        
-       /* can't do menu, so event is checked manually */
-       if(evt->shift)
-               RNA_enum_set(op->ptr, "dir", 'v');
-       else
-               RNA_enum_set(op->ptr, "dir", 'h');
-
-       return region_split_exec(C, op);
+       /* api callbacks */
+       ot->invoke= WM_operator_confirm;
+       ot->exec= region_foursplit_exec;
+       ot->poll= ED_operator_areaactive;
+       ot->flag= OPTYPE_REGISTER;
 }
 
 
-void ED_SCR_OT_region_split(wmOperatorType *ot)
+
+/* ************** region flip operator ***************************** */
+
+/* flip a region alignment */
+static int region_flip_exec(bContext *C, wmOperator *op)
 {
-       PropertyRNA *prop;
+       ARegion *ar= CTX_wm_region(C);
+
+       if(ar->alignment==RGN_ALIGN_TOP)
+               ar->alignment= RGN_ALIGN_BOTTOM;
+       else if(ar->alignment==RGN_ALIGN_BOTTOM)
+               ar->alignment= RGN_ALIGN_TOP;
+       else if(ar->alignment==RGN_ALIGN_LEFT)
+               ar->alignment= RGN_ALIGN_RIGHT;
+       else if(ar->alignment==RGN_ALIGN_RIGHT)
+               ar->alignment= RGN_ALIGN_LEFT;
        
+       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+       printf("executed region flip\n");
+       
+       return OPERATOR_FINISHED;
+}
+
+
+void SCREEN_OT_region_flip(wmOperatorType *ot)
+{
        /* identifiers */
-       ot->name= "Split Region";
-       ot->idname= "ED_SCR_OT_region_split";
+       ot->name= "Flip Region";
+       ot->idname= "SCREEN_OT_region_flip";
        
        /* api callbacks */
-       ot->exec= region_split_exec;
-       ot->invoke= region_split_invoke;
+       ot->exec= region_flip_exec;
        
        ot->poll= ED_operator_areaactive;
+       ot->flag= OPTYPE_REGISTER;
+
+}
+
+/* ****************** anim player, with timer ***************** */
+
+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;
+               
+               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)
+                               scene->r.cfra= scene->r.psfra;
+               }
+               else {
+                       if(scene->r.cfra > scene->r.efra)
+                               scene->r.cfra= scene->r.sfra;
+               }
+
+               /* 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;
        
-       prop= RNA_def_property(ot->srna, "dir", PROP_ENUM, PROP_NONE);
-       RNA_def_property_enum_items(prop, prop_direction_items);
-       RNA_def_property_enum_default(prop, 'h');
 }
 
+/* ****************** 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 */
+       ot->name= "Animation player";
+       ot->idname= "SCREEN_OT_animation_play";
+       
+       /* api callbacks */
+       ot->invoke= screen_animation_play;
+       
+       ot->poll= ED_operator_screenactive;
+       
+       
+}
 
 /* ************** border select operator (template) ***************************** */
 
@@ -1292,11 +2178,11 @@ static int border_select_do(bContext *C, wmOperator *op)
        return 1;
 }
 
-void ED_SCR_OT_border_select(wmOperatorType *ot)
+void SCREEN_OT_border_select(wmOperatorType *ot)
 {
        /* identifiers */
        ot->name= "Border select";
-       ot->idname= "ED_SCR_OT_border_select";
+       ot->idname= "SCREEN_OT_border_select";
        
        /* api callbacks */
        ot->exec= border_select_do;
@@ -1306,34 +2192,462 @@ void ED_SCR_OT_border_select(wmOperatorType *ot)
        ot->poll= ED_operator_areaactive;
        
        /* rna */
-       RNA_def_property(ot->srna, "event_type", PROP_INT, PROP_NONE);
-       RNA_def_property(ot->srna, "xmin", PROP_INT, PROP_NONE);
-       RNA_def_property(ot->srna, "xmax", PROP_INT, PROP_NONE);
-       RNA_def_property(ot->srna, "ymin", PROP_INT, PROP_NONE);
-       RNA_def_property(ot->srna, "ymax", PROP_INT, PROP_NONE);
+       RNA_def_int(ot->srna, "event_type", 0, INT_MIN, INT_MAX, "Event Type", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "xmin", 0, INT_MIN, INT_MAX, "X Min", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "xmax", 0, INT_MIN, INT_MAX, "X Max", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "ymin", 0, INT_MIN, INT_MAX, "Y Min", "", INT_MIN, INT_MAX);
+       RNA_def_int(ot->srna, "ymax", 0, INT_MIN, INT_MAX, "Y Max", "", INT_MIN, INT_MAX);
 
 }
 #endif
 
+/* ****************************** render invoking ***************** */
+
+/* set callbacks, exported to sequence render too. 
+Only call in foreground (UI) renders. */
+
+/* returns biggest area that is not uv/image editor. Note that it uses buttons */
+/* window as the last possible alternative.                                                                       */
+static ScrArea *biggest_non_image_area(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa, *big= NULL;
+       int size, maxsize= 0, bwmaxsize= 0;
+       short foundwin= 0;
+       
+       for(sa= sc->areabase.first; sa; sa= sa->next) {
+               if(sa->winx > 30 && sa->winy > 30) {
+                       size= sa->winx*sa->winy;
+                       if(sa->spacetype == SPACE_BUTS) {
+                               if(foundwin == 0 && size > bwmaxsize) {
+                                       bwmaxsize= size;
+                                       big= sa;        
+                               }
+                       }
+                       else if(sa->spacetype != SPACE_IMAGE && size > maxsize) {
+                               maxsize= size;
+                               big= sa;
+                               foundwin= 1;
+                       }
+               }
+       }
+       
+       return big;
+}
+
+static ScrArea *biggest_area(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa, *big= NULL;
+       int size, maxsize= 0;
+       
+       for(sa= sc->areabase.first; sa; sa= sa->next) {
+               size= sa->winx*sa->winy;
+               if(size > maxsize) {
+                       maxsize= size;
+                       big= sa;
+               }
+       }
+       return big;
+}
+
+
+static ScrArea *find_area_showing_r_result(bContext *C)
+{
+       bScreen *sc= CTX_wm_screen(C);
+       ScrArea *sa;
+       SpaceImage *sima;
+       
+       /* find an imagewindow showing render result */
+       for(sa=sc->areabase.first; sa; sa= sa->next) {
+               if(sa->spacetype==SPACE_IMAGE) {
+                       sima= sa->spacedata.first;
+                       if(sima->image && sima->image->type==IMA_TYPE_R_RESULT)
+                               break;
+               }
+       }
+       return sa;
+}
+
+static void screen_set_image_output(bContext *C)
+{
+       ScrArea *sa;
+       SpaceImage *sima;
+       
+       sa= find_area_showing_r_result(C);
+       
+       if(sa==NULL) {
+               /* find largest open non-image area */
+               sa= biggest_non_image_area(C);
+               if(sa) {
+                       ED_area_newspace(C, sa, SPACE_IMAGE);
+                       sima= sa->spacedata.first;
+                       
+                       /* makes ESC go back to prev space */
+                       sima->flag |= SI_PREVSPACE;
+               }
+               else {
+                       /* use any area of decent size */
+                       sa= biggest_area(C);
+                       if(sa->spacetype!=SPACE_IMAGE) {
+                               // XXX newspace(sa, SPACE_IMAGE);
+                               sima= sa->spacedata.first;
+                               
+                               /* makes ESC go back to prev space */
+                               sima->flag |= SI_PREVSPACE;
+                       }
+               }
+       }
+       
+       sima= sa->spacedata.first;
+       
+       /* get the correct image, and scale it */
+       sima->image= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+       
+       if(G.displaymode==2) { // XXX
+               if(sa->full==0) {
+                       sima->flag |= SI_FULLWINDOW;
+                       
+                       ed_screen_fullarea(C, sa);
+               }
+       }
+       
+}
+
+/* executes blocking render */
+static int screen_render_exec(bContext *C, wmOperator *op)
+{
+       Scene *scene= CTX_data_scene(C);
+       Render *re= RE_GetRender(scene->id.name);
+       
+       if(re==NULL) {
+               re= RE_NewRender(scene->id.name);
+       }
+       RE_test_break_cb(re, NULL, (int (*)(void *)) blender_test_break);
+       
+       if(RNA_boolean_get(op->ptr, "anim"))
+               RE_BlenderAnim(re, scene, scene->r.sfra, scene->r.efra, scene->frame_step);
+       else
+               RE_BlenderFrame(re, scene, scene->r.cfra);
+       
+       // no redraw needed, we leave state as we entered it
+       ED_update_for_newframe(C, 1);
+       
+       WM_event_add_notifier(C, NC_SCENE|ND_RENDER_RESULT, scene);
+
+       return OPERATOR_FINISHED;
+}
+
+typedef struct RenderJob {
+       Scene *scene;
+       Render *re;
+       wmWindow *win;
+       int anim;
+       Image *image;
+       ImageUser iuser;
+       short *stop;
+       short *do_update;
+} RenderJob;
+
+static void render_freejob(void *rjv)
+{
+       RenderJob *rj= rjv;
+       
+       MEM_freeN(rj);
+}
+
+/* called inside thread! */
+static void image_rect_update(void *rjv, RenderResult *rr, volatile rcti *renrect)
+{
+       RenderJob *rj= rjv;
+       ImBuf *ibuf;
+       float x1, y1, *rectf= NULL;
+       int ymin, ymax, xmin, xmax;
+       int rymin, rxmin;
+       char *rectc;
+       
+       ibuf= BKE_image_get_ibuf(rj->image, &rj->iuser);
+       if(ibuf==NULL) return;
+
+       /* if renrect argument, we only refresh scanlines */
+       if(renrect) {
+               /* if ymax==recty, rendering of layer is ready, we should not draw, other things happen... */
+               if(rr->renlay==NULL || renrect->ymax>=rr->recty)
+                       return;
+               
+               /* xmin here is first subrect x coord, xmax defines subrect width */
+               xmin = renrect->xmin + rr->crop;
+               xmax = renrect->xmax - xmin - rr->crop;
+               if (xmax<2) return;
+               
+               ymin= renrect->ymin + rr->crop;
+               ymax= renrect->ymax - ymin - rr->crop;
+               if(ymax<2)
+                       return;
+               renrect->ymin= renrect->ymax;
+               
+       }
+       else {
+               xmin = ymin = rr->crop;
+               xmax = rr->rectx - 2*rr->crop;
+               ymax = rr->recty - 2*rr->crop;
+       }
+       
+       /* xmin ymin is in tile coords. transform to ibuf */
+       rxmin= rr->tilerect.xmin + xmin;
+       if(rxmin >= ibuf->x) return;
+       rymin= rr->tilerect.ymin + ymin;
+       if(rymin >= ibuf->y) return;
+       
+       if(rxmin + xmax > ibuf->x)
+               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 */
+       if(rr->rectf)
+               rectf= rr->rectf;
+       else {
+               if(rr->rect32)
+                       return;
+               else {
+                       if(rr->renlay==NULL || rr->renlay->rectf==NULL) return;
+                       rectf= rr->renlay->rectf;
+               }
+       }
+       if(rectf==NULL) return;
+       
+       rectf+= 4*(rr->rectx*ymin + xmin);
+       rectc= (char *)(ibuf->rect + ibuf->x*rymin + rxmin);
+
+       for(y1= 0; y1<ymax; y1++) {
+               float *rf= rectf;
+               char *rc= rectc;
+               
+               /* 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;
+       }
+       
+       /* make jobs timer to send notifier */
+       *(rj->do_update)= 1;
+}
+
+static void render_startjob(void *rjv, short *stop, short *do_update)
+{
+       RenderJob *rj= rjv;
+       
+       rj->stop= stop;
+       rj->do_update= do_update;
+       
+       if(rj->anim)
+               RE_BlenderAnim(rj->re, rj->scene, rj->scene->r.sfra, rj->scene->r.efra, rj->scene->frame_step);
+       else
+               RE_BlenderFrame(rj->re, rj->scene, rj->scene->r.cfra);
+}
+
+/* called by render, check job 'stop' value or the global */
+static int render_breakjob(void *rjv)
+{
+       RenderJob *rj= rjv;
+       
+       if(G.afbreek)
+               return 1;
+       if(rj->stop && *(rj->stop))
+               return 1;
+       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)
+{
+       /* new render clears all callbacks */
+       Scene *scene= CTX_data_scene(C);
+       Render *re;
+       wmJob *steve;
+       RenderJob *rj;
+       Image *ima;
+       
+       /* only one job at a time */
+       if(WM_jobs_test(CTX_wm_manager(C), scene))
+               return OPERATOR_CANCELLED;
+       
+       /* handle UI stuff */
+       WM_cursor_wait(1);
+
+       /* flush multires changes (for sculpt) */
+       multires_force_update(CTX_data_active_object(C));
+       
+       // get editmode results
+       // store spare
+       // get view3d layer, local layer, make this nice api call to render
+       // store spare
+       
+       /* ensure at least 1 area shows result */
+       screen_set_image_output(C);
+
+       /* job custom data */
+       rj= MEM_callocN(sizeof(RenderJob), "render job");
+       rj->scene= scene;
+       rj->win= CTX_wm_window(C);
+       rj->anim= RNA_boolean_get(op->ptr, "anim");
+       rj->iuser.scene= scene;
+       rj->iuser.ok= 1;
+       
+       /* setup job */
+       steve= WM_jobs_get(CTX_wm_manager(C), CTX_wm_window(C), scene);
+       WM_jobs_customdata(steve, rj, render_freejob);
+       WM_jobs_timer(steve, 0.2, NC_SCENE|ND_RENDER_RESULT, 0);
+       WM_jobs_callbacks(steve, render_startjob, NULL, NULL);
+       
+       /* get a render result image, and make sure it is empty */
+       ima= BKE_image_verify_viewer(IMA_TYPE_R_RESULT, "Render Result");
+       BKE_image_signal(ima, NULL, IMA_SIGNAL_FREE);
+       rj->image= ima;
+       
+       /* setup new render */
+       re= RE_NewRender(scene->id.name);
+       RE_test_break_cb(re, rj, render_breakjob);
+       RE_display_draw_cb(re, rj, image_rect_update);
+       rj->re= re;
+       G.afbreek= 0;
+       
+       //      BKE_report in render!
+       //      RE_error_cb(re, error_cb);
+
+       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);
+
+       /* add modal handler for ESC */
+       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+
+/* contextual render, using current scene, view3d? */
+void SCREEN_OT_render(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Render";
+       ot->idname= "SCREEN_OT_render";
+       
+       /* api callbacks */
+       ot->invoke= screen_render_invoke;
+       ot->modal= screen_render_modal;
+       ot->exec= screen_render_exec;
+       
+       ot->poll= ED_operator_screenactive;
+       
+       RNA_def_int(ot->srna, "layers", 0, 0, INT_MAX, "Layers", "", 0, INT_MAX);
+       RNA_def_boolean(ot->srna, "anim", 0, "Animation", "");
+}
+
+/* *********************** cancel render viewer *************** */
+
+static int render_view_cancel_exec(bContext *C, wmOperator *unused)
+{
+       ScrArea *sa= CTX_wm_area(C);
+       SpaceImage *sima= sa->spacedata.first;
+       
+       if(sima->flag & SI_PREVSPACE) {
+               sima->flag &= ~SI_PREVSPACE;
+               
+               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_fullarea(C, sa);
+       }               
+       
+       return OPERATOR_FINISHED;
+}
+
+void SCREEN_OT_render_view_cancel(struct wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Cancel Render View";
+       ot->idname= "SCREEN_OT_render_view_cancel";
+       
+       /* api callbacks */
+       ot->exec= render_view_cancel_exec;
+       ot->poll= ED_operator_image_active;
+}
+
+
 /* ****************  Assigning operatortypes to global list, adding handlers **************** */
 
 /* called in spacetypes.c */
 void ED_operatortypes_screen(void)
 {
        /* generic UI stuff */
-       WM_operatortype_append(ED_SCR_OT_cursor_type);
-       WM_operatortype_append(ED_SCR_OT_actionzone);
-       WM_operatortype_append(ED_SCR_OT_repeat_last);
+       WM_operatortype_append(SCREEN_OT_actionzone);
+       WM_operatortype_append(SCREEN_OT_repeat_last);
+       WM_operatortype_append(SCREEN_OT_repeat_history);
+       WM_operatortype_append(SCREEN_OT_redo_last);
        
        /* screen tools */
-       WM_operatortype_append(ED_SCR_OT_area_move);
-       WM_operatortype_append(ED_SCR_OT_area_split);
-       WM_operatortype_append(ED_SCR_OT_area_join);
-       WM_operatortype_append(ED_SCR_OT_area_rip);
-       WM_operatortype_append(ED_SCR_OT_region_split);
-               
+       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_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 */
+       WM_operatortype_append(SCREEN_OT_render);
+       WM_operatortype_append(SCREEN_OT_render_view_cancel);
+       
        /* tools shared by more space types */
-       ED_marker_operatortypes();      
+       WM_operatortype_append(ED_OT_undo);
+       WM_operatortype_append(ED_OT_redo);     
        
 }
 
@@ -1342,17 +2656,63 @@ void ED_keymap_screen(wmWindowManager *wm)
 {
        ListBase *keymap= WM_keymap_listbase(wm, "Screen", 0, 0);
        
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_cursor_type", MOUSEMOVE, 0, 0, 0);
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0);
+       /* standard timers */
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
        
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_area_split", EVT_ACTIONZONE, 0, 0, 0); /* action tria */
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_area_join", EVT_ACTIONZONE, 0, 0, 0);  /* action tria */ 
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_area_rip", RKEY, KM_PRESS, KM_ALT, 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);
+       
+       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, "ED_SCR_OT_region_split", SKEY, KM_PRESS, 0, 0);
-       WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0);
-       WM_keymap_verify_item(keymap, "ED_SCR_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_region_split", SKEY, KM_PRESS, KM_CTRL|KM_ALT, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_region_foursplit", SKEY, KM_PRESS, KM_CTRL|KM_ALT|KM_SHIFT, 0);
+       
+       WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_history", F3KEY, KM_PRESS, 0, 0);
+       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, "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);
+       WM_keymap_add_item(keymap, "ED_OT_undo", ZKEY, KM_PRESS, KM_OSKEY, 0);
+       WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "ED_OT_redo", ZKEY, KM_PRESS, KM_SHIFT|KM_OSKEY, 0);
+                                                 
+       /* render */
+       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 & 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);
+       
 }