From a0d15026dff1982df3fd6c62642c2d2e75247aa8 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Sun, 29 May 2016 21:03:21 -0400 Subject: [PATCH 1/7] 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) { From ce1cd2700724c77312dd42f61bf7f361c9730f38 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 30 May 2016 00:17:08 -0400 Subject: [PATCH 2/7] ifdef'd windows focus calls, remove unnecessary meter refreshes --- src/AppFrame.cpp | 3 ++- src/AppFrame.h | 4 +++- src/visual/MeterCanvas.cpp | 9 ++------- src/visual/SpectrumCanvas.cpp | 2 ++ src/visual/TuningCanvas.cpp | 2 ++ src/visual/WaterfallCanvas.cpp | 2 ++ 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index e760533..38c74f1 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1779,10 +1779,11 @@ void AppFrame::refreshGainUI() { gainCanvas->Refresh(); } - +#ifdef _WIN32 bool AppFrame::canFocus() { return (!wxGetApp().isDeviceSelectorOpen() && (!modemProps || !modemProps->isMouseInView())); } +#endif FrequencyDialog::FrequencyDialogTarget AppFrame::getFrequencyDialogTarget() { FrequencyDialog::FrequencyDialogTarget target = FrequencyDialog::FrequencyDialogTarget::FDIALOG_TARGET_DEFAULT; diff --git a/src/AppFrame.h b/src/AppFrame.h index 000ca15..8679c9a 100644 --- a/src/AppFrame.h +++ b/src/AppFrame.h @@ -96,8 +96,10 @@ public: FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget(); void refreshGainUI(); +#ifdef _WIN32 bool canFocus(); - +#endif + private: void OnMenu(wxCommandEvent& event); void OnClose(wxCloseEvent& event); diff --git a/src/visual/MeterCanvas.cpp b/src/visual/MeterCanvas.cpp index 4196af0..e0bf014 100644 --- a/src/visual/MeterCanvas.cpp +++ b/src/visual/MeterCanvas.cpp @@ -126,18 +126,15 @@ void MeterCanvas::OnMouseDown(wxMouseEvent& event) { InteractiveCanvas::OnMouseDown(event); userInputValue = mouseTracker.getMouseY() * (level_max-level_min) + level_min; mouseTracker.setHorizDragLock(true); - Refresh(); } void MeterCanvas::OnMouseReleased(wxMouseEvent& event) { InteractiveCanvas::OnMouseReleased(event); userInputValue = mouseTracker.getMouseY() * (level_max-level_min) + level_min; - Refresh(); } void MeterCanvas::OnMouseRightDown(wxMouseEvent& event) { InteractiveCanvas::OnMouseRightDown(event); - Refresh(); } void MeterCanvas::OnMouseRightReleased(wxMouseEvent& event) { @@ -145,7 +142,6 @@ void MeterCanvas::OnMouseRightReleased(wxMouseEvent& event) { if (showUserInput) { userInputValue = level - level * 0.02; } - Refresh(); } void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) { @@ -169,8 +165,6 @@ void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) { } userInputValue = currentValue; - - Refresh(); } void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { @@ -182,10 +176,11 @@ void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); - Refresh(); +#ifdef _WIN32 if (wxGetApp().getAppFrame()->canFocus()) { this->SetFocus(); } +#endif } void MeterCanvas::setHelpTip(std::string tip) { diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index 421fc81..42877bd 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -259,11 +259,13 @@ void SpectrumCanvas::OnMouseReleased(wxMouseEvent& event) { void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseEnterWindow(event); SetCursor(wxCURSOR_SIZEWE); +#ifdef _WIN32 if (waterfallCanvas) { if (wxGetApp().getAppFrame()->canFocus()) { this->SetFocus(); } } +#endif } void SpectrumCanvas::OnMouseLeftWindow(wxMouseEvent& event) { diff --git a/src/visual/TuningCanvas.cpp b/src/visual/TuningCanvas.cpp index fd10d8a..4302cf5 100644 --- a/src/visual/TuningCanvas.cpp +++ b/src/visual/TuningCanvas.cpp @@ -410,9 +410,11 @@ void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) { hoverIndex = 0; hoverState = TUNING_HOVER_NONE; lastPPM = currentPPM = wxGetApp().getPPM(); +#ifdef _WIN32 if (wxGetApp().getAppFrame()->canFocus()) { this->SetFocus(); } +#endif } void TuningCanvas::setHelpTip(std::string tip) { diff --git a/src/visual/WaterfallCanvas.cpp b/src/visual/WaterfallCanvas.cpp index 9bb08e8..740efab 100644 --- a/src/visual/WaterfallCanvas.cpp +++ b/src/visual/WaterfallCanvas.cpp @@ -852,9 +852,11 @@ void WaterfallCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void WaterfallCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); +#ifdef _WIN32 if (wxGetApp().getAppFrame()->canFocus()) { this->SetFocus(); } +#endif } void WaterfallCanvas::OnMouseRightDown(wxMouseEvent& event) { From 640b4bb219c85fe57c8a463aa7d0016f6df1c253 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 30 May 2016 19:14:14 -0400 Subject: [PATCH 3/7] Mouse Wheel support for gain; @vsonnier's wheel movement tweak --- src/visual/GainCanvas.cpp | 25 ++++++++++++++++++++++--- src/visual/MeterCanvas.cpp | 4 ++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/visual/GainCanvas.cpp b/src/visual/GainCanvas.cpp index e72aa66..409e7de 100644 --- a/src/visual/GainCanvas.cpp +++ b/src/visual/GainCanvas.cpp @@ -22,6 +22,7 @@ EVT_LEFT_DOWN(GainCanvas::OnMouseDown) EVT_LEFT_UP(GainCanvas::OnMouseReleased) EVT_LEAVE_WINDOW(GainCanvas::OnMouseLeftWindow) EVT_ENTER_WINDOW(GainCanvas::OnMouseEnterWindow) +EVT_MOUSEWHEEL(GainCanvas::OnMouseWheelMoved) wxEND_EVENT_TABLE() GainCanvas::GainCanvas(wxWindow *parent, int *dispAttrs) : @@ -151,12 +152,31 @@ void GainCanvas::OnMouseDown(wxMouseEvent& event) { void GainCanvas::OnMouseWheelMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseWheelMoved(event); -// Refresh(); + + CubicVR::vec2 hitResult; + int panelHit = GetPanelHit(hitResult); + + if (panelHit >= 0) { + float movement = 3.0 * (float)event.GetWheelRotation(); + + GainInfo *gInfo; + + gInfo = gainInfo[panelHit]; + + gInfo->current = gInfo->current + ((movement / 100.0) * ((gInfo->high - gInfo->low) / 100.0)); + gInfo->changed = true; + + float levelVal = float(gInfo->current-gInfo->low)/float(gInfo->high-gInfo->low); + gInfo->levelPanel.setSize(1.0, levelVal); + gInfo->levelPanel.setPosition(0.0, levelVal-1.0); + + gInfo->valuePanel.setText(std::to_string(int(gInfo->current))); + } + } void GainCanvas::OnMouseReleased(wxMouseEvent& event) { InteractiveCanvas::OnMouseReleased(event); -// Refresh(); } void GainCanvas::OnMouseLeftWindow(wxMouseEvent& event) { @@ -174,7 +194,6 @@ void GainCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void GainCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); -// Refresh(); } diff --git a/src/visual/MeterCanvas.cpp b/src/visual/MeterCanvas.cpp index e0bf014..d92c571 100644 --- a/src/visual/MeterCanvas.cpp +++ b/src/visual/MeterCanvas.cpp @@ -146,8 +146,8 @@ void MeterCanvas::OnMouseRightReleased(wxMouseEvent& event) { void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseWheelMoved(event); - float movement = (float)event.GetWheelRotation() / (float)event.GetLinesPerAction(); - + float movement = 3.0 * (float)event.GetWheelRotation(); + float currentValue = 0; if (showUserInput) { currentValue = userInputValue; From b8568639c33e4a00f7434a79d71fa8182468a812 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 30 May 2016 19:25:46 -0400 Subject: [PATCH 4/7] Windows focus tweak --- src/AppFrame.cpp | 6 ++++++ src/visual/SpectrumCanvas.cpp | 8 +++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index 38c74f1..aeb71b4 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1490,6 +1490,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) { } #endif +#ifdef _WIN32 + if (scopeCanvas->HasFocus() || spectrumCanvas->HasFocus()) { + waterfallCanvas->SetFocus(); + } +#endif + if (!this->IsActive()) { std::this_thread::sleep_for(std::chrono::milliseconds(30)); } else { diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index 42877bd..69d0e00 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -260,11 +260,9 @@ void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::OnMouseEnterWindow(event); SetCursor(wxCURSOR_SIZEWE); #ifdef _WIN32 - if (waterfallCanvas) { - if (wxGetApp().getAppFrame()->canFocus()) { - this->SetFocus(); - } - } + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } #endif } From 649d34f81177c83ea483a2447d6dfb3ac1f24ede Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 30 May 2016 19:45:38 -0400 Subject: [PATCH 5/7] Make spectrum mouse wheel zoom feature universal --- src/AppFrame.cpp | 2 +- src/visual/SpectrumCanvas.cpp | 3 +++ src/visual/WaterfallCanvas.h | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/AppFrame.cpp b/src/AppFrame.cpp index aeb71b4..84200e7 100644 --- a/src/AppFrame.cpp +++ b/src/AppFrame.cpp @@ -1491,7 +1491,7 @@ void AppFrame::OnIdle(wxIdleEvent& event) { #endif #ifdef _WIN32 - if (scopeCanvas->HasFocus() || spectrumCanvas->HasFocus()) { + if (scopeCanvas->HasFocus()) { waterfallCanvas->SetFocus(); } #endif diff --git a/src/visual/SpectrumCanvas.cpp b/src/visual/SpectrumCanvas.cpp index 69d0e00..faad1cb 100644 --- a/src/visual/SpectrumCanvas.cpp +++ b/src/visual/SpectrumCanvas.cpp @@ -248,6 +248,9 @@ void SpectrumCanvas::OnMouseDown(wxMouseEvent& event) { void SpectrumCanvas::OnMouseWheelMoved(wxMouseEvent& event) { InteractiveCanvas::OnMouseWheelMoved(event); + if (waterfallCanvas) { + waterfallCanvas->OnMouseWheelMoved(event); + } } void SpectrumCanvas::OnMouseReleased(wxMouseEvent& event) { diff --git a/src/visual/WaterfallCanvas.h b/src/visual/WaterfallCanvas.h index 038e699..aa53448 100644 --- a/src/visual/WaterfallCanvas.h +++ b/src/visual/WaterfallCanvas.h @@ -35,7 +35,8 @@ public: void OnKeyDown(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event); - + void OnMouseWheelMoved(wxMouseEvent& event); + private: void OnPaint(wxPaintEvent& event); void OnIdle(wxIdleEvent &event); @@ -43,7 +44,6 @@ private: void updateHoverState(); void OnMouseMoved(wxMouseEvent& event); - void OnMouseWheelMoved(wxMouseEvent& event); void OnMouseDown(wxMouseEvent& event); void OnMouseReleased(wxMouseEvent& event); void OnMouseRightDown(wxMouseEvent& event); From baa7501711690dc37a1de19d72e13622eef27981 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Mon, 30 May 2016 21:44:59 -0400 Subject: [PATCH 6/7] Version bump --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f607efe..19e5d0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") SET(CUBICSDR_VERSION_MAJOR "0") SET(CUBICSDR_VERSION_MINOR "1") -SET(CUBICSDR_VERSION_PATCH "28") +SET(CUBICSDR_VERSION_PATCH "29") SET(CUBICSDR_VERSION_REL "alpha") SET(CUBICSDR_VERSION "${CUBICSDR_VERSION_MAJOR}.${CUBICSDR_VERSION_MINOR}.${CUBICSDR_VERSION_PATCH}-${CUBICSDR_VERSION_REL}") From ce697c610d9d9773559b699acf4b662953255ce3 Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 31 May 2016 17:42:44 -0400 Subject: [PATCH 7/7] Missed gain canvas focus for Win7 wheel support --- src/visual/GainCanvas.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/visual/GainCanvas.cpp b/src/visual/GainCanvas.cpp index 409e7de..cb1dce6 100644 --- a/src/visual/GainCanvas.cpp +++ b/src/visual/GainCanvas.cpp @@ -194,6 +194,11 @@ void GainCanvas::OnMouseLeftWindow(wxMouseEvent& event) { void GainCanvas::OnMouseEnterWindow(wxMouseEvent& event) { InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event); SetCursor(wxCURSOR_CROSS); +#ifdef _WIN32 + if (wxGetApp().getAppFrame()->canFocus()) { + this->SetFocus(); + } +#endif }