Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv26457

Modified Files:
      Tag: Audacity_UmixIt
        Lyrics.cpp Project.cpp 
Log Message:
Mac fixes and improvements to Lyrics bouncing

Index: Project.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Project.cpp,v
retrieving revision 1.178.2.17.2.4
retrieving revision 1.178.2.17.2.5
diff -u -d -r1.178.2.17.2.4 -r1.178.2.17.2.5
--- Project.cpp 29 Nov 2006 03:14:04 -0000      1.178.2.17.2.4
+++ Project.cpp 29 Nov 2006 09:59:36 -0000      1.178.2.17.2.5
@@ -166,11 +166,14 @@
 
 bool ImportXMLTagHandler::HandleXMLTag(const char *tag, const char **attrs) 
 {
-   if (strcmp(tag, "import") || strcmp(*attrs++, "filename")) return false;
+   if (strcmp(tag, "import") ||
+       attrs==NULL || (*attrs)==NULL ||
+       strcmp(*attrs++, "filename")) return false;
    wxString strPathname = *attrs;
    if (!wxFile::Exists(FILENAME(strPathname))) {
-      strPathname = mProject->GetDirManager()->GetProjectDataDir() + "\\" + 
strPathname;
-      if (!wxFile::Exists(FILENAME(strPathname))) return false;
+      strPathname = mProject->GetDirManager()->GetProjectDataDir() + 
wxFILE_SEP_PATH + strPathname;
+      if (!wxFile::Exists(FILENAME(strPathname)))
+        return false;
    }
    mProject->Import(strPathname);
    return true; //v result from Import?

Index: Lyrics.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Attic/Lyrics.cpp,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- Lyrics.cpp  29 Nov 2006 03:14:04 -0000      1.1.2.3
+++ Lyrics.cpp  29 Nov 2006 09:59:36 -0000      1.1.2.4
@@ -50,6 +50,11 @@
    Clear();
    Finish(0.0);
    mT = 0.0;
+
+  #ifdef __WXMAC__
+   wxSizeEvent dummyEvent;
+   OnSize(dummyEvent);
+  #endif
 }
 
 Lyrics::~Lyrics()
@@ -142,7 +147,30 @@
       else {
          dc->GetTextExtent(mSyllables[i].textWithSpace, &width, &height);
       }
-      mSyllables[i].width = width + 30;
+
+      // Add some space between words; the space is normally small but
+      // when there's a long pause relative to the previous word, insert
+      // extra space.
+      int extraSpacing;
+      if (i >= 2 && i < mSyllables.GetCount()-2) {
+         double deltaThis = mSyllables[i+1].t - mSyllables[i].t;
+         double deltaPrev = mSyllables[i].t - mSyllables[i-1].t;
+
+         double ratio;
+         if (deltaPrev > 0.0)
+            ratio = deltaThis / deltaPrev;
+         else
+            ratio = deltaThis;
+
+         if (ratio > 2.0)
+            extraSpacing = 15 + (int)(15.0 * ratio);
+         else
+            extraSpacing = 15;
+      }
+      else
+         extraSpacing = 20;
+      
+      mSyllables[i].width = width + extraSpacing;
       mSyllables[i].leftX = x;
       mSyllables[i].x = x + width/2;
       x += mSyllables[i].width;
@@ -243,6 +271,12 @@
 
    t = (t - t1) / (t2 - t1);
    double xx = a*t*t*t + b*t*t + c*t + d;
+
+   // Unfortunately sometimes our cubic goes backwards.  This is a quick
+   // hack to stop that from happening.
+   if (xx < x1)
+      xx = x1;
+
    *outX = (int)xx;
 
    // The y position is a simple cosine curve; the max height is a
@@ -282,7 +316,7 @@
          wxString strLogoFilename = pBranding->GetBrandLogoFilename();
          if (!strLogoFilename.IsEmpty()){
             wxString strLogoPathname = 
-               pProject->GetDirManager()->GetProjectDataDir() + "\\" + 
strLogoFilename;
+               pProject->GetDirManager()->GetProjectDataDir() + 
wxFILE_SEP_PATH + strLogoFilename;
             if (::wxFileExists(FILENAME(strLogoPathname))) 
                strIMGtag = "<img src=\"" + FILENAME(strLogoPathname) + "\" 
alt=\"" + strLogoFilename + "\"><br>";
          }
@@ -351,7 +385,13 @@
          "</body>\n</html>";
    }
 
+   //int x, y;
+   //mHtml->GetViewStart(&x, &y);
+
    mHtml->SetPage(htmlText);
+
+   //mHtml->Scroll(x, y);
+
    mHtml->Refresh(false);
 
    mCurrentSyllable = i;   
@@ -425,8 +465,13 @@
          dc.SetTextForeground(*wxBLACK);
          changedColor = true;
       }
-         
-      dc.DrawText(mSyllables[i].text,
+
+      wxString text = mSyllables[i].text;
+      if (text.Length() > 0 && text.Right(1)=="_") {
+         text = text.Left(text.Length() - 1);
+      }
+
+      dc.DrawText(text,
                   mSyllables[i].leftX + ctr - x,
                   yTextTop);
    }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to