TimelineClipHandle.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using UnityEngine;
  2. namespace UnityEditor.Timeline
  3. {
  4. class TimelineClipHandle : ILayerable
  5. {
  6. Rect m_Rect;
  7. readonly TimelineClipGUI m_ClipGUI;
  8. readonly TrimEdge m_TrimDirection;
  9. readonly LayerZOrder m_ZOrder;
  10. public Rect boundingRect
  11. {
  12. get { return m_ClipGUI.parent.ToWindowSpace(m_Rect); }
  13. }
  14. public TrimEdge trimDirection
  15. {
  16. get { return m_TrimDirection; }
  17. }
  18. public TimelineClipGUI clipGUI
  19. {
  20. get { return m_ClipGUI; }
  21. }
  22. public LayerZOrder zOrder
  23. {
  24. get { return m_ZOrder; }
  25. }
  26. public TimelineClipHandle(TimelineClipGUI theClipGUI, TrimEdge trimDirection)
  27. {
  28. m_TrimDirection = trimDirection;
  29. m_ClipGUI = theClipGUI;
  30. m_ZOrder = theClipGUI.zOrder.ChangeLayer(Layer.ClipHandles);
  31. }
  32. public void Draw(Rect clientRect, float width, WindowState state)
  33. {
  34. var handleRect = clientRect;
  35. handleRect.width = width;
  36. if (m_TrimDirection == TrimEdge.End)
  37. handleRect.x = clientRect.xMax - width;
  38. m_Rect = handleRect;
  39. if (!TimelineWindow.instance.state.editSequence.isReadOnly)
  40. EditorGUIUtility.AddCursorRect(handleRect, MouseCursor.SplitResizeLeftRight);
  41. state.spacePartitioner.AddBounds(this, boundingRect);
  42. }
  43. }
  44. }