Exemplo n.º 1
0
 public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
 {
     if (_customFocusAlgorithm == null)
     {
         Tizen.Log.Error("NUI", $"[ERROR] User defined ICustomFocusAlgorithm interface class becomes unreachable. Null will be proposed for next focusing!");
         return(null);
     }
     return(_customFocusAlgorithm.GetNextFocusableView(current, proposed, direction));
 }
        public virtual View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
        {
            View ret = new View(Interop.CustomAlgorithmInterface.CustomAlgorithmInterface_GetNextFocusableActor(swigCPtr, View.getCPtr(current), View.getCPtr(proposed), (int)direction), true);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Moves the focus to the next focusable view in the focus chain in the given direction (according to the focus traversal order).
        /// </summary>
        /// <param name="direction">The direction of the focus movement.</param>
        /// <returns>True if the movement was successful.</returns>
        /// <since_tizen> 3 </since_tizen>
        public bool MoveFocus(View.FocusDirection direction)
        {
            bool ret = NDalicManualPINVOKE.FocusManager_MoveFocus(swigCPtr, (int)direction);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 4
0
        public View Emit(View arg1, View arg2, View.FocusDirection arg3)
        {
            View ret = new View(Interop.PreFocusSignal.PreFocusChangeSignal_Emit(swigCPtr, View.getCPtr(arg1), View.getCPtr(arg2), (int)arg3), true);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 5
0
        public virtual int GetNextFocusItemID(int itemID, int maxItems, View.FocusDirection direction, bool loopEnabled)
        {
            int ret = Interop.ItemLayout.ItemLayout_GetNextFocusItemID(swigCPtr, itemID, maxItems, (int)direction, loopEnabled);

            if (NDalicPINVOKE.SWIGPendingException.Pending)
            {
                throw NDalicPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Show a icon or a new view
        /// </summary>
        /// <param name="show">Is show or not</param>
        /// <param name="direction">direction</param>
        /// <returns>
        /// If showing, return the icon that will be shown for KeyboardFocusManager.
        /// else return a new view.
        /// </returns>
        public View Show(bool show, View.FocusDirection direction)
        {
            _active = show;

            _systemMenuAnimation.Clear();

            float         moveDelta  = Constants.SystemMenuWidth;
            float         scaleDelta = 1.0f + (moveDelta / Constants.SystemMenuWidth);
            AlphaFunction alphaFunction;

            if (show)
            {
                alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseInOutSine);
            }
            else
            {
                alphaFunction = new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine);
            }

            _systemMenuAnimation.AnimateTo(_menu, "ScaleX", show ? scaleDelta : 1.0f, alphaFunction);

            for (int i = 0; i < _systemIcons.Length; ++i)
            {
                Position targetPosition = GetSystemIconPosition(i, show);
                _systemMenuAnimation.AnimateTo(_systemIcons[i], "Scale", show ? new Vector3(1.0f, 1.0f, 1.0f) : new Vector3(0.5f, 0.5f, 0.5f), alphaFunction);
                _systemMenuAnimation.AnimateTo(_systemIcons[i], "Position", targetPosition, alphaFunction);

                if (show)
                {
                    //todor comment
                    targetPosition.X += ((((Constants.SystemMenuWidth * scaleDelta) / 2.0f) - (Constants.SystemMenuWidth / 2.0f)) / scaleDelta);
                }

                _systemMenuAnimation.AnimateTo(_systemStencilIcons[i], "Scale", show ? new Vector3(1.0f, 1.0f, 1.0f) : new Vector3(0.5f, 0.5f, 0.5f), alphaFunction);
                _systemMenuAnimation.AnimateTo(_systemStencilIcons[i], "Position", targetPosition, alphaFunction);
            }

            _systemMenuAnimation.Play();

            MoveSelector(false, false, direction);

            if (show)
            {
                // If showing, return the icon that will be shown for KeyboardFocusManager.
                return(_systemIcons[_focusedIcon]);
            }

            return(new View());
        }
Exemplo n.º 7
0
 /// <summary>
 /// This override function supports two dimensional keyboard navigation.
 /// This function returns the next keyboard focusable actor in ScrollMenu control towards the given direction.
 /// </summary>
 /// <param name="currentFocusedView"> the current focused view</param>
 /// <param name="direction">the direction of the focus move</param>
 /// <param name="loopEnabled">the focus in scrollmenu is loop enabled or not</param>
 /// <returns>next focusable view or current focused view</returns>
 public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     if (direction == View.FocusDirection.Left)
     {
         return(FocusPrevious(loopEnabled));
     }
     else if (direction == View.FocusDirection.Right)
     {
         return(FocusNext(loopEnabled));
     }
     else
     {
         return(currentFocusedView);
     }
 }
Exemplo n.º 8
0
        private View A1_PreFocusChange(object o, FocusManager.PreFocusChangeEventArgs e)
        {
            View v1 = e.CurrentView;

            e.CurrentView = v1;

            View v2 = e.ProposedView;

            e.ProposedView = v2;

            View.FocusDirection b1 = e.Direction;
            e.Direction = b1;

            return(v1);
        }
Exemplo n.º 9
0
        public override View RequestNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
        {
            if (currentFocusedView == null)
            {
                throw new ArgumentNullException(nameof(currentFocusedView));
            }

            View nextFocusedView = null;
            int  targetSibling   = -1;

            switch (direction)
            {
            case View.FocusDirection.Left:
            {
                targetSibling = IsHorizontal ? currentFocusedView.SiblingOrder - 1 : targetSibling;
                break;
            }

            case View.FocusDirection.Right:
            {
                targetSibling = IsHorizontal ? currentFocusedView.SiblingOrder + 1 : targetSibling;
                break;
            }

            case View.FocusDirection.Up:
            {
                targetSibling = IsHorizontal ? targetSibling : currentFocusedView.SiblingOrder - 1;
                break;
            }

            case View.FocusDirection.Down:
            {
                targetSibling = IsHorizontal ? targetSibling : currentFocusedView.SiblingOrder + 1;
                break;
            }
            }

            if (targetSibling > -1 && targetSibling < Container.Children.Count)
            {
                RecyclerViewItem candidate = Container.Children[targetSibling] as RecyclerViewItem;
                if (candidate.Index >= 0 && candidate.Index < colView.InternalItemSource.Count)
                {
                    nextFocusedView = candidate;
                }
            }

            return(nextFocusedView);
        }
Exemplo n.º 10
0
 public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction, string deviceName)
 {
     if (customFocusAlgorithm == null)
     {
         Tizen.Log.Error("NUI", $"[ERROR] User defined ICustomFocusAlgorithm interface class becomes unreachable. Null will be proposed for next focusing!");
         return(null);
     }
     if (customFocusAlgorithm is ICustomAwareDeviceFocusAlgorithm deviceAwared)
     {
         return(deviceAwared.GetNextFocusableView(current, proposed, direction, deviceName));
     }
     else
     {
         return(customFocusAlgorithm.GetNextFocusableView(current, proposed, direction));
     }
 }
        public override View RequestNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
        {
            View nextFocusedView = null;
            int  targetSibling   = -1;
            bool isHorizontal    = LayoutOrientation == Orientation.Horizontal;

            switch (direction)
            {
            case View.FocusDirection.Left:
            {
                targetSibling = isHorizontal ? currentFocusedView.SiblingOrder - 1 : targetSibling;
                break;
            }

            case View.FocusDirection.Right:
            {
                targetSibling = isHorizontal ? currentFocusedView.SiblingOrder + 1 : targetSibling;
                break;
            }

            case View.FocusDirection.Up:
            {
                targetSibling = isHorizontal ? targetSibling : currentFocusedView.SiblingOrder - 1;
                break;
            }

            case View.FocusDirection.Down:
            {
                targetSibling = isHorizontal ? targetSibling : currentFocusedView.SiblingOrder + 1;
                break;
            }
            }

            if (targetSibling > -1 && targetSibling < Container.Children.Count)
            {
                RecycleItem candidate = Container.Children[targetSibling] as RecycleItem;
                if (candidate != null && candidate.DataIndex >= 0 && candidate.DataIndex < DataCount)
                {
                    nextFocusedView = candidate;
                }
            }

            return(nextFocusedView);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Overrides the method of GetNextKeyboardFocusableView() for the CustomView class.<br />
        /// Gets the next key focusable view in this view towards the given direction.<br />
        /// A view needs to override this function in order to support two-dimensional key navigation.<br />
        /// </summary>
        /// <param name="currentFocusedView">The current focused view.</param>
        /// <param name="direction">The direction to move the focus towards.</param>
        /// <param name="loopEnabled">Whether the focus movement should be looped within the control.</param>
        /// <returns>The next keyboard focusable view in this control or an empty handle if no view can be focused.</returns>
        /// <since_tizen> 3 </since_tizen>
        public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
        {
            // Respond to Up/Down keys to change the value while keeping the current spin focused
            View nextFocusedView = currentFocusedView;

            if (direction == View.FocusDirection.Up)
            {
                this.Value     += this.Step;
                nextFocusedView = textField;
            }
            else if (direction == View.FocusDirection.Down)
            {
                this.Value     -= this.Step;
                nextFocusedView = textField;
            }
            else
            {
                // Return null
                return(null);
            }

            return(nextFocusedView);
        }
Exemplo n.º 13
0
 public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     if (currentFocusedView == hourPicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(minutePicker);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(null);
         }
     }
     else if (currentFocusedView == minutePicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(ampmPicker);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(hourPicker);
         }
     }
     else if (currentFocusedView == ampmPicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(minutePicker);
         }
     }
     return(null);
 }
