RNA
[blender-staging.git] / source / blender / editors / screen / screen_ops.c
index ce7022d8176fe60e2bfa45b9f9189e330e449aec..dae7a7cedd5e76627b0c99d5b12fc8c890f62ae0 100644 (file)
@@ -225,7 +225,8 @@ int ED_operator_uvedit(bContext *C)
                return 1;
        }
 
-       BKE_mesh_end_editmesh(obedit->data, em);
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
 }
 
@@ -242,7 +243,8 @@ int ED_operator_uvmap(bContext *C)
                return 1;
        }
 
-       BKE_mesh_end_editmesh(obedit->data, em);
+       if(obedit)
+               BKE_mesh_end_editmesh(obedit->data, em);
        return 0;
 }
 
@@ -323,46 +325,51 @@ static ScrArea *screen_areahascursor(bScreen *scr, int x, int y)
        return sa;
 }
 
+/* quick poll to save operators to be created and handled */
+static int actionzone_area_poll(bContext *C)
+{
+       wmWindow *win= CTX_wm_window(C);
+       ScrArea *sa= CTX_wm_area(C);
+       
+       if(sa && win) {
+               AZone *az;
+               int x= win->eventstate->x;
+               int y= win->eventstate->y;
+               
+               for(az= sa->actionzones.first; az; az= az->next)
+                       if(BLI_in_rcti(&az->rect, x, y))
+                          return 1;
+       }       
+       return 0;
+}
 
 AZone *is_in_area_actionzone(ScrArea *sa, int x, int y)
 {
        AZone *az= NULL;
-       int i= 0;
        
-       for(az= sa->actionzones.first, i= 0; az; az= az->next, i++) {
-               if(az->type == AZONE_TRI) {
-                       if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) 
-                               break;
-               }
-               if(az->type == AZONE_QUAD) {
-                       if(az->x1 < x && x < az->x2 && az->y1 < y && y < az->y2) 
-                               break;
+       for(az= sa->actionzones.first; az; az= az->next) {
+               if(BLI_in_rcti(&az->rect, x, y)) {
+                       if(az->type == AZONE_AREA) {
+                               if(IsPointInTri2DInts(az->x1, az->y1, az->x2, az->y2, x, y)) 
+                                       break;
+                       }
+                       else if(az->type == AZONE_REGION) {
+                               float v1[2], v2[2], v3[2], pt[2];
+                               
+                               v1[0]= az->x1; v1[1]= az->y1;
+                               v2[0]= az->x2; v2[1]= az->y2;
+                               v3[0]= az->x3; v3[1]= az->y3;
+                               pt[0]= x; pt[1]=y;
+
+                               if(IsPointInTri2D(v1, v2, v3, pt)) 
+                                       break;
+                       }
                }
        }
        
        return az;
 }
 
-static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
-{
-       AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
-       sActionzoneData *sad;
-       
-       /* quick escape */
-       if(az==NULL)
-               return OPERATOR_PASS_THROUGH;
-       
-       /* ok we do the actionzone */
-       sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
-       sad->sa1= CTX_wm_area(C);
-       sad->az= az;
-       sad->x= event->x; sad->y= event->y;
-       
-       /* add modal handler */
-       WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
-       
-       return OPERATOR_RUNNING_MODAL;
-}
 
 static void actionzone_exit(bContext *C, wmOperator *op)
 {
@@ -372,15 +379,19 @@ static void actionzone_exit(bContext *C, wmOperator *op)
 }
 
 /* send EVT_ACTIONZONE event */
-static void actionzone_apply(bContext *C, wmOperator *op)
+static void actionzone_apply(bContext *C, wmOperator *op, int type)
 {
        wmEvent event;
        wmWindow *win= CTX_wm_window(C);
        sActionzoneData *sad= op->customdata;
+       
        sad->modifier= RNA_int_get(op->ptr, "modifier");
        
        event= *(win->eventstate);      /* XXX huh huh? make api call */
-       event.type= EVT_ACTIONZONE;
+       if(type==AZONE_AREA)
+               event.type= EVT_ACTIONZONE_AREA;
+       else
+               event.type= EVT_ACTIONZONE_REGION;
        event.customdata= op->customdata;
        event.customdatafree= TRUE;
        op->customdata= NULL;
@@ -388,10 +399,41 @@ static void actionzone_apply(bContext *C, wmOperator *op)
        wm_event_add(win, &event);
 }
 
+static int actionzone_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       AZone *az= is_in_area_actionzone(CTX_wm_area(C), event->x, event->y);
+       sActionzoneData *sad;
+       
+       /* quick escape */
+       if(az==NULL)
+               return OPERATOR_PASS_THROUGH;
+       
+       /* ok we do the actionzone */
+       sad= op->customdata= MEM_callocN(sizeof(sActionzoneData), "sActionzoneData");
+       sad->sa1= CTX_wm_area(C);
+       sad->az= az;
+       sad->x= event->x; sad->y= event->y;
+       
+       /* region azone directly reacts on mouse clicks */
+       if(sad->az->type==AZONE_REGION) {
+               actionzone_apply(C, op, AZONE_REGION);
+               actionzone_exit(C, op);
+               return OPERATOR_FINISHED;
+       }
+       else {
+               /* add modal handler */
+               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               
+               return OPERATOR_RUNNING_MODAL;
+       }
+}
+
+
 static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
 {
        sActionzoneData *sad= op->customdata;
        int deltax, deltay;
+       int mindelta= sad->az->type==AZONE_REGION?1:12;
        
        switch(event->type) {
                case MOUSEMOVE:
@@ -400,30 +442,33 @@ static int actionzone_modal(bContext *C, wmOperator *op, wmEvent *event)
                        deltay= (event->y - sad->y);
                        
                        if(deltay > ABS(deltax))
-                               sad->gesture_dir= AZONE_N;
+                               sad->gesture_dir= 'n';
                        else if(deltax > ABS(deltay))
-                               sad->gesture_dir= AZONE_E;
+                               sad->gesture_dir= 'e';
                        else if(deltay < -ABS(deltax))
-                               sad->gesture_dir= AZONE_S;
+                               sad->gesture_dir= 's';
                        else
-                               sad->gesture_dir= AZONE_W;
+                               sad->gesture_dir= 'w';
                        
                        /* gesture is large enough? */
-                       if(ABS(deltax) > 12 || ABS(deltay) > 12) {
+                       if(ABS(deltax) > mindelta || ABS(deltay) > mindelta) {
                                
                                /* second area, for join */
                                sad->sa2= screen_areahascursor(CTX_wm_screen(C), event->x, event->y);
                                /* apply sends event */
-                               actionzone_apply(C, op);
+                               actionzone_apply(C, op, sad->az->type);
                                actionzone_exit(C, op);
                                
                                return OPERATOR_FINISHED;
                        }
                                break;
                case ESCKEY:
-               case LEFTMOUSE:
                        actionzone_exit(C, op);
                        return OPERATOR_CANCELLED;
+               case LEFTMOUSE:                         
+                       actionzone_exit(C, op);
+                       return OPERATOR_CANCELLED;
+
        }
        
        return OPERATOR_RUNNING_MODAL;
@@ -438,7 +483,7 @@ void SCREEN_OT_actionzone(wmOperatorType *ot)
        ot->invoke= actionzone_invoke;
        ot->modal= actionzone_modal;
        
-       ot->poll= ED_operator_areaactive;
+       ot->poll= actionzone_area_poll;
        RNA_def_int(ot->srna, "modifier", 0, 0, 2, "modifier", "modifier state", 0, 2);
 }
 
@@ -544,7 +589,7 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event)
        return OPERATOR_RUNNING_MODAL;
 }
 
