+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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)
{
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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;
}
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;
if ((tx + str_width) < _timeline.width()) {
gc->DrawText (str, time_x (t), _y + 16);
}
- t += mark_interval;
+
+ t += mark_interval * TIME_HZ;
}
}
};
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)
{
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));
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
{
return _film.lock ();
}
+
+void
+Timeline::resized (wxSizeEvent &)
+{
+ setup_pixels_per_time_unit ();
+}
+/* -*- c-basic-offset: 8; default-tab-width: 8; -*- */
+
/*
Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
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;