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
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2013-03-08 17:03:04 +0400
committerTon Roosendaal <ton@blender.org>2013-03-08 17:03:04 +0400
commit616a00950eb6490d14a602b35ac54b5446fd823e (patch)
treed132565e17f2c0c2b6d391a98f67708a7a1fa1ca /source/blender/windowmanager/intern/wm_playanim.c
parent181ac91d6de5d2829be3b61aa46d1b264147769c (diff)
Feature request:
Blender's anim player (blender -a) now allows drop of image or movie file. It then restarts itself completely (close window, open new).
Diffstat (limited to 'source/blender/windowmanager/intern/wm_playanim.c')
-rw-r--r--source/blender/windowmanager/intern/wm_playanim.c62
1 files changed, 55 insertions, 7 deletions
diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c
index 5a9d3d7d340..b3e6fd04320 100644
--- a/source/blender/windowmanager/intern/wm_playanim.c
+++ b/source/blender/windowmanager/intern/wm_playanim.c
@@ -91,7 +91,7 @@ typedef struct PlayState {
short wait2;
short stopped;
short go;
-
+
int fstep;
/* current picture */
@@ -103,6 +103,9 @@ typedef struct PlayState {
/* saves passing args */
struct ImBuf *curframe_ibuf;
+
+ /* restarts player for file drop */
+ char dropped_file[FILE_MAX];
} PlayState;
/* for debugging */
@@ -735,6 +738,23 @@ static int ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void)
ps->go = FALSE;
break;
}
+ case GHOST_kEventDraggingDropDone:
+ {
+ GHOST_TEventDragnDropData *ddd = GHOST_GetEventData(evt);
+
+ if (ddd->dataType == GHOST_kDragnDropTypeFilenames) {
+ GHOST_TStringArray *stra = ddd->data;
+ int a;
+
+ for (a = 0; a < stra->count; a++) {
+ BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file));
+ ps->go = FALSE;
+ printf("drop file %s\n", stra->strings[a]);
+ break; /* only one drop element supported now */
+ }
+ }
+ break;
+ }
default:
/* quiet warnings */
break;
@@ -785,12 +805,12 @@ static void playanim_window_zoom(const PlayState *ps, const float zoom_offset)
GHOST_SetClientSize(g_WS.ghost_window, sizex, sizey);
}
-void WM_main_playanim(int argc, const char **argv)
+/* return path for restart */
+static char *wm_main_playanim_intern(int argc, const char **argv)
{
struct ImBuf *ibuf = NULL;
- char filepath[FILE_MAX];
+ static char filepath[FILE_MAX]; /* abused to return dropped file path */
GHOST_TUns32 maxwinx, maxwiny;
- /* short c233 = FALSE, yuvx = FALSE; */ /* UNUSED */
int i;
/* This was done to disambiguate the name for use under c++. */
struct anim *anim = NULL;
@@ -798,7 +818,7 @@ void WM_main_playanim(int argc, const char **argv)
int sfra = -1;
int efra = -1;
int totblock;
-
+
PlayState ps = {0};
/* ps.doubleb = TRUE;*/ /* UNUSED */
@@ -813,6 +833,7 @@ void WM_main_playanim(int argc, const char **argv)
ps.wait2 = FALSE;
ps.stopped = FALSE;
ps.picture = NULL;
+ ps.dropped_file[0] = 0;
/* resetmap = FALSE */
ps.fstep = 1;
@@ -1142,12 +1163,20 @@ void WM_main_playanim(int argc, const char **argv)
#else
/* we still miss freeing a lot!,
* but many areas could skip initialization too for anim play */
- IMB_exit();
- BKE_images_exit();
+
BLF_exit();
#endif
GHOST_DisposeWindow(g_WS.ghost_system, g_WS.ghost_window);
+ /* early exit, IMB and BKE should be exited only in end */
+ if (ps.dropped_file) {
+ BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath));
+ return filepath;
+ }
+
+ IMB_exit();
+ BKE_images_exit();
+
totblock = MEM_get_memory_blocks_in_use();
if (totblock != 0) {
/* prints many bAKey, bArgument's which are tricky to fix */
@@ -1156,4 +1185,23 @@ void WM_main_playanim(int argc, const char **argv)
MEM_printmemlist();
#endif
}
+
+ return NULL;
+}
+
+
+void WM_main_playanim(int argc, const char **argv)
+{
+ int looping = TRUE;
+
+ while (looping) {
+ char *filepath = wm_main_playanim_intern(argc, argv);
+
+ if (filepath) { /* use simple args */
+ argv[1] = "-a";
+ argv[2] = filepath;
+ argc = 3;
+ }
+ else looping = 0;
+ }
}