UnityEditor.ZoomableArea.HandleZoomAndPanEvents C# (CSharp) Method

HandleZoomAndPanEvents() public method

public HandleZoomAndPanEvents ( Rect area ) : void
area UnityEngine.Rect
return void
        public void HandleZoomAndPanEvents(Rect area)
        {
            GUILayout.BeginArea(area);
            area.x = 0f;
            area.y = 0f;
            int controlID = GUIUtility.GetControlID(zoomableAreaHash, FocusType.Passive, area);
            switch (Event.current.GetTypeForControl(controlID))
            {
                case EventType.MouseDown:
                    if (area.Contains(Event.current.mousePosition))
                    {
                        GUIUtility.keyboardControl = controlID;
                        if (this.IsZoomEvent() || this.IsPanEvent())
                        {
                            GUIUtility.hotControl = controlID;
                            m_MouseDownPosition = this.mousePositionInDrawing;
                            Event.current.Use();
                        }
                    }
                    break;

                case EventType.MouseUp:
                    if (GUIUtility.hotControl == controlID)
                    {
                        GUIUtility.hotControl = 0;
                        m_MouseDownPosition = new Vector2(-1000000f, -1000000f);
                    }
                    break;

                case EventType.MouseDrag:
                    if (GUIUtility.hotControl == controlID)
                    {
                        if (this.IsZoomEvent())
                        {
                            this.HandleZoomEvent(m_MouseDownPosition, false);
                            Event.current.Use();
                        }
                        else if (this.IsPanEvent())
                        {
                            this.Pan();
                            Event.current.Use();
                        }
                        break;
                    }
                    break;

                case EventType.ScrollWheel:
                    if (area.Contains(Event.current.mousePosition))
                    {
                        if (!this.m_IgnoreScrollWheelUntilClicked || (GUIUtility.keyboardControl == controlID))
                        {
                            this.HandleZoomEvent(this.mousePositionInDrawing, true);
                            Event.current.Use();
                        }
                        break;
                    }
                    break;
            }
            GUILayout.EndArea();
        }