コード例 #1
0
        // This function is protected so that only specific subclasses can offer the
        // functionality from specific IPointerEvent types.
        protected static T GetPooled(IPointerEvent pointerEvent)
        {
            T e = GetPooled();

            e.target     = (pointerEvent as EventBase)?.target;
            e.imguiEvent = (pointerEvent as EventBase)?.imguiEvent;

            if ((pointerEvent as EventBase)?.path != null)
            {
                e.path = (pointerEvent as EventBase).path;
            }

            e.modifiers          = pointerEvent.modifiers;
            e.mousePosition      = pointerEvent.position;
            e.localMousePosition = pointerEvent.position;
            e.mouseDelta         = pointerEvent.deltaPosition;
            e.button             = pointerEvent.button == -1 ? 0 : pointerEvent.button;
            e.pressedButtons     = pointerEvent.pressedButtons;
            e.clickCount         = pointerEvent.clickCount;

            IPointerEventInternal pointerEventInternal = pointerEvent as IPointerEventInternal;

            if (pointerEventInternal != null)
            {
                ((IMouseEventInternal)e).triggeredByOS = pointerEventInternal.triggeredByOS;
                ((IMouseEventInternal)e).recomputeTopElementUnderMouse = true;

                // Link the mouse event and the pointer event so we can forward
                // the propagation result (for tests and for IMGUI)
                ((IMouseEventInternal)e).sourcePointerEvent = pointerEvent;
            }

            return(e);
        }
コード例 #2
0
        public static T GetPooled(IPointerEvent triggerEvent)
        {
            T e = GetPooled();

            if (triggerEvent != null)
            {
                e.pointerId          = triggerEvent.pointerId;
                e.pointerType        = triggerEvent.pointerType;
                e.isPrimary          = triggerEvent.isPrimary;
                e.button             = triggerEvent.button;
                e.pressedButtons     = triggerEvent.pressedButtons;
                e.position           = triggerEvent.position;
                e.localPosition      = triggerEvent.localPosition;
                e.deltaPosition      = triggerEvent.deltaPosition;
                e.deltaTime          = triggerEvent.deltaTime;
                e.clickCount         = triggerEvent.clickCount;
                e.pressure           = triggerEvent.pressure;
                e.tangentialPressure = triggerEvent.tangentialPressure;

                e.altitudeAngle  = triggerEvent.altitudeAngle;
                e.azimuthAngle   = triggerEvent.azimuthAngle;
                e.twist          = triggerEvent.twist;
                e.radius         = triggerEvent.radius;
                e.radiusVariance = triggerEvent.radiusVariance;

                e.modifiers = triggerEvent.modifiers;

                IPointerEventInternal pointerEventInternal = triggerEvent as IPointerEventInternal;
                if (pointerEventInternal != null)
                {
                    ((IPointerEventInternal)e).triggeredByOS = pointerEventInternal.triggeredByOS;
                }
            }
            return(e);
        }
