Example #1
0
        public override void Render(Rect rect, float headerWidth)
        {
            Rect = rect;

            Rect headerRect = rect;

            headerRect.height = HeaderHeight;
            RenderHeader(headerRect, headerWidth);

            Rect headerTimelineRect = rect;

            headerTimelineRect.xMin += headerWidth;
            if (headerTimelineRect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x - headerWidth, this);
            }

            headerRect.width = headerWidth;
            HeaderRect       = headerRect;

            Rect listRect = rect;

            listRect.yMin += HeaderHeight;

            _contentOffset.y = listRect.y;

            if (_showPercentage.value > 0)
            {
                listRect.height *= _showPercentage.value;
                RenderList(listRect, headerWidth);
            }

            if (IsSelected && Event.current.type == EventType.Repaint)
            {
                float lineWidth     = 3;
                float halfLineWidth = lineWidth * 0.33f;
                Color c             = Handles.selectedColor;    //FGUI.GetTextColor();//Color.white;//new Color(0.5f, 0.7f, 0.1f, 1f);//FGUI.GetSelectionColor();
                c.a           = 1f;
                Handles.color = c;
                Vector3 pt0 = new Vector3(rect.xMin + halfLineWidth, rect.yMin + halfLineWidth);
                Vector3 pt1 = new Vector3(rect.xMin + halfLineWidth, rect.yMax - halfLineWidth);
                Vector3 pt2 = new Vector3(rect.xMax - halfLineWidth, rect.yMax - halfLineWidth);
                Vector3 pt3 = new Vector3(rect.xMax - halfLineWidth, rect.yMin + halfLineWidth);
//				Handles.DrawAAPolyLine( lineWidth, pt0, pt1, pt2, pt3, pt0 );
                Handles.DrawSolidRectangleWithOutline(new Vector3[] { pt0, pt1, pt2, pt3 }, new Color(0, 0, 0, 0), c);
                //				Handles.DrawPolyLine( pt0, pt1, pt2, pt3, pt0 );
            }

            Handles.color = FGUI.GetLineColor();
            Handles.DrawLine(Rect.min, Rect.min + new Vector2(Rect.width, 0));
            Handles.DrawLine(Rect.max - new Vector2(Rect.width, 0), Rect.max);
        }
Example #2
0
        // pixelsPerFrame can be calculated from rect and viewRange, but being cached on a higher level
        public void Render(Rect rect, FrameRange viewRange, float pixelsPerFrame, FrameRange validKeyframeRange)
        {
            Rect = rect;

            _eventRect = rect;

            int eventStartFrame = Mathf.Max(Evt.Start, viewRange.Start);
            int eventEndFrame   = Mathf.Min(Evt.End, viewRange.End);

            _eventRect.xMin += (eventStartFrame - viewRange.Start) * pixelsPerFrame;                               // first set the start
            _eventRect.xMax  = _eventRect.xMin + Mathf.Max(4, (eventEndFrame - eventStartFrame) * pixelsPerFrame); // then width

            if (_eventRect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x - rect.x, this);
            }

            RenderEvent(viewRange, validKeyframeRange);
        }
Example #3
0
        // pixelsPerFrame can be calculated from rect and viewRange, but being cached on a higher level
        public void Render(Rect rect, FrameRange viewRange, float pixelsPerFrame, FrameRange validKeyframeRange)
        {
            Rect = rect;

            _eventRect = rect;

            int eventStartFrame = Mathf.Max(Evt.Start, viewRange.Start);
            int eventEndFrame   = Mathf.Min(Evt.End, viewRange.End);

            _eventRect.xMin = SequenceEditor.GetXForFrame(eventStartFrame);
            _eventRect.xMax = SequenceEditor.GetXForFrame(eventEndFrame);


            if (_eventRect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x, this);
            }

            RenderEvent(viewRange, validKeyframeRange);
        }