-void SCREEN_OT_area_swap(wmOperatorType *ot)
+static void SCREEN_OT_area_swap(wmOperatorType *ot)
 {
        ot->name= "Swap areas";
        ot->idname= "SCREEN_OT_area_swap";
@@ -563,18 +608,25 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
        bScreen *newsc, *sc;
        ScrArea *sa;
        rcti rect;
-       sActionzoneData *sad= event->customdata;
-
-       if(sad==NULL)
-               return OPERATOR_PASS_THROUGH;
        
        win= CTX_wm_window(C);
        sc= CTX_wm_screen(C);
-       sa= sad->sa1;
+       sa= CTX_wm_area(C);
+       
+       /* XXX hrmf! */
+       if(event->type==EVT_ACTIONZONE_AREA) {
+               sActionzoneData *sad= event->customdata;
 
+               if(sad==NULL)
+                       return OPERATOR_PASS_THROUGH;
+       
+               sa= sad->sa1;
+       }
+       
        /*  poll() checks area context, but we don't accept full-area windows */
        if(sc->full != SCREENNORMAL) {
-               actionzone_exit(C, op);
+               if(event->type==EVT_ACTIONZONE_AREA)
+                       actionzone_exit(C, op);
                return OPERATOR_CANCELLED;
        }
        
@@ -593,12 +645,13 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event)
        /* screen, areas init */
        WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
 
