mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-22 03:36:24 -05:00
Merge pull request #355 from cjcliffe/mousewheel_tweak
Mousewheel tweaks - Fix wheel for windows 7 - Fix mousewheel ranges and movement - Add gain mousewheel support - Focus tweaks / fixes
This commit is contained in:
commit
a75faaf4f2
@ -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}")
|
||||
|
||||
|
@ -1490,6 +1490,12 @@ void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
if (scopeCanvas->HasFocus()) {
|
||||
waterfallCanvas->SetFocus();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!this->IsActive()) {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(30));
|
||||
} else {
|
||||
@ -1779,6 +1785,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;
|
||||
|
@ -95,7 +95,11 @@ public:
|
||||
|
||||
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
|
||||
void refreshGainUI();
|
||||
|
||||
|
||||
#ifdef _WIN32
|
||||
bool canFocus();
|
||||
#endif
|
||||
|
||||
private:
|
||||
void OnMenu(wxCommandEvent& event);
|
||||
void OnClose(wxCloseEvent& event);
|
||||
|
@ -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,11 @@ void GainCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
void GainCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
||||
SetCursor(wxCURSOR_CROSS);
|
||||
// Refresh();
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().getAppFrame()->canFocus()) {
|
||||
this->SetFocus();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -126,31 +126,45 @@ 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) {
|
||||
InteractiveCanvas::OnMouseRightReleased(event);
|
||||
userInputValue = level - level * 0.02;
|
||||
Refresh();
|
||||
if (showUserInput) {
|
||||
userInputValue = level - level * 0.02;
|
||||
}
|
||||
}
|
||||
|
||||
void MeterCanvas::OnMouseWheelMoved(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseWheelMoved(event);
|
||||
float movement = (float)event.GetWheelRotation() / (float)event.GetLinesPerAction();
|
||||
userInputValue = userInputValue + movement / 1000;
|
||||
Refresh();
|
||||
float movement = 3.0 * (float)event.GetWheelRotation();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
@ -162,8 +176,11 @@ void MeterCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
void MeterCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::mouseTracker.OnMouseEnterWindow(event);
|
||||
SetCursor(wxCURSOR_CROSS);
|
||||
Refresh();
|
||||
this->SetFocus();
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().getAppFrame()->canFocus()) {
|
||||
this->SetFocus();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MeterCanvas::setHelpTip(std::string tip) {
|
||||
|
@ -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) {
|
||||
@ -259,9 +262,11 @@ void SpectrumCanvas::OnMouseReleased(wxMouseEvent& event) {
|
||||
void SpectrumCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseEnterWindow(event);
|
||||
SetCursor(wxCURSOR_SIZEWE);
|
||||
if (waterfallCanvas) {
|
||||
waterfallCanvas->SetFocus();
|
||||
}
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().getAppFrame()->canFocus()) {
|
||||
this->SetFocus();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SpectrumCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
|
@ -410,7 +410,11 @@ void TuningCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
hoverIndex = 0;
|
||||
hoverState = TUNING_HOVER_NONE;
|
||||
lastPPM = currentPPM = wxGetApp().getPPM();
|
||||
this->SetFocus();
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().getAppFrame()->canFocus()) {
|
||||
this->SetFocus();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TuningCanvas::setHelpTip(std::string tip) {
|
||||
|
@ -852,7 +852,11 @@ void WaterfallCanvas::OnMouseLeftWindow(wxMouseEvent& event) {
|
||||
void WaterfallCanvas::OnMouseEnterWindow(wxMouseEvent& event) {
|
||||
InteractiveCanvas::OnMouseEnterWindow(event);
|
||||
SetCursor(wxCURSOR_CROSS);
|
||||
this->SetFocus();
|
||||
#ifdef _WIN32
|
||||
if (wxGetApp().getAppFrame()->canFocus()) {
|
||||
this->SetFocus();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void WaterfallCanvas::OnMouseRightDown(wxMouseEvent& event) {
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user