// Set frame callback to start drag animation. private void SetFrameCallback(float position) { // remove frame callback if it is already added. mWindow.RemoveFrameCallback(mFrameCallback); mFrameCallback.ResetAnimationData(); mFrameCallback.AddMovement(0.0f); // Add first movement. // Set container start position and start positions of each icon(and vertical bar) // And compute total container size. float totalSize = 0.0f; mFrameCallback.SetContainerStartPosition(mControlView.Position.X); for (int i = 0; i < mLayoutView.ChildCount; ++i) { mFrameCallback.SetViewPosition(i, mLayoutView.Children[i].Position.X); totalSize += (float)(mLayoutView.Children[i].Size.Width + DEFAULT_SPACE); } totalSize -= (float)DEFAULT_SPACE; // Find touched icon for (int i = (int)mLayoutView.ChildCount - 1; i >= 0; --i) { if (position >= mLayoutView.Children[i].Position.X + mControlView.Position.X) { mFrameCallback.SetTouchedViewIndex(i); mTouchedViewIndex = i; break; } } if (position < mLayoutView.Children[0].Position.X + mControlView.Position.X) { mFrameCallback.SetTouchedViewIndex(0); mTouchedViewIndex = 0; } mPreviousTouchedPosition = position; // Add frame callback on window. // OnUpdate callback of mFrameCallback will be called before every render frame. mWindow.AddFrameCallback(mFrameCallback); // compute limit position the container could go. mLeftDirectionLimit = (float)mWindow.Size.Width - (totalSize + (float)(INITIAL_POSITION)); mWindow.RenderingBehavior = RenderingBehaviorType.Continuously; // make rendering be done for upto 60 fps even though there is no update in main thread. mAnimationState = TOUCH_ANIMATION_STATE.ON_ANIMATION; // make rendering state on. }