-       actionzone_exit(C, op);
+       if(event->type==EVT_ACTIONZONE_AREA)
+               actionzone_exit(C, op);
        
        return OPERATOR_FINISHED;
 }
 
-void SCREEN_OT_area_dupli(wmOperatorType *ot)
+static void SCREEN_OT_area_dupli(wmOperatorType *ot)
 {
        ot->name= "Duplicate Area into New Window";
        ot->idname= "SCREEN_OT_area_dupli";
@@ -1015,7 +1068,7 @@ 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;
 
@@ -1023,6 +1076,10 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        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;
@@ -1032,7 +1089,7 @@ static int area_split_invoke(bContext *C, wmOperator *op, wmEvent *event)
                        return OPERATOR_PASS_THROUGH;
                
                /* prepare operator state vars */
-               if(sad->gesture_dir==AZONE_N || sad->gesture_dir==AZONE_S) {
+               if(sad->gesture_dir=='n' || sad->gesture_dir=='s') {
                        dir= 'h';
                        RNA_float_set(op->ptr, "factor", ((float)(event->x - sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
                }
@@ -1135,9 +1192,9 @@ static int area_split_modal(bContext *C, wmOperator *op, wmEvent *event)
 }
 
 static EnumPropertyItem prop_direction_items[] = {
-       {'h', "HORIZONTAL", "Horizontal", ""},
-       {'v', "VERTICAL", "Vertical", ""},
-       {0, NULL, NULL, NULL}};
+       {'h', "HORIZONTAL", 0, "Horizontal", ""},
+       {'v', "VERTICAL", 0, "Vertical", ""},
+       {0, NULL, 0, NULL, NULL}};
 
 void SCREEN_OT_area_split(wmOperatorType *ot)
 {
@@ -1156,6 +1213,119 @@ void SCREEN_OT_area_split(wmOperatorType *ot)
        RNA_def_float(ot->srna, "factor", 0.5f, 0.0, 1.0, "Factor", "", 0.0, 1.0);
 }
 
+
+
+/* ************** scale region edge operator *********************************** */
+
+typedef struct RegionMoveData {
+       ARegion *ar;
+       int bigger, smaller, origval;
+       int origx, origy;
+       char edge;
+       
+} RegionMoveData;
+
+static int region_scale_invoke(bContext *C, wmOperator *op, wmEvent *event)
+{
+       sActionzoneData *sad= event->customdata;
+       AZone *az= sad->az;
+       
+       if(az->ar) {
+               RegionMoveData *rmd= MEM_callocN(sizeof(RegionMoveData), "RegionMoveData");
+               
+               op->customdata= rmd;
+               
+               rmd->ar= az->ar;
+               rmd->edge= az->edge;
+               rmd->origx= event->x;
+               rmd->origy= event->y;
+               if(rmd->edge=='l' || rmd->edge=='r') 
+                       rmd->origval= rmd->ar->type->minsizex;
+               else
+                       rmd->origval= rmd->ar->type->minsizey;
+               
+               /* add temp handler */
+               WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op);
+               
+               return OPERATOR_RUNNING_MODAL;
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
+static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event)
+{
+       RegionMoveData *rmd= op->customdata;
+       int delta;
+       
+       /* execute the events */
+       switch(event->type) {
+               case MOUSEMOVE:
+                       
+                       if(rmd->edge=='l' || rmd->edge=='r') {
+                               delta= event->x - rmd->origx;
+                               if(rmd->edge=='l') delta= -delta;
+                               rmd->ar->type->minsizex= rmd->origval + delta;
+                               CLAMP(rmd->ar->type->minsizex, 0, 1000);
+                               if(rmd->ar->type->minsizex < 10) {
+                                       rmd->ar->type->minsizex= 10;
+                                       rmd->ar->flag |= RGN_FLAG_HIDDEN;
+                               }
+                               else
+                                       rmd->ar->flag &= ~RGN_FLAG_HIDDEN;
+                       }
+                       else {
+                               delta= event->y - rmd->origy;
+                               if(rmd->edge=='b') delta= -delta;
+                               rmd->ar->type->minsizey= rmd->origval + delta;
+                               CLAMP(rmd->ar->type->minsizey, 0, 1000);
+                               if(rmd->ar->type->minsizey < 10) {
+                                       rmd->ar->type->minsizey= 10;
+                                       rmd->ar->flag |= RGN_FLAG_HIDDEN;
+                               }
+                               else
+                                       rmd->ar->flag &= ~RGN_FLAG_HIDDEN;
+                       }
+                       
+                       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+                                       
+                       break;
+                       
+               case LEFTMOUSE:
+                       if(event->val==0) {
+                               
+                               if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) {
+                                       rmd->ar->flag ^= RGN_FLAG_HIDDEN;
+                                       WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL);
+                               }                               
+                               MEM_freeN(op->customdata);
+                               op->customdata = NULL;
+
+                               return OPERATOR_FINISHED;
+                       }
+                       break;
+                       
+               case ESCKEY:
+                       ;
+       }
+       
+       return OPERATOR_RUNNING_MODAL;
+}
+
+
+static void SCREEN_OT_region_scale(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Scale Region Size";
+       ot->idname= "SCREEN_OT_region_scale";
+       
+       ot->invoke= region_scale_invoke;
+       ot->modal= region_scale_modal;
+       
+       ot->poll= ED_operator_areaactive;
+}
+
+
 /* ************** frame change operator ***************************** */
 
 
@@ -1383,7 +1553,7 @@ 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) {
@@ -1581,7 +1751,7 @@ static int repeat_history_invoke(bContext *C, wmOperator *op, wmEvent *event)
        if(items==0)
                return OPERATOR_CANCELLED;
        
-       pup= uiPupMenuBegin(op->type->name, 0);
+       pup= uiPupMenuBegin(C, op->type->name, 0);
        layout= uiPupMenuLayout(pup);
 
        for (i=items-1, lastop= wm->operators.last; lastop; lastop= lastop->prev, i--)
@@ -1810,37 +1980,6 @@ static int region_flip_exec(bContext *C, wmOperator *op)
        return OPERATOR_FINISHED;
 }
 
