public override void Overlay(Event evt, WindowState state)
        {
            var r = CurrentRectangle();

            if (evt.type == EventType.Repaint)
            {
                if (IsValidRect(r))
                {
                    using (new GUIViewportScope(m_ActiveRect))
                    {
                        DrawRectangle(r);
                    }
                }
            }

            m_TimeAreaAutoPanner?.OnGUI(evt);
        }
        public override void Overlay(Event evt, WindowState state)
        {
            if (!m_Dragged)
            {
                return;
            }

            if (m_TimeAreaAutoPanner != null)
            {
                m_TimeAreaAutoPanner.OnGUI(evt);
            }

            m_MoveItemHandler.OnGUI(evt);

            if (!m_MoveItemHandler.allowTrackSwitch || m_MoveItemHandler.targetTrack != null)
            {
                TimeIndicator.Draw(state, m_MoveItemHandler.start, m_MoveItemHandler.end);
                m_SnapEngine.OnGUI();
            }
        }
Beispiel #3
0
        public void OnGUI(WindowState state, EventType rawType, Vector2 mousePosition)
        {
            if (m_Id == 0)
            {
                m_Id = GUIUtility.GetPermanentControlID();
            }

            if (state == null || state.GetWindow().treeView == null)
            {
                return;
            }

            var evt = Event.current;

            if (rawType == EventType.MouseDown || evt.type == EventType.MouseDown)
            {
                if (state.IsCurrentEditingASequencerTextField())
                {
                    return;
                }

                m_ActiveRect = TimelineWindow.instance.sequenceContentRect;

                //remove the track header splitter overlap
                m_ActiveRect.x     += k_HeaderSplitterOverlap;
                m_ActiveRect.width -= k_HeaderSplitterOverlap;

                if (!m_ActiveRect.Contains(mousePosition))
                {
                    return;
                }

                if (!CanStartRectangle(evt))
                {
                    return;
                }

                if (enableAutoPan)
                {
                    m_TimeAreaAutoPanner = new TimeAreaAutoPanner(state);
                }

                m_StartPoint = new TimelinePoint(state, mousePosition);
                m_EndPixel   = mousePosition;

                GUIUtility.hotControl = m_Id; //HACK: Because the treeView eats all the events, steal the hotControl if necessary...
                evt.Use();

                return;
            }

            switch (evt.GetTypeForControl(m_Id))
            {
            case EventType.KeyDown:
            {
                if (GUIUtility.hotControl == m_Id)
                {
                    if (evt.keyCode == KeyCode.Escape)
                    {
                        m_TimeAreaAutoPanner = null;

                        GUIUtility.hotControl = 0;
                        evt.Use();
                    }
                }

                return;
            }

            case EventType.MouseDrag:
            {
                if (GUIUtility.hotControl != m_Id)
                {
                    return;
                }

                m_EndPixel = mousePosition;
                evt.Use();

                return;
            }

            case EventType.MouseUp:
            {
                if (GUIUtility.hotControl != m_Id)
                {
                    return;
                }

                m_TimeAreaAutoPanner = null;

                var rect = CurrentRectangle();

                if (IsValidRect(rect))
                {
                    OnFinish(evt, state, rect);
                }

                GUIUtility.hotControl = 0;
                evt.Use();

                return;
            }
            }

            if (GUIUtility.hotControl == m_Id)
            {
                if (evt.type == EventType.Repaint)
                {
                    var r = CurrentRectangle();

                    if (IsValidRect(r))
                    {
                        using (new GUIViewportScope(m_ActiveRect))
                        {
                            DrawRectangle(r);
                        }
                    }
                }

                if (m_TimeAreaAutoPanner != null)
                {
                    m_TimeAreaAutoPanner.OnGUI(evt);
                }
            }
        }