private void OnDragSelecting(Vector2 mousePos) { if (!_isDragSelecting) { return; } if (Event.current.shift) { EditorGUIUtility.AddCursorRect(_rect, MouseCursor.ArrowPlus); } else if (Event.current.control) { EditorGUIUtility.AddCursorRect(_rect, MouseCursor.ArrowMinus); } FrameRange selectedRange = new FrameRange(); bool isSelectingTimelines; Rect selectionRect = GetDragSelectionRect(_dragSelectingStartPos, mousePos, out selectedRange, out isSelectingTimelines); if (selectionRect.width == 0) { selectionRect.width = 1; } GUI.color = FGUI.GetSelectionColor(); GUI.DrawTexture(selectionRect, EditorGUIUtility.whiteTexture); }
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; }
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; }
public virtual void Render(int id, Rect rect, int headerWidth, FrameRange viewRange, float pixelsPerFrame) { rect.y += _offsetAnim.value.y; _rect = rect; Rect viewRect = rect; viewRect.y += _offsetAnim.value.y; viewRect.xMax = 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? { _track.IsPreviewing = !_track.IsPreviewing; FUtility.RepaintGameView(); Event.current.Use(); } } } } Rect trackHeaderRect = rect; trackHeaderRect.xMax = headerWidth; bool selected = _isSelected; if (selected) { Color c = FGUI.GetSelectionColor(); GUI.color = c; GUI.DrawTexture(trackHeaderRect, EditorGUIUtility.whiteTexture); GUI.color = FGUI.GetTextColor(); // Debug.Log( GUI.color ); } Rect trackLabelRect = trackHeaderRect; trackLabelRect.xMin += 10; GUI.Label(trackLabelRect, new GUIContent(_track.name), FGUI.GetTrackHeaderStyle()); rect.xMin = trackHeaderRect.xMax; FrameRange validKeyframeRange = new FrameRange(0, SequenceEditor.GetSequence().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.GetSequence().Length; } else { validKeyframeRange.End = _eventEditors[i + 1]._evt.Start; } _eventEditors[i].Render(rect, viewRange, pixelsPerFrame, validKeyframeRange); } switch (Event.current.type) { case EventType.ContextClick: if (trackHeaderRect.Contains(Event.current.mousePosition)) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Duplicate Track"), false, DuplicateTrack); menu.AddItem(new GUIContent("Delete Track"), false, DeleteTrack); menu.ShowAsContext(); Event.current.Use(); } 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); _timelineEditor.StartTrackDrag(this); _offsetAnim.value = _offsetAnim.target = new Vector2(0, rect.yMin) - Event.current.mousePosition; EditorGUIUtility.hotControl = id; } Event.current.Use(); } } break; case EventType.MouseUp: if (EditorGUIUtility.hotControl == id) { EditorGUIUtility.hotControl = 0; _offsetAnim.value = _offsetAnim.target = Vector2.zero; _timelineEditor.StopTrackDrag(); SequenceEditor.Repaint(); Event.current.Use(); } break; case EventType.MouseDrag: if (EditorGUIUtility.hotControl == id) { SequenceEditor.Repaint(); Event.current.Use(); } break; } if (_track.CanTogglePreview()) { GUI.color = FGUI.GetTextColor(); if (!_track.IsPreviewing) { Color c = GUI.color; c.a = 0.3f; GUI.color = c; } GUI.DrawTexture(viewRect, _previewIcon); GUI.color = Color.white; } #if UNITY_4_5 if (_offsetAnim.isAnimating) { SequenceEditor.Repaint(); } #endif }