private void UpdateDragTarget(TimelineClipGUI uiClip, Vector2 point, TimelineWindow.TimelineState state)
        {
            List <IBounds>   elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, point);
            TimelineTrackGUI timelineTrackGUI   = elementsAtPosition.OfType <TimelineTrackGUI>().FirstOrDefault((TimelineTrackGUI t) => MoveClip.ValidateClipDrag(t.track, uiClip.clip));

            this.m_HasValidDropTarget = (timelineTrackGUI != null && timelineTrackGUI.track.IsCompatibleWithItem(uiClip.clip));
            if (this.m_HasValidDropTarget)
            {
                AnimationTrack animationTrack = timelineTrackGUI.track as AnimationTrack;
                float          start          = state.PixelToTime(this.m_PreviewRect.get_x());
                float          end            = state.PixelToTime(this.m_PreviewRect.get_xMax());
                bool           hasValidDropTarget;
                if (animationTrack != null && animationTrack.CanConvertToClipMode())
                {
                    hasValidDropTarget = ((animationTrack.animClip.get_startTime() < start || animationTrack.animClip.get_stopTime() > end) && (start <animationTrack.animClip.get_startTime() || end> animationTrack.animClip.get_stopTime()));
                }
                else
                {
                    float num = end - start;
                    start = Math.Max(start, 0f);
                    end   = start + num;
                    hasValidDropTarget = (!timelineTrackGUI.track.clips.Any((TimelineClip x) => x.start >= (double)start && x.end <= (double)end) && !timelineTrackGUI.track.clips.Any((TimelineClip x) => (double)start >= x.start && (double)end <= x.end));
                }
                this.m_HasValidDropTarget = hasValidDropTarget;
            }
            this.m_DropTarget = ((!this.m_HasValidDropTarget) ? null : timelineTrackGUI);
        }
 public override void Init(IControl parent)
 {
     parent.MouseDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (state.IsCurrentEditingASequencerTextField())
         {
             result = base.IgnoreEvent();
         }
         else if (evt.get_button() != 0 && evt.get_button() != 1)
         {
             result = base.IgnoreEvent();
         }
         else if (evt.get_modifiers() == 4)
         {
             result = base.IgnoreEvent();
         }
         else if (TimelineWindow.instance.sequenceHeaderBounds.Contains(evt.get_mousePosition()))
         {
             foreach (TimelineTrackBaseGUI current in TimelineWindow.instance.allTracks)
             {
                 Rect headerBounds = current.headerBounds;
                 headerBounds.set_y(headerBounds.get_y() + TimelineWindow.instance.treeviewBounds.get_y());
                 if (headerBounds.Contains(evt.get_mousePosition()))
                 {
                     result = base.IgnoreEvent();
                     return(result);
                 }
             }
             if (evt.get_modifiers() == null)
             {
                 SelectionManager.Clear();
             }
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_ActiveRect = TimelineWindow.instance.clipArea;
             if (!this.m_ActiveRect.Contains(evt.get_mousePosition()))
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 List <IBounds> elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, evt.get_mousePosition());
                 bool           flag;
                 if (!RectangleSelect.CanStartRectableSelect(evt, elementsAtPosition, out flag))
                 {
                     if (flag)
                     {
                         RectangleSelect.HandleReselection(elementsAtPosition);
                     }
                     else
                     {
                         RectangleSelect.HandleSingleSelection(evt, state, elementsAtPosition);
                     }
                     result = base.IgnoreEvent();
                 }
                 else
                 {
                     state.captured.Add(target as IControl);
                     this.m_IsCaptured = true;
                     this.m_Start      = evt.get_mousePosition();
                     this.m_End        = evt.get_mousePosition();
                     if (RectangleSelect.CanClearSelection(evt))
                     {
                         SelectionManager.Clear();
                     }
                     result = base.IgnoreEvent();
                 }
             }
         }
         return(result);
     };
     parent.KeyDown += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (this.m_IsCaptured && evt.get_keyCode() == 27)
         {
             state.captured.Remove(target as IControl);
             this.m_IsCaptured = false;
             result            = base.ConsumeEvent();
         }
         else
         {
             result = base.IgnoreEvent();
         }
         return(result);
     };
     parent.MouseUp += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             if (evt.get_modifiers() == null && evt.get_button() == 0 && SelectionManager.IsMultiSelect())
             {
                 List <IBounds>  elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, evt.get_mousePosition());
                 TimelineItemGUI timelineItemGUI    = RectangleSelect.PickItemGUI(elementsAtPosition);
                 if (timelineItemGUI != null && SelectionManager.Contains(timelineItemGUI.item))
                 {
                     SelectionManager.Clear();
                     SelectionManager.Add(timelineItemGUI.item);
                 }
             }
             result = base.IgnoreEvent();
         }
         else
         {
             state.captured.Remove(target as IControl);
             this.m_IsCaptured = false;
             Rect r = this.CurrentSelectionRect();
             if (r.get_width() < 1f || r.get_height() < 1f)
             {
                 result = base.IgnoreEvent();
             }
             else
             {
                 List <IBounds> elementsInRectangle = Manipulator.GetElementsInRectangle(state.quadTree, r);
                 if (elementsInRectangle.Count == 0)
                 {
                     result = base.IgnoreEvent();
                 }
                 else
                 {
                     if (RectangleSelect.CanClearSelection(evt))
                     {
                         SelectionManager.Clear();
                     }
                     foreach (IBounds current in elementsInRectangle)
                     {
                         if (!(current is TimelineGroupGUI))
                         {
                             if (current is TimelineItemGUI)
                             {
                                 SelectionManager.Add(((TimelineItemGUI)current).item);
                             }
                         }
                     }
                     result = base.ConsumeEvent();
                 }
             }
         }
         return(result);
     };
     parent.MouseDrag += delegate(object target, Event evt, TimelineWindow.TimelineState state)
     {
         bool result;
         if (!this.m_IsCaptured)
         {
             result = base.IgnoreEvent();
         }
         else
         {
             this.m_End = evt.get_mousePosition();
             result     = base.ConsumeEvent();
         }
         return(result);
     };
     parent.Overlay += new TimelineUIEvent(this.DrawSelection);
 }
        private static TimelineTrackGUI GetDropTargetAt(TimelineWindow.TimelineState state, Vector2 point)
        {
            List <IBounds> elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, point);

            return(elementsAtPosition.OfType <TimelineTrackGUI>().FirstOrDefault <TimelineTrackGUI>());
        }
        private static bool IsOverAnimEditor(Event evt, TimelineWindow.TimelineState state)
        {
            List <IBounds> elementsAtPosition = Manipulator.GetElementsAtPosition(state.quadTree, evt.get_mousePosition());

            return(elementsAtPosition.Any((IBounds x) => x is InlineCurveEditor));
        }