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

Modified Files:
      Tag: Audacity_UmixIt
        Ruler.cpp Ruler.h 
Log Message:
UI changes: About box, ControlToolBar, EQ, and AdornedRulerPanel.

Index: Ruler.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/Ruler.h,v
retrieving revision 1.7.4.2
retrieving revision 1.7.4.2.2.1
diff -u -d -r1.7.4.2 -r1.7.4.2.2.1
--- Ruler.h     4 Jun 2006 08:59:48 -0000       1.7.4.2
+++ Ruler.h     20 Apr 2007 01:22:35 -0000      1.7.4.2.2.1
@@ -202,23 +202,20 @@
 // Once TrackPanel uses wxSizers, we will derive it from some 
 // wxWindow and the GetSize and SetSize functions
 // will then be wxWindows functions instead.
-//class AdornedRulerPanel : public RulerPanel {
-class AdornedRulerPanel 
+class AdornedRulerPanel : public wxPanel
 {
  public:
-//   AdornedRulerPanel(wxWindow* parent, wxWindowID id,
-//              const wxPoint& pos = wxDefaultPosition,
-//              const wxSize& size = wxDefaultSize);
+   AdornedRulerPanel(wxWindow* parent, wxWindowID id = -1,
+                     const wxPoint& pos = wxDefaultPosition,
+                     const wxSize& size = wxDefaultSize);
 
-    AdornedRulerPanel();
+   AdornedRulerPanel();
    ~AdornedRulerPanel();
 
 public:
    void DrawAdornedRuler(wxDC * dc, ViewInfo * pViewInfo, 
       bool text, bool indicator, bool bRecording);
    static int GetRulerHeight() { return 22;}
-   void SetSize( const wxRect & r );
-   void GetSize( int * width, int * height );
    void SetLeftOffset( int offset ){ leftOffset = offset;}
    double indicatorPos;
 
@@ -226,7 +223,6 @@
    Ruler  ruler;
 
 private:
-   wxRect mRect;
    ViewInfo * mViewInfo;
    int leftOffset;  // Number of pixels before we hit the 'zero position'.
    int GetLeftOffset() { return leftOffset;}
@@ -234,6 +230,12 @@
    void DrawSelection(wxDC * dc,  const wxRect r);
    void DrawMarks(wxDC * dc, const wxRect r, bool /*text */ );
    void DrawIndicator(wxDC * dc, bool bRecording);
+
+   void OnMouseEvent(wxMouseEvent &evt);
+   void OnPaint(wxPaintEvent &evt);
+
+private:
+    DECLARE_EVENT_TABLE()
 };
 
 #endif //define __AUDACITY_RULER__

Index: Ruler.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/widgets/Ruler.cpp,v
retrieving revision 1.17.2.10.2.4
retrieving revision 1.17.2.10.2.5
diff -u -d -r1.17.2.10.2.4 -r1.17.2.10.2.5
--- Ruler.cpp   18 Apr 2007 01:34:54 -0000      1.17.2.10.2.4
+++ Ruler.cpp   20 Apr 2007 01:22:35 -0000      1.17.2.10.2.5
@@ -960,17 +960,20 @@
 #include "../ViewInfo.h"
 #include "../AColor.h"
 
-#if 0
+BEGIN_EVENT_TABLE(AdornedRulerPanel, wxPanel)
+   EVT_MOUSE_EVENTS(AdornedRulerPanel::OnMouseEvent)
+   EVT_PAINT(AdornedRulerPanel::OnPaint)
+END_EVENT_TABLE()
+
 AdornedRulerPanel::AdornedRulerPanel(wxWindow* parent, wxWindowID id,
               const wxPoint& pos,
               const wxSize& size ) :
-   RulerPanel( parent, id, pos, size )
+   wxPanel( parent, id, pos, size )
 {
    ruler.SetLabelEdges(false);
    ruler.SetFormat(Ruler::TimeFormat);
 
 }
-#endif
 
 AdornedRulerPanel::AdornedRulerPanel()
 {
@@ -983,18 +986,6 @@
 {
 }
 
-void AdornedRulerPanel::SetSize( const wxRect & r )
-{
-   mRect = r;
-}
-
-void AdornedRulerPanel::GetSize( int * width, int * height )
-{
-   *width = mRect.width;
-   *height= mRect.height;
-}
-
-
 void AdornedRulerPanel::DrawAdornedRuler(
    wxDC * dc, ViewInfo * pViewInfo, bool text, bool indicator, bool bRecording)
 {
@@ -1104,3 +1095,64 @@
       dc->DrawPolygon(3, tri);
    }
 }
+
+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;
+
+      int p0 = int (sel0 * mViewInfo->zoom + 0.5);
+      int p1 = int (sel1 * mViewInfo->zoom + 0.5);
+
+      long evtX = evt.GetX();
+      if (evtX < p0)
+      {
+         sel0 = evtX / mViewInfo->zoom;
+         if (sel0 < 0.0)
+            sel0 = 0.0;
+         mViewInfo->sel0 = sel0 + mViewInfo->h - zoomedLeftOffset;
+      }
+      else if (evtX > p1)
+      {
+         sel1 = evtX / mViewInfo->zoom;
+         if (sel1 > (width / mViewInfo->zoom))
+            sel1 = width / mViewInfo->zoom;
+         mViewInfo->sel1 = sel1 + mViewInfo->h - zoomedLeftOffset;
+      }
+      this->Refresh(false);
+   }
+}
+
+#include "../AudioIO.h"
+#include "../Project.h"
+void AdornedRulerPanel::OnPaint(wxPaintEvent &evt)
+{
+   wxPaintDC dc(this);
+
+   // Borrow settings from the one place DrawAdornedRuler was originally 
called, TrackPanel::DrawRuler.
+   const bool bText = true; // ALWAYS true in all current calls to 
TrackPanel::DrawRuler.
+   bool bIndicators = 
gAudioIO->IsStreamActive(GetActiveProject()->GetAudioIOToken());
+   this->indicatorPos = bIndicators ? gAudioIO->GetStreamTime() : 0.0;
+   bool bRecording = (gAudioIO->GetNumCaptureChannels() ? false : true);
+
+   this->DrawAdornedRuler(&dc, mViewInfo, bText, bIndicators, bRecording);
+
+   ruler.Draw(dc);
+}
+


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