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

Modified Files:
        Experimental.h LabelTrack.cpp LabelTrack.h TrackPanel.cpp 
        TrackPanel.h WaveTrack.cpp WaveTrack.h 
Log Message:


Alpha of sticky tracks, full writeup on -devel


Index: TrackPanel.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TrackPanel.h,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- TrackPanel.h        17 Feb 2008 23:06:05 -0000      1.125
+++ TrackPanel.h        12 Jun 2008 15:29:08 -0000      1.126
@@ -21,6 +21,7 @@
 #include "Sequence.h"  
 #include "WaveClip.h"
 #include "WaveTrack.h"
+#include "LabelTrack.h"
 
 class wxMenu;
 class wxRect;
@@ -212,6 +213,8 @@
 
    Track *GetFocusedTrack();
    void SetFocusedTrack(Track *t);
+   
+   void OnTrackSticky(wxCommandEvent & event);
 
    void HandleCursorForLastMouseEvent();
 #ifdef EXPERIMENTAL_RULER_AUTOSIZE
@@ -567,6 +570,7 @@
    wxMenu *mLabelTrackMenu;
    wxMenu *mRateMenu;
    wxMenu *mFormatMenu;
+   wxMenu *mStickyLabelMenu;
    wxMenu *mLabelTrackInfoMenu;
 
    Track *mPopupMenuTarget;

Index: LabelTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LabelTrack.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- LabelTrack.h        26 Dec 2007 16:11:33 -0000      1.40
+++ LabelTrack.h        12 Jun 2008 15:29:06 -0000      1.41
@@ -166,6 +166,9 @@
    //get current cursor position
    bool CalcCursorX(wxWindow * parent, int * x);
    int getCurrentCursorPosition() const { return mCurrentCursorPos; };
+   
+   void ShiftLabelsOnClear(double b, double e, WaveTrack *track);
+   void ShiftLabelsOnInsert(double length, double pt, WaveTrack *track);
 
  public:
         void SortLabels();

Index: TrackPanel.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TrackPanel.cpp,v
retrieving revision 1.395
retrieving revision 1.396
diff -u -d -r1.395 -r1.396
--- TrackPanel.cpp      3 Jun 2008 14:30:19 -0000       1.395
+++ TrackPanel.cpp      12 Jun 2008 15:29:06 -0000      1.396
@@ -313,6 +313,7 @@
    OnCutSelectedTextID,
    OnCopySelectedTextID,
    OnPasteSelectedTextID,
+   OnStickySubmenuID = 12000,//leave 12000-12999 open for sticky tracks
 };
 
 BEGIN_EVENT_TABLE(TrackPanel, wxWindow)
@@ -344,6 +345,7 @@
     EVT_MENU(OnCutSelectedTextID, TrackPanel::OnCutSelectedText)
     EVT_MENU(OnCopySelectedTextID, TrackPanel::OnCopySelectedText)
     EVT_MENU(OnPasteSelectedTextID, TrackPanel::OnPasteSelectedText)
+    EVT_MENU_RANGE(OnStickySubmenuID, OnStickySubmenuID+999, 
TrackPanel::OnTrackSticky)
 END_EVENT_TABLE()
 
 
@@ -5775,8 +5777,46 @@
    if (t->GetKind() == Track::Note)
       theMenu = mNoteTrackMenu;
    