-static void testfunc(bContext *C, void *argv, int arg)
-{
-       printf("arg %d\n", arg);
-}
-
-static void newlevel1(bContext *C, uiLayout *layout, void *arg)
-{
-       uiLayoutFunc(layout, testfunc, NULL);
-       
-       uiItemV(layout, "First", ICON_PROP_ON, 1);
-       uiItemV(layout, "Second", ICON_PROP_CON, 2);
-       uiItemV(layout, "Third", ICON_SMOOTHCURVE, 3);
-       uiItemV(layout, "Fourth", ICON_SHARPCURVE, 4);  
-}
-
-static int testing123(bContext *C, wmOperator *op, wmEvent *event)
-{
-       uiPopupMenu *pup= uiPupMenuBegin("Hello world", 0);
-       uiLayout *layout= uiPupMenuLayout(pup);
-       
-       uiLayoutContext(layout, WM_OP_EXEC_DEFAULT);
-       uiItemO(layout, NULL, ICON_PROP_ON, "SCREEN_OT_region_flip");
-       uiItemO(layout, NULL, ICON_PROP_CON, "SCREEN_OT_screen_full_area");
-       uiItemO(layout, NULL, ICON_SMOOTHCURVE, "SCREEN_OT_region_foursplit");
-       uiItemLevel(layout, "Submenu", 0, newlevel1);
-       
-       uiPupMenuEnd(C, pup);
-       
-       /* this operator is only for a menu, not used further */
-       return OPERATOR_CANCELLED;
-}
 
 void SCREEN_OT_region_flip(wmOperatorType *ot)
 {
@@ -1849,27 +1988,72 @@ void SCREEN_OT_region_flip(wmOperatorType *ot)
        ot->idname= "SCREEN_OT_region_flip";
        
        /* api callbacks */
-       ot->invoke= testing123; // XXX WM_operator_confirm;
        ot->exec= region_flip_exec;
        
        ot->poll= ED_operator_areaactive;
        ot->flag= OPTYPE_REGISTER;
-       
-       RNA_def_int(ot->srna, "test", 0, INT_MIN, INT_MAX, "test", "", INT_MIN, INT_MAX);
 
 }
 
