string GetScrollerProximateParentScrollerString() { if (thisUIM != null) { IScroller scrollerInMotion = thisUIM.GetInputHandlingScroller(); if (scrollerInMotion != null) { IScroller proximateParentScroller = scrollerInMotion.GetProximateParentScroller(); string result = "par: "; if (proximateParentScroller != null) { result += proximateParentScroller.GetUIAdaptor().GetName(); } else { result += "null"; } return(result); } else { return("scroller: null"); } } else { return("uim is not set"); } }
public void Calculate_ScrollerElementIsNOTUndersizedToCursorLength_NormalizedCursoredPositionOnAxisWithinRange_ReturnsZero( Vector2 normalizedCursoredPosition ) { IScroller scroller = Substitute.For <IScroller>(); scroller.ScrollerElementIsUndersizedTo(Arg.Any <Vector2>(), Arg.Any <int>()).Returns(false); Vector2 anyCursorLength = Vector2.zero; Vector2 anyCursorPosition = Vector2.zero; Vector2 anyScrollerElementLength = Vector2.zero; ElementCursorOffsetInPixelCalculator calculator = new ElementCursorOffsetInPixelCalculator( scroller, anyCursorLength, anyCursorPosition, anyScrollerElementLength ); float anyLocalPos = 0f; for (int i = 0; i < 2; i++) { scroller.GetNormalizedCursoredPositionOnAxis(Arg.Any <float>(), i).Returns(normalizedCursoredPosition[i]); float actual = calculator.Calculate(anyLocalPos, i); Assert.That(actual, Is.EqualTo(0f)); } }
public void Calculate_ScrollerElementIsNOTUndersizedToCursorLength_NormalizedCursoredPositionOnAxisNotWithinRange_ReturnsNonZeroVarious( Vector2 normalizedCursoredPosition, Vector2 scrollerElementLength, Vector2 cursorLength, Vector2 expected ) { IScroller scroller = Substitute.For <IScroller>(); scroller.ScrollerElementIsUndersizedTo(Arg.Any <Vector2>(), Arg.Any <int>()).Returns(false); Vector2 anyCursorPosition = Vector2.zero; ElementCursorOffsetInPixelCalculator calculator = new ElementCursorOffsetInPixelCalculator( scroller, cursorLength, anyCursorPosition, scrollerElementLength ); for (int i = 0; i < 2; i++) { scroller.GetNormalizedCursoredPositionOnAxis(Arg.Any <float>(), i).Returns(normalizedCursoredPosition[i]); float actual = calculator.Calculate(normalizedCursoredPosition[i], i); Assert.That(actual, Is.EqualTo(expected[i])); } }
public IndexOperations(IClient client, ILogger logger = null, IScroller scroller = null, IIndexer indexer = null, ISearcher searcher = null) { _logger = logger; _searcher = searcher ?? new Searcher(client, logger); _scroller = scroller ?? new Scroller(client, logger); _indexer = indexer ?? new Indexer(client, logger); }
/* Touch */ public void OnTouch(int touchCount) { if (this.IsActivated()) { // Debug.Log(GetName() + " is activated"); if (thisIsEnabledInput) { // Debug.Log(GetName() + " is enabled"); IScroller scrollerToStartPauseMotorProcess = GetTargetUIEOrItsProximateParentAsScroller(this); if (scrollerToStartPauseMotorProcess != null) { scrollerToStartPauseMotorProcess.StopRunningMotorProcessRecursivelyUp(); } OnTouchImple(touchCount); } else { // Debug.Log(GetName() + " is disabled"); PassOnTouchUpward(touchCount); } } else { // Debug.Log(GetName() + " is deactivated"); PassOnTouchUpward(touchCount); } }
protected override IScroller FindProximateParentScroller() { IScroller parentScroller = Substitute.For <IScroller>(); IScroller nullScroller = null; parentScroller.GetProximateParentScroller().Returns(nullScroller); return(parentScroller); }
public virtual void DisableScrollInputRecursively(IScroller disablingScroller) { this.DisableInputSelf(); thisTopmostScrollerInMotion = disablingScroller; foreach (IUIElement child in thisChildUIEs) { child.DisableScrollInputRecursively(disablingScroller); } }
public void Run_CallsScrollerSetRunningMotorProcessThis() { IScrollerElementMotorProcessConstArg arg = CreateMockConstArg(); IScroller scroller = arg.scroller; TestScrollerElementMotorProcess process = new TestScrollerElementMotorProcess(arg); process.Run(); scroller.Received(1).SwitchRunningElementMotorProcess(process, 0); }
public ElementCursorOffsetInPixelCalculator( IScroller scroller, Vector2 cursorLength, Vector2 cursorLocalPosition, Vector2 scrollerElementLength ) { thisScroller = scroller; thisCursorLength = cursorLength; thisCursorLocalPosition = cursorLocalPosition; thisScrollerElementLength = scrollerElementLength; }
/* Scroller Hieracrchy */ public override void DisableScrollInputRecursively(IScroller disablingScroller) { if (this == disablingScroller) // initiating { if (thisUIManager.ShowsInputability()) { TurnTo(Color.blue); } } thisTopmostScrollerInMotion = disablingScroller; thisScrollerElement.DisableScrollInputRecursively(disablingScroller); }
public ParalaxBackground(string filename) { m_textureFile = filename; mTileX = true; mTileY = false; TypeConverterRegistration.Register <Vector2, Vector2Converter>(); layerDepth = 0; m_Offset = new Vector2(0, 0); mXScrollerComponent = new NullScroller(); mYScrollerComponent = new NullScroller(); }
public ScrollerElementMotorProcessConstArg( IProcessManager processManager, IScroller scroller, IUIElement scrollerElement, int dimension ) : base( processManager ) { thisScroller = scroller; thisDimension = dimension; thisScrollerElement = scrollerElement; }
string GetInputHandlingScrollerString() { string result = "InputHandling: \n"; IScroller scroller = thisUIM.GetInputHandlingScroller(); if (scroller == null) { return(result += "null"); } else { return(result += scroller.GetUIAdaptor().GetName()); } }
public void Calculate_DeltaPosZero_ReturnsFalse() { IScroller scroller = Substitute.For <IScroller>(); scroller.GetElementCursorOffsetInPixel(Arg.Any <float>(), Arg.Any <int>()).Returns(0f); ElementIsScrolledToIncreaseCursorOffsetCalculator calculator = new ElementIsScrolledToIncreaseCursorOffsetCalculator(scroller); float anyLocalPosOnAxis = 222222222f; for (int i = 0; i < 2; i++) { bool actual = calculator.Calculate(0f, anyLocalPosOnAxis, i); Assert.That(actual, Is.False); } }
public void Calculate_DeltaPosNonZero_ElementCursorOfffsetPixelIsNotZero_Various(float cursorOffsetInPixel, float deltaPosOnAxis, bool expected) { IScroller scroller = Substitute.For <IScroller>(); scroller.GetElementCursorOffsetInPixel(Arg.Any <float>(), Arg.Any <int>()).Returns(cursorOffsetInPixel); ElementIsScrolledToIncreaseCursorOffsetCalculator calculator = new ElementIsScrolledToIncreaseCursorOffsetCalculator(scroller); float anyLocalPosOnAxis = -1111111f; for (int i = 0; i < 2; i++) { bool actual = calculator.Calculate(deltaPosOnAxis, anyLocalPosOnAxis, i); Assert.That(actual, Is.EqualTo(expected)); } }
public virtual void SetUpReference() { // Debug.Log(GetName() + DKUtility.DebugHelper.StringInColor(" SetUpRef", Color.green)); IUIImage uiImage = CreateUIImage(); thisUIElement.SetUIImage(uiImage); IScroller proximateParentScroller = FindProximateParentTypedUIElement <IScroller>(); thisUIElement.SetProximateParentScroller(proximateParentScroller); thisInputStateEngine = CreateUIAdaptorInputStateEngine(); thisSetUpRefIsDone = true; }
/* Touch */ public void OnTouch(int touchCount) { if (this.IsActivated() && thisIsEnabledInput) { IScroller scrollerToStartPauseMotorProcess = GetTargetUIEOrItsProximateParentAsScroller(this); if (scrollerToStartPauseMotorProcess != null) { scrollerToStartPauseMotorProcess.PauseRunningMotorProcessRecursivelyUp(); } OnTouchImple(touchCount); } else { PassOnTouchUpward(touchCount); } }
public void OnTap_IsActivated_IsNotDisabledForPopUp_IsEnabledInput_CallsParentScrollerInSequence() { ITestUIElementConstArg arg = CreateMockArg(); TestUIElement testUIE = new TestUIElement(arg); testUIE.SetIsActivated_Test(true); testUIE.SetIsDisabledForPopUp_Test(false); testUIE.SetIsEnabledInput_Test(true); IScroller parentScroller = testUIE.GetProximateParentScroller(); testUIE.OnTap(1); parentScroller.Received(1).UpdateVelocity(0f, 0); parentScroller.Received(1).UpdateVelocity(0f, 1); parentScroller.Received(1).ResetDrag(); parentScroller.Received(1).CheckAndPerformStaticBoundarySnap(); }
/* Scroller Helper */ public void CheckAndPerformStaticBoundarySnapFrom(IUIElement uieToStartCheck) { ClearTopMostScroller(); IScroller scrollerToStartCheck = GetTargetUIEOrItsProximateParentAsScroller(uieToStartCheck); IScroller scrollerToExamine = scrollerToStartCheck; while (true) { if (scrollerToExamine == null) { break; } scrollerToExamine.ResetDrag(); scrollerToExamine.CheckAndPerformStaticBoundarySnap(); scrollerToExamine = scrollerToExamine.GetProximateParentScroller(); } }
void ClearAllParentScrollerVelocity() { IScroller scrollerToExamine = GetTargetUIEOrItsProximateParentAsScroller(this); while (true) { if (scrollerToExamine == null) { break; } for (int i = 0; i < 2; i++) { scrollerToExamine.UpdateVelocity(0f, i); } scrollerToExamine = scrollerToExamine.GetProximateParentScroller(); } }
public IScrollerElementSnapProcess CreateScrollerElementSnapProcess( IScroller scroller, IUIElement scrollerElement, float targetElementLocalPosOnAxis, float initialVelOnAxis, int dimension ) { ScrollerElementSnapProcess.IConstArg arg = new ScrollerElementSnapProcess.ConstArg( thisProcessManager, scrollerElement, scroller, dimension, targetElementLocalPosOnAxis, initialVelOnAxis ); return(new ScrollerElementSnapProcess(arg)); }
public ConstArg( IProcessManager processManager, IUIElement scrollerElement, IScroller scroller, int dimension, float targetElementLocalPositionOnAxis, float initialVelocityOnAxis ) : base( processManager, scroller, scrollerElement, dimension ) { thisTargetElementLocalPositionOnAxis = targetElementLocalPositionOnAxis; thisInitialVelocityOnAxis = initialVelocityOnAxis; }
public ConstArg( IProcessManager processManager, IScroller scroller, IUIElement scrollerElement, int dimension, float initialVelocity, float deceleration, float decelerationAxisComponentMultiplier ) : base( processManager, scroller, scrollerElement, dimension ) { thisInitialVelocity = initialVelocity; thisDeceleration = deceleration; thisDecelerationAxisComponentMultiplier = decelerationAxisComponentMultiplier; }
public IInertialScrollProcess CreateInertialScrollProcess( float deltaPosOnAxis, float decelerationAxisFactor, IScroller scroller, IUIElement scrollerElement, int dimension, float inertiaDecay ) { InertialScrollProcess.IConstArg arg = new InertialScrollProcess.ConstArg( thisProcessManager, scroller, scrollerElement, dimension, deltaPosOnAxis, inertiaDecay, decelerationAxisFactor ); return(new InertialScrollProcess(arg)); }
private void Start() { _scrollerUi = GetComponentInChildren <IScroller>(); if (_scrollerUi == null) { Debug.LogWarning("No scrollers found"); } _elementList = new List <RectTransform>(); _rectTransform = GetComponent <RectTransform>(); FindChildren(); if (!_scrollInverse) { _scrollerUi.ScrollValue = 1 - _scrollerUi.ScrollValue; } }
string GetHandlingScrollerVelocityString() { if (thisUIM != null) { IScroller scrollerInMotion = thisUIM.GetInputHandlingScroller(); if (scrollerInMotion != null) { Vector2 velocity = scrollerInMotion.GetVelocity(); return(velocity.magnitude.ToString()); } else { return("scroller: null"); } } else { return("uim is not set"); } }
public IInertialScrollProcess CreateInertialScrollProcess( float deltaPosOnAxis, float decelerationAxisFactor, IScroller scroller, IUIElement scrollerElement, int dimension ) { float deceleration = thisProcessManager.GetInertialScrollDeceleration(); IInertialScrollProcessConstArg arg = new InertialScrollProcessConstArg( thisProcessManager, scroller, scrollerElement, dimension, deltaPosOnAxis, deceleration, decelerationAxisFactor ); return(new InertialScrollProcess(arg)); }
public void Calculate_ScrollerElementIsUndersizedToCursorLength_ReturnLocalPosDiff(Vector2 cursorLocalPos, Vector2 scrollerElementLocalPos, Vector2 expected) { Vector2 anyCursorLength = new Vector2(1000f, 10000f); Vector2 anyScrollerElementLength = new Vector2(100f, 100000f); IScroller scroller = Substitute.For <IScroller>(); scroller.ScrollerElementIsUndersizedTo(Arg.Any <Vector2>(), Arg.Any <int>()).Returns(true); ElementCursorOffsetInPixelCalculator calculator = new ElementCursorOffsetInPixelCalculator( scroller, anyCursorLength, cursorLocalPos, anyScrollerElementLength ); for (int i = 0; i < 2; i++) { float actual = calculator.Calculate(scrollerElementLocalPos[i], i); Assert.That(actual, Is.EqualTo(expected[i])); } }
public IScrollerElementSnapProcess CreateScrollerElementSnapProcess( IScroller scroller, IUIElement scrollerElement, float targetElementLocalPosOnAxis, float initialVelOnAxis, int dimension ) { float diffThreshold = thisProcessManager.GetScrollerElementSnapProcessDiffThreshold(); float stopDelta = thisProcessManager.GetScrollerElementSnapProcessStopDelta(); IScrollerElementSnapProcessConstArg arg = new ScrollerElementSnapProcessConstArg( thisProcessManager, scrollerElement, scroller, dimension, targetElementLocalPosOnAxis, initialVelOnAxis, stopDelta ); return(new ScrollerElementSnapProcess(arg)); }
void DrawScrollerDebug(Rect rect) { if (thisSystemIsReady) { string result = ""; IUIManager uiManager = uiManagerAdaptor.GetUIManager(); result += "scroller: "; IScroller handlingScroller = uiManager.GetInputHandlingScroller(); if (handlingScroller != null) { result += handlingScroller.GetName() + "\n"; } else { result += "null\n"; } result += "event: " + uiManager.GetEventName(); GUI.Label( rect, result ); } }
string GetTopMostScrollerInMotionString() { string result = "TopMost: \n"; IScroller handlingScroller = thisUIM.GetInputHandlingScroller(); if (handlingScroller == null) { result += "no handling scroller"; } else { IScroller topMost = handlingScroller.GetTopmostScrollerInMotion(); if (topMost == null) { result += "null"; } else { result += topMost.GetUIAdaptor().GetName(); } } return(result); }