diff options
Diffstat (limited to 'source/blender/editors/screen/screen_ops.c')
-rw-r--r-- | source/blender/editors/screen/screen_ops.c | 153 |
1 files changed, 68 insertions, 85 deletions
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c index b70cb03869d..2b9a929d4bf 100644 --- a/source/blender/editors/screen/screen_ops.c +++ b/source/blender/editors/screen/screen_ops.c @@ -41,20 +41,13 @@ #include "DNA_scene_types.h" #include "DNA_meta_types.h" -#include "BKE_blender.h" -#include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_customdata.h" -#include "BKE_global.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_scene.h" #include "BKE_screen.h" -#include "BKE_utildefines.h" #include "BKE_tessmesh.h" #include "BKE_sound.h" @@ -608,10 +601,8 @@ static int area_swap_modal(bContext *C, wmOperator *op, wmEvent *event) return area_swap_cancel(C, op); } -#ifdef WM_FAST_DRAW ED_area_tag_redraw(sad->sa1); ED_area_tag_redraw(sad->sa2); -#endif ED_area_swapspace(C, sad->sa1, sad->sa2); @@ -684,10 +675,8 @@ static int area_dupli_invoke(bContext *C, wmOperator *op, wmEvent *event) /* copy area to new screen */ area_copy_data((ScrArea *)newsc->areabase.first, sa, 0); - -#ifdef WM_FAST_DRAW + ED_area_tag_redraw((ScrArea *)newsc->areabase.first); -#endif /* screen, areas init */ WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -813,6 +802,7 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int wmWindow *win= CTX_wm_window(C); bScreen *sc= CTX_wm_screen(C); ScrVert *v1; + ScrArea *sa; delta= CLAMPIS(delta, -smaller, bigger); @@ -835,15 +825,12 @@ static void area_move_apply_do(bContext *C, int origval, int delta, int dir, int } } } -#ifdef WM_FAST_DRAW - { - ScrArea *sa; - for(sa= sc->areabase.first; sa; sa= sa->next) - if(sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) - ED_area_tag_redraw(sa); + + for(sa= sc->areabase.first; sa; sa= sa->next) { + if(sa->v1->flag || sa->v2->flag || sa->v3->flag || sa->v4->flag) + ED_area_tag_redraw(sa); } -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); /* redraw everything */ } @@ -1106,10 +1093,9 @@ 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; -#ifdef WM_FAST_DRAW ED_area_tag_redraw(sd->sarea); ED_area_tag_redraw(sd->narea); -#endif + WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); return 1; @@ -1121,11 +1107,9 @@ static int area_split_apply(bContext *C, wmOperator *op) static void area_split_exit(bContext *C, wmOperator *op) { if (op->customdata) { -#ifdef WM_FAST_DRAW sAreaSplitData *sd= (sAreaSplitData *)op->customdata; if(sd->sarea) ED_area_tag_redraw(sd->sarea); if(sd->narea) ED_area_tag_redraw(sd->narea); -#endif MEM_freeN(op->customdata); op->customdata = NULL; @@ -1437,9 +1421,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) else if(rmd->ar->flag & RGN_FLAG_HIDDEN) ED_region_toggle_hidden(C, rmd->ar); } -#ifdef WM_FAST_DRAW ED_area_tag_redraw(rmd->sa); -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); break; @@ -1450,9 +1432,7 @@ static int region_scale_modal(bContext *C, wmOperator *op, wmEvent *event) if(ABS(event->x - rmd->origx) < 2 && ABS(event->y - rmd->origy) < 2) { if(rmd->ar->flag & RGN_FLAG_HIDDEN) { ED_region_toggle_hidden(C, rmd->ar); -#ifdef WM_FAST_DRAW ED_area_tag_redraw(rmd->sa); -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } } @@ -1547,7 +1527,7 @@ static void SCREEN_OT_frame_jump(wmOperatorType *ot) ot->exec= frame_jump_exec; ot->poll= ED_operator_screenactive; - ot->flag= 0; + ot->flag= OPTYPE_UNDO; /* rna */ RNA_def_boolean(ot->srna, "end", 0, "Last Frame", "Jump to the last frame of the frame range."); @@ -1626,7 +1606,7 @@ static void SCREEN_OT_keyframe_jump(wmOperatorType *ot) ot->exec= keyframe_jump_exec; ot->poll= ED_operator_screenactive; - ot->flag= 0; + ot->flag= OPTYPE_UNDO; /* rna */ RNA_def_boolean(ot->srna, "next", 1, "Next Keyframe", ""); @@ -1761,10 +1741,10 @@ static int area_join_init(bContext *C, wmOperator *op) int x2, y2; /* required properties, make negative to get return 0 if not set by caller */ - x1= RNA_int_get(op->ptr, "x1"); - y1= RNA_int_get(op->ptr, "y1"); - x2= RNA_int_get(op->ptr, "x2"); - y2= RNA_int_get(op->ptr, "y2"); + x1= RNA_int_get(op->ptr, "min_x"); + y1= RNA_int_get(op->ptr, "min_y"); + x2= RNA_int_get(op->ptr, "max_x"); + y2= RNA_int_get(op->ptr, "max_y"); sa1 = screen_areahascursor(CTX_wm_screen(C), x1, y1); sa2 = screen_areahascursor(CTX_wm_screen(C), x2, y2); @@ -1845,10 +1825,10 @@ static int area_join_invoke(bContext *C, wmOperator *op, wmEvent *event) return OPERATOR_PASS_THROUGH; /* prepare operator state vars */ - RNA_int_set(op->ptr, "x1", sad->x); - RNA_int_set(op->ptr, "y1", sad->y); - RNA_int_set(op->ptr, "x2", event->x); - RNA_int_set(op->ptr, "y2", event->y); + RNA_int_set(op->ptr, "min_x", sad->x); + RNA_int_set(op->ptr, "min_y", sad->y); + RNA_int_set(op->ptr, "max_x", event->x); + RNA_int_set(op->ptr, "max_y", event->y); if(!area_join_init(C, op)) return OPERATOR_PASS_THROUGH; @@ -1955,10 +1935,9 @@ static int area_join_modal(bContext *C, wmOperator *op, wmEvent *event) break; case LEFTMOUSE: if(event->val==KM_RELEASE) { -#ifdef WM_FAST_DRAW ED_area_tag_redraw(jd->sa1); ED_area_tag_redraw(jd->sa2); -#endif + area_join_apply(C, op); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); area_join_exit(C, op); @@ -1991,10 +1970,10 @@ static void SCREEN_OT_area_join(wmOperatorType *ot) ot->flag= OPTYPE_BLOCKING; /* rna */ - 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); + RNA_def_int(ot->srna, "min_x", -100, INT_MIN, INT_MAX, "X 1", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "min_y", -100, INT_MIN, INT_MAX, "Y 1", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "max_x", -100, INT_MIN, INT_MAX, "X 2", "", INT_MIN, INT_MAX); + RNA_def_int(ot->srna, "max_y", -100, INT_MIN, INT_MAX, "Y 2", "", INT_MIN, INT_MAX); } /* ************** repeat last operator ***************************** */ @@ -2141,9 +2120,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op) MEM_freeN(ar); } } -#ifdef WM_FAST_DRAW ED_area_tag_redraw(sa); -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } else if(ar->next) @@ -2183,10 +2160,7 @@ static int region_quadview_exec(bContext *C, wmOperator *op) rv3d->view= RV3D_VIEW_CAMERA; rv3d->persp= RV3D_CAMOB; if (rv3d->localvd) {rv3d->localvd->view = rv3d->view; rv3d->localvd->persp = rv3d->persp; } } - -#ifdef WM_FAST_DRAW ED_area_tag_redraw(sa); -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); } @@ -2228,10 +2202,8 @@ static int region_flip_exec(bContext *C, wmOperator *op) ar->alignment= RGN_ALIGN_RIGHT; else if(ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; - -#ifdef WM_FAST_DRAW - ED_area_tag_redraw(CTX_wm_area(C)); -#endif + + ED_area_tag_redraw(CTX_wm_area(C)); WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); return OPERATOR_FINISHED; @@ -2283,10 +2255,8 @@ static int header_flip_exec(bContext *C, wmOperator *op) ar->alignment= RGN_ALIGN_RIGHT; else if(ar->alignment==RGN_ALIGN_RIGHT) ar->alignment= RGN_ALIGN_LEFT; - -#ifdef WM_FAST_DRAW + ED_area_tag_redraw(CTX_wm_area(C)); -#endif WM_event_add_notifier(C, NC_SCREEN|NA_EDITED, NULL); @@ -2434,20 +2404,20 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) ScrArea *sa; int sync; float time; - + /* sync, don't sync, or follow scene setting */ - if(sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; - else if(sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; + if (sad->flag & ANIMPLAY_FLAG_SYNC) sync= 1; + else if (sad->flag & ANIMPLAY_FLAG_NO_SYNC) sync= 0; else sync= (scene->flag & SCE_FRAME_DROP); if((scene->audio.flag & AUDIO_SYNC) && !(sad->flag & ANIMPLAY_FLAG_REVERSE) && finite(time = sound_sync_scene(scene))) - scene->r.cfra = round(time * FPS); + scene->r.cfra = time * FPS + 0.5; else { - if(sync) { + if (sync) { int step = floor(wt->duration * FPS); /* skip frames */ - if(sad->flag & ANIMPLAY_FLAG_REVERSE) + if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra -= step; else scene->r.cfra += step; @@ -2455,7 +2425,7 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) } else { /* one frame +/- */ - if(sad->flag & ANIMPLAY_FLAG_REVERSE) + if (sad->flag & ANIMPLAY_FLAG_REVERSE) scene->r.cfra--; else scene->r.cfra++; @@ -2496,19 +2466,19 @@ static int screen_animation_step(bContext *C, wmOperator *op, wmEvent *event) } } - if(sad->flag & ANIMPLAY_FLAG_JUMPED) + if (sad->flag & ANIMPLAY_FLAG_JUMPED) sound_seek_scene(C); /* 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) { + for (sa= screen->areabase.first; sa; sa= sa->next) { ARegion *ar; - for(ar= sa->regionbase.first; ar; ar= ar->next) { - if(ar==sad->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)) + if (match_region_with_redraws(sa->spacetype, ar->regiontype, sad->redraws)) ED_region_tag_redraw(ar); } @@ -2553,9 +2523,9 @@ static void SCREEN_OT_animation_step(wmOperatorType *ot) int ED_screen_animation_play(bContext *C, int sync, int mode) { bScreen *screen= CTX_wm_screen(C); - struct Scene* scene = CTX_data_scene(C); + Scene *scene = CTX_data_scene(C); - if(screen->animtimer) { + if (screen->animtimer) { /* stop playback now */ ED_screen_animation_timer(C, 0, 0, 0, 0); sound_stop_scene(scene); @@ -2563,33 +2533,33 @@ int ED_screen_animation_play(bContext *C, int sync, int mode) else { ScrArea *sa= CTX_wm_area(C); int refresh= SPACE_TIME; - - if(mode == 1) // XXX only play audio forwards!? + + if (mode == 1) // XXX only play audio forwards!? sound_play_scene(scene); - + /* timeline gets special treatment since it has it's own menu for determining redraws */ if ((sa) && (sa->spacetype == SPACE_TIME)) { SpaceTime *stime= (SpaceTime *)sa->spacedata.first; - + ED_screen_animation_timer(C, stime->redraws, refresh, sync, mode); - + /* update region if TIME_REGION was set, to leftmost 3d window */ ED_screen_animation_timer_update(screen, stime->redraws, refresh); } else { int redraws = TIME_REGION|TIME_ALL_3D_WIN; - + /* XXX - would like a better way to deal with this situation - Campbell */ - if((!sa) || (sa->spacetype == SPACE_SEQ)) { + if ((!sa) || (sa->spacetype == SPACE_SEQ)) { redraws |= TIME_SEQ; } - + ED_screen_animation_timer(C, redraws, refresh, sync, mode); - + if(screen->animtimer) { wmTimer *wt= screen->animtimer; ScreenAnimData *sad= wt->customdata; - + sad->ar= CTX_wm_region(C); } } @@ -2602,10 +2572,10 @@ static int screen_animation_play_exec(bContext *C, wmOperator *op) { int mode= (RNA_boolean_get(op->ptr, "reverse")) ? -1 : 1; int sync= -1; - - if(RNA_property_is_set(op->ptr, "sync")) + + if (RNA_property_is_set(op->ptr, "sync")) sync= (RNA_boolean_get(op->ptr, "sync")); - + return ED_screen_animation_play(C, sync, mode); } @@ -2854,9 +2824,9 @@ static int scene_new_exec(bContext *C, wmOperator *op) /* these can't be handled in blenkernel curently, so do them here */ if(type == SCE_COPY_LINK_DATA) - ED_object_single_users(newscene, 0); + ED_object_single_users(bmain, newscene, 0); else if(type == SCE_COPY_FULL) - ED_object_single_users(newscene, 1); + ED_object_single_users(bmain, newscene, 1); WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, newscene); @@ -2992,6 +2962,7 @@ static void keymap_modal_set(wmKeyConfig *keyconf) void ED_keymap_screen(wmKeyConfig *keyconf) { wmKeyMap *keymap; + //wmKeyMapItem *kmi; /* Screen Editing ------------------------------------------------ */ keymap= WM_keymap_find(keyconf, "Screen Editing", 0, 0); @@ -3087,10 +3058,22 @@ void ED_keymap_screen(wmKeyConfig *keyconf) /* play (forward and backwards) */ WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT, 0); - WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", KKEY, KM_PRESS, 0, LKEY); RNA_boolean_set(WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", AKEY, KM_PRESS, KM_ALT|KM_SHIFT, 0)->ptr, "reverse", 1); WM_keymap_add_item(keymap, "SCREEN_OT_animation_cancel", ESCKEY, KM_PRESS, 0, 0); + /* Alternative keys for animation and sequencer playing */ +#if 0 // XXX: disabled for restoring later... bad implementation + keymap= WM_keymap_find(keyconf, "Frames", 0, 0); + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", RIGHTARROWKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "cycle_speed", 1); + + kmi = WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", LEFTARROWKEY, KM_PRESS, KM_ALT, 0); + RNA_boolean_set(kmi->ptr, "reverse", 1); + RNA_boolean_set(kmi->ptr, "cycle_speed", 1); + + WM_keymap_add_item(keymap, "SCREEN_OT_animation_play", DOWNARROWKEY, KM_PRESS, KM_ALT, 0); +#endif + keymap_modal_set(keyconf); } |