private static void DrawCurveEditor(IClipCurveEditorOwner clipCurveEditorOwner, TimelineWindow.TimelineState state, Rect headerRect, Rect trackRect, Vector2 activeRange, bool locked) { ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor; CurveDataSource dataSource = clipCurveEditor.dataSource; Rect backgroundRect = dataSource.GetBackgroundRect(state); bool flag = false; if (Event.get_current().get_type() == null) { flag = (InlineCurveEditor.MouseOverTrackArea(backgroundRect, trackRect) || InlineCurveEditor.MouseOverHeaderArea(headerRect, trackRect)); } clipCurveEditorOwner.clipCurveEditor.DrawHeader(headerRect); bool selected = !locked && (clipCurveEditorOwner.inlineCurvesSelected || flag); using (new EditorGUI.DisabledScope(locked)) { using (new GUIViewportScope(trackRect)) { Rect animEditorRect = backgroundRect; animEditorRect.set_y(trackRect.get_y()); animEditorRect.set_height(trackRect.get_height()); animEditorRect.set_xMin(Mathf.Max(animEditorRect.get_xMin(), trackRect.get_xMin())); animEditorRect.set_xMax(trackRect.get_xMax()); if (activeRange == Vector2.get_zero()) { activeRange = new Vector2(animEditorRect.get_xMin(), animEditorRect.get_xMax()); } clipCurveEditor.DrawCurveEditor(animEditorRect, state, activeRange, clipCurveEditorOwner.supportsLooping, selected); } } if (flag) { clipCurveEditorOwner.inlineCurvesSelected = true; } }
public static void Add(IMarker marker) { var markerAsObject = marker as Object; if (markerAsObject != null) { if (!Selection.Contains(markerAsObject)) { currentInlineEditorCurve = null; WindowState state = null; if (TimelineWindow.instance != null) { state = TimelineWindow.instance.state; } if (!Selection.instanceIDs.Any() && state != null && state.editSequence.director != null) { Selection.SetActiveObjectWithContext(markerAsObject, TimelineWindow.instance.state.editSequence.director); } else { Selection.Add(markerAsObject); } } } }
public static void FrameInlineCurves(IClipCurveEditorOwner curveEditorOwner, bool selectionOnly) { var curveEditor = curveEditorOwner.clipCurveEditor.curveEditor; var frameBounds = selectionOnly ? curveEditor.GetSelectionBounds() : curveEditor.GetClipBounds(); var clipGUI = curveEditorOwner as TimelineClipGUI; var areaOffset = 0.0f; if (clipGUI != null) { areaOffset = (float)Math.Max(0.0, clipGUI.clip.FromLocalTimeUnbound(0.0)); var timeScale = (float)clipGUI.clip.timeScale; // Note: The getter for clip.timeScale is guaranteed to never be zero. // Apply scaling var newMin = frameBounds.min.x / timeScale; var newMax = (frameBounds.max.x - frameBounds.min.x) / timeScale + newMin; frameBounds.SetMinMax( new Vector3(newMin, frameBounds.min.y, frameBounds.min.z), new Vector3(newMax, frameBounds.max.y, frameBounds.max.z)); } curveEditor.Frame(frameBounds, true, true); var area = curveEditor.shownAreaInsideMargins; area.x += areaOffset; var curveStart = curveEditorOwner.clipCurveEditor.dataSource.start; FrameRange(curveStart + frameBounds.min.x, curveStart + frameBounds.max.x); }
public static void SelectInlineCurveEditor(IClipCurveEditorOwner selection) { // case 1030681 - selecting an inline curve should remove clips and // tracks to prevent shortcuts being forwarded incorrectly if (selection != null && selection != currentInlineEditorCurve) { var track = selection.owner; var selectedTracks = SelectedTracks().ToArray(); var selectedClips = SelectedClips().ToArray(); foreach (var t in selectedTracks) { if (t != track) { Remove(t); } } foreach (var c in selectedClips) { if (c.parentTrack != track) { Remove(c); } } } currentInlineEditorCurve = selection; }
static void RefreshInlineCurves(IClipCurveEditorOwner guiItem) { if (guiItem.clipCurveEditor != null && guiItem.clipCurveEditor.dataSource != null) { guiItem.clipCurveEditor.dataSource.RebuildCurves(); } }
public static bool ShouldHandleInlineCurve(IClipCurveEditorOwner curveEditorOwner) { return(curveEditorOwner?.clipCurveEditor != null && curveEditorOwner.inlineCurvesSelected && curveEditorOwner.owner != null && curveEditorOwner.owner.GetShowInlineCurves()); }
static void DrawCurveEditor(IClipCurveEditorOwner clipCurveEditorOwner, WindowState state, Rect headerRect, Rect trackRect, Vector2 activeRange, bool locked) { ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor; CurveDataSource dataSource = clipCurveEditor.dataSource; Rect curveRect = dataSource.GetBackgroundRect(state); bool newlySelected = false; if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.ContextClick) { newlySelected = MouseOverTrackArea(curveRect, trackRect) || MouseOverHeaderArea(headerRect, trackRect); } // make sure to not use any event before drawing the curve. bool prevEnabledState = GUI.enabled; GUI.enabled = true; clipCurveEditorOwner.clipCurveEditor.DrawHeader(headerRect); GUI.enabled = prevEnabledState; bool displayAsSelected = !locked && (clipCurveEditorOwner.inlineCurvesSelected || newlySelected); using (new EditorGUI.DisabledScope(locked)) clipCurveEditor.DrawCurveEditor(trackRect, state, activeRange, clipCurveEditorOwner.showLoops, displayAsSelected); if (newlySelected && !locked) { clipCurveEditorOwner.inlineCurvesSelected = true; HandleCurrentEvent(); } }
public static void Add(TrackAsset obj) { // this can indicate a deleted track (Unity 'null') if (obj == null) { return; } currentInlineEditorCurve = null; if (!Selection.Contains(obj)) { WindowState state = null; if (TimelineWindow.instance != null) { state = TimelineWindow.instance.state; } if (!Selection.instanceIDs.Any() && state != null && state.editSequence.director != null) { Selection.SetActiveObjectWithContext(obj, TimelineWindow.instance.state.editSequence.director); } else { Selection.Add(obj); } } }
static bool CanExecute(WindowState state, ActionContext context) { if (context.timeline == null) { return(false); } if (context.markers.Any()) { return(false); } if (context.tracks.ContainsTimelineMarkerTrack(context.timeline)) { return(false); } IClipCurveEditorOwner curveSelected = SelectionManager.GetCurrentInlineEditorCurve(); // Can't have an inline curve selected and have multiple tracks also. if (curveSelected != null) { return(state.IsArmedForRecord(curveSelected.owner)); } return(GetKeyableTracks(state, context).Any()); }
public static void Add(Object obj) { SelectionManager.currentInlineEditorCurve = null; if (!Selection.Contains(obj)) { Selection.Add(obj); } }
static void SelectFromCurveOwner(IClipCurveEditorOwner curveOwner) { if (curveOwner.clipCurveEditor == null) { SelectionManager.SelectInlineCurveEditor(null); } else if (!curveOwner.inlineCurvesSelected && SelectionManager.Count() == 1) { SelectionManager.SelectInlineCurveEditor(curveOwner); } }
static void DrawCurveEditor(IClipCurveEditorOwner clipCurveEditorOwner, WindowState state, Rect headerRect, Rect trackRect, Vector2 activeRange, bool locked) { ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor; CurveDataSource dataSource = clipCurveEditor.dataSource; Rect curveRect = dataSource.GetBackgroundRect(state); bool newlySelected = false; if (Event.current.type == EventType.MouseDown || Event.current.type == EventType.ContextClick) { newlySelected = MouseOverTrackArea(curveRect, trackRect) || MouseOverHeaderArea(headerRect, trackRect); } // make sure to not use any event before drawing the curve. bool prevEnabledState = GUI.enabled; GUI.enabled = true; clipCurveEditorOwner.clipCurveEditor.DrawHeader(headerRect); GUI.enabled = prevEnabledState; bool displayAsSelected = !locked && (clipCurveEditorOwner.inlineCurvesSelected || newlySelected); using (new EditorGUI.DisabledScope(locked)) { using (new GUIViewportScope(trackRect)) { Rect animEditorRect = curveRect; animEditorRect.y = trackRect.y; animEditorRect.height = trackRect.height; // clamp the curve editor to the track. this allows the menu to scroll properly animEditorRect.xMin = Mathf.Max(animEditorRect.xMin, trackRect.xMin); animEditorRect.xMax = trackRect.xMax; if (activeRange == Vector2.zero) { activeRange = new Vector2(animEditorRect.xMin, animEditorRect.xMax); } clipCurveEditor.DrawCurveEditor(animEditorRect, state, activeRange, clipCurveEditorOwner.showLoops, displayAsSelected); } } if (newlySelected && !locked) { clipCurveEditorOwner.inlineCurvesSelected = true; HandleCurrentEvent(); } }
public static void AddObject(Object obj) { if (obj == null) { return; } currentInlineEditorCurve = null; if (Selection.Contains(obj)) { return; } Selection.Add(obj); }
public bool OnEvent(Event evt, TimelineWindow.TimelineState state, bool isCaptureSession) { bool result; if (evt.get_type() == null || evt.get_type() == 16) { result = this.MouseOver(state); } else { IClipCurveEditorOwner clipCurveEditorOwner = this.GetClipCurveEditorOwner(); if (clipCurveEditorOwner == null) { result = false; } else if (!clipCurveEditorOwner.inlineCurvesSelected) { result = false; } else { ClipCurveEditor clipCurveEditor = clipCurveEditorOwner.clipCurveEditor; if (clipCurveEditor == null) { result = false; } else if (evt.get_commandName() == "FrameSelected") { this.FrameSelected(state, clipCurveEditor); result = true; } else { if (evt.get_type() == 4 && evt.get_modifiers() == null) { if (evt.get_character() == 'a') { this.FrameAll(state, clipCurveEditor); result = true; return(result); } } result = false; } } } return(result); }
static void OnMouseClick(IClipCurveEditorOwner clipCurveEditorOwner, Event currentEvent) { if (currentEvent.modifiers == ManipulatorsUtils.actionModifier) { if (clipCurveEditorOwner.inlineCurvesSelected) { SelectionManager.Clear(); } else { clipCurveEditorOwner.SelectCurves(); } } else { clipCurveEditorOwner.SelectCurves(); } HandleCurrentEvent(); }
public override bool Execute(TimelineWindow.TimelineState state) { IClipCurveEditorOwner currentInlineEditorCurve = SelectionManager.GetCurrentInlineEditorCurve(); bool result; if (currentInlineEditorCurve != null && currentInlineEditorCurve.clipCurveEditor != null) { currentInlineEditorCurve.clipCurveEditor.SelectAllKeys(); result = true; } else { SelectionManager.Clear(); state.GetWindow().allTracks.ForEach(delegate(TimelineTrackBaseGUI x) { SelectionManager.Add(x.track); }); result = true; } return(result); }
public static void Clear() { currentInlineEditorCurve = null; Selection.activeObject = null; }
public static bool IsCurveEditorFocused(IClipCurveEditorOwner selection) { return(selection == currentInlineEditorCurve); }
public static void SelectInlineCurveEditor(IClipCurveEditorOwner selection) { currentInlineEditorCurve = selection; }