-   if (t->GetKind() == Track::Label)
-      theMenu = mLabelTrackMenu;
+   if (t->GetKind() == Track::Label){
+#ifdef EXPERIMENTAL_STICKY_TRACKS
+      delete mLabelTrackMenu;
+      mLabelTrackMenu = new wxMenu();
+   
+      AudacityProject *p = GetActiveProject();
+      if (!p) return;
+      TrackListIterator iter(p->GetTracks());
+      WaveTrack *wt = (WaveTrack *) iter.First();
+      int count=1;
+      mStickyLabelMenu = new wxMenu();
+      while (wt) {
+         if (wt->GetKind()==Track::Wave){
+            wxString name;
+            name = wt->GetName();
+            if (name == wxT("Audio Track")) 
+               name.Printf(wxT("Wave Track #%d"), count);
+            mStickyLabelMenu->AppendCheckItem(OnStickySubmenuID + count, name);
+            if (wt->GetStickyTrack()){
+               if (wt->GetStickyTrack() == t)
+                  mStickyLabelMenu->Check(OnStickySubmenuID + count, true);
+               else
+                  mStickyLabelMenu->Enable(OnStickySubmenuID + count, false);
+            }
+            count++;
+         }
+         wt = (WaveTrack *) iter.Next();
+      }
+   
+      mLabelTrackMenu->Append(OnSetNameID, _("Name..."));
+      mLabelTrackMenu->AppendSeparator();
+      mLabelTrackMenu->Append(OnSetFontID, _("Font..."));
+      mLabelTrackMenu->AppendSeparator();
+      mLabelTrackMenu->Append(OnMoveUpID, _("Move Track Up"));
+      mLabelTrackMenu->Append(OnMoveDownID, _("Move Track Down"));
+      mLabelTrackMenu->Append(0, _("Group with Wave Track"), mStickyLabelMenu);
+      mLabelTrackMenu->Append(12999, _("Clear any grouping"));
+#endif
+       theMenu = mLabelTrackMenu;
+   }
    
    if (theMenu) {
       theMenu->Enable(OnMoveUpID, mTracks->CanMoveUp(t));
@@ -6473,6 +6513,40 @@
    RefreshTrack(lt, true);
 }
 
+void TrackPanel::OnTrackSticky(wxCommandEvent & event)
+{
+   wxASSERT(mPopupMenuTarget && mPopupMenuTarget->GetKind() == Track::Label);
+   int id = event.GetId();
+   int pos = id - 12000;
+   int count = 1;
+
+   AudacityProject *p = GetActiveProject();
+   if (!p) return;
+   TrackListIterator iter(p->GetTracks());
+   WaveTrack *wt = (WaveTrack *) iter.First();
+   while (wt && count!=pos) {
+      if (wt->GetKind()==Track::Wave){
+         count++;
+      }
+      wt = (WaveTrack *) iter.Next();
+   }
+   if (wt){
+      if (event.IsChecked())
+         wt->SetStickyTrack((LabelTrack *)mPopupMenuTarget);
+      else
+         wt->SetStickyTrack(NULL);
+   }
+   //TEMP CODE FOR REMOVAL OF ALL ASSOCIATIONS
+   if (id==12999){
+      wt = (WaveTrack *) iter.First();
+      while (wt) {
+         if (wt->GetKind()==Track::Wave)
+            wt->SetStickyTrack(NULL);
+         wt = (WaveTrack *) iter.Next();
+      }
+   }//END TEMP CODE
+}
+
 // Small helper class to enumerate all fonts in the system
 // We use this because the default implementation of
 // wxFontEnumerator::GetFacenames() has changed between wx2.6 and 2.8

Index: WaveTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- WaveTrack.h 1 Jun 2008 06:57:29 -0000       1.51
+++ WaveTrack.h 12 Jun 2008 15:29:10 -0000      1.52
@@ -304,6 +304,9 @@
    // Resample track (i.e. all clips in the track)
    bool Resample(int rate, ProgressDialog *progress = NULL);
 
+   void SetStickyTrack(LabelTrack *lt) { mStickyLabelTrack = lt; }
+   LabelTrack* GetStickyTrack() { return mStickyLabelTrack; }
+
    //
    // The following code will eventually become part of a GUIWaveTrack
    // and will be taken out of the WaveTrack class:
@@ -364,6 +367,7 @@
    wxCriticalSection mFlushCriticalSection;
    wxCriticalSection mAppendCriticalSection;
    double mLegacyProjectFileOffset;
+   LabelTrack *mStickyLabelTrack;
 
 };
 

Index: LabelTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LabelTrack.cpp,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- LabelTrack.cpp      26 Dec 2007 16:11:33 -0000      1.88
+++ LabelTrack.cpp      12 Jun 2008 15:29:05 -0000      1.89
@@ -141,6 +141,43 @@
    }
 }
 
