diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-05-07 12:18:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-05-07 12:18:21 +0400 |
commit | a8dddca0fe33e37c4af95e7944f66535d183aedf (patch) | |
tree | 87824b4bf15c5ac294655686c53350a36cc0bec3 /source/blender/windowmanager | |
parent | 5e55fc21b78a9a6070b951bccf10a539b06f8e97 (diff) |
playanim: check for escape key while loading images
(todo from 2.4x)
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/intern/wm_playanim.c | 52 |
1 files changed, 44 insertions, 8 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 445ba7344d3..cb263dcc9b5 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -96,6 +96,8 @@ typedef struct PlayState { bool wait2; bool stopped; bool go; + /* waiting for images to load */ + bool loading; int fstep; @@ -303,7 +305,7 @@ static void playanim_toscreen(PlayState *ps, PlayAnimPict *picture, struct ImBuf GHOST_SwapWindowBuffers(g_WS.ghost_window); } -static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep, int fontid) +static void build_pict_list_ex(PlayState *ps, const char *first, int totframes, int fstep, int fontid) { char *mem, filepath[FILE_MAX]; // short val; @@ -357,6 +359,7 @@ static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep */ while (IMB_ispic(filepath) && totframes) { + bool hasevent; size_t size; int file; @@ -431,21 +434,28 @@ static void build_pict_list(PlayState *ps, char *first, int totframes, int fstep BLI_newname(filepath, +fstep); -#if 0 // XXX25 - while (qtest()) { - switch (qreadN(&val)) { - case ESCKEY: - if (val) return; - break; + while ((hasevent = GHOST_ProcessEvents(g_WS.ghost_system, 0))) { + if (hasevent) { + GHOST_DispatchEvents(g_WS.ghost_system); + } + if (ps->loading == false) { + return; } } -#endif + totframes--; } } return; } +static void build_pict_list(PlayState *ps, const char *first, int totframes, int fstep, int fontid) +{ + ps->loading = true; + build_pict_list_ex(ps, first, totframes, fstep, fontid); + ps->loading = false; +} + static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) { PlayState *ps = (PlayState *)ps_void; @@ -459,6 +469,31 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) /* convert ghost event into value keyboard or mouse */ val = ELEM(type, GHOST_kEventKeyDown, GHOST_kEventButtonDown); + + /* first check if we're busy loading files */ + if (ps->loading) { + switch (type) { + case GHOST_kEventKeyDown: + case GHOST_kEventKeyUp: + { + GHOST_TEventKeyData *key_data; + + key_data = (GHOST_TEventKeyData *)GHOST_GetEventData(evt); + switch (key_data->key) { + case GHOST_kKeyEsc: + ps->loading = false; + break; + default: + break; + } + } + default: + break; + } + return 1; + } + + if (ps->wait2 && ps->stopped) { ps->stopped = false; } @@ -850,6 +885,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) ps.sstep = false; ps.wait2 = false; ps.stopped = false; + ps.loading = false; ps.picture = NULL; ps.dropped_file[0] = 0; ps.zoom = 1.0f; |