Revision: 55114
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55114
Author:   ton
Date:     2013-03-08 13:03:04 +0000 (Fri, 08 Mar 2013)
Log Message:
-----------
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).

Modified Paths:
--------------
    trunk/blender/source/blender/windowmanager/intern/wm_playanim.c

Modified: trunk/blender/source/blender/windowmanager/intern/wm_playanim.c
===================================================================
--- trunk/blender/source/blender/windowmanager/intern/wm_playanim.c     
2013-03-08 10:59:43 UTC (rev 55113)
+++ trunk/blender/source/blender/windowmanager/intern/wm_playanim.c     
2013-03-08 13:03:04 UTC (rev 55114)
@@ -91,7 +91,7 @@
        short wait2;
        short stopped;
        short go;
-
+       
        int fstep;
 
        /* current picture */
@@ -103,6 +103,9 @@
 
        /* saves passing args */
        struct ImBuf *curframe_ibuf;
+       
+       /* restarts player for file drop */
+       char dropped_file[FILE_MAX];
 } PlayState;
 
 /* for debugging */
@@ -735,6 +738,23 @@
                        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 @@
        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 @@
        int sfra = -1;
        int efra = -1;
        int totblock;
-
+       
        PlayState ps = {0};
 
        /* ps.doubleb   = TRUE;*/ /* UNUSED */
@@ -813,6 +833,7 @@
        ps.wait2     = FALSE;
        ps.stopped   = FALSE;
        ps.picture   = NULL;
+       ps.dropped_file[0] = 0;
        /* resetmap = FALSE */
 
        ps.fstep     = 1;
@@ -1142,12 +1163,20 @@
 #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 @@
                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;
+       }
+}

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to