Exemplo n.º 14
0
 public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     if (currentFocusedView == yearPicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(monthPicker);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(null);
         }
     }
     else if (currentFocusedView == monthPicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(dayPicker);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(yearPicker);
         }
     }
     else if (currentFocusedView == dayPicker)
     {
         if (direction == View.FocusDirection.Right)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(monthPicker);
         }
     }
     return(null);
 }
Exemplo n.º 15
0
        private IntPtr OnPreFocusChange(IntPtr current, IntPtr proposed, View.FocusDirection direction)
        {
            View view = null;
            PreFocusChangeEventArgs e = new PreFocusChangeEventArgs();

            if (current != global::System.IntPtr.Zero)
            {
                e.CurrentView = Registry.GetManagedBaseHandleFromNativePtr(current) as View;
            }
            if (proposed != global::System.IntPtr.Zero)
            {
                e.ProposedView = Registry.GetManagedBaseHandleFromNativePtr(proposed) as View;
            }
            e.Direction = direction;

            if (preFocusChangeEventHandler != null)
            {
                view = preFocusChangeEventHandler(this, e);
            }

            if (view != null)
            {
                return(view.GetPtrfromView());
            }
            else
            {
                if (e.ProposedView != null)
                {
                    return(proposed);
                }
                else
                {
                    return(current);
                }
            }
        }
