diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-12-21 11:02:24 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-12-21 11:02:24 +0300 |
commit | df274a8b58a9f3f9e4a6e34e76bb2fb2e06b7e3f (patch) | |
tree | f9ab9e835aad7cdf02470ff8693b6711647e53f8 /source/blender/editors/space_time | |
parent | e2cca3320ac9e32c9f5ad51e1c6de1d049aa5b98 (diff) |
2.5 - Time operations to Animation Module
Moved time_ops.c contents to anim_ops.c, as the operators there are applicable to all other Animation Editors too. anim_ops.c will therefore contain all operators which will apply to all Animation Editors (i.e. change frame, frames/seconds display toggle, and soon Preview Range tools).
As such, added new global 'Animation' keymap like for View2D and Markers, which will ensure that these tools can be accessed in an uniform way across editors.
Note that the order that these things are added is important, as the Animation ones will often 'steal' events from the View2D and Markers ones if placed before the others. To prevent that, we'd need to be able to set boundboxes here...
Diffstat (limited to 'source/blender/editors/space_time')
-rw-r--r-- | source/blender/editors/space_time/space_time.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_ops.c | 161 |
2 files changed, 4 insertions, 161 deletions
diff --git a/source/blender/editors/space_time/space_time.c b/source/blender/editors/space_time/space_time.c index 5cadd521b66..54ab83e6de8 100644 --- a/source/blender/editors/space_time/space_time.c +++ b/source/blender/editors/space_time/space_time.c @@ -296,12 +296,12 @@ void ED_spacetype_time(void) /* regions: main window */ art= MEM_callocN(sizeof(ARegionType), "spacetype time region"); art->regionid = RGN_TYPE_WINDOW; - art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS; + art->keymapflag= ED_KEYMAP_VIEW2D|ED_KEYMAP_MARKERS|ED_KEYMAP_ANIMATION; art->init= time_main_area_init; art->draw= time_main_area_draw; art->listener= time_main_area_listener; - art->keymap= time_keymap; + //art->keymap= time_keymap; BLI_addhead(&st->regiontypes, art); /* regions: header */ diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index e8704457c00..51808fbf623 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -50,175 +50,18 @@ #include "WM_api.h" #include "WM_types.h" -#include "ED_markers.h" -/* ********************** frame change operator ***************************/ - -static int change_frame_init(bContext *C, wmOperator *op) -{ - SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); - - stime->flag |= TIME_CFRA_NUM; - - return 1; -} - -static void change_frame_apply(bContext *C, wmOperator *op) -{ - Scene *scene= CTX_data_scene(C); - int cfra; - - cfra= RNA_int_get(op->ptr, "frame"); - - if(cfra < MINFRAME) - cfra= MINFRAME; - -#if 0 - if( cfra!=CFRA || first ) - { - first= 0; - CFRA= cfra; - update_for_newframe_nodraw(0); // 1= nosound - timeline_force_draw(stime->redraws); - } - else PIL_sleep_ms(30); -#endif - - if(cfra!=scene->r.cfra) - scene->r.cfra= cfra; - - WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL); - /* XXX: add WM_NOTE_TIME_CHANGED? */ -} - -static void change_frame_exit(bContext *C, wmOperator *op) -{ - SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C); - - stime->flag &= ~TIME_CFRA_NUM; -} - -static int change_frame_exec(bContext *C, wmOperator *op) -{ - if(!change_frame_init(C, op)) - return OPERATOR_CANCELLED; - - change_frame_apply(C, op); - change_frame_exit(C, op); - return OPERATOR_FINISHED; -} - -static int frame_from_event(bContext *C, wmEvent *event) -{ - ARegion *region= CTX_wm_region(C); - int x, y; - float viewx; - - x= event->x - region->winrct.xmin; - y= event->y - region->winrct.ymin; - UI_view2d_region_to_view(®ion->v2d, x, y, &viewx, NULL); - - return (int)floor(viewx+0.5f); -} - -static int change_frame_invoke(bContext *C, wmOperator *op, wmEvent *event) -{ - RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); - change_frame_init(C, op); - change_frame_apply(C, op); - - /* add temp handler */ - WM_event_add_modal_handler(C, &CTX_wm_window(C)->handlers, op); - - return OPERATOR_RUNNING_MODAL; -} - -static int change_frame_cancel(bContext *C, wmOperator *op) -{ - change_frame_exit(C, op); - return OPERATOR_CANCELLED; -} - -static int change_frame_modal(bContext *C, wmOperator *op, wmEvent *event) -{ - /* execute the events */ - switch(event->type) { - case MOUSEMOVE: - RNA_int_set(op->ptr, "frame", frame_from_event(C, event)); - change_frame_apply(C, op); - break; - - case LEFTMOUSE: - if(event->val==0) { - change_frame_exit(C, op); - return OPERATOR_FINISHED; - } - break; - } - - return OPERATOR_RUNNING_MODAL; -} - -void ED_TIME_OT_change_frame(wmOperatorType *ot) -{ - PropertyRNA *prop; - - /* identifiers */ - ot->name= "Change frame"; - ot->idname= "ED_TIME_OT_change_frame"; - - /* api callbacks */ - ot->exec= change_frame_exec; - ot->invoke= change_frame_invoke; - ot->cancel= change_frame_cancel; - ot->modal= change_frame_modal; - - /* rna */ - prop= RNA_def_property(ot->srna, "frame", PROP_INT, PROP_NONE); -} - -/* ****************** time display toggle operator ****************************/ - -static int toggle_time_exec(bContext *C, wmOperator *op) -{ - SpaceTime *stime= (SpaceTime *)CTX_wm_space_data(C); - ScrArea *curarea= CTX_wm_area(C); - - if (ELEM(NULL, curarea, stime)) - return OPERATOR_CANCELLED; - - /* simply toggle draw frames flag for now */ - // in past, this asked user to choose in a menu beforehand, but that is clumsy - stime->flag ^= TIME_DRAWFRAMES; - - ED_area_tag_redraw(curarea); - - return OPERATOR_FINISHED; -} - -void ED_TIME_OT_toggle_time(wmOperatorType *ot) -{ - /* identifiers */ - ot->name= "Toggle Frames/Seconds"; - ot->idname= "ED_TIME_OT_toggle_time"; - - /* api callbacks */ - ot->exec= toggle_time_exec; -} +/* *************************************************/ /* ************************** registration **********************************/ void time_operatortypes(void) { - WM_operatortype_append(ED_TIME_OT_change_frame); - WM_operatortype_append(ED_TIME_OT_toggle_time); + } void time_keymap(wmWindowManager *wm) { - ListBase *keymap= WM_keymap_listbase(wm, "TimeLine", SPACE_TIME, 0); - WM_keymap_verify_item(keymap, "ED_TIME_OT_change_frame", LEFTMOUSE, KM_PRESS, 0, 0); - WM_keymap_verify_item(keymap, "ED_TIME_OT_toggle_time", TKEY, KM_PRESS, 0, 0); } |