2.5
Animated screen! (unfinished, now only draws, no animation code yet). Fun though to see it all work. :) NOTE: Mac ghost has timer bug, the GHOST_ProcessEvents() doesnt wake up for timers. NOTE2: Added while loop in wm_window_process_events() to force Ghost giving all events to Blender. Timers otherwise don't accumulate... might be needed to fix in ghost too. I tend to think to code own timer, this ghost stuff is totally different per platform.
This commit is contained in:
@@ -74,6 +74,7 @@ void ED_screen_do_listen(struct wmWindow *win, struct wmNotifier *note);
|
||||
bScreen *ED_screen_duplicate(struct wmWindow *win, struct bScreen *sc);
|
||||
void ED_screen_set_subwinactive(struct wmWindow *win, struct wmEvent *event);
|
||||
void ED_screen_exit(struct bContext *C, struct wmWindow *window, struct bScreen *screen);
|
||||
void ED_animation_timer(struct wmWindow *win, int enable);
|
||||
|
||||
void ED_operatortypes_screen(void);
|
||||
void ED_keymap_screen(struct wmWindowManager *wm);
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
|
||||
#include "DNA_vec_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
|
||||
#include "BLI_blenlib.h"
|
||||
|
||||
@@ -1263,3 +1264,14 @@ void ed_screen_fullarea(bContext *C)
|
||||
|
||||
}
|
||||
|
||||
void ED_animation_timer(wmWindow *win, int enable)
|
||||
{
|
||||
|
||||
if(win->animtimer)
|
||||
WM_event_remove_window_timer(win, win->animtimer);
|
||||
win->animtimer= NULL;
|
||||
|
||||
if(enable)
|
||||
win->animtimer= WM_event_add_window_timer(win, (int)(1000/FPS), (int)(1000/FPS));
|
||||
}
|
||||
|
||||
|
||||
@@ -1310,7 +1310,6 @@ static int region_flip_exec(bContext *C, wmOperator *op)
|
||||
|
||||
void ED_SCR_OT_region_flip(wmOperatorType *ot)
|
||||
{
|
||||
|
||||
/* identifiers */
|
||||
ot->name= "Flip Region";
|
||||
ot->idname= "ED_SCR_OT_region_flip";
|
||||
@@ -1322,6 +1321,38 @@ void ED_SCR_OT_region_flip(wmOperatorType *ot)
|
||||
ot->poll= ED_operator_areaactive;
|
||||
}
|
||||
|
||||
/* ****************** anim player, typically with timer ***************** */
|
||||
|
||||
static int screen_animation_play(bContext *C, wmOperator *op, wmEvent *event)
|
||||
{
|
||||
wmWindow *win= CTX_wm_window(C);
|
||||
|
||||
if(win->animtimer==event->customdata) {
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
||||
scene->r.cfra++;
|
||||
if(scene->r.cfra > scene->r.efra)
|
||||
scene->r.cfra= scene->r.sfra;
|
||||
|
||||
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
return OPERATOR_PASS_THROUGH;
|
||||
}
|
||||
|
||||
void ED_SCR_OT_animation_play(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name= "Animation player";
|
||||
ot->idname= "ED_SCR_OT_animation_play";
|
||||
|
||||
/* api callbacks */
|
||||
ot->invoke= screen_animation_play;
|
||||
|
||||
ot->poll= ED_operator_screenactive;
|
||||
|
||||
}
|
||||
|
||||
/* ************** border select operator (template) ***************************** */
|
||||
|
||||
@@ -1402,7 +1433,8 @@ void ED_operatortypes_screen(void)
|
||||
|
||||
/*frame changes*/
|
||||
WM_operatortype_append(ED_SCR_OT_frame_offset);
|
||||
|
||||
WM_operatortype_append(ED_SCR_OT_animation_play);
|
||||
|
||||
/* tools shared by more space types */
|
||||
ED_marker_operatortypes();
|
||||
|
||||
@@ -1430,6 +1462,7 @@ void ED_keymap_screen(wmWindowManager *wm)
|
||||
RNA_enum_set(WM_keymap_add_item(keymap, "ED_SCR_OT_region_split", SKEY, KM_PRESS, KM_SHIFT, 0)->ptr, "dir", 'v');
|
||||
|
||||
/*frame offsets*/
|
||||
WM_keymap_add_item(keymap, "ED_SCR_OT_animation_play", TIMER, KM_ANY, 0, 0);
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_frame_offset", UPARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", 10);
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_frame_offset", DOWNARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -10);
|
||||
RNA_int_set(WM_keymap_add_item(keymap, "ED_SCR_OT_frame_offset", LEFTARROWKEY, KM_PRESS, 0, 0)->ptr, "delta", -1);
|
||||
|
||||
@@ -337,23 +337,6 @@ static uiBlock *time_framemenu(bContext *C, uiMenuBlockHandle *handle, void *arg
|
||||
return block;
|
||||
}
|
||||
|
||||
static void start_animated_screen(SpaceTime *stime)
|
||||
{
|
||||
// XXX add_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM, stime->redraws);
|
||||
|
||||
// if(stime->redraws & TIME_WITH_SEQ_AUDIO)
|
||||
// audiostream_start( CFRA );
|
||||
|
||||
// BKE_ptcache_set_continue_physics((stime->redraws & TIME_CONTINUE_PHYSICS));
|
||||
}
|
||||
|
||||
static void end_animated_screen(SpaceTime *stime)
|
||||
{
|
||||
// rem_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM);
|
||||
|
||||
// audiostream_stop();
|
||||
// BKE_ptcache_set_continue_physics(0);
|
||||
}
|
||||
|
||||
#define B_REDRAWALL 750
|
||||
#define B_TL_REW 751
|
||||
@@ -374,7 +357,7 @@ static void end_animated_screen(SpaceTime *stime)
|
||||
|
||||
void do_time_buttons(bContext *C, void *arg, int event)
|
||||
{
|
||||
SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
|
||||
// SpaceTime *stime= (SpaceTime*)CTX_wm_space_data(C);
|
||||
Scene *scene= CTX_data_scene(C);
|
||||
|
||||
switch(event) {
|
||||
@@ -386,10 +369,10 @@ void do_time_buttons(bContext *C, void *arg, int event)
|
||||
//update_for_newframe();
|
||||
break;
|
||||
case B_TL_PLAY:
|
||||
start_animated_screen(stime);
|
||||
ED_animation_timer(CTX_wm_window(C), 1);
|
||||
break;
|
||||
case B_TL_STOP:
|
||||
end_animated_screen(stime);
|
||||
ED_animation_timer(CTX_wm_window(C), 0);
|
||||
WM_event_add_notifier(C, WM_NOTE_WINDOW_REDRAW, 0, NULL);
|
||||
break;
|
||||
case B_TL_FF:
|
||||
@@ -524,10 +507,10 @@ void time_header_buttons(const bContext *C, ARegion *ar)
|
||||
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Skip to previous keyframe (Ctrl PageDown)");
|
||||
xco+= XIC+4;
|
||||
|
||||
// if(has_screenhandler(G.curscreen, SCREEN_HANDLER_ANIM))
|
||||
// uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
|
||||
// xco, 0, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
|
||||
// else
|
||||
if(CTX_wm_window(C)->animtimer)
|
||||
uiDefIconBut(block, BUT, B_TL_STOP, ICON_PAUSE,
|
||||
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Stop Playing Timeline");
|
||||
else
|
||||
uiDefIconBut(block, BUT, B_TL_PLAY, ICON_PLAY,
|
||||
xco, yco, XIC, YIC, 0, 0, 0, 0, 0, "Play Timeline ");
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ struct wmLocal;
|
||||
struct bScreen;
|
||||
struct uiBlock;
|
||||
struct wmSubWindow;
|
||||
struct wmTimerHandle;
|
||||
struct StructRNA;
|
||||
struct PointerRNA;
|
||||
|
||||
@@ -93,6 +94,8 @@ typedef struct wmWindow {
|
||||
|
||||
struct wmSubWindow *curswin; /* internal for wm_subwindow.c only */
|
||||
|
||||
struct wmTimerHandle *animtimer;
|
||||
|
||||
ListBase queue; /* all events (ghost level events were handled) */
|
||||
ListBase handlers; /* window+screen handlers, overriding all queues */
|
||||
|
||||
|
||||
@@ -675,7 +675,7 @@ void wm_event_do_handlers(bContext *C)
|
||||
CTX_wm_area_set(C, area_event_inside(C, event));
|
||||
CTX_wm_region_set(C, region_event_inside(C, event));
|
||||
|
||||
/* MVC demands to not draw in event handlers... for now we leave it */
|
||||
/* MVC demands to not draw in event handlers... but we need to leave it for ogl selecting etc */
|
||||
wm_window_make_drawable(C, win);
|
||||
|
||||
action= wm_handlers_do(C, event, &win->handlers);
|
||||
|
||||
@@ -498,8 +498,21 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr private)
|
||||
|
||||
void wm_window_process_events(int wait_for_event)
|
||||
{
|
||||
GHOST_ProcessEvents(g_system, wait_for_event);
|
||||
GHOST_DispatchEvents(g_system);
|
||||
int handled= 0;
|
||||
|
||||
/* ghost only processes 1 (timer?) event a time... we want to accumulate all */
|
||||
while(1) {
|
||||
if(GHOST_ProcessEvents(g_system, 0)) {
|
||||
GHOST_DispatchEvents(g_system);
|
||||
handled= 1;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
if(handled==0 && wait_for_event) {
|
||||
GHOST_ProcessEvents(g_system, wait_for_event);
|
||||
GHOST_DispatchEvents(g_system);
|
||||
}
|
||||
}
|
||||
|
||||
/* **************** init ********************** */
|
||||
|
||||
Reference in New Issue
Block a user