+void LabelTrack::ShiftLabelsOnClear(double b, double e, WaveTrack *track)
+{
+   for (unsigned int i=0;i<mLabels.GetCount();i++){
+      if (mLabels[i]->t >= e){//label is after deletion region
+         mLabels[i]->t  = mLabels[i]->t  - (e-b);
+         mLabels[i]->t1 = mLabels[i]->t1 - (e-b);
+      }else if (mLabels[i]->t >= b && mLabels[i]->t1 <= e){//deletion region 
encloses label
+         wxASSERT((i < (int)mLabels.GetCount()));
+         mLabels.RemoveAt(i);
+         i--;
+      }else if (mLabels[i]->t >= b && mLabels[i]->t1 > e){//deletion region 
covers start
+         mLabels[i]->t  = b;
+         mLabels[i]->t1 = mLabels[i]->t1 - (e - mLabels[i]->t);
+      }else if (mLabels[i]->t < b && mLabels[i]->t1 > b && mLabels[i]->t1 <= 
e){//deletion regions covers end
+         mLabels[i]->t1 = b;
+      }else if (mLabels[i]->t < b && mLabels[i]->t1 > e){//label encloses 
deletion region
+         mLabels[i]->t1 = mLabels[i]->t1 - (e-b);
+      }else if (mLabels[i]->t1 <= b){
+         //nothing
+      }
+   }
+}
+
+void LabelTrack::ShiftLabelsOnInsert(double length, double pt, WaveTrack 
*track)
+{
+   for (unsigned int i=0;i<mLabels.GetCount();i++){
+      if (mLabels[i]->t > pt && mLabels[i]->t1 > pt) {
+         mLabels[i]->t = mLabels[i]->t + length;
+         mLabels[i]->t1 = mLabels[i]->t1 + length;
+      }else if (mLabels[i]->t1 < pt) {
+         //nothing
+      }else if (mLabels[i]->t < pt && mLabels[i]->t1 > pt){
+         mLabels[i]->t1 = mLabels[i]->t1 + length;
+      }
+   }
+}
+
 void LabelTrack::ResetFlags()
 {
    mMouseXPos = -1;

Index: Experimental.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Experimental.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- Experimental.h      11 Jun 2008 20:09:47 -0000      1.31
+++ Experimental.h      12 Jun 2008 15:29:04 -0000      1.32
@@ -35,6 +35,9 @@
 //#define EXPERIMENTAL_THEMING
 #define EXPERIMENTAL_THEME_PREFS
 
+//Enables label/wavetrack pairing
+#define EXPERIMENTAL_STICKY_TRACKS
+
 //Next line enables Mic monitoring at times when it was previously off.
 //More work is needed as after recording or playing it results in an 
 //unwanted record-cursor on the wave track.

Index: WaveTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/WaveTrack.cpp,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- WaveTrack.cpp       1 Jun 2008 06:57:29 -0000       1.115
+++ WaveTrack.cpp       12 Jun 2008 15:29:08 -0000      1.116
@@ -36,6 +36,7 @@
 #include "float_cast.h"
 
 #include "WaveTrack.h"
+#include "LabelTrack.h"
 
 #include "Envelope.h"
 #include "Sequence.h"
@@ -89,6 +90,7 @@
    mDisplayNumLocations = 0;
    mDisplayLocations = NULL;
    mDisplayNumLocationsAllocated = 0;
+   mStickyLabelTrack = NULL;
 }
 
 WaveTrack::WaveTrack(WaveTrack &orig):
@@ -475,6 +477,10 @@
    double insertDuration = other->GetEndTime();
    WaveClipList::Node* it;
 
+#ifdef EXPERIMENTAL_STICKY_TRACKS
+   if (mStickyLabelTrack) 
mStickyLabelTrack->ShiftLabelsOnInsert(insertDuration, t0, this);
+#endif
+
    //printf("Check if we need to make room for the pasted data\n");
    
    // Make room for the pasted data, unless the space being pasted in is empty 
of
@@ -616,6 +622,12 @@
    if (t1 < t0)
       return false;
 
+#ifdef EXPERIMENTAL_STICKY_TRACKS
+   if (!split){
+      if (mStickyLabelTrack) mStickyLabelTrack->ShiftLabelsOnClear(t0, t1, 
this);
+   }
+#endif
+
    bool editClipCanMove = true;
    gPrefs->Read(wxT("/GUI/EditClipCanMove"), &editClipCanMove);
 


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to