Tweak mousewheel response for Meter UI elements

This commit is contained in:
Charles J. Cliffe 2016-05-29 21:03:21 -04:00
parent bd3b9ac921
commit a0d15026df
6 changed files with 42 additions and 8 deletions

View File

@ -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;

View File

@ -95,6 +95,8 @@ public:
FrequencyDialog::FrequencyDialogTarget getFrequencyDialogTarget();
void refreshGainUI();
bool canFocus();
private:
void OnMenu(wxCommandEvent& event);

View File

@ -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) {

View File

@ -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();
}
}
}

View File

@ -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) {

View File

@ -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) {