void Joystick::mouseUp (const MouseEvent& e) //Called when the mouse button is released { if (isEnabled() && ! menuShown) { // If not holding, then jump to snapback values if (! holdOnMouseRelease) { current_x = x_snap; current_y = y_snap; } // Call user defined callback valueChanged (current_x, current_y); // Send controllers changes values sendChanges (); // update drawing position calculateDrawingSpot(); // restore mouse restoreMouseIfHidden(); repaint (); } }
void Joystick::mouseDrag (const MouseEvent& e) //Called continuously while moving mouse { if (isEnabled() && ! menuShown) { // If shift is down, don't allow changes to the X value if (! e.mods.isShiftDown()) { //Determine current X value based on mouse location int x = startPressX + e.getDistanceFromDragStartX (); if (x < 0) current_x = 0; else if (x >= getWidth()) current_x = x_max - x_min; else current_x = x / x_ratio; } // If ctrl is down, don't allow changes to Y value if (! e.mods.isCtrlDown()) { //Determine current Y value based on mouse location int y = startPressY + e.getDistanceFromDragStartY (); if (y < 0) current_y = 0; else if (y > getHeight()) current_y = y_max - y_min; else current_y = y / y_ratio; } // If holding down control key, then set snapback values if (e.mods.isLeftButtonDown()) { x_snap = current_x; y_snap = current_y; } // If right left is down, then hold if (e.mods.isLeftButtonDown()) holdOnMouseRelease = true; else holdOnMouseRelease = false; // Send changes and repaint screen if (! sendChangeOnlyOnRelease) { valueChanged (current_x, current_y); sendChanges (); } // update drawing position calculateDrawingSpot(); repaint (); } }
void Joystick::setValues (double newHorizontalValue, double newVerticalValue, const bool sendUpdateMessage, const bool sendMessageSynchronously) { if (newHorizontalValue <= x_min || x_max <= x_min) { newHorizontalValue = x_min; } else if (newHorizontalValue >= x_max) { newHorizontalValue = x_max; } else if (interval > 0) { newHorizontalValue = x_min + interval * floor ((newHorizontalValue - x_min) / interval + 0.5); } if (newVerticalValue <= y_min || y_max <= y_min) { newVerticalValue = y_min; } else if (newVerticalValue >= y_max) { newVerticalValue = y_max; } else if (interval > 0) { newVerticalValue = y_min + interval * floor ((newVerticalValue - y_min) / interval + 0.5); } if (current_x != newHorizontalValue) current_x = newHorizontalValue; if (current_y != newVerticalValue) current_y = newVerticalValue; if (current_x != newHorizontalValue || current_y != newVerticalValue) { if (sendUpdateMessage) { if (sendMessageSynchronously) sendChanges(); else jassertfalse; // asyncronous message not implemented ! valueChanged (current_x, current_y); } calculateDrawingSpot(); } }
void ImageSettingsDialog::sendChangesAndClose() { sendChanges(); close(); }