From a0d15026dff1982df3fd6c62642c2d2e75247aa8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 29 May 2016 21:03:21 -0400 Subject: [PATCH] Tweak mousewheel response for Meter UI elements --- src/AppFrame.cpp | 4 ++++ src/AppFrame.h | 2 ++ src/visual/MeterCanvas.cpp | 32 +++++++++++++++++++++++++++----- src/visual/SpectrumCanvas.cpp | 4 +++- src/visual/TuningCanvas.cpp | 4 +++- src/visual/WaterfallCanvas.cpp | 4 +++- 6 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 4995d41..e760533 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1780,6 +1780,10 @@ void AppFrame::refreshGainUI() { } +bool AppFrame::canFocus() { + return (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())); +} + FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT; diff --git a/src/AppFrame.h b/src/AppFrame.h index 6abd443..000ca15 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -95,6 +95,8 @@ public: FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget(); void refreshGainUI(); + + bool canFocus(); private: void OnMenu(wxCommandEvent& event); diff --git a/src/visual/MeterCanvas.cpp b/src/visual/MeterCanvas.cpp index 0d6b90f..4196af0 100644 --- a/src/visual/MeterCanvas.cpp +++ b/src/visual/MeterCanvas.cpp @@ -142,15 +142,35 @@ void MeterCanvas::OnMouseRightDown(wxMouseEvent& event) { void MeterCanvas::OnMouseRightReleased(wxMouseEvent& event) { InteractiveCanvas::OnMouseRightReleased(event); - userInputValue = level - level * 0.02; - Refresh(); + if (showUserInput) { + userInputValue = level - level * 0.02; + } + Refresh(); } void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseWheelMoved(event); float movement = (float)event.GetWheelRotation() / (float)event.GetLinesPerAction(); - userInputValue = userInputValue + movement / 1000; - Refresh(); + + float currentValue = 0; + if (showUserInput) { + currentValue = userInputValue; + } else { + currentValue = level; + } + + currentValue = currentValue + ((movement / 100.0) * ((level_max - level_min) / 100.0)); + + if (currentValue > level_max) { + currentValue = level_max; + } + if (currentValue < level_min) { + currentValue = level_min; + } + + userInputValue = currentValue; + + Refresh(); } void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { @@ -163,7 +183,9 @@ void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); Refresh(); - this->SetFocus(); + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } } void MeterCanvas::setHelpTip(std::string tip) { diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index c8b96f5..421fc81 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -260,7 +260,9 @@ void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseEnterWindow(event); SetCursor(wxCURSOR_SIZEWE); if (waterfallCanvas) { - waterfallCanvas->SetFocus(); + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } } } diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index e333566..fd10d8a 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -410,7 +410,9 @@ void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) { hoverIndex = 0; hoverState = TUNING_HOVER_NONE; lastPPM = currentPPM = wxGetApp().getPPM(); - this->SetFocus(); + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } } void TuningCanvas::setHelpTip(std::string tip) { diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 9a21038..9bb08e8 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -852,7 +852,9 @@ void WaterfallCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void WaterfallCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); - this->SetFocus(); + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } } void WaterfallCanvas::OnMouseRightDown(wxMouseEvent& event) {