public ElementGroupOffsetCalculator(IUIElementGroup uieGroup, Vector2 groupElementLength, Vector2 padding, Vector2 cursorLocalPosition) { thisUIElementGroup = uieGroup; thisGroupElementLength = groupElementLength; thisPadding = padding; thisCursorLocalPosition = cursorLocalPosition; }
public void Calculate_Various( int sourceIndex, int[] arraySize, int[] sourceElementArrayIndex, int[] cursorSize, int[] expectedArrayIndex, int expectedIndex ) { IUIElement sourceElement = Substitute.For <IUIElement>(); IUIElementGroup uieGroup = Substitute.For <IUIElementGroup>(); uieGroup.GetGroupElement(sourceIndex).Returns(sourceElement); uieGroup.GetArraySize(0).Returns(arraySize[0]); uieGroup.GetArraySize(1).Returns(arraySize[1]); uieGroup.GetGroupElementArrayIndex(sourceElement).Returns(sourceElementArrayIndex); IUIElement expectedMock = Substitute.For <IUIElement>(); uieGroup.GetGroupElement(expectedArrayIndex[0], expectedArrayIndex[1]).Returns(expectedMock); uieGroup.GetGroupElementIndex(expectedMock).Returns(expectedIndex); ICorrectedCursoredElementIndexCalculator calculator = new CorrectedCursoredElementIndexCalculator(uieGroup, cursorSize); int actual = calculator.Calculate(sourceIndex); Assert.That(actual, Is.EqualTo(expectedIndex)); }
public override void RecalculateRect() { thisScroller.UpdateRect(); IUIElementGroup uieGroup = GetUIElementGroup(); IUIElementGroupAdaptor adaptor = (IUIElementGroupAdaptor)uieGroup.GetUIAdaptor(); adaptor.SetUpElements(); SetUpScrollerElementAndCursor(); }
public void SetUpElements() { IUIElement[] groupElements = GetGroupElements(); IRectCalculationData rectCalculationData = CreateRectCalculationData(groupElements); IUIElementGroup uieGroup = thisUIElementGroup; uieGroup.SetUpElements(groupElements); uieGroup.SetUpRects(rectCalculationData); uieGroup.PlaceElements(); }
protected override void SetUpUIElementReferenceImple() { base.SetUpUIElementReferenceImple(); List <IUIElement> groupElements = GetGroupElements(); IRectCalculationData rectCalculationData = CreateRectCalculationData(groupElements); IUIElementGroup uieGroup = (IUIElementGroup)this.GetUIElement(); uieGroup.SetUpElements(groupElements); uieGroup.SetUpRects(rectCalculationData); uieGroup.PlaceElements(); }
public void Calculate_Various( int[] arraySize, int[] cursorSize, ScrollerAxis scrollerAxis, Vector2 velocity, int[] currentElementUnderCursorArrayIndex, int[] expectedArrayIndex ) { IUIElementGroup uieGroup = Substitute.For <IUIElementGroup>(); for (int i = 0; i < 2; i++) { uieGroup.GetArraySize(i).Returns(arraySize[i]); } ISwipeNextTargetGroupElementArrayIndexCalculator calculator = new SwipeNextTargetGroupElementArrayIndexCalculator(uieGroup, cursorSize, scrollerAxis); int[] actual = calculator.Calculate(velocity, currentElementUnderCursorArrayIndex); Assert.That(actual, Is.EqualTo(expectedArrayIndex)); }
public IUIElementGroupScrollerConstArg CreateMockConstArg( int initiallyCursoredElementIndex, int[] cursorSize, Vector2 relativeCursorPosition, ScrollerAxis scrollerAxis, Vector2 rubberBandLimitMultiplier, Vector2 scrollerLength, Vector2 elementGroupLength ) { IUIElementGroupScrollerConstArg arg = Substitute.For <IUIElementGroupScrollerConstArg>(); arg.initiallyCursoredGroupElementIndex.Returns(initiallyCursoredElementIndex); arg.cursorSize.Returns(cursorSize); arg.startSearchSpeed.Returns(1f); arg.relativeCursorPosition.Returns(relativeCursorPosition); arg.scrollerAxis.Returns(scrollerAxis); arg.rubberBandLimitMultiplier.Returns(rubberBandLimitMultiplier); arg.isEnabledInertia.Returns(true); arg.swipeToSnapNext.Returns(false); arg.uim.Returns(Substitute.For <IUIManager>()); arg.processFactory.Returns(Substitute.For <IUISystemProcessFactory>()); arg.uiElementFactory.Returns(Substitute.For <IUIElementFactory>()); IScrollerAdaptor scrollerAdaptor = Substitute.For <IScrollerAdaptor>(); scrollerAdaptor.GetRect().Returns(new Rect(Vector2.zero, scrollerLength)); IUIElementGroup uieGroup = Substitute.For <IUIElementGroup>(); uieGroup.GetGroupElementArrayIndex(Arg.Any <IUIElement>()).Returns(new int[] { 0, 0 }); IUIElementGroupAdaptor uieGroupAdaptor = Substitute.For <IUIElementGroupAdaptor>(); uieGroup.GetUIAdaptor().Returns(uieGroupAdaptor); uieGroupAdaptor.GetRect().Returns(new Rect(Vector2.zero, elementGroupLength)); scrollerAdaptor.GetChildUIEs().Returns(new List <IUIElement>(new IUIElement[] { uieGroup })); arg.uia.Returns(scrollerAdaptor); arg.image.Returns(Substitute.For <IUIImage>()); return(arg); }
public SwipeNextTargetGroupElementArrayIndexCalculator(IUIElementGroup uieGroup, int[] cursorSize, ScrollerAxis scrollerAxis) { thisUIElementGroup = uieGroup; thisCursorSize = cursorSize; thisScrollerAxis = scrollerAxis; }
public CorrectedCursoredElementIndexCalculator(IUIElementGroup uieGroup, int[] cursorSize) { thisUIElementGroup = uieGroup; thisCursorSize = cursorSize; }