public SnapEngine(IAttractable attractable, IAttractionHandler attractionHandler, ManipulateEdges manipulateEdges, WindowState state, Vector2 mousePosition, IEnumerable <ISnappable> snappables = null) { m_Attractable = attractable; m_ManipulateEdges = manipulateEdges; m_AttractionHandler = attractionHandler; m_State = state; m_CurrentTimes = m_GrabbedTimes = new TimeBoundaries(m_Attractable.start, m_Attractable.end); m_GrabbedTime = m_State.PixelToTime(mousePosition.x); // Add Time zero as Magnet AddMagnet(0.0, true, state); // Add current Time as Magnet // case1157280 only add current time as magnet if visible if (TimelineWindow.instance.currentMode.ShouldShowTimeCursor(m_State)) { AddMagnet(state.editSequence.time, true, state); } if (state.IsEditingASubTimeline()) { // Add start and end of evaluable range as Magnets // This includes the case where the master timeline has a fixed length var range = state.editSequence.GetEvaluableRange(); AddMagnet(range.start, true, state); AddMagnet(range.end, true, state); } else if (state.masterSequence.asset.durationMode == TimelineAsset.DurationMode.FixedLength) { // Add end sequence Time as Magnet AddMagnet(state.masterSequence.asset.duration, true, state); } if (snappables == null) { snappables = GetVisibleSnappables(m_State); } foreach (var snappable in snappables) { if (!attractable.ShouldSnapTo(snappable)) { continue; } var edges = snappable.SnappableEdgesFor(attractable, manipulateEdges); foreach (var edge in edges) { AddMagnet(edge.time, edge.showSnapHint, state); } } }
public MagnetEngine(IAttractable attractable, IAttractionHandler attractionHandler, TimelineWindow.TimelineState state) { this.m_Attractable = attractable; this.m_AttractionHandler = attractionHandler; this.m_State = state; Rect timeAreaBounds = TimelineWindow.instance.timeAreaBounds; timeAreaBounds.set_height(3.40282347E+38f); List <IBounds> elementsInRectangle = Manipulator.GetElementsInRectangle(state.quadTree, timeAreaBounds); IEnumerable <ISnappable> enumerable = elementsInRectangle.OfType <ISnappable>(); this.AddMagnet(0.0, timeAreaBounds, state); this.AddMagnet(state.time, timeAreaBounds, state); this.AddMagnet(state.timeline.get_duration(), timeAreaBounds, state); foreach (ISnappable current in enumerable) { IEnumerable <Edge> enumerable2 = current.SnappableEdgesFor(attractable); foreach (Edge current2 in enumerable2) { this.AddMagnet(current2.time, timeAreaBounds, state); } } }