WorldWindEarth / WorldWindAndroid

The WorldWind Android "Community Edition" SDK (WWA-CE) includes the library, examples and tutorials for building 3D virtual globe applications for phones and tablets.
https://worldwind.earth/WorldWindAndroid/
Other
16 stars 7 forks source link

Add MousePanRecognizer to interpret tilt using secondary mouse button #7

Closed ComBatVision closed 5 years ago

ComBatVision commented 5 years ago

Mouse pan recognizer allow to pan earth using secondary mouse button:

public class MousePanRecognizer extends PanRecognizer {
    @Override
    protected boolean shouldRecognize(MotionEvent event) {
        return super.shouldRecognize(event) && event.getButtonState() == MotionEvent.BUTTON_SECONDARY;
    }
}

To use MousePanRecognizer add it to WorldWindController:

    protected GestureRecognizer mouseTiltRecognizer = new MousePanRecognizer();

    protected List<GestureRecognizer> allRecognizers = Arrays.asList(
        this.panRecognizer, this.pinchRecognizer, this.rotationRecognizer, this.tiltRecognizer, this.mouseTiltRecognizer);

and:

    public void gestureStateChanged(MotionEvent event, GestureRecognizer recognizer) {
        if (recognizer == this.panRecognizer) {
            this.handlePan(recognizer);
        } else if (recognizer == this.pinchRecognizer) {
            this.handlePinch(recognizer);
        } else if (recognizer == this.rotationRecognizer) {
            this.handleRotate(recognizer);
        } else if (recognizer == this.tiltRecognizer || recognizer == this.mouseTiltRecognizer) {
            this.handleTilt(recognizer);
        }
    }