void DrawDuration(bool drawhead, bool drawline, double duration) { if (state.TimeIsInRange((float)duration)) { // Set the colors based on the mode Color lineColor = DirectorStyles.Instance.customSkin.colorEndmarker; Color headColor = Color.white; bool canMoveHead = !EditorApplication.isPlaying && state.editSequence.asset.durationMode == TimelineAsset.DurationMode.FixedLength; if (canMoveHead) { if (Event.current.type == EventType.MouseDown) { if (m_TimelineDuration.bounds.Contains(Event.current.mousePosition)) { if (m_PlayHead != null && m_PlayHead.bounds.Contains(Event.current.mousePosition)) { // ignore duration markers if the mouse is over the TimeCursor. canMoveHead = false; } } } } else { lineColor.a *= 0.66f; headColor = DirectorStyles.Instance.customSkin.colorDuration; } if (canMoveHead) { m_TimelineDuration.HandleManipulatorsEvents(state); } m_TimelineDuration.lineColor = lineColor; m_TimelineDuration.headColor = headColor; m_TimelineDuration.drawHead = drawhead; m_TimelineDuration.drawLine = drawline; m_TimelineDuration.canMoveHead = canMoveHead; // Draw the TimeAreaItem // Rect trackheadRect = treeviewBounds; //trackheadRect.height = clientArea.height; m_TimelineDuration.Draw(sequenceRect, state, duration); } // Draw Blue line in timeline indicating the duration... if (state.editSequence.asset != null && drawhead) { HighlightTimeAreaRange(state.editSequence.GetEvaluableRange(), DirectorStyles.Instance.customSkin.colorDurationLine); } }
void DrawTimeCursor(bool drawHead, bool drawline) { m_PlayHead.HandleManipulatorsEvents(state); if (Event.current.type == EventType.MouseDown && Event.current.button == 0) { if (state.timeAreaRect.Contains(Event.current.mousePosition)) { state.SetPlaying(false); m_PlayHead.HandleManipulatorsEvents(state); state.editSequence.time = Math.Max(0.0, state.GetSnappedTimeAtMousePosition(Event.current.mousePosition)); } } m_PlayHead.drawLine = drawline; m_PlayHead.drawHead = drawHead; m_PlayHead.Draw(sequenceContentRect, state, state.editSequence.time); }
void DrawPlayRange(bool drawHeads, bool drawLines) { Rect timeCursorRect = state.timeAreaRect; timeCursorRect.height = clientArea.height; m_PlayRangeEnd.HandleManipulatorsEvents(state); m_PlayRangeStart.HandleManipulatorsEvents(state); // The first time a user enable the play range, we put the play range 75% around the current time... if (state.playRange == TimelineAssetViewModel.NoPlayRangeSet) { float minimumPlayRangeTime = 0.01f; float t0 = Mathf.Max(0.0f, state.PixelToTime(state.timeAreaRect.xMin)); float t1 = Mathf.Min((float)state.masterSequence.duration, state.PixelToTime(state.timeAreaRect.xMax)); if (Mathf.Abs(t1 - t0) <= minimumPlayRangeTime) { state.playRange = new Vector2(t0, t1); return; } float deltaT = (t1 - t0) * 0.25f / 2.0f; t0 += deltaT; t1 -= deltaT; if (t1 < t0) { float temp = t0; t0 = t1; t1 = temp; } if (Mathf.Abs(t1 - t0) < minimumPlayRangeTime) { if (t0 - minimumPlayRangeTime > 0.0f) { t0 -= minimumPlayRangeTime; } else if (t1 + minimumPlayRangeTime < state.masterSequence.duration) { t1 += minimumPlayRangeTime; } } state.playRange = new Vector2(t0, t1); } // Draw the head or the lines according to the parameters.. m_PlayRangeStart.drawHead = drawHeads; m_PlayRangeStart.drawLine = drawLines; m_PlayRangeEnd.drawHead = drawHeads; m_PlayRangeEnd.drawLine = drawLines; var playRangeTime = state.playRange; m_PlayRangeStart.Draw(timeCursorRect, state, playRangeTime.x); m_PlayRangeEnd.Draw(timeCursorRect, state, playRangeTime.y); // Draw Time Range Box from Start to End... if (state.playRangeEnabled && m_PlayHead != null) { Rect rect = Rect.MinMaxRect( Mathf.Clamp(state.TimeToPixel(playRangeTime.x), state.timeAreaRect.xMin, state.timeAreaRect.xMax), m_PlayHead.bounds.yMax, Mathf.Clamp(state.TimeToPixel(playRangeTime.y), state.timeAreaRect.xMin, state.timeAreaRect.xMax), timeCursorRect.height + state.timeAreaRect.height ); EditorGUI.DrawRect(rect, DirectorStyles.Instance.customSkin.colorRange); rect.height = 3f; EditorGUI.DrawRect(rect, Color.white); } }