-/* ****************** anim player, typically with timer ***************** */
+/* ****************** anim player, with timer ***************** */
 
-static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
+static int match_region_with_redraws(int spacetype, int regiontype, int redraws)
+{
+       if(regiontype==RGN_TYPE_WINDOW) {
+
+               switch (spacetype) {
+                       case SPACE_VIEW3D:
+                               if(redraws & TIME_ALL_3D_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_IPO:
+                       case SPACE_ACTION:
+                       case SPACE_NLA:
+                               if(redraws & TIME_ALL_ANIM_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_TIME:
+                               /* if only 1 window or 3d windows, we do timeline too */
+                               if(redraws & (TIME_ALL_ANIM_WIN|TIME_REGION|TIME_ALL_3D_WIN))
+                                       return 1;
+                               break;
+                       case SPACE_BUTS:
+                               if(redraws & TIME_ALL_BUTS_WIN)
+                                       return 1;
+                               break;
+                       case SPACE_SEQ:
+                               if(redraws & (TIME_SEQ|TIME_ALL_ANIM_WIN))
+                                       return 1;
+                               break;
+                       case SPACE_IMAGE:
+                               if(redraws & TIME_ALL_IMAGE_WIN)
+                                       return 1;
+                               break;
+                               
+               }
+       }
+       else if(regiontype==RGN_TYPE_UI) {
+               if(redraws & TIME_ALL_BUTS_WIN)
+                       return 1;
+       }
+       else if(regiontype==RGN_TYPE_HEADER) {
+               if(spacetype==SPACE_TIME)
+                       return 1;
+       }
+       return 0;
+}
+
+static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event)
 {
        bScreen *screen= CTX_wm_screen(C);
        
        if(screen->animtimer==event->customdata) {
                Scene *scene= CTX_data_scene(C);
+               wmTimer *wt= screen->animtimer;
+               ScreenAnimData *sad= wt->customdata;
+               ScrArea *sa;
                
                if(scene->audio.flag & AUDIO_SYNC) {
-                       wmTimer *wt= screen->animtimer;
                        int step = floor(wt->duration * FPS);
                        scene->r.cfra += step;
                        wt->duration -= ((float)step)/FPS;
@@ -1886,13 +2070,65 @@ static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
                                scene->r.cfra= scene->r.sfra;
                }
 
-               WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
+               /* since we follow drawflags, we can't send notifier but tag regions ourselves */
+               ED_update_for_newframe(C, 1);
+               
+               for(sa= screen->areabase.first; sa; sa= sa->next) {
+                       ARegion *ar;
+                       for(ar= sa->regionbase.first; ar; ar= ar->next) {
+                               if(ar==sad->ar)
+                                       ED_region_tag_redraw(ar);
+                               else
+                                       if(match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws))
+                                               ED_region_tag_redraw(ar);
+                       }
+               }
+               
+               //WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
                
                return OPERATOR_FINISHED;
        }
        return OPERATOR_PASS_THROUGH;
 }
 
+static void SCREEN_OT_animation_step(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Animation Step";
+       ot->idname= "SCREEN_OT_animation_step";
+       
+       /* api callbacks */
+       ot->invoke= screen_animation_step;
+       
+       ot->poll= ED_operator_screenactive;
+       
+}
+
+/* ****************** anim player, starts or ends timer ***************** */
+
+/* toggle operator */
+static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
+{
+       bScreen *screen= CTX_wm_screen(C);
+       
+       if(screen->animtimer) {
+               ED_screen_animation_timer(C, 0, 0);
+       }
+       else {
+               /* todo: RNA properties to define play types */
+               ED_screen_animation_timer(C, TIME_REGION|TIME_ALL_3D_WIN, 1);
+               
+               if(screen->animtimer) {
+                       wmTimer *wt= screen->animtimer;
+                       ScreenAnimData *sad= wt->customdata;
+                       
+                       sad->ar= CTX_wm_region(C);
+               }
+       }
+       
+       return OPERATOR_FINISHED;
+}
+
 void SCREEN_OT_animation_play(wmOperatorType *ot)
 {
        /* identifiers */
@@ -1904,6 +2140,7 @@ void SCREEN_OT_animation_play(wmOperatorType *ot)
        
        ot->poll= ED_operator_screenactive;
        
+       
 }
 
 /* ************** border select operator (template) ***************************** */
