+
+void
+VideoWaveformPlot::mouse_moved (wxMouseEvent& ev)
+{
+ if (!_image) {
+ return;
+ }
+
+ if (_dirty) {
+ create_waveform ();
+ _dirty = false;
+ }
+
+ shared_ptr<const Film> film = _film.lock ();
+ if (!film) {
+ return;
+ }
+
+ dcp::Size const full = film->frame_size ();
+
+ double const xs = static_cast<double> (full.width) / _waveform->size().width;
+ int const x1 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width - 0.5) * xs)));
+ int const x2 = max (0, min (full.width - 1, int (floor (ev.GetPosition().x - _x_axis_width + 0.5) * xs)));
+
+ double const ys = static_cast<double> (_pixel_values) / _waveform->size().height;
+ int const fy = _waveform->size().height - (ev.GetPosition().y - _vertical_margin);
+ int const y1 = max (0, min (_pixel_values - 1, int (floor (fy - 0.5) * ys)));
+ int const y2 = max (0, min (_pixel_values - 1, int (floor (fy + 0.5) * ys)));
+
+ MouseMoved (x1, x2, y1, y2);
+}