summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-20 14:53:55 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-20 14:53:55 +0100
commit56aa7eef1572e48c96ff198ee52a5a5fe17a6bf0 (patch)
tree269b846bc2bf32e611eb4102710131dd41c7f3c6 /src
parentb5e8836102e7f5571ecf852125c711477fd32c81 (diff)
Timeline fix ups.
Diffstat (limited to 'src')
-rw-r--r--src/wx/audio_dialog.cc2
-rw-r--r--src/wx/audio_plot.cc4
-rw-r--r--src/wx/timeline.cc20
-rw-r--r--src/wx/timeline.h3
4 files changed, 23 insertions, 6 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc
index f508b8943..6fd77a2df 100644
--- a/src/wx/audio_dialog.cc
+++ b/src/wx/audio_dialog.cc
@@ -1,3 +1,5 @@
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index 2a6210164..46c64c9bf 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -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)
{
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index f6d41dcb9..af38dfc28 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -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 ();
+}
diff --git a/src/wx/timeline.h b/src/wx/timeline.h
index 4214ee3a8..5d7960be5 100644
--- a/src/wx/timeline.h
+++ b/src/wx/timeline.h
@@ -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;