Exemplo n.º 16
0
 public virtual View RequestNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     return(null);
 }
Exemplo n.º 17
0
 // This method is called when a direction key is pressed.
 public View GetNextFocusableView(View current, View proposed, View.FocusDirection direction, string deviceName)
 {
     Tizen.Log.Error("NUI", $" GetNextFocusableView deviceName {deviceName}\n");
     return(proposed);
 }
Exemplo n.º 18
0
 public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
 {
     return(_customFocusAlgorithm.GetNextFocusableView(current, proposed, direction));
 }
Exemplo n.º 19
0
 // This method is never called.
 public View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
 {
     Tizen.Log.Error("NUI", $" GetNextFocusableView \n");
     return(proposed);
 }
Exemplo n.º 20
0
 public override View GetNextFocusableView(View current, View proposed, View.FocusDirection direction)
 {
     return(base.GetNextFocusableView(current, proposed, direction));
 }
Exemplo n.º 21
0
        /// <summary>
        /// Move selector to certain direction
        /// </summary>
        /// <param name="moveOnly">whether only move</param>
        /// <param name="instant">Whether instant,default is false</param>
        /// <param name="direction">move direction</param>
        private void MoveSelector(bool moveOnly, bool instant = false, View.FocusDirection direction = View.FocusDirection.Right)
        {
            int targetIconPosition = _focusedIcon;
            int viewIcon           = targetIconPosition;

            int  showSelectorStartTime       = 0;
            bool delaySelectorPositionChange = false;

            if (!moveOnly)
            {
                switch (direction)
                {
                case View.FocusDirection.Left:
                {
                    if (_active)
                    {
                        _focusedIcon       = _maxIconIndex;
                        targetIconPosition = _focusedIcon;
                    }

                    break;
                }

                case View.FocusDirection.Right:
                {
                    if (!_active)
                    {
                        targetIconPosition = _maxIconIndex + 1;
                        _focusedIcon       = -1;
                    }

                    break;
                }

                case View.FocusDirection.Up:
                {
                    if (!_active)
                    {
                        instant            = true;
                        targetIconPosition = _maxIconIndex + 1;
                    }

                    break;
                }

                case View.FocusDirection.Down:
                {
                    if (_active)
                    {
                        if (_focusedIcon == -1)
                        {
                            _focusedIcon       = _maxIconIndex;
                            targetIconPosition = _focusedIcon;
                        }

                        showSelectorStartTime       = Constants.SystemMenuAnimationDuration;
                        delaySelectorPositionChange = true;
                    }

                    break;
                }
                }

                viewIcon = _focusedIcon;
                if (viewIcon > _maxIconIndex)
                {
                    viewIcon = _maxIconIndex;
                }

                if (viewIcon == -1)
                {
                    viewIcon = 0;
                }
            }

            float selectorWidth = (Constants.SystemMenuWidth / (float)_systemIcons.Length);
            float iconX         = _active ? (Constants.SystemMenuWidth / (float)_systemIcons.Length) * (float)(targetIconPosition - (_systemIcons.Length / 2)) : (Constants.SystemMenuWidth - selectorWidth);
            int   startTime     = 0;

            _systemSelectorAnimation.Clear();

            // Handle the selector color & transparency.
            if (instant)
            {
                // We are hiding instantly, set the color to transparent and set the position directly (without animating).
                _systemSelectorColor.Color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
                _systemSelector.PositionX  = iconX;
            }
            else
            {
                // We animate the fade if we are showing, or if we are hiding *gradually* - IE. not moving the position instantly.
                Color targetColor = _active ? _systemSelectorColors[viewIcon] : new Color(1.0f, 1.0f, 0.0f, 0.0f);

                // We set the endtime to starttime + duration so, if necessary, the selector animation can start *after* the menu animation ends
                _systemSelectorAnimation = _systemSelector.AnimateVisual(_systemSelectorColor, "mixColor",
                                                                         targetColor, showSelectorStartTime, showSelectorStartTime + Constants.SystemMenuAnimationDuration, AlphaFunction.BuiltinFunctions.EaseOutSine);

                if (delaySelectorPositionChange)
                {
                    startTime = Constants.SystemMenuSelectorAnimationDuration;
                }

                // We allow the start time to be modified but fix the end time.
                // This allows us to delay a property set if required (by starting and finishing the animation after the menu animation ends).
                _systemSelectorAnimation.AnimateTo(_systemSelector, "PositionX", iconX, startTime, Constants.SystemMenuSelectorAnimationDuration, new AlphaFunction(AlphaFunction.BuiltinFunctions.EaseOutSine));

                _systemSelectorAnimation.Play();
            }
        }
