public new static MouseMoveEvent GetPooled(Event systemEvent)
        {
            MouseMoveEvent pooled = MouseEventBase <MouseMoveEvent> .GetPooled(systemEvent);

            pooled.button = 0;
            return(pooled);
        }
        private static MouseUpEvent MakeFromPointerEvent(IPointerEvent pointerEvent)
        {
            bool flag = pointerEvent != null && pointerEvent.button >= 0;

            if (flag)
            {
                PointerDeviceState.ReleaseButton(PointerId.mousePointerId, pointerEvent.button);
            }
            return(MouseEventBase <MouseUpEvent> .GetPooled(pointerEvent));
        }
        public new static MouseUpEvent GetPooled(Event systemEvent)
        {
            bool flag = systemEvent != null;

            if (flag)
            {
                PointerDeviceState.ReleaseButton(PointerId.mousePointerId, systemEvent.button);
            }
            return(MouseEventBase <MouseUpEvent> .GetPooled(systemEvent));
        }
        public new static MouseLeaveWindowEvent GetPooled(Event systemEvent)
        {
            bool flag = systemEvent != null;

            if (flag)
            {
                PointerDeviceState.ReleaseAllButtons(PointerId.mousePointerId);
            }
            return(MouseEventBase <MouseLeaveWindowEvent> .GetPooled(systemEvent));
        }
Exemple #5
0
        public new static DragUpdatedEvent GetPooled(Event systemEvent)
        {
            bool flag = systemEvent != null;

            if (flag)
            {
                PointerDeviceState.PressButton(PointerId.mousePointerId, systemEvent.button);
            }
            DragUpdatedEvent pooled = MouseEventBase <DragUpdatedEvent> .GetPooled(systemEvent);

            pooled.button = 0;
            return(pooled);
        }
Exemple #6
0
        public new static WheelEvent GetPooled(Event systemEvent)
        {
            WheelEvent pooled = MouseEventBase <WheelEvent> .GetPooled(systemEvent);

            pooled.imguiEvent = systemEvent;
            bool flag = systemEvent != null;

            if (flag)
            {
                pooled.delta = systemEvent.delta;
            }
            return(pooled);
        }
        internal static T GetPooled(IMouseEvent triggerEvent, Vector2 mousePosition, bool recomputeTopElementUnderMouse)
        {
            bool flag = triggerEvent != null;
            T    result;

            if (flag)
            {
                result = MouseEventBase <T> .GetPooled(triggerEvent);
            }
            else
            {
                T pooled = EventBase <T> .GetPooled();

                pooled.mousePosition                 = mousePosition;
                pooled.localMousePosition            = mousePosition;
                pooled.recomputeTopElementUnderMouse = recomputeTopElementUnderMouse;
                result = pooled;
            }
            return(result);
        }
Exemple #8
0
        internal static void SendMouseOverMouseOut(VisualElement previousTopElementUnderMouse, VisualElement currentTopElementUnderMouse, IMouseEvent triggerEvent, Vector2 mousePosition)
        {
            bool flag = previousTopElementUnderMouse != null && previousTopElementUnderMouse.panel != null;

            if (flag)
            {
                using (MouseOutEvent pooled = MouseEventBase <MouseOutEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    pooled.target = previousTopElementUnderMouse;
                    previousTopElementUnderMouse.SendEvent(pooled);
                }
            }
            bool flag2 = currentTopElementUnderMouse != null;

            if (flag2)
            {
                using (MouseOverEvent pooled2 = MouseEventBase <MouseOverEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    pooled2.target = currentTopElementUnderMouse;
                    currentTopElementUnderMouse.SendEvent(pooled2);
                }
            }
        }
Exemple #9
0
        internal static void SendEnterLeave <TLeaveEvent, TEnterEvent>(VisualElement previousTopElementUnderMouse, VisualElement currentTopElementUnderMouse, IMouseEvent triggerEvent, Vector2 mousePosition) where TLeaveEvent : MouseEventBase <TLeaveEvent>, new() where TEnterEvent : MouseEventBase <TEnterEvent>, new()
        {
            if (previousTopElementUnderMouse != null && previousTopElementUnderMouse.panel == null)
            {
                // If previousTopElementUnderMouse has been removed from panel,
                // do as if there is no element under the mouse.
                previousTopElementUnderMouse = null;
            }

            // We want to find the common ancestor CA of previousTopElementUnderMouse and currentTopElementUnderMouse,
            // send Leave (MouseLeave or DragLeave) events to elements between CA and previousTopElementUnderMouse
            // and send Enter (MouseEnter or DragEnter) events to elements between CA and currentTopElementUnderMouse.

            int prevDepth = 0;
            var p         = previousTopElementUnderMouse;

            while (p != null)
            {
                prevDepth++;
                p = p.hierarchy.parent;
            }

            int currDepth = 0;
            var c         = currentTopElementUnderMouse;

            while (c != null)
            {
                currDepth++;
                c = c.hierarchy.parent;
            }

            p = previousTopElementUnderMouse;
            c = currentTopElementUnderMouse;

            while (prevDepth > currDepth)
            {
                using (var leaveEvent = MouseEventBase <TLeaveEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    leaveEvent.target = p;
                    p.SendEvent(leaveEvent);
                }

                prevDepth--;
                p = p.hierarchy.parent;
            }

            // We want to send enter events after all the leave events.
            // We will store the elements being entered in this list.
            List <VisualElement> enteringElements = VisualElementListPool.Get(currDepth);

            while (currDepth > prevDepth)
            {
                enteringElements.Add(c);

                currDepth--;
                c = c.hierarchy.parent;
            }

            // Now p and c are at the same depth. Go up the tree until p == c.
            while (p != c)
            {
                using (var leaveEvent = MouseEventBase <TLeaveEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    leaveEvent.target = p;
                    p.SendEvent(leaveEvent);
                }

                enteringElements.Add(c);

                p = p.hierarchy.parent;
                c = c.hierarchy.parent;
            }

            for (var i = enteringElements.Count - 1; i >= 0; i--)
            {
                using (var enterEvent = MouseEventBase <TEnterEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    enterEvent.target = enteringElements[i];
                    enteringElements[i].SendEvent(enterEvent);
                }
            }

            VisualElementListPool.Release(enteringElements);
        }
