Timeline fix ups.
authorCarl Hetherington <cth@carlh.net>
Mon, 20 May 2013 13:53:55 +0000 (14:53 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 20 May 2013 13:53:55 +0000 (14:53 +0100)
src/wx/audio_dialog.cc
src/wx/audio_plot.cc
src/wx/timeline.cc
src/wx/timeline.h

index f508b89438906f33cd8f0224a5e3067f403b9d5c..6fd77a2df672a4618aca318866eb60d07cbc8a58 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
index 2a6210164e3a23f66076fc7f1fe063d8ffda7c00..46c64c9bf4eb8337f05f71b939e5a228cb4f2fe1 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
@@ -37,7 +39,7 @@ int const AudioPlot::_minimum = -70;
 int const AudioPlot::max_smoothing = 128;
 
 AudioPlot::AudioPlot (wxWindow* parent)
-       : wxPanel (parent)
+       : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
        , _gain (0)
        , _smoothing (max_smoothing / 2)
 {
index f6d41dcb9ba5ac133bc6dc2079ccc3dab2544006..af38dfc2836506310552e05f2470d10fcfed0459 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
@@ -205,7 +207,7 @@ public:
                gc->SetPen (*wxThePenList->FindOrCreatePen (wxColour (0, 0, 0), 1, wxSOLID));
 #endif             
                
-               int mark_interval = rint (128 * TIME_HZ / _timeline.pixels_per_time_unit ());
+               int mark_interval = rint (128 / (TIME_HZ * _timeline.pixels_per_time_unit ()));
                if (mark_interval > 5) {
                        mark_interval -= mark_interval % 5;
                }
@@ -235,7 +237,7 @@ public:
                        path.AddLineToPoint (time_x (t), _y + 4);
                        gc->StrokePath (path);
 
-                       int tc = t;
+                       int tc = t / TIME_HZ;
                        int const h = tc / 3600;
                        tc -= h * 3600;
                        int const m = tc / 60;
@@ -253,7 +255,8 @@ public:
                        if ((tx + str_width) < _timeline.width()) {
                                gc->DrawText (str, time_x (t), _y + 16);
                        }
-                       t += mark_interval;
+                       
+                       t += mark_interval * TIME_HZ;
                }
        }
 
@@ -267,7 +270,7 @@ private:
 };
 
 Timeline::Timeline (wxWindow* parent, shared_ptr<const Film> film)
-       : wxPanel (parent)
+       : wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
        , _film (film)
        , _pixels_per_time_unit (0)
 {
@@ -277,6 +280,7 @@ Timeline::Timeline (wxWindow* parent, shared_ptr<const Film> film)
        
        Connect (wxID_ANY, wxEVT_PAINT, wxPaintEventHandler (Timeline::paint), 0, this);
        Connect (wxID_ANY, wxEVT_LEFT_DOWN, wxMouseEventHandler (Timeline::left_down), 0, this);
+       Connect (wxID_ANY, wxEVT_SIZE, wxSizeEventHandler (Timeline::resized), 0, this);
 
        SetMinSize (wxSize (640, tracks() * track_height() + 96));
 
@@ -345,7 +349,7 @@ Timeline::setup_pixels_per_time_unit ()
                return;
        }
 
-       _pixels_per_time_unit = (width() - x_offset() * 2) / film->length();
+       _pixels_per_time_unit = static_cast<double>(width() - x_offset() * 2) / film->length();
 }
 
 void
@@ -376,3 +380,9 @@ Timeline::film () const
 {
        return _film.lock ();
 }
+
+void
+Timeline::resized (wxSizeEvent &)
+{
+       setup_pixels_per_time_unit ();
+}
index 4214ee3a85adb019ab38185d23dc85ccc6794b37..5d7960be5ff4a000aa12c5f1178a0602f4955240 100644 (file)
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
 /*
     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
 
@@ -61,6 +63,7 @@ private:
        void left_down (wxMouseEvent &);
        void playlist_changed ();
        void setup_pixels_per_time_unit ();
+       void resized (wxSizeEvent &);
 
        boost::weak_ptr<const Film> _film;
        std::list<boost::shared_ptr<View> > _views;