Example #4
0
        public override void Render(Rect rect, float headerWidth)
        {
            Rect = rect;

            _headerWidth = headerWidth;

            Rect headerRect = rect;

            headerRect.width = headerWidth;

            Rect viewRect = rect;

            viewRect.xMax   = rect.xMin + headerWidth;
            viewRect.xMin   = viewRect.xMax - 16;
            viewRect.height = 16;

            if (Track.CanTogglePreview)
            {
                if (Event.current.type == EventType.MouseDown)
                {
                    if (viewRect.Contains(Event.current.mousePosition))
                    {
                        if (Event.current.button == 0)                          // left click?
                        {
                            if (Event.current.shift)                            // turn all?
                            {
                                SequenceEditor.TurnOnAllPreviews(!Track.CanPreview);
                            }
                            else
                            {
                                OnTogglePreview(!Track.CanPreview);
                            }
                            FUtility.RepaintGameView();
                            Event.current.Use();
                        }
                    }
                }
            }

            Rect trackHeaderRect = rect;

            trackHeaderRect.xMax = viewRect.xMax;            //headerWidth;

            Color guiColor = GUI.color;

            bool selected = _isSelected;

            if (selected)
            {
                Color c = FGUI.GetSelectionColor();
                c.a       = GUI.color.a;
                GUI.color = c;
                GUI.DrawTexture(trackHeaderRect, EditorGUIUtility.whiteTexture);
                GUI.color = guiColor;
            }

            if (!Track.enabled)
            {
                Color c = guiColor;
                c.a       = 0.5f;
                GUI.color = c;
            }

            Rect trackLabelRect = trackHeaderRect;

            trackLabelRect.xMin += 8;

            GUI.Label(trackLabelRect, new GUIContent(Track.name), FGUI.GetTrackHeaderStyle());

            rect.xMin = trackHeaderRect.xMax;

            if (rect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x - rect.xMin, this);
            }

            FrameRange validKeyframeRange = new FrameRange(0, SequenceEditor.Sequence.Length);

            for (int i = 0; i != _eventEditors.Count; ++i)
            {
                if (i == 0)
                {
                    validKeyframeRange.Start = 0;
                }
                else
                {
                    validKeyframeRange.Start = _eventEditors[i - 1].Evt.End;
                }

                if (i == _eventEditors.Count - 1)
                {
                    validKeyframeRange.End = SequenceEditor.Sequence.Length;
                }
                else
                {
                    validKeyframeRange.End = _eventEditors[i + 1].Evt.Start;
                }
                _eventEditors[i].Render(rect, SequenceEditor.ViewRange, SequenceEditor.PixelsPerFrame, validKeyframeRange);
            }

            switch (Event.current.type)
            {
            case EventType.ContextClick:
                if (trackHeaderRect.Contains(Event.current.mousePosition))
                {
                    OnHeaderContextClick();
                }
                else if (Rect.Contains(Event.current.mousePosition))
                {
                    OnBodyContextClick();
                }
                break;

            case EventType.MouseDown:
                if (EditorGUIUtility.hotControl == 0 && trackHeaderRect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.button == 0)                      // selecting
                    {
                        if (Event.current.control)
                        {
                            if (IsSelected)
                            {
                                SequenceEditor.Deselect(this);
                            }
                            else
                            {
                                SequenceEditor.Select(this);
                            }
                        }
                        else if (Event.current.shift)
                        {
                            SequenceEditor.Select(this);
                        }
                        else
                        {
                            SequenceEditor.SelectExclusive(this);
                        }
                        Event.current.Use();
                    }
                }
                break;

            case EventType.MouseUp:
//				if( EditorGUIUtility.hotControl == GuiId )
//				{
//					EditorGUIUtility.hotControl = 0;
//					_offsetAnim.value = _offsetAnim.target = Vector2.zero;
//
////					if( TimelineEditor ) TimelineEditor.StopTrackDrag();
//
//					SequenceEditor.Repaint();
//					Event.current.Use();
//				}
                break;

            case EventType.MouseDrag:
//				if( EditorGUIUtility.hotControl == GuiId )
//				{
//					SequenceEditor.Repaint();
//					Event.current.Use();
//				}
                break;
            }

            if (Track.CanTogglePreview)
            {
                GUI.color = GetPreviewIconColor();                //FGUI.GetTextColor();

                if (!Track.CanPreview)
                {
                    Color c = GUI.color;
                    c.a       = 0.3f;
                    GUI.color = c;
                }

                GUI.DrawTexture(viewRect, _previewIcon);

                GUI.color = Color.white;
            }

            Handles.color = FGUI.GetLineColor();
            Handles.DrawLine(Rect.min, Rect.min + new Vector2(Rect.width, 0));
            Handles.DrawLine(Rect.max, Rect.max - new Vector2(Rect.width, 0));

            GUI.color = guiColor;
        }
