Esempio n. 1
0
        void UpdateContentZoomer()
        {
            if (m_MinScale != m_MaxScale)
            {
                if (m_Zoomer == null)
                {
                    m_Zoomer = new ContentZoomer();
                    this.AddManipulator(m_Zoomer);
                }

                m_Zoomer.minScale       = m_MinScale;
                m_Zoomer.maxScale       = m_MaxScale;
                m_Zoomer.scaleStep      = m_ScaleStep;
                m_Zoomer.referenceScale = m_ReferenceScale;
            }
            else
            {
                if (m_Zoomer != null)
                {
                    this.RemoveManipulator(m_Zoomer);
                }
            }

            ValidateTransform();
        }
Esempio n. 2
0
        private void OnWheel(WheelEvent evt)
        {
            GraphView graphView = base.target as GraphView;

            if (graphView != null)
            {
                if (!MouseCaptureController.IsMouseCaptureTaken())
                {
                    Vector3 vector  = graphView.viewTransform.position;
                    Vector3 scale   = graphView.viewTransform.scale;
                    Vector2 vector2 = base.target.ChangeCoordinatesTo(graphView.contentViewContainer, evt.localMousePosition);
                    float   x       = vector2.x + graphView.contentViewContainer.layout.x;
                    float   y       = vector2.y + graphView.contentViewContainer.layout.y;
                    vector += Vector3.Scale(new Vector3(x, y, 0f), scale);
                    float num = ContentZoomer.CalculateNewZoom(scale.y, -evt.delta.y, this.scaleStep, this.referenceScale, this.minScale, this.maxScale);
                    scale.x = num;
                    scale.y = num;
                    scale.z = 1f;
                    vector -= Vector3.Scale(new Vector3(x, y, 0f), scale);
                    if (graphView.elementPanel != null && this.keepPixelCacheOnZoom)
                    {
                        graphView.elementPanel.keepPixelCacheOnWorldBoundChange = true;
                        if (this.m_OnTimerTicker == null)
                        {
                            this.m_OnTimerTicker = graphView.schedule.Execute(new Action <TimerState>(this.OnTimer));
                        }
                        this.m_OnTimerTicker.ExecuteLater(500L);
                        this.delayRepaintScheduled = true;
                    }
                    graphView.UpdateViewTransform(vector, scale);
                    evt.StopPropagation();
                }
            }
        }