diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-04-16 01:10:36 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-04-21 00:52:07 +0200 |
| commit | 425f936336e669555a0806b321cb90ea569e18c3 (patch) | |
| tree | 3f5a3d94ac5fde9805b0f5a815d36d9e83823d99 /src/wx/audio_plot.cc | |
| parent | 191adfe030803a49588afc4b9087da27654d946b (diff) | |
Only snap the crosshair to visible plots.
Diffstat (limited to 'src/wx/audio_plot.cc')
| -rw-r--r-- | src/wx/audio_plot.cc | 37 |
1 files changed, 20 insertions, 17 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 = {}; |