Exemplo n.º 22
0
 public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     return(null);
 }
Exemplo n.º 23
0
 public void OnGetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     base.GetNextFocusableView(currentFocusedView, direction, loopEnabled);
 }
Exemplo n.º 24
0
 public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     if (currentFocusedView == null)
     {
         if (navigationContent != null && navigationContent.Focusable)
         {
             return(navigationContent);
         }
         else if (titleContent != null && titleContent.Focusable)
         {
             return(titleContent);
         }
         else
         {
             return(null);
         }
     }
     else if (currentFocusedView == this)
     {
         return(null);
     }
     else if (currentFocusedView == navigationContent)
     {
         if (direction == View.FocusDirection.Up)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Right)
         {
             if (titleContent != null && titleContent.Focusable)
             {
                 return(titleContent);
             }
             else
             {
                 return(null);
             }
         }
         else if (direction == View.FocusDirection.Down)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Left)
         {
             return(null);
         }
     }
     else if (currentFocusedView == titleContent)
     {
         if (direction == View.FocusDirection.Up)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Right)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Down)
         {
             return(null);
         }
         else if (direction == View.FocusDirection.Left)
         {
             if (navigationContent != null && navigationContent.Focusable)
             {
                 return(navigationContent);
             }
             else
             {
                 return(null);
             }
         }
     }
     return(null);
 }