Example #5
0
        public override void Render(Rect rect, float headerWidth)
        {
            Rect = rect;

            HeaderWidth = headerWidth;

            Rect headerRect = rect;

            headerRect.width = headerWidth;

            Rect enableButtonRect = rect;

            enableButtonRect.xMax   = rect.xMin + headerWidth;
            enableButtonRect.xMin   = enableButtonRect.xMax - 16;
            enableButtonRect.height = 16;

            Rect trackHeaderRect = rect;

            trackHeaderRect.width = headerWidth;

            Color guiColor = GUI.color;

            bool selected = _isSelected;

            if (selected)
            {
                Color c = FGUI.GetSelectionColor();
                c.a       = GUI.color.a;
                GUI.color = c;
                GUI.DrawTexture(trackHeaderRect, EditorGUIUtility.whiteTexture);
                GUI.color = guiColor;
            }

            GUI.color = GetPreviewIconColor();

            if (!Track.enabled)
            {
                Color c = guiColor;
                c.a       = 0.5f;
                GUI.color = c;
            }

            if (FGUI.Button(enableButtonRect, _enableContent))
            {
                if (Event.current.shift) // turn all?
                {
                    SequenceEditor.EnableAllTracks(!Track.enabled);
                }
                else
                {
                    OnToggle(!Track.enabled);
                }
                FUtility.RepaintGameView();
                Event.current.Use();
            }

            Rect trackLabelRect = trackHeaderRect;

            trackLabelRect.xMin += 8;
            RenderHeader(trackLabelRect, new GUIContent(Track.name));

            rect.xMin = trackHeaderRect.xMax;

            if (rect.Contains(Event.current.mousePosition))
            {
                SequenceEditor.SetMouseHover(Event.current.mousePosition.x - rect.xMin, this);
            }

            FrameRange validKeyframeRange = new FrameRange(0, SequenceEditor.Sequence.Length);

            _contentOffset = rect.min;

            GUI.BeginGroup(rect);

            rect.x = 0;
            rect.y = 0;

            for (int i = 0; i != _eventEditors.Count; ++i)
            {
                if (i == 0)
                {
                    validKeyframeRange.Start = 0;
                }
                else
                {
                    validKeyframeRange.Start = _eventEditors[i - 1].Evt.End;
                }

                if (i == _eventEditors.Count - 1)
                {
                    validKeyframeRange.End = SequenceEditor.Sequence.Length;
                }
                else
                {
                    validKeyframeRange.End = _eventEditors[i + 1].Evt.Start;
                }

                rect.xMin = SequenceEditor.GetXForFrame(_eventEditors[i].Evt.Start);
                rect.xMax = SequenceEditor.GetXForFrame(_eventEditors[i].Evt.End);
                _eventEditors[i].Render(rect, SequenceEditor.ViewRange, SequenceEditor.PixelsPerFrame, validKeyframeRange);
            }

            GUI.EndGroup();

            switch (Event.current.type)
            {
            case EventType.ContextClick:
                if (trackHeaderRect.Contains(Event.current.mousePosition))
                {
                    OnHeaderContextClick();
                }
                else if (Rect.Contains(Event.current.mousePosition))
                {
                    OnBodyContextClick();
                }
                break;

            case EventType.MouseDown:
                if (EditorGUIUtility.hotControl == 0 && trackHeaderRect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.button == 0)     // selecting
                    {
                        if (Event.current.control)
                        {
                            if (IsSelected)
                            {
                                SequenceEditor.Deselect(this);
                            }
                            else
                            {
                                SequenceEditor.Select(this);
                            }
                        }
                        else if (Event.current.shift)
                        {
                            SequenceEditor.Select(this);
                        }
                        else
                        {
                            SequenceEditor.SelectExclusive(this);
                        }
                        Event.current.Use();
                    }
                }
                break;

            case EventType.MouseUp:
                break;

            case EventType.MouseDrag:
                break;
            }

            Handles.color = FGUI.GetLineColor();
            Handles.DrawLine(Rect.min, Rect.min + new Vector2(Rect.width, 0));
            Handles.DrawLine(Rect.max, Rect.max - new Vector2(Rect.width, 0));

            GUI.color = guiColor;
        }