/// <summary> /// Play animation to show page /// </summary> internal void AnimateShowPage(RotaryItemWrapper wrapper, bool isReverse = true, PageAnimationType type = PageAnimationType.Slide) { RotarySelectorItem rotaryItem = wrapper.RotaryItem; rotaryItem.Show(); rotaryItem.Opacity = 0.0f; int wrapperIndex = wrapper.CurrentIndex; if (type == PageAnimationType.Slide) { int sTime = isReverse ? mAniUtil.GetStartTime(wrapperIndex) : 240 - mAniUtil.GetStartTime(wrapperIndex); Position pos = wrapper.GetRotaryPosition(wrapperIndex + 1); rotaryItem.Position = new Position(pos.X + (isReverse ? 70 : -70), pos.Y);; animationCore.AnimateTo(rotaryItem, "Position", pos, 167 + sTime, 84 + sTime + 334, alphaSineOut33); animationCore.AnimateTo(rotaryItem, "Opacity", 1.0f, 167 + sTime, 84 + sTime + 334, alphaSineOut33); } else { animationCore.AnimatePath(rotaryItem, mAniUtil.GetItemRotaryPath(wrapper, isReverse), Vector3.Zero, 200, 699, alphaGlideOut); animationCore.AnimateTo(rotaryItem, "Opacity", 1.0f, 200, 300, alphaGlideOut); } }
internal void PrependItem(RotarySelectorItem item) { SetBadge(item); rotaryLayerView.PrependItem(item); InitItem(item); ReWrappingAllItems(); }
protected void CallOnNotify(RotarySelectorItem item, int opt) { if (OnNotify != null) { OnNotify(item, opt); } }
//Need to add function internal void DeleteItem(RotarySelectorItem item) { int page = currentPage * ApplicationConstants.MAX_ITEM_COUNT; int pageIdx = rotaryLayerView.RotaryItemList.Count % ApplicationConstants.MAX_ITEM_COUNT; rotaryLayerView.DeleteItem(item); ReWrappingAllItems(); if (lastPage == currentPage) { //Delete Last Item if (item.CurrentIndex == pageIdx) { SelectItem(rotaryLayerView.RotaryItemList[page + item.CurrentIndex - 1]); return; } if (item.CurrentIndex == 0 && pageIdx == 1) { PrevPage(); pagination.DeletePage(); return; } } SelectItem(rotaryLayerView.RotaryItemList[page + item.CurrentIndex - 1], false); }
internal void AppendItem(RotarySelectorItem item) { rotaryLayerView.AppendItem(item); InitItem(item); ReWrappingAllItems(); //WrappingAppendItem(item); }
//Create Default UI public void InitializeDefaultUI() { rotarySelector = new RotarySelector() { Size2D = defaultWindow.WindowSize, BackgroundColor = Color.Black, }; List <CommonResource.ResourceData> imageFileList = SaveImageIconList(); for (int i = 0; i < imageFileList.Count; i++) { RotarySelectorItem item = new RotarySelectorItem() { ResourceUrl = imageFileList[i].path, Size = new Size(ICON_SIZE, ICON_SIZE), CornerRadius = ICON_SIZE / 2, MainText = imageFileList[i].name, }; //Icon init:opacity 0, for starting animation item.Opacity = 0.0f; rotarySelector.AppendItem(item); } defaultWindow.Add(rotarySelector); }
private void SelectItem(RotarySelectorItem item = null, bool isAnimating = true) { if (item == null) { int page = currentPage * ApplicationConstants.MAX_ITEM_COUNT; item = wrapperList[page + currentSelectIdx].RotaryItem; } currentSelectIdx = item.CurrentIndex; rotaryLayerView.SetItem(item); if (!isEditMode) { rotaryLayerView.SetText(item.MainText, item.SubText); rotaryLayerView.SetRotaryPosition(item.CurrentIndex); } if (isAnimating) { //for moving indicator animationManager.AnimateChangeState(rotaryLayerView, false, true); } else { rotaryLayerView.SetIndicatorPosition(); } }
public bool ProcessTouchEvent(object source, View.TouchEventArgs e) { if (source is RotarySelectorItem) { RotarySelectorItem item = source as RotarySelectorItem; if ((e.Touch.GetState(0) == PointStateType.Down)) { if (ProcessTouchDownEvent(item)) { CallOnNotify(item, 1); } } else if (e.Touch.GetState(0) == PointStateType.Up) { ProcessTouchUpEvent(item); } else if ((e.Touch.GetState(0) == PointStateType.Motion)) { if (ProcessMotionEvent(item)) { CallOnNotify(item, 0); } } } return(false); }
private void OnItemSelected(RotarySelectorItem item) { if (!isEditMode) { SelectItem(item); } }
internal void DeleteItem(RotarySelectorItem item) { itemList.Remove(item); item.Unparent(); item.Dispose(); item = null; }
//Change position a->b internal void ChagneItemPosition(RotarySelectorItem a, RotarySelectorItem b) { int idx = itemList.IndexOf(b); itemList.Remove(a); itemList.Insert(idx, a); }
internal void SetRotarySelectorMode(bool isEditMode) { if (isEditMode) { rotaryTouchController = new RotaryTouchEditMode(); rotaryTouchController.OnNotify += RotaryTouchController_OnNotify; int idx = 0; foreach (RotarySelectorItem item in rotaryLayerView.RotaryItemList) { item.AddDeleteIcon(idx++); item.Touch_DeleteBadgeHandler += Item_Touch_DeleteBadgeHandler; } } else { rotaryTouchController = new RotaryTouchNormalMode(); IsPaging = false; foreach (RotarySelectorItem item in rotaryLayerView.RotaryItemList) { item.RemoveDeleteIcon(); } int page = currentPage * ApplicationConstants.MAX_ITEM_COUNT; RotarySelectorItem selectItem = rotaryLayerView.RotaryItemList[page + currentSelectIdx]; rotaryLayerView.SetText(selectItem.MainText, selectItem.SubText); rotaryLayerView.SetRotaryPosition(currentSelectIdx); } rotaryLayerView.ChangeMode(isEditMode, currentPage, lastPage); animationManager.AnimateChangeState(rotaryLayerView, isEditMode); rotaryLayerView.RegisterPageMoveOnEdit(MovePageOnEditMode); this.isEditMode = isEditMode; }
internal void InsertItem(int index, RotarySelectorItem item) { SetBadge(item); rotaryLayerView.InsertItem(index, item); InitItem(item); ReWrappingAllItems(); }
public override bool ProcessTouchUpEvent(RotarySelectorItem item) { if (SelectedItem != null && !IsProcessing) { SelectedItem.ClickedItem(); } return(false); }
private void Item_Touch_DeleteBadgeHandler(object sender, EventArgs e) { // if (!isDetector() || !animationManager.IsAnimating) { RotarySelectorItem item = sender as RotarySelectorItem; DeleteItem(item); } }
//Need to add function internal void DeleteItem(RotarySelectorItem item) { if (rotaryLayerView.RotaryItemList.Count == 1) { Tizen.Log.Error("MYLOG", "Last Item"); return; } int page = currentPage * ApplicationConstants.MAX_ITEM_COUNT; int pageIdx = rotaryLayerView.RotaryItemList.Count % ApplicationConstants.MAX_ITEM_COUNT; rotaryLayerView.DeleteItem(item); ReWrappingAllItems(); if (lastPage == currentPage) { //Delete Last Item if (item.CurrentIndex == pageIdx) { SelectItem(rotaryLayerView.RotaryItemList[page + item.CurrentIndex - 1]); return; } //If delete last item on last page, move prev page & delete last page if (item.CurrentIndex == 0 && pageIdx == 1) { pagination.DeletePage(currentPage); PrevPage(); return; } } else { //If delete Last Item, delete page if (pageIdx == 1) { pagination.DeletePage(currentPage); } } pagination.SetCurrentPage(currentPage); if (page + item.CurrentIndex < rotaryLayerView.RotaryItemList.Count) { SelectItem(rotaryLayerView.RotaryItemList[page + item.CurrentIndex], false); } else { SelectItem(rotaryLayerView.RotaryItemList[page + item.CurrentIndex - 1], false); } if (currentPage + 1 == lastPage && item.CurrentIndex == currentSelectIdx + 1) { if (currentSelectIdx - 1 >= 0) { rotaryLayerView.SetRotaryPosition(currentSelectIdx - 1); } } }
public override bool ProcessTouchDownEvent(RotarySelectorItem item) { if (SelectedItem == null) { SelectedItem = item; SelectedItem.LowerToBottom(); return(true); } return(false); }
internal void PrevPage(bool isEndEffect = true, AnimationManager.PageAnimationType type = AnimationManager.PageAnimationType.Slide) { if (animationManager.IsAnimating) { return; } animationManager.IsAnimating = true; if (currentPage > 0) { //For editing mode rotaryLayerView.CheckEditBG(currentPage - 1, lastPage); rotaryLayerView.AnimateBG(false); PlayPageAnimation(rotaryLayerView.RotaryItemList, currentPage - 1, true, type); currentPage--; pagination.SetCurrentPage(currentPage); } else { if (isEditMode) { animationManager.IsAnimating = false; return; } if (isEndEffect) { animationManager.AnimateEndEffect(rotaryLayerView.GetContainer()); return; } } int selIdx = currentPage * ApplicationConstants.MAX_ITEM_COUNT + currentSelectIdx; RotarySelectorItem item = rotaryLayerView.RotaryItemList[selIdx]; rotaryLayerView.SetItem(item); if (!isEditMode) { rotaryLayerView.SetText(item.MainText, item.SubText); rotaryLayerView.SetIndicatorPosition(); } else { if (rotaryTouchController.SelectedItem != null) { if ((rotaryLayerView.GetMovingIcon() != null) && (rotaryLayerView.GetMovingIconRes() == rotaryTouchController.SelectedItem.ResourceUrl)) { rotaryLayerView.RemoveMovingIcon(); } else { rotaryLayerView.AddMovingIcon(rotaryTouchController.SelectedItem); rotaryLayerView.SetLeft(); } } } }
private void SetBadge(RotarySelectorItem item) { if (isEditMode) { item.AddDeleteIcon(-1); } else { item.EnableBadge(); } }
public override bool ProcessTouchUpEvent(RotarySelectorItem item) { if (SelectedItem != null && !IsProcessing) { //SelectedItem.ClickedItem(); } else if (IsProcessing) { StopCheckingTimer(); } return(false); }
private void SetBadge(RotarySelectorItem item) { if (isEditMode) { item.AddDeleteIcon(-1); item.Touch_DeleteBadgeHandler += Item_Touch_DeleteBadgeHandler; } else { item.EnableBadge(); } }
private void WrappingAppendItem(RotarySelectorItem item) { if (currentWrapIdx < ApplicationConstants.MAX_ITEM_COUNT) { wrapperList[currentWrapIdx].RotaryItem = item; currentWrapIdx++; } else { item.Hide(); } GeneratePage(); }
internal void NextPage(bool isEndEffect = true, AnimationManager.PageAnimationType type = AnimationManager.PageAnimationType.Slide) { if (animationManager.IsAnimating) { return; } animationManager.IsAnimating = true; if (currentPage + 1 < lastPage) { //For editing mode rotaryLayerView.CheckEditBG(currentPage + 1, lastPage); rotaryLayerView.AnimateBG(true); PlayPageAnimation(rotaryLayerView.RotaryItemList, currentPage + 1, false, type); currentPage++; pagination.SetCurrentPage(currentPage); int mod = rotaryLayerView.RotaryItemList.Count % ApplicationConstants.MAX_ITEM_COUNT; if (currentSelectIdx + 1 > mod && currentPage + 1 == lastPage) { int lastIdx = currentPage * ApplicationConstants.MAX_ITEM_COUNT + mod; SelectItem(rotaryLayerView.RotaryItemList[lastIdx - 1], false); return; } } else { if (isEditMode) { animationManager.IsAnimating = false; return; } if (isEndEffect) { animationManager.AnimateEndEffect(rotaryLayerView.GetContainer()); return; } } int selIdx = currentPage * ApplicationConstants.MAX_ITEM_COUNT + currentSelectIdx; RotarySelectorItem item = rotaryLayerView.RotaryItemList[selIdx]; rotaryLayerView.SetItem(item); rotaryLayerView.SetText(item.MainText, item.SubText); return; }
private void RotaryTouchController_OnNotify(RotarySelectorItem item, int opt) { switch (opt) { case 0: { if (isEditMode) { animationManager.InitRotaryPathAnimation(); RotarySelectorItem SelectedItem = rotaryTouchController.SelectedItem; RotarySelectorItem collisionItem = item; int page = (currentPage % 2) * ApplicationConstants.MAX_ITEM_COUNT; int selIdx = (int)SelectedItem?.CurrentIndex; int colIdx = (int)collisionItem?.CurrentIndex; if (selIdx < colIdx) { for (int i = selIdx; i < colIdx; i++) { int idx = page + i; wrapperList[idx].RotaryItem = wrapperList[idx + 1].RotaryItem; animationManager.AnimatePathOnEdit(wrapperList[idx]); } } else { for (int i = selIdx; i > colIdx; i--) { int idx = page + i; wrapperList[idx].RotaryItem = wrapperList[idx - 1].RotaryItem; animationManager.AnimatePathOnEdit(wrapperList[idx], false); } } rotaryLayerView.ChagneItemPosition(SelectedItem, collisionItem); wrapperList[page + colIdx].RotaryItem = SelectedItem; animationManager.PlayCoreAnimation(); } break; } case 1: { Window.Instance.TouchEvent += Instance_TouchEvent; break; } } }
public override bool ProcessMotionEvent(RotarySelectorItem item) { if (item == SelectedItem) { return(false); } if (!IsProcessing && SelectedItem != null) { IsProcessing = true; StartCheckingTimer(); return(true); } return(false); }
internal void AddMovingIcon(RotarySelectorItem item) { if (temporaryMovingIcon == null) { temporaryMovingIcon = new View() { Size = new Size(60, 60), //BackgroundColor = Color.Red, PivotPoint = Tizen.NUI.PivotPoint.Center, PositionUsesPivotPoint = true, BackgroundImage = item.ResourceUrl, }; this.Add(temporaryMovingIcon); } }
private void SelectItem(RotarySelectorItem item = null, bool isAnimating = true) { if (item == null) { item = wrapperList[currentSelectIdx].RotaryItem; } currentSelectIdx = item.CurrentIndex; rotaryLayerView.SetText(item.MainText, item.SubText); rotaryLayerView.SetRotaryPosition(item.CurrentIndex); if (isAnimating) { //for moving indicator animationManager.AnimateChangeState(rotaryLayerView, false, true); } }
/// <summary> /// Play animation to hide page /// </summary> internal void AnimateHidePage(RotaryItemWrapper wrapper, bool isReverse = true, PageAnimationType type = PageAnimationType.Slide) { RotarySelectorItem rotaryItem = wrapper.RotaryItem; rotaryItem.Opacity = 1.0f; if (type == PageAnimationType.Slide) { Position pos = wrapper.GetRotaryPosition(wrapper.CurrentIndex + 1); Position movePos = new Position(pos.X + (isReverse ? -70 : 70), pos.Y); animationCore.AnimateTo(rotaryItem, "Position", movePos, 0, 250, alphaGlideOut); animationCore.AnimateTo(rotaryItem, "Opacity", 0.0f, 0, 250, alphaGlideOut); } else { //Rotary hide animation animationCore.AnimatePath(rotaryItem, mAniUtil.GetRotaryPositionHidePath(wrapper, isReverse), Vector3.Zero, 0, 200, alphaSineOut33); animationCore.AnimateTo(rotaryItem, "Opacity", 0.0f, 0, 150, alphaSineOut33); } }
public override bool ProcessTouchUpEvent(RotarySelectorItem item) { if (!IsProcessing) { IsProcessing = true; if (ani != null) { ani.Reset(); ani.Clear(); ani.Dispose(); ani = null; } ani = new Animation(400); ani.DefaultAlphaFunction = GetSineOut33(); if (SelectedItem == null) { ani.AnimateTo(item, "Scale", new Vector3(1.17f, 1.17f, 1.17f)); ani.Play(); SelectedItem = item; SelectedItem.ClickedItem(); ani.Finished += Ani_Finished; return(true); } else { ani.AnimateTo(SelectedItem, "Scale", new Vector3(1.0f, 1.0f, 1.0f)); ani.AnimateTo(item, "Scale", new Vector3(1.17f, 1.17f, 1.17f)); ani.Play(); SelectedItem = item; SelectedItem.ClickedItem(); ani.Finished += Ani_Finished; return(true); } } return(false); }
internal void AnimateStarting(RotaryLayerView layer, List <RotaryItemWrapper> wrapperList) { animationCore.Duration = 350; animationCore.Clear(); RotaryIndicator indicator = layer.GetIndicator(); TextLabel mainText = layer.GetMainText(); //Init value -> Animate position from 131(radius) to default value indicator.Position = indicator.GetRotaryPosition(indicator.CurrentIndex + 1, 131); indicator.Opacity = 0.0f; mainText.Opacity = 0.0f; mainText.Scale = new Vector3(1.2f, 1.2f, 1.2f); mainText.Text = wrapperList[0].RotaryItem.MainText; //Add animation animationCore.AnimateTo(indicator, "Position", indicator.GetRotaryPosition(indicator.CurrentIndex + 1), alphaSineInOut80); animationCore.AnimateTo(indicator, "Opacity", 1.0f, alphaSineInOut80); animationCore.AnimateTo(mainText, "Scale", new Vector3(1.0f, 1.0f, 1.0f), alphaSineInOut80); animationCore.AnimateTo(mainText, "Opacity", 1.0f, alphaSineInOut80); // Second Page -> hide for (int i = 0; i < wrapperList.Count; i++) { RotarySelectorItem item = wrapperList[i]?.RotaryItem; if (item != null) { item.Opacity = 0.0f; item.Position = wrapperList[i].GetRotaryPosition(wrapperList[i].CurrentIndex + 1, true, 170); animationCore.AnimateTo(item, "Position", wrapperList[i].GetRotaryPosition(wrapperList[i].CurrentIndex + 1, true, 139), alphaSineInOut80); animationCore.AnimateTo(item, "Opacity", 1.0f, alphaSineInOut80); } } animationCore.Play(); }