Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2008-12-21 22:58:25 +0300
committerTon Roosendaal <ton@blender.org>2008-12-21 22:58:25 +0300
commitf1e0cf36f857501b43bc4cf81a845c45dc9f294e (patch)
treed144602aa1f2bd893a74f1bd54f3d77c017930e1 /source
parent05aa83ad1e580bb793ff529760a81c5595193d97 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/include/ED_screen.h1
-rw-r--r--source/blender/editors/screen/screen_edit.c12
-rw-r--r--source/blender/editors/screen/screen_ops.c37
-rw-r--r--source/blender/editors/space_time/time_header.c31
-rw-r--r--source/blender/makesdna/DNA_windowmanager_types.h3
-rw-r--r--source/blender/windowmanager/intern/wm_event_system.c2
-rw-r--r--source/blender/windowmanager/intern/wm_window.c17
7 files changed, 74 insertions, 29 deletions
diff --git a/source/blender/editors/include/ED_screen.h b/source/blender/editors/include/ED_screen.h
index 22b74ea3715..c6e1764bb7b 100644
--- a/source/blender/editors/include/ED_screen.h
+++ b/source/blender/editors/include/ED_screen.h
@@ -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);
diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c
index 1022fea605c..4a60fc07a99 100644
--- a/source/blender/editors/screen/screen_edit.c
+++ b/source/blender/editors/screen/screen_edit.c
@@ -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));
+}
+
diff --git a/source/blender/editors/screen/screen_ops.c b/source/blender/editors/screen/screen_ops.c
index dd88b7ad2c3..c342962c2da 100644
--- a/source/blender/editors/screen/screen_ops.c
+++ b/source/blender/editors/screen/screen_ops.c
@@ -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);
diff --git a/source/blender/editors/space_time/time_header.c b/source/blender/editors/space_time/time_header.c
index d664cb28ee5..e7184ffd2d2 100644
--- a/source/blender/editors/space_time/time_header.c
+++ b/source/blender/editors/space_time/time_header.c
@@ -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 ");
diff --git a/source/blender/makesdna/DNA_windowmanager_types.h b/source/blender/makesdna/DNA_windowmanager_types.h
index 7144710ae47..874dd86e419 100644
--- a/source/blender/makesdna/DNA_windowmanager_types.h
+++ b/source/blender/makesdna/DNA_windowmanager_types.h
@@ -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 */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c
index 16b7e15612d..abd562a73cd 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -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);
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 649bc887e6c..7fba9a6115a 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -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 ********************** */