Merged 15170:15635 from trunk (no conflicts or even merges)
[blender.git] / source / blender / src / editsound.c
index 2e333b9f43e3d6eb865cac0665b6dcdb7a62419f..05eb094a7c21a3b13b8533eb62c27ed623afb719 100644 (file)
@@ -1,15 +1,12 @@
 /**
  * $Id$
  *
- * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ * ***** BEGIN GPL LICENSE BLOCK *****
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
  * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version. The Blender
- * Foundation also sells licenses for use in proprietary software under
- * the Blender License.  See http://www.blender.org/BL/ for information
- * about this.
+ * of the License, or (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +24,7 @@
  *
  * Contributor(s): none yet.
  *
- * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ * ***** END GPL LICENSE BLOCK *****
  */
 
 #include <stdio.h>
@@ -123,7 +120,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
 
        if(val) {
                
-               if( uiDoBlocks(&curarea->uiblocks, event)!=UI_NOTHING ) event= 0;
+               if( uiDoBlocks(&curarea->uiblocks, event, 1)!=UI_NOTHING ) event= 0;
 
                /* swap mouse buttons based on user preference */
                if (U.flag & USER_LMOUSESELECT) {
@@ -143,7 +140,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                getmouseco_areawin(mval);
                                areamouseco_to_ipoco(G.v2d, mval, &dx, &dy);
                                
-                               cfra = (int)dx;
+                               cfra = (int)(dx+0.5f);
                                if(cfra< 1) cfra= 1;
                                
                                if( cfra!=CFRA || first )
@@ -151,7 +148,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                        first= 0;
                                        CFRA= cfra;
                                        update_for_newframe();
-                                       force_draw_plus(SPACE_VIEW3D, 1);
+                                       force_draw_all(0);
                                }
                                else PIL_sleep_ms(30);
                        
@@ -173,7 +170,7 @@ void winqreadsoundspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                getmouseco_areawin(mval);
                                areamouseco_to_ipoco(G.v2d, mval, &dx, &dy);
 
-                               marker = find_nearest_marker(0);
+                               marker = find_nearest_marker(SCE_MARKERS, 0);
                                if (marker) {
                                        if ((G.qual & LR_SHIFTKEY)==0)
                                                deselect_markers(0, 0);
@@ -716,7 +713,7 @@ bSound *sound_new_sound(char *name)
        if (!G.scene->audio.mixrate) G.scene->audio.mixrate = 44100;
        /* convert the name to absolute path */
        strcpy(str, name);
-       BLI_convertstringcode(str, G.sce, G.scene->r.cfra);
+       BLI_convertstringcode(str, G.sce);
 
        /* check if the sample on disk can be opened */
        file = open(str, O_BINARY|O_RDONLY);
@@ -798,6 +795,7 @@ int sound_set_sample(bSound *sound, bSample *sample)
 
 bSample *sound_new_sample(bSound *sound)
 {
+       char samplename[FILE_MAX];
        bSample *sample = NULL;
        int len;
        char *name;
@@ -824,9 +822,12 @@ bSample *sound_new_sample(bSound *sound)
                sample->alindex = SAMPLE_INVALID;
 
                /* convert sound->name to abolute filename */
-               strcpy(sample->name, sound->name);
-               BLI_convertstringcode(sample->name, G.sce, G.scene->r.cfra);
-               
+               /* TODO: increase sound->name, sample->name and strip->name to FILE_MAX, to avoid
+                  cutting off sample name here - elubie */
+               BLI_strncpy(samplename, sound->name, FILE_MAX);         
+               BLI_convertstringcode(samplename, G.sce);
+               BLI_strncpy(sample->name, samplename, FILE_MAXDIR);
+
                /* connect the pf to the sample */
                if (sound->newpackedfile)
                        sample->packedfile = sound->newpackedfile;
@@ -848,13 +849,13 @@ bSample *sound_find_sample(bSound *sound)
        
        // convert sound->name to abolute filename
        strcpy(name, sound->name);
-       BLI_convertstringcode(name, G.sce, G.scene->r.cfra);
+       BLI_convertstringcode(name, G.sce);
        
        /* search through the list of loaded samples */
        sample = samples->first;
        while (sample) {
                strcpy(samplename, sample->name);
-               BLI_convertstringcode(samplename, G.sce, G.scene->r.cfra);
+               BLI_convertstringcode(samplename, G.sce);
                
                if (strcmp(name, samplename) == 0)      {
                        break;