mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-16 13:37:47 -04:00
Update hover state on click -- fixes focus issues that tabbing introduces
This commit is contained in:
parent
786f5ba524
commit
843363d961
@ -471,55 +471,7 @@ void WaterfallCanvas::OnIdle(wxIdleEvent &event) {
|
|||||||
event.RequestMore();
|
event.RequestMore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
void WaterfallCanvas::updateHoverState() {
|
||||||
InteractiveCanvas::OnMouseMoved(event);
|
|
||||||
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getActiveDemodulator();
|
|
||||||
|
|
||||||
if (mouseTracker.mouseDown()) {
|
|
||||||
if (demod == NULL) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (dragState == WF_DRAG_BANDWIDTH_LEFT || dragState == WF_DRAG_BANDWIDTH_RIGHT) {
|
|
||||||
|
|
||||||
int bwDiff = (int) (mouseTracker.getDeltaMouseX() * (float) getBandwidth()) * 2;
|
|
||||||
|
|
||||||
if (dragState == WF_DRAG_BANDWIDTH_LEFT) {
|
|
||||||
bwDiff = -bwDiff;
|
|
||||||
}
|
|
||||||
|
|
||||||
int currentBW = dragBW;
|
|
||||||
|
|
||||||
currentBW = currentBW + bwDiff;
|
|
||||||
if (currentBW > CHANNELIZER_RATE_MAX) {
|
|
||||||
currentBW = CHANNELIZER_RATE_MAX;
|
|
||||||
}
|
|
||||||
if (currentBW < MIN_BANDWIDTH) {
|
|
||||||
currentBW = MIN_BANDWIDTH;
|
|
||||||
}
|
|
||||||
|
|
||||||
demod->setBandwidth(currentBW);
|
|
||||||
dragBW = currentBW;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dragState == WF_DRAG_FREQUENCY) {
|
|
||||||
long long bwTarget = getFrequencyAt(mouseTracker.getMouseX()) - dragOfs;
|
|
||||||
long long currentFreq = demod->getFrequency();
|
|
||||||
long long bwDiff = bwTarget - currentFreq;
|
|
||||||
int snap = wxGetApp().getFrequencySnap();
|
|
||||||
|
|
||||||
if (snap > 1) {
|
|
||||||
bwDiff = roundf((float)bwDiff/(float)snap)*snap;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bwDiff) {
|
|
||||||
demod->setFrequency(currentFreq + bwDiff);
|
|
||||||
currentFreq = demod->getFrequency();
|
|
||||||
demod->updateLabel(currentFreq);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (mouseTracker.mouseRightDown()) {
|
|
||||||
mouseZoom = mouseZoom + ((1.0 - (mouseTracker.getDeltaMouseY() * 4.0)) - mouseZoom) * 0.1;
|
|
||||||
} else {
|
|
||||||
long long freqPos = getFrequencyAt(mouseTracker.getMouseX());
|
long long freqPos = getFrequencyAt(mouseTracker.getMouseX());
|
||||||
|
|
||||||
std::vector<DemodulatorInstance *> *demodsHover = wxGetApp().getDemodMgr().getDemodulatorsAt(freqPos, 15000);
|
std::vector<DemodulatorInstance *> *demodsHover = wxGetApp().getDemodMgr().getDemodulatorsAt(freqPos, 15000);
|
||||||
@ -617,11 +569,64 @@ void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
|||||||
|
|
||||||
delete demodsHover;
|
delete demodsHover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WaterfallCanvas::OnMouseMoved(wxMouseEvent& event) {
|
||||||
|
InteractiveCanvas::OnMouseMoved(event);
|
||||||
|
DemodulatorInstance *demod = wxGetApp().getDemodMgr().getActiveDemodulator();
|
||||||
|
|
||||||
|
if (mouseTracker.mouseDown()) {
|
||||||
|
if (demod == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dragState == WF_DRAG_BANDWIDTH_LEFT || dragState == WF_DRAG_BANDWIDTH_RIGHT) {
|
||||||
|
|
||||||
|
int bwDiff = (int) (mouseTracker.getDeltaMouseX() * (float) getBandwidth()) * 2;
|
||||||
|
|
||||||
|
if (dragState == WF_DRAG_BANDWIDTH_LEFT) {
|
||||||
|
bwDiff = -bwDiff;
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentBW = dragBW;
|
||||||
|
|
||||||
|
currentBW = currentBW + bwDiff;
|
||||||
|
if (currentBW > CHANNELIZER_RATE_MAX) {
|
||||||
|
currentBW = CHANNELIZER_RATE_MAX;
|
||||||
|
}
|
||||||
|
if (currentBW < MIN_BANDWIDTH) {
|
||||||
|
currentBW = MIN_BANDWIDTH;
|
||||||
|
}
|
||||||
|
|
||||||
|
demod->setBandwidth(currentBW);
|
||||||
|
dragBW = currentBW;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dragState == WF_DRAG_FREQUENCY) {
|
||||||
|
long long bwTarget = getFrequencyAt(mouseTracker.getMouseX()) - dragOfs;
|
||||||
|
long long currentFreq = demod->getFrequency();
|
||||||
|
long long bwDiff = bwTarget - currentFreq;
|
||||||
|
int snap = wxGetApp().getFrequencySnap();
|
||||||
|
|
||||||
|
if (snap > 1) {
|
||||||
|
bwDiff = roundf((float)bwDiff/(float)snap)*snap;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bwDiff) {
|
||||||
|
demod->setFrequency(currentFreq + bwDiff);
|
||||||
|
currentFreq = demod->getFrequency();
|
||||||
|
demod->updateLabel(currentFreq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (mouseTracker.mouseRightDown()) {
|
||||||
|
mouseZoom = mouseZoom + ((1.0 - (mouseTracker.getDeltaMouseY() * 4.0)) - mouseZoom) * 0.1;
|
||||||
|
} else {
|
||||||
|
updateHoverState();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WaterfallCanvas::OnMouseDown(wxMouseEvent& event) {
|
void WaterfallCanvas::OnMouseDown(wxMouseEvent& event) {
|
||||||
InteractiveCanvas::OnMouseDown(event);
|
InteractiveCanvas::OnMouseDown(event);
|
||||||
|
|
||||||
|
updateHoverState();
|
||||||
dragState = nextDragState;
|
dragState = nextDragState;
|
||||||
wxGetApp().getDemodMgr().updateLastState();
|
wxGetApp().getDemodMgr().updateLastState();
|
||||||
|
|
||||||
|
@ -40,6 +40,8 @@ private:
|
|||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
void OnIdle(wxIdleEvent &event);
|
void OnIdle(wxIdleEvent &event);
|
||||||
|
|
||||||
|
void updateHoverState();
|
||||||
|
|
||||||
void OnMouseMoved(wxMouseEvent& event);
|
void OnMouseMoved(wxMouseEvent& event);
|
||||||
void OnMouseWheelMoved(wxMouseEvent& event);
|
void OnMouseWheelMoved(wxMouseEvent& event);
|
||||||
void OnMouseDown(wxMouseEvent& event);
|
void OnMouseDown(wxMouseEvent& event);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user