From 56aa7eef1572e48c96ff198ee52a5a5fe17a6bf0 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 20 May 2013 14:53:55 +0100 Subject: [PATCH 1/1] Timeline fix ups. --- src/wx/audio_dialog.cc | 2 ++ src/wx/audio_plot.cc | 4 +++- src/wx/timeline.cc | 20 +++++++++++++++----- src/wx/timeline.h | 3 +++ 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 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 @@ -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 @@ -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 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 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(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 @@ -61,6 +63,7 @@ private: void left_down (wxMouseEvent &); void playlist_changed (); void setup_pixels_per_time_unit (); + void resized (wxSizeEvent &); boost::weak_ptr _film; std::list > _views; -- 2.30.2