Exemple #10
0
        internal static void SendEnterLeave <TLeaveEvent, TEnterEvent>(VisualElement previousTopElementUnderMouse, VisualElement currentTopElementUnderMouse, IMouseEvent triggerEvent, Vector2 mousePosition) where TLeaveEvent : MouseEventBase <TLeaveEvent>, new() where TEnterEvent : MouseEventBase <TEnterEvent>, new()
        {
            bool flag = previousTopElementUnderMouse != null && previousTopElementUnderMouse.panel == null;

            if (flag)
            {
                previousTopElementUnderMouse = null;
            }
            int           i = 0;
            VisualElement visualElement;

            for (visualElement = previousTopElementUnderMouse; visualElement != null; visualElement = visualElement.hierarchy.parent)
            {
                i++;
            }
            int           j = 0;
            VisualElement visualElement2;

            for (visualElement2 = currentTopElementUnderMouse; visualElement2 != null; visualElement2 = visualElement2.hierarchy.parent)
            {
                j++;
            }
            visualElement  = previousTopElementUnderMouse;
            visualElement2 = currentTopElementUnderMouse;
            while (i > j)
            {
                using (TLeaveEvent pooled = MouseEventBase <TLeaveEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    pooled.target = visualElement;
                    visualElement.SendEvent(pooled);
                }
                i--;
                visualElement = visualElement.hierarchy.parent;
            }
            List <VisualElement> list = VisualElementListPool.Get(j);

            while (j > i)
            {
                list.Add(visualElement2);
                j--;
                visualElement2 = visualElement2.hierarchy.parent;
            }
            while (visualElement != visualElement2)
            {
                using (TLeaveEvent pooled2 = MouseEventBase <TLeaveEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    pooled2.target = visualElement;
                    visualElement.SendEvent(pooled2);
                }
                list.Add(visualElement2);
                visualElement  = visualElement.hierarchy.parent;
                visualElement2 = visualElement2.hierarchy.parent;
            }
            for (int k = list.Count - 1; k >= 0; k--)
            {
                using (TEnterEvent pooled3 = MouseEventBase <TEnterEvent> .GetPooled(triggerEvent, mousePosition, false))
                {
                    pooled3.target = list[k];
                    list[k].SendEvent(pooled3);
                }
            }
            VisualElementListPool.Release(list);
        }
 internal static MouseMoveEvent GetPooled(PointerMoveEvent pointerEvent)
 {
     return(MouseEventBase <MouseMoveEvent> .GetPooled(pointerEvent));
 }
Exemple #12
0
        internal static EventBase CreateEvent(Event systemEvent, EventType eventType)
        {
            EventBase pooled;

            switch (eventType)
            {
            case EventType.MouseDown:
            {
                bool flag = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button);
                if (flag)
                {
                    pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                    return(pooled);
                }
                pooled = PointerEventBase <PointerDownEvent> .GetPooled(systemEvent);

                return(pooled);
            }

            case EventType.MouseUp:
            {
                bool flag2 = PointerDeviceState.HasAdditionalPressedButtons(PointerId.mousePointerId, systemEvent.button);
                if (flag2)
                {
                    pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                    return(pooled);
                }
                pooled = PointerEventBase <PointerUpEvent> .GetPooled(systemEvent);

                return(pooled);
            }

            case EventType.MouseMove:
                pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseDrag:
                pooled = PointerEventBase <PointerMoveEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.KeyDown:
                pooled = KeyboardEventBase <KeyDownEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.KeyUp:
                pooled = KeyboardEventBase <KeyUpEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ScrollWheel:
                pooled = WheelEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.DragUpdated:
                pooled = DragUpdatedEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.DragPerform:
                pooled = MouseEventBase <DragPerformEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ValidateCommand:
                pooled = CommandEventBase <ValidateCommandEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.ExecuteCommand:
                pooled = CommandEventBase <ExecuteCommandEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.DragExited:
                pooled = DragExitedEvent.GetPooled(systemEvent);
                return(pooled);

            case EventType.ContextClick:
                pooled = MouseEventBase <ContextClickEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseEnterWindow:
                pooled = MouseEventBase <MouseEnterWindowEvent> .GetPooled(systemEvent);

                return(pooled);

            case EventType.MouseLeaveWindow:
                pooled = MouseLeaveWindowEvent.GetPooled(systemEvent);
                return(pooled);
            }
            pooled = IMGUIEvent.GetPooled(systemEvent);
            return(pooled);
        }
Exemple #13
0
 internal static DragUpdatedEvent GetPooled(PointerMoveEvent pointerEvent)
 {
     return(MouseEventBase <DragUpdatedEvent> .GetPooled(pointerEvent));
 }
 public static T GetPooled(Vector2 position, int button, int clickCount, Vector2 delta, EventModifiers modifiers = EventModifiers.None)
 {
     return(MouseEventBase <T> .GetPooled(position, button, clickCount, delta, modifiers, false));
 }