prevent mouseup tuner step on drag stop

This commit is contained in:
Charles J. Cliffe 2015-03-28 01:11:33 -04:00
parent d945c58579
commit b4fb0984d3
2 changed files with 9 additions and 1 deletions

View File

@ -30,7 +30,10 @@ TuningCanvas::TuningCanvas(wxWindow *parent, int *attribList) :
glContext = new TuningContext(this, &wxGetApp().GetContext(this)); glContext = new TuningContext(this, &wxGetApp().GetContext(this));
hoverIndex = 0; hoverIndex = 0;
downIndex = 0;
hoverState = TUNING_HOVER_NONE; hoverState = TUNING_HOVER_NONE;
downState = TUNING_HOVER_NONE;
dragging = false;
freqDP = -1.0; freqDP = -1.0;
freqW = (1.0 / 3.0) * 2.0; freqW = (1.0 / 3.0) * 2.0;
@ -192,13 +195,16 @@ void TuningCanvas::OnIdle(wxIdleEvent &event) {
while (dragAccum > 1.0) { while (dragAccum > 1.0) {
StepTuner(downState, downIndex-1, true); StepTuner(downState, downIndex-1, true);
dragAccum -= 1.0; dragAccum -= 1.0;
dragging = true;
} }
while (dragAccum < -1.0) { while (dragAccum < -1.0) {
StepTuner(downState, downIndex-1, false); StepTuner(downState, downIndex-1, false);
dragAccum += 1.0; dragAccum += 1.0;
dragging = true;
} }
} else { } else {
dragAccum = 0; dragAccum = 0;
dragging = false;
} }
} }
@ -264,12 +270,13 @@ void TuningCanvas::OnMouseReleased(wxMouseEvent& event) {
int hExponent = hoverIndex - 1; int hExponent = hoverIndex - 1;
if (hoverState != TUNING_HOVER_NONE) { if (hoverState != TUNING_HOVER_NONE && !dragging) {
StepTuner(hoverState, hExponent, top); StepTuner(hoverState, hExponent, top);
} }
mouseTracker.setVertDragLock(false); mouseTracker.setVertDragLock(false);
dragging = false;
SetCursor(wxCURSOR_ARROW); SetCursor(wxCURSOR_ARROW);
} }

View File

@ -44,6 +44,7 @@ private:
ActiveState downState; ActiveState downState;
int hoverIndex; int hoverIndex;
int downIndex; int downIndex;
bool dragging;
float freqDP; float freqDP;
float freqW; float freqW;