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

Modified Files:
      Tag: Audacity_UmixIt
        Ruler.cpp Ruler.h 
Log Message:
Fixed control toolbar spacing, updated Makefile, fixed a crash on startup, and 
rewrote the AdornedRulerPanel selection clicking and dragging handler.

Index: Ruler.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/Ruler.h,v
retrieving revision 1.7.4.2.2.1
retrieving revision 1.7.4.2.2.2
diff -u -d -r1.7.4.2.2.1 -r1.7.4.2.2.2
--- Ruler.h     20 Apr 2007 01:22:35 -0000      1.7.4.2.2.1
+++ Ruler.h     20 Apr 2007 09:57:08 -0000      1.7.4.2.2.2
@@ -223,6 +223,8 @@
    Ruler  ruler;
 
 private:
+   int  mMouseClickX;
+   double mSelStart;
    ViewInfo * mViewInfo;
    int leftOffset;  // Number of pixels before we hit the 'zero position'.
    int GetLeftOffset() { return leftOffset;}

Index: Ruler.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/Ruler.cpp,v
retrieving revision 1.17.2.10.2.5
retrieving revision 1.17.2.10.2.6
diff -u -d -r1.17.2.10.2.5 -r1.17.2.10.2.6
--- Ruler.cpp   20 Apr 2007 01:22:35 -0000      1.17.2.10.2.5
+++ Ruler.cpp   20 Apr 2007 09:57:07 -0000      1.17.2.10.2.6
@@ -999,8 +999,8 @@
 
    DrawBorder(dc, r);
 
-   if (pViewInfo->sel0 < pViewInfo->sel1)
-      DrawSelection(dc, r);
+   //if (pViewInfo->sel0 < pViewInfo->sel1)
+   DrawSelection(dc, r);
 
    if( indicator )
       DrawIndicator(dc, bRecording);
@@ -1052,6 +1052,10 @@
    sr.y = 1;
    sr.width = p1 - p0 - 1;
    sr.height = GetRulerHeight() - 3;
+
+   if (sr.width < 1)
+     sr.width = 1;
+
    dc->DrawRectangle(sr);
 }
 
@@ -1098,43 +1102,38 @@
 
 void AdornedRulerPanel::OnMouseEvent(wxMouseEvent &evt)
 {
-   //vvvvv DRAGGING - but just for play region.
-   if (evt.LeftDown())
-   {
-   }
-   else if (evt.ButtonUp())
-   {
-      double zoomedLeftOffset = GetLeftOffset() / mViewInfo->zoom;
-      double sel0 = mViewInfo->sel0 - mViewInfo->h + zoomedLeftOffset;
-      double sel1 = mViewInfo->sel1 - mViewInfo->h + zoomedLeftOffset;
-
-      if (sel0 < 0.0)
-         sel0 = 0.0;
-      int width;
-      int height;
-      this->GetSize(&width, &height);
-
-      if (sel1 > (width / mViewInfo->zoom))
-         sel1 = width / mViewInfo->zoom;
+   double zoomedLeftOffset = GetLeftOffset() / mViewInfo->zoom;
+   double t = mViewInfo->h - zoomedLeftOffset +
+     (evt.m_x / mViewInfo->zoom);
 
-      int p0 = int (sel0 * mViewInfo->zoom + 0.5);
-      int p1 = int (sel1 * mViewInfo->zoom + 0.5);
+   if (evt.ButtonDown())
+   {
+      mMouseClickX = evt.m_x;
+      mSelStart = t;
 
-      long evtX = evt.GetX();
-      if (evtX < p0)
+      if (evt.ShiftDown())
       {
-         sel0 = evtX / mViewInfo->zoom;
-         if (sel0 < 0.0)
-            sel0 = 0.0;
-         mViewInfo->sel0 = sel0 + mViewInfo->h - zoomedLeftOffset;
+         if (fabs(t - mViewInfo->sel0) < fabs(t - mViewInfo->sel1)) {
+            mSelStart = mViewInfo->sel1;
+           mViewInfo->sel0 = t;
+        }
+        else {
+           mSelStart = mViewInfo->sel0;
+           mViewInfo->sel1 = t;
+        }
       }
-      else if (evtX > p1)
+      else
       {
-         sel1 = evtX / mViewInfo->zoom;
-         if (sel1 > (width / mViewInfo->zoom))
-            sel1 = width / mViewInfo->zoom;
-         mViewInfo->sel1 = sel1 + mViewInfo->h - zoomedLeftOffset;
+         mViewInfo->sel0 = t;
+         mViewInfo->sel1 = t;
       }
+
+      this->Refresh(false);
+   }
+   else if (evt.Dragging())
+   {
+      mViewInfo->sel0 = wxMin(mSelStart, t);
+      mViewInfo->sel1 = wxMax(mSelStart, t);
       this->Refresh(false);
    }
 }


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to