summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-05-17 21:13:25 +0200
committerCarl Hetherington <cth@carlh.net>2020-05-17 21:13:25 +0200
commit9f940fe8533526b10eb9cf22a8772e122760c368 (patch)
tree139e0aed0209e87c8d3819aad67ffc21adb269d1
parent119bf28caa0e3469128a1f015ee00cdf773039b0 (diff)
Clicking on the audio graph jumps to that position in the film (#1507).
-rw-r--r--src/wx/audio_dialog.cc6
-rw-r--r--src/wx/audio_dialog.h4
-rw-r--r--src/wx/audio_panel.cc2
-rw-r--r--src/wx/audio_plot.cc23
-rw-r--r--src/wx/audio_plot.h7
-rw-r--r--src/wx/dcp_panel.cc2
6 files changed, 34 insertions, 10 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc
index efc506aff..f2377de43 100644
--- a/src/wx/audio_dialog.cc
+++ b/src/wx/audio_dialog.cc
@@ -38,6 +38,7 @@ using std::list;
using std::vector;
using std::pair;
using boost::shared_ptr;
+using boost::weak_ptr;
using boost::bind;
using boost::optional;
using boost::const_pointer_cast;
@@ -48,7 +49,7 @@ using namespace dcpomatic;
* @param film Film we are using.
* @param content Content to analyse, or 0 to analyse all of the film's audio.
*/
-AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content)
+AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, weak_ptr<FilmViewer> viewer, shared_ptr<Content> content)
: wxDialog (
parent,
wxID_ANY,
@@ -65,6 +66,7 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Co
#endif
)
, _film (film)
+ , _viewer (viewer)
, _content (content)
, _channels (film->audio_channels ())
, _plot (0)
@@ -79,7 +81,7 @@ AudioDialog::AudioDialog (wxWindow* parent, shared_ptr<Film> film, shared_ptr<Co
_cursor = new StaticText (this, wxT("Cursor: none"));
left->Add (_cursor, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP);
- _plot = new AudioPlot (this);
+ _plot = new AudioPlot (this, viewer);
left->Add (_plot, 1, wxTOP | wxEXPAND, 12);
_sample_peak = new StaticText (this, wxT (""));
left->Add (_sample_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP);
diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h
index 34c174cf4..93c33152a 100644
--- a/src/wx/audio_dialog.h
+++ b/src/wx/audio_dialog.h
@@ -26,12 +26,13 @@
#include <boost/signals2.hpp>
class AudioPlot;
+class FilmViewer;
class Film;
class AudioDialog : public wxDialog
{
public:
- AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film, boost::shared_ptr<Content> content = boost::shared_ptr<Content> ());
+ AudioDialog (wxWindow* parent, boost::shared_ptr<Film> film, boost::weak_ptr<FilmViewer> viewer, boost::shared_ptr<Content> content = boost::shared_ptr<Content>());
bool Show (bool show = true);
@@ -49,6 +50,7 @@ private:
boost::shared_ptr<AudioAnalysis> _analysis;
boost::weak_ptr<Film> _film;
+ boost::weak_ptr<FilmViewer> _viewer;
/** content to analyse, or 0 to analyse all the film's content */
boost::weak_ptr<Content> _content;
int _channels;
diff --git a/src/wx/audio_panel.cc b/src/wx/audio_panel.cc
index 37d6f8bb6..8c3d6f6ca 100644
--- a/src/wx/audio_panel.cc
+++ b/src/wx/audio_panel.cc
@@ -365,7 +365,7 @@ AudioPanel::show_clicked ()
return;
}
- _audio_dialog = new AudioDialog (this, _parent->film (), ac.front ());
+ _audio_dialog = new AudioDialog (this, _parent->film(), _parent->film_viewer(), ac.front());
_audio_dialog->Show ();
}
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index 0b7b29923..629de7767 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -19,10 +19,11 @@
*/
#include "audio_plot.h"
+#include "wx_util.h"
+#include "film_viewer.h"
#include "lib/audio_decoder.h"
#include "lib/audio_analysis.h"
#include "lib/compose.hpp"
-#include "wx/wx_util.h"
#include <wx/graphics.h>
#include <boost/bind.hpp>
#include <iostream>
@@ -37,14 +38,16 @@ using std::map;
using boost::bind;
using boost::optional;
using boost::shared_ptr;
+using boost::weak_ptr;
using namespace dcpomatic;
int const AudioPlot::_minimum = -70;
int const AudioPlot::_cursor_size = 8;
int const AudioPlot::max_smoothing = 128;
-AudioPlot::AudioPlot (wxWindow* parent)
+AudioPlot::AudioPlot (wxWindow* parent, weak_ptr<FilmViewer> viewer)
: wxPanel (parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)
+ , _viewer (viewer)
, _smoothing (max_smoothing / 2)
, _gain_correction (0)
{
@@ -87,6 +90,7 @@ AudioPlot::AudioPlot (wxWindow* parent)
Bind (wxEVT_PAINT, boost::bind (&AudioPlot::paint, this));
Bind (wxEVT_MOTION, boost::bind (&AudioPlot::mouse_moved, this, _1));
Bind (wxEVT_LEAVE_WINDOW, boost::bind (&AudioPlot::mouse_leave, this, _1));
+ Bind (wxEVT_LEFT_DOWN, boost::bind(&AudioPlot::left_down, this));
SetMinSize (wxSize (640, 512));
}
@@ -427,6 +431,19 @@ AudioPlot::search (map<int, PointList> const & search, wxMouseEvent const & ev,
}
}
+
+void
+AudioPlot::left_down ()
+{
+ if (_cursor) {
+ shared_ptr<FilmViewer> fv = _viewer.lock ();
+ if (fv) {
+ fv->seek (_cursor->time, true);
+ }
+ }
+}
+
+
void
AudioPlot::mouse_moved (wxMouseEvent& ev)
{
diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h
index edb444a2a..6eb853dce 100644
--- a/src/wx/audio_plot.h
+++ b/src/wx/audio_plot.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -26,11 +26,12 @@
#include <vector>
struct Metrics;
+class FilmViewer;
class AudioPlot : public wxPanel
{
public:
- explicit AudioPlot (wxWindow *);
+ explicit AudioPlot (wxWindow *, boost::weak_ptr<FilmViewer> viewer);
void set_analysis (boost::shared_ptr<AudioAnalysis>);
void set_channel_visible (int c, bool v);
@@ -70,10 +71,12 @@ private:
void plot_rms (wxGraphicsPath &, int, Metrics const &) const;
float y_for_linear (float, Metrics const &) const;
AudioPoint get_point (int channel, int point) const;
+ void left_down ();
void mouse_moved (wxMouseEvent& ev);
void mouse_leave (wxMouseEvent& ev);
void search (std::map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) const;
+ boost::weak_ptr<FilmViewer> _viewer;
boost::shared_ptr<AudioAnalysis> _analysis;
bool _channel_visible[MAX_DCP_AUDIO_CHANNELS];
bool _type_visible[AudioPoint::COUNT];
diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc
index c4a14a58b..c3cfc91d4 100644
--- a/src/wx/dcp_panel.cc
+++ b/src/wx/dcp_panel.cc
@@ -1020,7 +1020,7 @@ DCPPanel::show_audio_clicked ()
_audio_dialog = 0;
}
- AudioDialog* d = new AudioDialog (_panel, _film);
+ AudioDialog* d = new AudioDialog (_panel, _film, _viewer);
d->Show ();
}