コード例 #3
0
        private void Init(EventBase evt)
        {
            this.eventBaseName                 = evt.GetType().Name;
            this.eventTypeId                   = evt.eventTypeId;
            this.eventId                       = evt.eventId;
            this.triggerEventId                = evt.triggerEventId;
            this.timestamp                     = evt.timestamp;
            this.target                        = evt.target;
            this.skipElements                  = evt.skipElements;
            this.isPropagationStopped          = evt.isPropagationStopped;
            this.isImmediatePropagationStopped = evt.isImmediatePropagationStopped;
            this.isDefaultPrevented            = evt.isDefaultPrevented;
            IMouseEvent         mouseEvent         = evt as IMouseEvent;
            IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal;

            this.hasUnderlyingPhysicalEvent = (mouseEvent != null && mouseEventInternal != null && mouseEventInternal.triggeredByOS);
            this.propagationPhase           = evt.propagationPhase;
            this.originalMousePosition      = evt.originalMousePosition;
            this.currentTarget = evt.currentTarget;
            this.dispatch      = evt.dispatch;
            bool flag = mouseEvent != null;

            if (flag)
            {
                this.modifiers      = mouseEvent.modifiers;
                this.mousePosition  = mouseEvent.mousePosition;
                this.button         = mouseEvent.button;
                this.pressedButtons = mouseEvent.pressedButtons;
                this.clickCount     = mouseEvent.clickCount;
            }
            IPointerEvent         pointerEvent         = evt as IPointerEvent;
            IPointerEventInternal pointerEventInternal = evt as IPointerEventInternal;

            this.hasUnderlyingPhysicalEvent = (pointerEvent != null && pointerEventInternal != null && pointerEventInternal.triggeredByOS);
            bool flag2 = pointerEvent != null;

            if (flag2)
            {
                this.modifiers      = pointerEvent.modifiers;
                this.mousePosition  = pointerEvent.position;
                this.button         = pointerEvent.button;
                this.pressedButtons = pointerEvent.pressedButtons;
                this.clickCount     = pointerEvent.clickCount;
            }
            IKeyboardEvent keyboardEvent = evt as IKeyboardEvent;
            bool           flag3         = keyboardEvent != null;

            if (flag3)
            {
                this.character = keyboardEvent.character;
                this.keyCode   = keyboardEvent.keyCode;
            }
            ICommandEvent commandEvent = evt as ICommandEvent;
            bool          flag4        = commandEvent != null;

            if (flag4)
            {
                this.commandName = commandEvent.commandName;
            }
        }
コード例 #4
0
        public static T GetPooled(IPointerEvent triggerEvent)
        {
            T pooled = EventBase <T> .GetPooled();

            bool flag = triggerEvent != null;

            if (flag)
            {
                pooled.pointerId          = triggerEvent.pointerId;
                pooled.pointerType        = triggerEvent.pointerType;
                pooled.isPrimary          = triggerEvent.isPrimary;
                pooled.button             = triggerEvent.button;
                pooled.pressedButtons     = triggerEvent.pressedButtons;
                pooled.position           = triggerEvent.position;
                pooled.localPosition      = triggerEvent.localPosition;
                pooled.deltaPosition      = triggerEvent.deltaPosition;
                pooled.deltaTime          = triggerEvent.deltaTime;
                pooled.clickCount         = triggerEvent.clickCount;
                pooled.pressure           = triggerEvent.pressure;
                pooled.tangentialPressure = triggerEvent.tangentialPressure;
                pooled.altitudeAngle      = triggerEvent.altitudeAngle;
                pooled.azimuthAngle       = triggerEvent.azimuthAngle;
                pooled.twist          = triggerEvent.twist;
                pooled.radius         = triggerEvent.radius;
                pooled.radiusVariance = triggerEvent.radiusVariance;
                pooled.modifiers      = triggerEvent.modifiers;
                IPointerEventInternal pointerEventInternal = triggerEvent as IPointerEventInternal;
                bool flag2 = pointerEventInternal != null;
                if (flag2)
                {
                    pooled.triggeredByOS = pointerEventInternal.triggeredByOS;
                }
            }
            return(pooled);
        }
コード例 #5
0
        private static void UpdateElementUnderPointer(EventBase evt, IPanel panel, out VisualElement elementUnderPointer)
        {
            IPointerEvent          pointerEvent           = evt as IPointerEvent;
            BaseVisualElementPanel baseVisualElementPanel = panel as BaseVisualElementPanel;
            IPointerEventInternal  expr_15 = evt as IPointerEventInternal;

            elementUnderPointer = ((expr_15 == null || expr_15.recomputeTopElementUnderPointer) ? ((baseVisualElementPanel != null) ? baseVisualElementPanel.RecomputeTopElementUnderPointer(pointerEvent.position, evt) : null) : ((baseVisualElementPanel != null) ? baseVisualElementPanel.GetTopElementUnderPointer(pointerEvent.pointerId) : null));
        }
