summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-16 01:10:36 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-21 00:52:07 +0200
commit425f936336e669555a0806b321cb90ea569e18c3 (patch)
tree3f5a3d94ac5fde9805b0f5a815d36d9e83823d99 /src
parent191adfe030803a49588afc4b9087da27654d946b (diff)
Only snap the crosshair to visible plots.
Diffstat (limited to 'src')
-rw-r--r--src/wx/audio_plot.cc37
-rw-r--r--src/wx/audio_plot.h3
2 files changed, 22 insertions, 18 deletions
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index 7c9dae6a5..4e4b6d6a0 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -440,21 +440,6 @@ AudioPlot::colour (int n) const
void
-AudioPlot::search (map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) const
-{
- for (auto const& i: search) {
- for (auto const& j: i.second) {
- double const dist = pow(ev.GetX() - j.draw.x, 2) + pow(ev.GetY() - j.draw.y, 2);
- if (dist < min_dist) {
- min_dist = dist;
- min_point = j;
- }
- }
- }
-}
-
-
-void
AudioPlot::left_down ()
{
if (_cursor) {
@@ -471,8 +456,26 @@ AudioPlot::mouse_moved (wxMouseEvent& ev)
double min_dist = DBL_MAX;
Point min_point;
- search (_rms, ev, min_dist, min_point);
- search (_peak, ev, min_dist, min_point);
+ auto search = [this](map<int, PointList> const & search, wxMouseEvent const & ev, double& min_dist, Point& min_point) {
+ for (auto const& i: search) {
+ if (_channel_visible[i.first]) {
+ for (auto const& j: i.second) {
+ double const dist = pow(ev.GetX() - j.draw.x, 2) + pow(ev.GetY() - j.draw.y, 2);
+ if (dist < min_dist) {
+ min_dist = dist;
+ min_point = j;
+ }
+ }
+ }
+ }
+ };
+
+ if (_type_visible[AudioPoint::RMS]) {
+ search (_rms, ev, min_dist, min_point);
+ }
+ if (_type_visible[AudioPoint::PEAK]) {
+ search (_peak, ev, min_dist, min_point);
+ }
_cursor = {};
diff --git a/src/wx/audio_plot.h b/src/wx/audio_plot.h
index 27d76b6db..9edabf8ec 100644
--- a/src/wx/audio_plot.h
+++ b/src/wx/audio_plot.h
@@ -76,7 +76,6 @@ private:
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;
std::weak_ptr<FilmViewer> _viewer;
std::shared_ptr<AudioAnalysis> _analysis;
@@ -87,7 +86,9 @@ private:
wxString _message;
float _gain_correction;
+ /** peak values keyed by channel */
mutable std::map<int, PointList> _peak;
+ /** RMS values keyed by channel */
mutable std::map<int, PointList> _rms;
boost::optional<Point> _cursor;