public virtual bool onTouchHandleResize(int id, XWindow window, View view, MotionEvent @event) { StandOutLayoutParams @params = (StandOutLayoutParams)window .getLayoutParams(); if (@event.getAction() == MotionEvent.ACTION_DOWN) { window.touchInfo.lastX = (int)@event.getRawX(); window.touchInfo.lastY = (int)@event.getRawY(); window.touchInfo.firstX = window.touchInfo.lastX; window.touchInfo.firstY = window.touchInfo.lastY; } else if (@event.getAction() == MotionEvent.ACTION_MOVE) { int deltaX = (int)@event.getRawX() - window.touchInfo.lastX; int deltaY = (int)@event.getRawY() - window.touchInfo.lastY; // update the size of the window @params.width += deltaX; @params.height += deltaY; // keep window between min/max width/height if (@params.width >= @params.minWidth && @params.width <= @params.maxWidth) { window.touchInfo.lastX = (int)@event.getRawX(); } if (@params.height >= @params.minHeight && @params.height <= @params.maxHeight) { window.touchInfo.lastY = (int)@event.getRawY(); } window.edit().setSize(@params.width, @params.height).commit(); } onResize(id, window, view, @event); return(true); }
public virtual bool onTouchHandleMove(int id, XWindow window, View view, MotionEvent @event) { var @params = (StandOutLayoutParams)window.getLayoutParams(); // how much you have to move in either direction in order for the // gesture to be a move and not tap int totalDeltaX = window.touchInfo.lastX - window.touchInfo.firstX; int totalDeltaY = window.touchInfo.lastY - window.touchInfo.firstY; if (@event.getAction() == MotionEvent.ACTION_DOWN) { window.touchInfo.lastX = (int)@event.getRawX(); window.touchInfo.lastY = (int)@event.getRawY(); window.touchInfo.firstX = window.touchInfo.lastX; window.touchInfo.firstY = window.touchInfo.lastY; } else if (@event.getAction() == MotionEvent.ACTION_MOVE) { int deltaX = (int)@event.getRawX() - window.touchInfo.lastX; int deltaY = (int)@event.getRawY() - window.touchInfo.lastY; window.touchInfo.lastX = (int)@event.getRawX(); window.touchInfo.lastY = (int)@event.getRawY(); if (window.touchInfo.moving || System.Math.Abs(totalDeltaX) >= @params.threshold || System.Math.Abs(totalDeltaY) >= @params.threshold) { window.touchInfo.moving = true; // if window is moveable if (XUtils.isSet(window.flags, XStandOutFlags.FLAG_BODY_MOVE_ENABLE)) { // update the position of the window if (@event.getPointerCount() == 1) { @params.x += deltaX; @params.y += deltaY; } window.edit().setPosition(@params.x, @params.y).commit(); } } } else if (@event.getAction() == MotionEvent.ACTION_UP) { window.touchInfo.moving = false; if (@event.getPointerCount() == 1) { // bring to front on tap var tap = System.Math.Abs(totalDeltaX) < @params.threshold && System.Math.Abs(totalDeltaY) < @params.threshold; if (tap && XUtils.isSet( window.flags, XStandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP)) { this.bringToFront(id); } } // bring to front on touch else if (XUtils.isSet(window.flags, XStandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TOUCH)) { this.bringToFront(id); } } onMove(id, window, view, @event); return(true); }