コード例 #6
0
        public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, DropdownMenu menu, IEventHandler target, ContextualMenuManager menuManager)
        {
            ContextualMenuPopulateEvent pooled = EventBase <ContextualMenuPopulateEvent> .GetPooled(triggerEvent);

            bool flag = triggerEvent != null;

            if (flag)
            {
                triggerEvent.Acquire();
                pooled.triggerEvent = triggerEvent;
                IMouseEvent mouseEvent = triggerEvent as IMouseEvent;
                bool        flag2      = mouseEvent != null;
                if (flag2)
                {
                    pooled.modifiers          = mouseEvent.modifiers;
                    pooled.mousePosition      = mouseEvent.mousePosition;
                    pooled.localMousePosition = mouseEvent.mousePosition;
                    pooled.mouseDelta         = mouseEvent.mouseDelta;
                    pooled.button             = mouseEvent.button;
                    pooled.clickCount         = mouseEvent.clickCount;
                }
                else
                {
                    IPointerEvent pointerEvent = triggerEvent as IPointerEvent;
                    bool          flag3        = pointerEvent != null;
                    if (flag3)
                    {
                        pooled.modifiers          = pointerEvent.modifiers;
                        pooled.mousePosition      = pointerEvent.position;
                        pooled.localMousePosition = pointerEvent.position;
                        pooled.mouseDelta         = pointerEvent.deltaPosition;
                        pooled.button             = pointerEvent.button;
                        pooled.clickCount         = pointerEvent.clickCount;
                    }
                }
                IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal;
                bool flag4 = mouseEventInternal != null;
                if (flag4)
                {
                    ((IMouseEventInternal)pooled).triggeredByOS = mouseEventInternal.triggeredByOS;
                }
                else
                {
                    IPointerEventInternal pointerEventInternal = triggerEvent as IPointerEventInternal;
                    bool flag5 = pointerEventInternal != null;
                    if (flag5)
                    {
                        ((IMouseEventInternal)pooled).triggeredByOS = pointerEventInternal.triggeredByOS;
                    }
                }
            }
            pooled.target = target;
            pooled.menu   = menu;
            pooled.m_ContextualMenuManager = menuManager;
            return(pooled);
        }
コード例 #7
0
        public static ContextualMenuPopulateEvent GetPooled(EventBase triggerEvent, DropdownMenu menu, IEventHandler target, ContextualMenuManager menuManager)
        {
            ContextualMenuPopulateEvent e = GetPooled(triggerEvent);

            if (triggerEvent != null)
            {
                triggerEvent.Acquire();
                e.triggerEvent = triggerEvent;

                IMouseEvent mouseEvent = triggerEvent as IMouseEvent;
                if (mouseEvent != null)
                {
                    e.modifiers          = mouseEvent.modifiers;
                    e.mousePosition      = mouseEvent.mousePosition;
                    e.localMousePosition = mouseEvent.mousePosition;
                    e.mouseDelta         = mouseEvent.mouseDelta;
                    e.button             = mouseEvent.button;
                    e.clickCount         = mouseEvent.clickCount;
                }
                else
                {
                    IPointerEvent pointerEvent = triggerEvent as IPointerEvent;
                    if (pointerEvent != null)
                    {
                        e.modifiers          = pointerEvent.modifiers;
                        e.mousePosition      = pointerEvent.position;
                        e.localMousePosition = pointerEvent.position;
                        e.mouseDelta         = pointerEvent.deltaPosition;
                        e.button             = pointerEvent.button;
                        e.clickCount         = pointerEvent.clickCount;
                    }
                }

                IMouseEventInternal mouseEventInternal = triggerEvent as IMouseEventInternal;
                if (mouseEventInternal != null)
                {
                    ((IMouseEventInternal)e).triggeredByOS = mouseEventInternal.triggeredByOS;
                }
                else
                {
                    IPointerEventInternal pointerEventInternal = triggerEvent as IPointerEventInternal;
                    if (pointerEventInternal != null)
                    {
                        ((IMouseEventInternal)e).triggeredByOS = pointerEventInternal.triggeredByOS;
                    }
                }
            }

            e.target = target;
            e.menu   = menu;
            e.m_ContextualMenuManager = menuManager;

            return(e);
        }
