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

Modified Files:
        TrackPanel.cpp LabelTrack.cpp LabelTrack.h 
Log Message:
Ensure typing into labels is always visible.

Index: LabelTrack.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LabelTrack.cpp,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- LabelTrack.cpp      12 Mar 2007 09:23:07 -0000      1.76
+++ LabelTrack.cpp      16 Mar 2007 04:53:07 -0000      1.77
@@ -37,6 +37,7 @@
 #include <wx/clipbrd.h>
 #include <wx/dataobj.h>
 #include <wx/dc.h>
+#include <wx/dcclient.h>
 #include <wx/event.h>
 #include <wx/intl.h>
 #include <wx/log.h>
@@ -532,6 +533,23 @@
    }
 }
 
+bool LabelTrack::CalcCursorX(wxWindow * parent, int * x)
+{
+   if (mSelIndex >= 0) {
+      wxClientDC dc(parent);
+
+      if (msFont.Ok()) {
+         dc.SetFont(msFont);
+      }
+
+      mLabels[mSelIndex]->getXPos(dc, x, mCurrentCursorPos);
+      *x += LabelTrack::mIconWidth / 2;
+      return true;
+   }
+
+   return false;
+}
+
 /// Draw calls other functions to draw the LabelTrack.
 ///   @param  dc the device context
 ///   @param  r  the LabelTrack rectangle.
@@ -1242,12 +1260,18 @@
          case WXK_TAB:
             return true;
          break;
+         case 'C':
+         case 'X':
+         case 'V':
+//            if (event.CmdDown())
+//               return true;
+         break;
       }
    }
 
    if (IsGoodLabelCharacter(keyCode, charCode) && !event.CmdDown())
       return true;
-
+printf("false\n");
    return false;
 }
 

Index: LabelTrack.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/LabelTrack.h,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- LabelTrack.h        6 Nov 2006 05:36:45 -0000       1.36
+++ LabelTrack.h        16 Mar 2007 04:53:07 -0000      1.37
@@ -165,6 +165,7 @@
    void DeleteLabel(int index);
 
    //get current cursor position
+   bool CalcCursorX(wxWindow * parent, int * x);
    int getCurrentCursorPosition() const { return mCurrentCursorPos; };
 
  public:

Index: TrackPanel.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/TrackPanel.cpp,v
retrieving revision 1.344
retrieving revision 1.345
diff -u -d -r1.344 -r1.345
--- TrackPanel.cpp      13 Mar 2007 07:34:53 -0000      1.344
+++ TrackPanel.cpp      16 Mar 2007 04:53:07 -0000      1.345
@@ -3722,14 +3722,22 @@
       return;
    }
 
+   LabelTrack *lt = (LabelTrack *)t;
    double bkpSel0 = mViewInfo->sel0, bkpSel1 = mViewInfo->sel1;
+
    // Pass keystroke to labeltrack's handler and add to history if any
    // updates were done
-   if (((LabelTrack *)t)->OnKeyDown(mViewInfo->sel0, mViewInfo->sel1, event))
+   if (lt->OnKeyDown(mViewInfo->sel0, mViewInfo->sel1, event))
       MakeParentPushState(_("Modified Label"),
                           _("Label Edit"),
                           true /* consolidate */);
-   
+
+   // Make sure caret is in view
+   int x;
+   if (lt->CalcCursorX(this, &x)) {
+      ScrollIntoView(PositionToTime(x, GetLeftOffset()));
+   }
+
    // If selection modified, refresh
    // Otherwise, refresh track display if the keystroke was handled
    if( bkpSel0 != mViewInfo->sel0 || bkpSel1 != mViewInfo->sel1 )
@@ -3755,7 +3763,7 @@
       MakeParentPushState(_("Modified Label"),
                           _("Label Edit"),
                           true /* consolidate */);
-   
+
    // If selection modified, refresh
    // Otherwise, refresh track display if the keystroke was handled
    if( bkpSel0 != mViewInfo->sel0 || bkpSel1 != mViewInfo->sel1 )


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