public bool move(int x, int y, int pointer) { if (tryMoveTo) { return(false); } CapturesData d = capturedStates[pointer]; if (d == null) { return(false); } int capturedState = d.state; float capturedStart = d.start; float capturedEnd = d.end; int capturedX = d.capturedX; d.lastMovingX = x; bool notifyPicker = false; if (capturedState == CAPTURE_LEFT) { pickerStart = capturedStart - (capturedX - x) / (float)pickerWidth; if (pickerStart < 0f) { pickerStart = 0f; } if (pickerEnd - pickerStart < minDistance) { pickerStart = pickerEnd - minDistance; } notifyPicker = true; } if (capturedState == CAPTURE_RIGHT) { pickerEnd = capturedEnd - (capturedX - x) / (float)pickerWidth; if (pickerEnd > 1f) { pickerEnd = 1f; } if (pickerEnd - pickerStart < minDistance) { pickerEnd = pickerStart + minDistance; } notifyPicker = true; } if (capturedState == CAPTURE_MIDDLE) { pickerStart = capturedStart - (capturedX - x) / (float)pickerWidth; pickerEnd = capturedEnd - (capturedX - x) / (float)pickerWidth; if (pickerStart < 0f) { pickerStart = 0f; pickerEnd = capturedEnd - capturedStart; } if (pickerEnd > 1f) { pickerEnd = 1f; pickerStart = 1f - (capturedEnd - capturedStart); } notifyPicker = true; } if (notifyPicker) { view.onPickerDataChanged(); } return(true); }
public bool capture(int x, int y, int pointerIndex) { if (disabled) { return(false); } if (pointerIndex == 0) { if (leftPickerArea.Contains(new Point(x, y))) { if (capturedStates[0] != null) { capturedStates[1] = capturedStates[0]; } capturedStates[0] = new CapturesData(view, CAPTURE_LEFT); capturedStates[0].start = pickerStart; capturedStates[0].capturedX = x; capturedStates[0].lastMovingX = x; capturedStates[0].captured(); if (moveToAnimator != null) { moveToAnimator.cancel(); } return(true); } if (rightPickerArea.Contains(new Point(x, y))) { if (capturedStates[0] != null) { capturedStates[1] = capturedStates[0]; } capturedStates[0] = new CapturesData(view, CAPTURE_RIGHT); capturedStates[0].end = pickerEnd; capturedStates[0].capturedX = x; capturedStates[0].lastMovingX = x; capturedStates[0].captured(); if (moveToAnimator != null) { moveToAnimator.cancel(); } return(true); } if (middlePickerArea.Contains(new Point(x, y))) { capturedStates[0] = new CapturesData(view, CAPTURE_MIDDLE); capturedStates[0].end = pickerEnd; capturedStates[0].start = pickerStart; capturedStates[0].capturedX = x; capturedStates[0].lastMovingX = x; capturedStates[0].captured(); if (moveToAnimator != null) { moveToAnimator.cancel(); } return(true); } if (y < leftPickerArea.Bottom && y > leftPickerArea.Top) { tryMoveTo = true; moveToX = x; moveToY = y; startTapTime = DateTime.Now.ToTimestamp() * 1000; if (moveToAnimator != null) { if (moveToAnimator.isRunning()) { view.onPickerJumpTo(pickerStart, pickerEnd, true); } moveToAnimator.cancel(); } return(true); } } else if (pointerIndex == 1) { if (capturedStates[0] == null) { return(false); } if (capturedStates[0].state == CAPTURE_MIDDLE) { return(false); } if (leftPickerArea.Contains(new Point(x, y)) && capturedStates[0].state != CAPTURE_LEFT) { capturedStates[1] = new CapturesData(view, CAPTURE_LEFT); capturedStates[1].start = pickerStart; capturedStates[1].capturedX = x; capturedStates[1].lastMovingX = x; capturedStates[1].captured(); if (moveToAnimator != null) { moveToAnimator.cancel(); } return(true); } if (rightPickerArea.Contains(new Point(x, y))) { if (capturedStates[0].state == CAPTURE_RIGHT) { return(false); } capturedStates[1] = new CapturesData(view, CAPTURE_RIGHT); capturedStates[1].end = pickerEnd; capturedStates[1].capturedX = x; capturedStates[1].lastMovingX = x; capturedStates[1].captured(); if (moveToAnimator != null) { moveToAnimator.cancel(); } return(true); } } return(false); }