コード例 #8
0
        protected static T GetPooled(IPointerEvent pointerEvent)
        {
            T pooled = EventBase <T> .GetPooled();

            EventBase arg_1F_0 = pooled;
            EventBase expr_13  = pointerEvent as EventBase;

            arg_1F_0.target = ((expr_13 != null) ? expr_13.target : null);
            EventBase arg_3D_0 = pooled;
            EventBase expr_31  = pointerEvent as EventBase;

            arg_3D_0.imguiEvent = ((expr_31 != null) ? expr_31.imguiEvent : null);
            EventBase expr_49 = pointerEvent as EventBase;
            bool      flag    = ((expr_49 != null) ? expr_49.path : null) != null;

            if (flag)
            {
                pooled.path = (pointerEvent as EventBase).path;
            }
            pooled.modifiers          = pointerEvent.modifiers;
            pooled.mousePosition      = pointerEvent.position;
            pooled.localMousePosition = pointerEvent.position;
            pooled.mouseDelta         = pointerEvent.deltaPosition;
            pooled.button             = ((pointerEvent.button == -1) ? 0 : pointerEvent.button);
            pooled.pressedButtons     = pointerEvent.pressedButtons;
            pooled.clickCount         = pointerEvent.clickCount;
            IPointerEventInternal pointerEventInternal = pointerEvent as IPointerEventInternal;
            bool flag2 = pointerEventInternal != null;

            if (flag2)
            {
                pooled.triggeredByOS = pointerEventInternal.triggeredByOS;
                pooled.recomputeTopElementUnderMouse = true;
                pooled.sourcePointerEvent            = pointerEvent;
            }
            return(pooled);
        }
コード例 #9
0
        void Init(EventBase evt)
        {
            eventBaseName  = evt.GetType().Name;
            eventTypeId    = evt.eventTypeId;
            eventId        = evt.eventId;
            triggerEventId = evt.triggerEventId;

            timestamp = evt.timestamp;

            target = evt.target;

            skipElements = evt.skipElements;

            isPropagationStopped          = evt.isPropagationStopped;
            isImmediatePropagationStopped = evt.isImmediatePropagationStopped;
            isDefaultPrevented            = evt.isDefaultPrevented;

            IMouseEvent         mouseEvent         = evt as IMouseEvent;
            IMouseEventInternal mouseEventInternal = evt as IMouseEventInternal;

            hasUnderlyingPhysicalEvent = mouseEvent != null &&
                                         mouseEventInternal != null &&
                                         mouseEventInternal.triggeredByOS;

            propagationPhase = evt.propagationPhase;

            originalMousePosition = evt.originalMousePosition;
            currentTarget         = evt.currentTarget;

            dispatch = evt.dispatch;

            if (mouseEvent != null)
            {
                modifiers      = mouseEvent.modifiers;
                mousePosition  = mouseEvent.mousePosition;
                button         = mouseEvent.button;
                pressedButtons = mouseEvent.pressedButtons;
                clickCount     = mouseEvent.clickCount;
                // TODO: Scroll Wheel
                //delta = mouseEvent.delta;
            }

            IPointerEvent         pointerEvent         = evt as IPointerEvent;
            IPointerEventInternal pointerEventInternal = evt as IPointerEventInternal;

            hasUnderlyingPhysicalEvent = pointerEvent != null &&
                                         pointerEventInternal != null &&
                                         pointerEventInternal.triggeredByOS;

            if (pointerEvent != null)
            {
                modifiers      = pointerEvent.modifiers;
                mousePosition  = pointerEvent.position;
                button         = pointerEvent.button;
                pressedButtons = pointerEvent.pressedButtons;
                clickCount     = pointerEvent.clickCount;
                // TODO: Scroll Wheel
                //delta = mouseEvent.delta;
            }

            IKeyboardEvent keyboardEvent = evt as IKeyboardEvent;

            if (keyboardEvent != null)
            {
                character = keyboardEvent.character;
                keyCode   = keyboardEvent.keyCode;
            }

            ICommandEvent commandEvent = evt as ICommandEvent;

            if (commandEvent != null)
            {
                commandName = commandEvent.commandName;
            }
        }