@@ -1979,7 +2216,7 @@ static ScrArea *biggest_non_image_area(bContext *C)
        short foundwin= 0;
        
        for(sa= sc->areabase.first; sa; sa= sa->next) {
-               if(sa->winx > 10 && sa->winy > 10) {
+               if(sa->winx > 30 && sa->winy > 30) {
                        size= sa->winx*sa->winy;
                        if(sa->spacetype == SPACE_BUTS) {
                                if(foundwin == 0 && size > bwmaxsize) {
@@ -2304,7 +2541,7 @@ static int screen_render_invoke(bContext *C, wmOperator *op, wmEvent *event)
        //      BKE_report in render!
        //      RE_error_cb(re, error_cb);
 
-       WM_jobs_start(steve);
+       WM_jobs_start(CTX_wm_manager(C), steve);
        
        G.afbreek= 0;
        
@@ -2393,6 +2630,7 @@ void ED_operatortypes_screen(void)
        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);
@@ -2400,6 +2638,7 @@ void ED_operatortypes_screen(void)
        
        /*frame changes*/
        WM_operatortype_append(SCREEN_OT_frame_offset);
+       WM_operatortype_append(SCREEN_OT_animation_step);
        WM_operatortype_append(SCREEN_OT_animation_play);
        
        /* render */
@@ -2418,18 +2657,21 @@ void ED_keymap_screen(wmWindowManager *wm)
        ListBase *keymap= WM_keymap_listbase(wm, "Screen", 0, 0);
        
        /* standard timers */
-       WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", TIMER0, KM_ANY, KM_ANY, 0);
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_step", TIMER0, KM_ANY, KM_ANY, 0);
        
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, 0, 0)->ptr, "modifier", 0);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "modifier", 1);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_actionzone", LEFTMOUSE, KM_PRESS, KM_ALT, 0)->ptr, "modifier", 2);
        
        /* screen tools */
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE_AREA, 0, 0, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE_AREA, 0, 0, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_dupli", EVT_ACTIONZONE_AREA, 0, KM_SHIFT, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_area_swap", EVT_ACTIONZONE_AREA, 0, KM_ALT, 0);
+       WM_keymap_verify_item(keymap, "SCREEN_OT_region_scale", EVT_ACTIONZONE_REGION, 0, 0, 0);
+                       /* area move after action zones */
        WM_keymap_verify_item(keymap, "SCREEN_OT_area_move", LEFTMOUSE, KM_PRESS, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_split", EVT_ACTIONZONE, 0, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_join", EVT_ACTIONZONE, 0, 0, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_dupli", EVT_ACTIONZONE, 0, KM_SHIFT, 0);
-       WM_keymap_verify_item(keymap, "SCREEN_OT_area_swap", EVT_ACTIONZONE, 0, KM_ALT, 0);
+       
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", RIGHTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", 1);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_screen_set", LEFTARROWKEY, KM_PRESS, KM_CTRL, 0)->ptr, "delta", -1);
        WM_keymap_add_item(keymap, "SCREEN_OT_screen_full_area", UPARROWKEY, KM_PRESS, KM_CTRL, 0);
@@ -2446,6 +2688,9 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_verify_item(keymap, "SCREEN_OT_repeat_last", F4KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_region_flip", F5KEY, KM_PRESS, 0, 0);
        WM_keymap_verify_item(keymap, "SCREEN_OT_redo_last", F6KEY, KM_PRESS, 0, 0);
+       
+       RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_python_file_run", F7KEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
+       WM_keymap_verify_item(keymap, "SCRIPT_OT_python_run_ui_scripts", F8KEY, KM_PRESS, 0, 0);
 
        /* files */
        WM_keymap_add_item(keymap, "FILE_OT_exec", RETKEY, KM_PRESS, 0, 0);
@@ -2461,12 +2706,13 @@ void ED_keymap_screen(wmWindowManager *wm)
        WM_keymap_add_item(keymap, "SCREEN_OT_render", F12KEY, KM_PRESS, 0, 0);
        WM_keymap_add_item(keymap, "SCREEN_OT_render_view_cancel", ESCKEY, KM_PRESS, 0, 0);
        
-       /* frame offsets */
+       /* frame offsets & play */
        keymap= WM_keymap_listbase(wm, "Frames", 0, 0);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1);
        RNA_int_set(WM_keymap_add_item(keymap, "SCREEN_OT_frame_offset", RIGHTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 1);
+       WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0);
        
 }