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

Modified Files:
        TrackPanel.cpp TrackPanel.h 
Log Message:
Handle drag zooming left/right edge detection better
Changed a few "GetLabelWidth()+1" to use GetLeftOffset() instead.


Index: TrackPanel.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TrackPanel.cpp,v
retrieving revision 1.351
retrieving revision 1.352
diff -u -d -r1.351 -r1.352
--- TrackPanel.cpp      2 Apr 2007 00:07:49 -0000       1.351
+++ TrackPanel.cpp      19 May 2007 18:56:43 -0000      1.352
@@ -2381,34 +2381,27 @@
 void TrackPanel::HandleZoom(wxMouseEvent & event)
 {
    if (event.ButtonDown() || event.ButtonDClick(1)) {
-      HandleZoomClick( event );
-   }
-   else if (event.Dragging()) {
-      HandleZoomDrag( event );
-   }
-   else if (event.ButtonUp()) {
-      HandleZoomButtonUp( event );
-   }
-}
-
-/// Vertical zooming (triggered by clicking in the
-/// vertical ruler)
-void TrackPanel::HandleVZoom(wxMouseEvent & event)
-{
-   if (event.ButtonDown() || event.ButtonDClick()) {
-      HandleVZoomClick( event );
+      HandleZoomClick(event);
    }
    else if (event.Dragging()) {
-      HandleVZoomDrag( event );
+      HandleZoomDrag(event);
    }
    else if (event.ButtonUp()) {
-      HandleVZoomButtonUp( event );
+      HandleZoomButtonUp(event);
    }
 }
 
 /// Zoom button down, record the position.
 void TrackPanel::HandleZoomClick(wxMouseEvent & event)
 {
+   Track *t;
+   wxRect r;
+   int num;
+
+   t = FindTrack(event.m_x, event.m_y, false, false, &r, &num);
+
+   SetCapturedTrack(t, IsZooming);
+
    mZoomStart = event.m_x;
    mZoomEnd = event.m_x;
 }
@@ -2416,8 +2409,21 @@
 /// Zoom drag
 void TrackPanel::HandleZoomDrag(wxMouseEvent & event)
 {
+   int left, width, height;
+
+   left = GetLeftOffset();
+   GetTracksUsableArea(&width, &height);
+
    mZoomEnd = event.m_x;
-   if (IsDragZooming()){
+
+   if (event.m_x < left) {
+      mZoomEnd = left;
+   }
+   else if (event.m_x >= left + width - 1) {
+      mZoomEnd = left + width - 1;
+   }
+
+   if (IsDragZooming()) {
       Refresh(false);
    }
 }
@@ -2432,12 +2438,14 @@
    }
 
    if (IsDragZooming())
-      DragZoom(event, GetLabelWidth()+1);
+      DragZoom(event, GetLeftOffset());
    else
-      DoZoomInOut(event, GetLabelWidth()+1);
+      DoZoomInOut(event, GetLeftOffset());
 
    mZoomEnd = mZoomStart = 0;
 
+   SetCapturedTrack(NULL);
+
    MakeParentRedrawScrollbars();
    Refresh(false);
 }
@@ -2482,6 +2490,21 @@
    mViewInfo->h += (center_h - new_center_h);
 }
 
+/// Vertical zooming (triggered by clicking in the
+/// vertical ruler)
+void TrackPanel::HandleVZoom(wxMouseEvent & event)
+{
+   if (event.ButtonDown() || event.ButtonDClick()) {
+      HandleVZoomClick( event );
+   }
+   else if (event.Dragging()) {
+      HandleVZoomDrag( event );
+   }
+   else if (event.ButtonUp()) {
+      HandleVZoomButtonUp( event );
+   }
+}
+
 /// VZoom click
 void TrackPanel::HandleVZoomClick( wxMouseEvent & event )
 {
@@ -3683,7 +3706,7 @@
    {
       // MM: Zoom in/out when used with Control key down
       // MM: I don't understand what trackLeftEdge does
-      int trackLeftEdge = GetLabelWidth()+1;
+      int trackLeftEdge = GetLeftOffset();
       
       double center_h = PositionToTime(event.m_x, trackLeftEdge);
       if (steps < 0)
@@ -3851,6 +3874,9 @@
    case IsMinimizing:
       HandleMinimizing(event);
       break;
+   case IsZooming:
+      HandleZoom(event);
+      break;
    default: //includes case of IsUncaptured
       HandleTrackSpecificMouseEvent(event);
       break;
@@ -4120,7 +4146,7 @@
    }
 
    //Determine if user clicked on the track's left-hand label
-   if (!mCapturedTrack && event.m_x < GetLabelWidth()+1) {
+   if (!mCapturedTrack && event.m_x < GetLeftOffset()) {
       if (event.m_x >= GetVRulerOffset()) {
          if( !event.Dragging() ) // JKC: Only want the mouse down event.
             HandleVZoom(event);
@@ -6018,7 +6044,7 @@
    GetSize(&r.width, &r.height);
 
    if (label) {
-      r.width = GetLabelWidth()+1;
+      r.width = GetLeftOffset();
    } else {
       r.x = GetLeftOffset();
       r.width -= GetLeftOffset();

Index: TrackPanel.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TrackPanel.h,v
retrieving revision 1.115
retrieving revision 1.116
diff -u -d -r1.115 -r1.116
--- TrackPanel.h        7 May 2007 09:25:15 -0000       1.115
+++ TrackPanel.h        19 May 2007 18:56:43 -0000      1.116
@@ -514,7 +514,8 @@
       IsMinimizing,
       IsOverCutLine,
       WasOverCutLine,
-      IsPopping
+      IsPopping,
+      IsZooming
    };
 
    enum MouseCaptureEnum mMouseCapture;


-------------------------------------------------------------------------
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