Beispiel #1
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);
        }
Beispiel #2
0
        private void DoOnGUI(Event evt, Matrix4x4 parentTransform, Rect clippingRect, bool isComputingLayout, Rect layoutSize, Action onGUIHandler, bool canAffectFocus = true)
        {
            bool flag = onGUIHandler == null || base.panel == null;

            if (!flag)
            {
                int num = GUIClip.Internal_GetCount();
                this.SaveGlobals();
                float layoutMeasuredWidth  = this.layoutMeasuredWidth;
                float layoutMeasuredHeight = this.layoutMeasuredHeight;
                UIElementsUtility.BeginContainerGUI(this.cache, evt, this);
                GUI.color = UIElementsUtility.editorPlayModeTintColor;
                bool flag2 = Event.current.type != EventType.Layout;
                if (flag2)
                {
                    bool flag3 = this.lostFocus;
                    if (flag3)
                    {
                        bool flag4 = this.focusController != null;
                        if (flag4)
                        {
                            bool flag5 = GUIUtility.OwnsId(GUIUtility.keyboardControl);
                            if (flag5)
                            {
                                GUIUtility.keyboardControl = 0;
                                this.focusController.imguiKeyboardControl = 0;
                            }
                        }
                        this.lostFocus = false;
                    }
                    bool flag6 = this.receivedFocus;
                    if (flag6)
                    {
                        bool flag7 = this.hasFocusableControls;
                        if (flag7)
                        {
                            bool flag8 = this.focusChangeDirection != FocusChangeDirection.unspecified && this.focusChangeDirection != FocusChangeDirection.none;
                            if (flag8)
                            {
                                bool flag9 = this.focusChangeDirection == VisualElementFocusChangeDirection.left;
                                if (flag9)
                                {
                                    GUIUtility.SetKeyboardControlToLastControlId();
                                }
                                else
                                {
                                    bool flag10 = this.focusChangeDirection == VisualElementFocusChangeDirection.right;
                                    if (flag10)
                                    {
                                        GUIUtility.SetKeyboardControlToFirstControlId();
                                    }
                                }
                            }
                            else
                            {
                                bool flag11 = GUIUtility.keyboardControl == 0 && this.m_IsFocusDelegated;
                                if (flag11)
                                {
                                    GUIUtility.SetKeyboardControlToFirstControlId();
                                }
                            }
                        }
                        bool flag12 = this.focusController != null;
                        if (flag12)
                        {
                            bool flag13 = this.focusController.imguiKeyboardControl != GUIUtility.keyboardControl && this.focusChangeDirection != FocusChangeDirection.unspecified;
                            if (flag13)
                            {
                                this.newKeyboardFocusControlID = GUIUtility.keyboardControl;
                            }
                            this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                        }
                        this.receivedFocus        = false;
                        this.focusChangeDirection = FocusChangeDirection.unspecified;
                    }
                }
                EventType type   = Event.current.type;
                bool      flag14 = false;
                try
                {
                    using (new GUIClip.ParentClipScope(parentTransform, clippingRect))
                    {
                        onGUIHandler();
                    }
                }
                catch (Exception exception)
                {
                    bool flag15 = type == EventType.Layout;
                    if (!flag15)
                    {
                        throw;
                    }
                    flag14 = GUIUtility.IsExitGUIException(exception);
                    bool flag16 = !flag14;
                    if (flag16)
                    {
                        Debug.LogException(exception);
                    }
                }
                finally
                {
                    bool flag17 = Event.current.type != EventType.Layout & canAffectFocus;
                    if (flag17)
                    {
                        int  keyboardControl = GUIUtility.keyboardControl;
                        int  num2            = GUIUtility.CheckForTabEvent(Event.current);
                        bool flag18          = this.focusController != null;
                        if (flag18)
                        {
                            bool flag19 = num2 < 0;
                            if (flag19)
                            {
                                Focusable leafFocusedElement = this.focusController.GetLeafFocusedElement();
                                Focusable focusable          = null;
                                using (KeyDownEvent pooled = KeyboardEventBase <KeyDownEvent> .GetPooled('\t', KeyCode.Tab, (num2 == -1) ? EventModifiers.None : EventModifiers.Shift))
                                {
                                    focusable = this.focusController.SwitchFocusOnEvent(pooled);
                                }
                                bool flag20 = leafFocusedElement == this;
                                if (flag20)
                                {
                                    bool flag21 = focusable == this;
                                    if (flag21)
                                    {
                                        bool flag22 = num2 == -2;
                                        if (flag22)
                                        {
                                            GUIUtility.SetKeyboardControlToLastControlId();
                                        }
                                        else
                                        {
                                            bool flag23 = num2 == -1;
                                            if (flag23)
                                            {
                                                GUIUtility.SetKeyboardControlToFirstControlId();
                                            }
                                        }
                                        this.newKeyboardFocusControlID            = GUIUtility.keyboardControl;
                                        this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                                    }
                                    else
                                    {
                                        GUIUtility.keyboardControl = 0;
                                        this.focusController.imguiKeyboardControl = 0;
                                    }
                                }
                            }
                            else
                            {
                                bool flag24 = num2 > 0;
                                if (flag24)
                                {
                                    this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                                    this.newKeyboardFocusControlID            = GUIUtility.keyboardControl;
                                }
                                else
                                {
                                    bool flag25 = num2 == 0;
                                    if (flag25)
                                    {
                                        bool flag26 = type == EventType.MouseDown && !this.focusOnlyIfHasFocusableControls;
                                        if (flag26)
                                        {
                                            this.focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this, true);
                                        }
                                        else
                                        {
                                            bool flag27 = keyboardControl != GUIUtility.keyboardControl || type == EventType.MouseDown;
                                            if (flag27)
                                            {
                                                this.focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this, false);
                                            }
                                            else
                                            {
                                                bool flag28 = GUIUtility.keyboardControl != this.focusController.imguiKeyboardControl;
                                                if (flag28)
                                                {
                                                    this.newKeyboardFocusControlID = GUIUtility.keyboardControl;
                                                    bool flag29 = this.focusController.GetLeafFocusedElement() == this;
                                                    if (flag29)
                                                    {
                                                        this.focusController.imguiKeyboardControl = GUIUtility.keyboardControl;
                                                    }
                                                    else
                                                    {
                                                        this.focusController.SyncIMGUIFocus(GUIUtility.keyboardControl, this, false);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        this.hasFocusableControls = GUIUtility.HasFocusableControls();
                    }
                }
                UIElementsUtility.EndContainerGUI(evt, layoutSize);
                this.RestoreGlobals();
                bool flag30 = evt.type == EventType.Layout && (!Mathf.Approximately(layoutMeasuredWidth, this.layoutMeasuredWidth) || !Mathf.Approximately(layoutMeasuredHeight, this.layoutMeasuredHeight));
                if (flag30)
                {
                    bool flag31 = isComputingLayout && clippingRect == Rect.zero;
                    if (flag31)
                    {
                        base.schedule.Execute(delegate
                        {
                            base.IncrementVersion(VersionChangeType.Layout);
                        });
                    }
                    else
                    {
                        base.IncrementVersion(VersionChangeType.Layout);
                    }
                }
                bool flag32 = !flag14;
                if (flag32)
                {
                    bool flag33 = evt.type != EventType.Ignore && evt.type != EventType.Used;
                    if (flag33)
                    {
                        int  num3   = GUIClip.Internal_GetCount();
                        bool flag34 = num3 > num;
                        if (flag34)
                        {
                            Debug.LogError("GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced.");
                        }
                        else
                        {
                            bool flag35 = num3 < num;
                            if (flag35)
                            {
                                Debug.LogError("GUI Error: You are popping more GUIClips than you are pushing. Make sure they are balanced.");
                            }
                        }
                    }
                }
                while (GUIClip.Internal_GetCount() > num)
                {
                    GUIClip.Internal_Pop();
                }
                bool flag36 = evt.type == EventType.Used;
                if (flag36)
                {
                    base.IncrementVersion(VersionChangeType.Repaint);
                }
            }
        }