コード例 #1
0
 void _handle_up(ICogaManager coga)
 {
     isMouseDown = false;
     if (isDragging)
     {
         OnDragEnd?.Invoke(Parent);
         coga.UnlockHover();
     }
     else
     {
         if (LongClickingEnabled)
         {
             // With long clicking enabled, allow early cancel out and
             // only long click past the const delay.
             if (mouseDownTime < MouseClickDelay)
             {
                 _update_click(coga);
             }
             else
             {
                 OnLongClick?.Invoke(Parent);
                 OnEndClicking?.Invoke(Parent);
             }
         }
         else
         {
             // If we don't need to worry about the long click,
             // just always click.
             _update_click(coga);
         }
     }
 }
コード例 #2
0
        void _update_drag(ICogaManager coga)
        {
            var vel = (coga.MousePosition - mousepos_lastframe);

            if (vel != Vector2.Zero)
            {
                OnDrag?.Invoke(Parent, vel);
            }
        }
コード例 #3
0
ファイル: CogaNode.cs プロジェクト: JonSnowbd/Ash
        // Local function to recurse the new manager throughout the tree.
        // This is necessary for nodes that are put together before being
        // added to the root.
        void PropagateManager(CogaNode node, ICogaManager manager)
        {
            if (node.Manager == null)
            {
                node.Manager = manager;
                node.OnReceiveManager();
            }

            foreach (var c in node.Children)
            {
                PropagateManager(c, manager);
            }
        }
コード例 #4
0
        void _update(ICogaManager coga, float deltaTime)
        {
            // Continuation from previous input
            if (isMouseDown)
            {
                if (mouseDownTime == 0f)
                {
                    OnStartClicking?.Invoke(Parent);
                    mousepos_lastframe = coga.MousePosition;
                }
                mouseDownTime += deltaTime;
                if (coga.IsClickReleased)                 // Exit out
                {
                    _handle_up(coga);
                    return;
                }

                if (isDragging)
                {
                    _update_drag(coga);
                    return;
                }

                if ((Vector2.Distance(coga.MousePosition, mouseInitial)) >= MouseDragMinimumDistance)
                {
                    OnDragStart?.Invoke(Parent);
                    Parent.Manager.LockHover();
                    OnDrag?.Invoke(Parent, (coga.MousePosition - mouseInitial));
                    isDragging = true;
                    return;
                }
            }
            else
            {
                if (coga.IsClickPressed)
                {
                    isDragging    = false;
                    isMouseDown   = true;
                    mouseDownTime = 0f;
                    mouseInitial  = coga.MousePosition;
                }
            }

            mousepos_lastframe = coga.MousePosition;
        }
コード例 #5
0
ファイル: CogaNode.cs プロジェクト: JonSnowbd/Ash
        /// <summary>
        /// You shouldn't call this unless you know you need to!
        /// This is a method that sets this root as the defacto root of all
        /// nodes in the hierarchy. There should only ever be one of these in a manager.
        /// </summary>
        public CogaNode SetRoot(int width, int height, ICogaManager manager)
        {
            IsRoot = true;
            NodeConfiguration.Width  = new CogaValue(width);
            NodeConfiguration.Height = new CogaValue(height);

            Manager = manager;

            Compute.Size.X.Complete(width);
            Compute.Size.Y.Complete(height);
            Compute.Position.X.Complete(0f);
            Compute.Position.Y.Complete(0f);

            SetChildrenDirty();
            SetDirty();

            TriggerNodeConfig();
            return(this);
        }
コード例 #6
0
 void _update_click(ICogaManager coga)
 {
     if (DoubleClickingEnabled)
     {
         if (has_clicked)
         {
             OnDoubleClick?.Invoke(Parent);
             OnEndClicking?.Invoke(Parent);
             has_clicked        = false;
             double_click_timer = -1f;
         }
         else
         {
             has_clicked        = true;
             double_click_timer = MouseClickDelay;
         }
     }
     else
     {
         OnClick?.Invoke(Parent);
         OnEndClicking?.Invoke(Parent);
         has_clicked = false;
     }
 }