public bool intersects(TimelineViewButton timelineButton)
        {
            int thisLeft   = timelineSelectionWidget.Left;
            int thisRight  = thisLeft + timelineSelectionWidget.Width;
            int thisTop    = timelineSelectionWidget.Top;
            int thisBottom = thisTop + timelineSelectionWidget.Height;

            int otherLeft   = timelineButton.Left;
            int otherRight  = otherLeft + timelineButton.Width;
            int otherTop    = timelineButton.Top;
            int otherBottom = otherTop + timelineButton.Height;

            if (thisBottom < otherTop)
            {
                return(false);
            }
            if (thisTop > otherBottom)
            {
                return(false);
            }

            if (thisRight < otherLeft)
            {
                return(false);
            }
            if (thisLeft > otherRight)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        private void insertButtonIntoStack(List <TimelineViewButton> buttonStack, TimelineViewButton insert)
        {
            //Sort the stack in order from top to bottom.
            buttonStack.Sort(topSortButtons);
            //Search the stack looking for a space in the buttons.
            int insertYPos     = yPosition;
            int lastButtonYPos = -1;

            foreach (TimelineViewButton button in buttonStack)
            {
                if (lastButtonYPos != button.Top) //Make sure the next button is actually lower, its possible that it is not
                {
                    lastButtonYPos = button.Top;
                    if (button.Top == insertYPos)
                    {
                        insertYPos = button.Bottom + STACKED_BUTTON_SPACE;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            insert._moveTop(insertYPos);
        }
Example #3
0
        private void closeGaps(TimelineViewButton movedButton, int oldLeft, int oldRight)
        {
            //Move any buttons that can be moved up.
            //Find the buttons that intersect the old position
            List <TimelineViewButton> formerStackedButtons = new List <TimelineViewButton>();

            if (oldLeft == movedButton.Left && oldRight == movedButton.Right) //Did not move, could be removed.
            {
                findIntersectingButtons(formerStackedButtons, oldLeft, oldRight);
            }
            else if (oldLeft > movedButton.Left)//Moved left
            {
                findIntersectingButtons(formerStackedButtons, movedButton.Right, oldRight);
            }
            else //Moved right
            {
                findIntersectingButtons(formerStackedButtons, oldLeft, movedButton.Left);
            }
            formerStackedButtons.Remove(movedButton);

            //Sort the old stack by top.
            formerStackedButtons.Sort(topSortButtons);

            //Go through the list and find the index of the first gap.
            int gapIndex = findGapIndex(formerStackedButtons);

            if (gapIndex != -1)
            {
                for (int i = gapIndex; i < formerStackedButtons.Count; ++i)
                {
                    moveUp(formerStackedButtons[i]);
                }
            }
        }
 public void addButton(TimelineViewButton button)
 {
     if (button != null && !selectedButtons.Contains(button))
     {
         setButtonSelected(button);
         selectedButtons.Add(button);
     }
 }
Example #5
0
        private void moveUp(TimelineViewButton button)
        {
            //Find the buttons that currently intersect the button
            List <TimelineViewButton> stackedButtons = new List <TimelineViewButton>();

            findIntersectingButtons(stackedButtons, button.Left, button.Right);
            stackedButtons.Remove(button);
            insertButtonIntoStack(stackedButtons, button);
        }
Example #6
0
 private void viewButton_CoordChanged(TimelineViewButton sender, TimelineViewButtonEventArgs e)
 {
     if (processButtonChanges)
     {
         computeButtonPosition(sender);
         closeGaps(sender, e.OldLeft, e.OldRight);
         findLowestButton();
     }
 }
Example #7
0
        public void addData(TimelineData data, bool clearSelection = true)
        {
            if (clearSelection)
            {
                selectionCollection.clearSelection();
            }
            Button             button       = timelineScrollView.createButton(pixelsPerSecond * data.StartTime, pixelsPerSecond * data.Duration);
            TimelineViewButton actionButton = namedTracks[data.Track].addButton(button, data);

            actionButton.Clicked += actionButton_Clicked;
        }
Example #8
0
        internal TimelineViewButton addButton(Button button, TimelineData data)
        {
            TimelineViewButton viewButton = new TimelineViewButton(pixelsPerSecond, timelineDuration, button, data, NormalColor, SelectedColor);

            buttons.Add(viewButton);
            button.setPosition(button.Left, yPosition);
            viewButton.CoordChanged += viewButton_CoordChanged;
            computeButtonPosition(viewButton);
            findLowestButton();
            return(viewButton);
        }
        void button_ButtonDragged(TimelineViewButton source, float arg)
        {
            float startDelta = source.StartTime - arg;

            foreach (TimelineViewButton button in selectedButtons)
            {
                if (button != source)
                {
                    button.StartTime += startDelta;
                }
            }
        }
 public void removeButton(TimelineViewButton button)
 {
     if (button != null && button.StateCheck)
     {
         setButtonUnselected(button);
         selectedButtons.Remove(button);
         if (currentButton == button)
         {
             setCurrentButton(null);
         }
     }
 }
Example #11
0
        public void removeData(TimelineData data)
        {
            selectionCollection.removeButton(data._CurrentButton);
            TimelineViewButton button = namedTracks[data.Track].removeButton(data);

            if (button == selectionCollection.CurrentButton)
            {
                //Null the internal property first as you do not want to toggle the state of the button that has already been disposed.
                selectionCollection.nullCurrentButton();
                selectionCollection.setCurrentButton(null);
            }
        }
Example #12
0
 internal void findRightmostButton(ref TimelineViewButton rightmostButton)
 {
     if (rightmostButton == null && buttons.Count > 0)
     {
         rightmostButton = buttons[0];
     }
     foreach (TimelineViewButton button in buttons)
     {
         if (button.Right > rightmostButton.Right)
         {
             rightmostButton = button;
         }
     }
 }
Example #13
0
        internal TimelineViewButton removeButton(TimelineData data)
        {
            TimelineViewButton removeMe = findButton(data);

            if (removeMe != null)
            {
                buttons.Remove(removeMe);
                removeMe.CoordChanged -= viewButton_CoordChanged;
                closeGaps(removeMe, removeMe.Left, removeMe.Right);
                removeMe.Dispose();
            }
            findLowestButton();
            return(removeMe);
        }
 public bool setCurrentButton(TimelineViewButton button, bool fireActiveDataChanged = true)
 {
     cancelEventArgs.reset();
     timelineView.fireActiveDataChanging(cancelEventArgs);
     if (!cancelEventArgs.Cancel)
     {
         addButton(button);
         currentButton = button;
         if (fireActiveDataChanged)
         {
             timelineView.fireActiveDataChanged();
         }
         return(true);
     }
     return(false);
 }
Example #15
0
        public void trimVisibleArea()
        {
            TimelineViewButton rightmostButton = null;

            foreach (TimelineViewTrack row in tracks)
            {
                row.findRightmostButton(ref rightmostButton);
            }
            if (rightmostButton != null)
            {
                timelineScrollView.CanvasWidth = rightmostButton.Right;
            }
            else
            {
                timelineScrollView.CanvasWidth  = 2;
                timelineScrollView.CanvasHeight = tracks.Count != 0 ? tracks[tracks.Count - 1].Bottom : 0;
            }
        }
Example #16
0
 void actionButton_Clicked(TimelineViewButton sender, MouseEventArgs e)
 {
     if (AddSelection.HeldDown)
     {
         selectionCollection.addButton(sender);
     }
     else if (RemoveSelection.HeldDown)
     {
         selectionCollection.removeButton(sender);
     }
     else
     {
         if (!sender.StateCheck)
         {
             selectionCollection.clearSelection(false);
         }
         selectionCollection.setCurrentButton(sender);
     }
 }
Example #17
0
        private void computeButtonPosition(TimelineViewButton movedButton)
        {
            //Find the buttons that currently intersect the moved button
            List <TimelineViewButton> currentStackedButtons = new List <TimelineViewButton>();

            findIntersectingButtons(currentStackedButtons, movedButton.Left, movedButton.Right);
            currentStackedButtons.Remove(movedButton);

            //If there are no buttons currently intersecting the new position, put the button at the top.
            if (currentStackedButtons.Count == 0)
            {
                movedButton._moveTop(yPosition);
            }
            //Put the button at the first blank space that can be found
            else
            {
                insertButtonIntoStack(currentStackedButtons, movedButton);
            }
        }
 void button_CoordChanged(TimelineViewButton sender, TimelineViewButtonEventArgs e)
 {
     timelineView.respondToCoordChange(sender.Left, sender.Right, sender.Width);
 }
 private void setButtonSelected(TimelineViewButton button)
 {
     button.StateCheck     = true;
     button.CoordChanged  += button_CoordChanged;
     button.ButtonDragged += button_ButtonDragged;
 }
 private void setButtonUnselected(TimelineViewButton button)
 {
     button.StateCheck     = false;
     button.CoordChanged  -= button_CoordChanged;
     button.ButtonDragged -= button_ButtonDragged;
 }
 public void nullCurrentButton()
 {
     currentButton = null;
 }
Example #22
0
 private int topSortButtons(TimelineViewButton a1, TimelineViewButton a2)
 {
     return(a1.Top - a2.Top);
 }