Exemplo n.º 25
0
 /// <summary>
 /// Gets the next keyboard focusable view in this control towards the given direction.<br />
 /// A control needs to override this function in order to support two dimensional keyboard navigation.<br />
 /// </summary>
 /// <param name="currentFocusedView">The current focused view.</param>
 /// <param name="direction">The direction to move the focus towards.</param>
 /// <param name="loopEnabled">Whether the focus movement should be looped within the control.</param>
 /// <returns>The next keyboard focusable view in this control or an empty handle if no view can be focused.</returns>
 /// <since_tizen> 3 </since_tizen>
 public virtual View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
 {
     return(new View());
 }
Exemplo n.º 26
0
        public override View GetNextFocusableView(View currentFocusedView, View.FocusDirection direction, bool loopEnabled)
        {
            View nextFocusedView = null;

            if (!focusedView)
            {
                // If focusedView is null, find child which has previous data index
                if (Children.Count > 0 && Adapter.Data.Count > 0)
                {
                    for (int i = 0; i < Children.Count; i++)
                    {
                        RecycleItem item = Children[i] as RecycleItem;
                        if (item.DataIndex == prevFocusedDataIndex)
                        {
                            nextFocusedView = item;
                            break;
                        }
                    }
                }
            }
            else
            {
                // If this is not first focus, request next focus to LayoutManager
                if (LayoutManager != null)
                {
                    nextFocusedView = LayoutManager.RequestNextFocusableView(currentFocusedView, direction, loopEnabled);
                }
            }

            if (nextFocusedView)
            {
                // Check next focused view is inside of visible area.
                // If it is not, move scroll position to make it visible.
                Position scrollPosition = ContentContainer.CurrentPosition;
                float    targetPosition = -(ScrollingDirection == Direction.Horizontal ? scrollPosition.X : scrollPosition.Y);

                float left   = nextFocusedView.Position.X;
                float right  = nextFocusedView.Position.X + nextFocusedView.Size.Width;
                float top    = nextFocusedView.Position.Y;
                float bottom = nextFocusedView.Position.Y + nextFocusedView.Size.Height;

                float visibleRectangleLeft   = -scrollPosition.X;
                float visibleRectangleRight  = -scrollPosition.X + Size.Width;
                float visibleRectangleTop    = -scrollPosition.Y;
                float visibleRectangleBottom = -scrollPosition.Y + Size.Height;

                if (ScrollingDirection == Direction.Horizontal)
                {
                    if ((direction == View.FocusDirection.Left || direction == View.FocusDirection.Up) && left < visibleRectangleLeft)
                    {
                        targetPosition = left;
                    }
                    else if ((direction == View.FocusDirection.Right || direction == View.FocusDirection.Down) && right > visibleRectangleRight)
                    {
                        targetPosition = right - Size.Width;
                    }
                }
                else
                {
                    if ((direction == View.FocusDirection.Up || direction == View.FocusDirection.Left) && top < visibleRectangleTop)
                    {
                        targetPosition = top;
                    }
                    else if ((direction == View.FocusDirection.Down || direction == View.FocusDirection.Right) && bottom > visibleRectangleBottom)
                    {
                        targetPosition = bottom - Size.Height;
                    }
                }

                focusedView = nextFocusedView;
                if ((nextFocusedView as RecycleItem) != null)
                {
                    prevFocusedDataIndex = (nextFocusedView as RecycleItem).DataIndex;
                }

                ScrollTo(targetPosition, true);
            }
            else
            {
                // If nextView is null, it means that we should move focus to outside of Control.
                // Return FocusableView depending on direction.
                switch (direction)
                {
                case View.FocusDirection.Left:
                {
                    nextFocusedView = LeftFocusableView;
                    break;
                }

                case View.FocusDirection.Right:
                {
                    nextFocusedView = RightFocusableView;
                    break;
                }

                case View.FocusDirection.Up:
                {
                    nextFocusedView = UpFocusableView;
                    break;
                }

                case View.FocusDirection.Down:
                {
                    nextFocusedView = DownFocusableView;
                    break;
                }
                }

                if (nextFocusedView)
                {
                    focusedView = null;
                }
                else
                {
                    //If FocusableView doesn't exist, not move focus.
                    nextFocusedView = focusedView;
                }
            }

            return(nextFocusedView);
        }
Exemplo n.º 27
0
 private IntPtr OnDummyCallback(IntPtr current, IntPtr proposed, View.FocusDirection direction)
 {
     return(proposed);
 }