Beispiel #1
0
        public override void Move(Selection sel, Point p, Point moveStart)
        {
            switch (sel.Position) {
            case SelectionPosition.All: {
                double xdiff, ydiff;

                xdiff = p.X - moveStart.X;
                ydiff = p.Y - moveStart.Y;
                foreach (Point point in Points) {
                    point.X += xdiff;
                    point.Y += ydiff;
                }
                break;
            }
            default:
                throw new Exception ("Unsupported move for multipoints:  " + sel.Position);
            }
        }
Beispiel #2
0
        public void Move(Selection sel, Point p, Point start)
        {
            double diffX;

            // Apply dragging restrictions
            if (DraggingMode == NodeDraggingMode.None)
                return;
            switch (sel.Position) {
            case SelectionPosition.Left:
            case SelectionPosition.Right:
                if (DraggingMode == NodeDraggingMode.Segment)
                    return;
                break;
            case SelectionPosition.All:
                if (DraggingMode == NodeDraggingMode.Borders)
                    return;
                break;
            }

            Time newTime = Utils.PosToTime (p, SecondsPerPixel);
            diffX = p.X - start.X;

            if (p.X < 0) {
                p.X = 0;
            } else if (newTime > MaxTime) {
                p.X = Utils.TimeToPos (MaxTime, SecondsPerPixel);
            }
            newTime = Utils.PosToTime (p, SecondsPerPixel);

            if (TimeNode is StatEvent) {
                TimeNode.EventTime = newTime;
                return;
            }

            switch (sel.Position) {
            case SelectionPosition.Left:
                if (newTime.MSeconds + MAX_TIME_SPAN > TimeNode.Stop.MSeconds) {
                    TimeNode.Start.MSeconds = TimeNode.Stop.MSeconds - MAX_TIME_SPAN;
                } else {
                    TimeNode.Start = newTime;
                }
                break;
            case SelectionPosition.Right:
                if (newTime.MSeconds - MAX_TIME_SPAN < TimeNode.Start.MSeconds) {
                    TimeNode.Stop.MSeconds = TimeNode.Start.MSeconds + MAX_TIME_SPAN;
                } else {
                    TimeNode.Stop = newTime;
                }
                break;
            case SelectionPosition.All:
                Time tstart, tstop;
                Time diff = Utils.PosToTime (new Point (diffX, p.Y), SecondsPerPixel);

                if (StrictClipping) {
                    tstart = TimeNode.Start;
                    tstop = TimeNode.Stop;
                } else {
                    tstart = TimeNode.Stop;
                    tstop = TimeNode.Start;
                }
                if ((tstart + diff) >= new Time (0) && (tstop + diff) < MaxTime) {
                    TimeNode.Start += diff;
                    TimeNode.Stop += diff;
                }
                break;
            }
            movingPos = sel.Position;
        }
Beispiel #3
0
        protected override void StartMove(Selection sel)
        {
            if (sel == null)
                return;

            if (sel.Position == SelectionPosition.All) {
                widget.SetCursor (CursorType.Selection);
            } else {
                widget.SetCursor (CursorType.DoubleArrow);
            }
        }
Beispiel #4
0
        protected override void StartMove(Selection sel)
        {
            Drawable drawable = null;
            SelectionPosition pos = SelectionPosition.BottomRight;
            bool resize = true, copycolor = true, sele = true;

            if (Tool == DrawTool.Selection) {
                if (Selections.Count == 0 && currentZoom != 1) {
                    widget.SetCursorForTool (DrawTool.Move);
                    inZooming = true;
                }
                return;
            }

            if (sel != null) {
                ClearSelection ();
            }

            switch (Tool) {
            case DrawTool.Line:
                drawable = new Line (MoveStart, new Point (MoveStart.X + 1, MoveStart.Y + 1),
                    LineType, LineStyle);
                drawable.FillColor = Color;
                pos = SelectionPosition.LineStop;
                break;
            case DrawTool.Cross:
                drawable = new Cross (MoveStart, new Point (MoveStart.X + 1, MoveStart.Y + 1),
                    LineStyle);
                break;
            case DrawTool.Ellipse:
                drawable = new Ellipse (MoveStart, 2, 2);
                break;
            case DrawTool.Rectangle:
                drawable = new Rectangle (MoveStart, 2, 2);
                break;
            case DrawTool.CircleArea:
                drawable = new Ellipse (MoveStart, 2, 2);
                drawable.FillColor = Color.Copy ();
                drawable.FillColor.A = byte.MaxValue / 2;
                break;
            case DrawTool.RectangleArea:
                drawable = new Rectangle (MoveStart, 2, 2);
                drawable.FillColor = Color.Copy ();
                drawable.FillColor.A = byte.MaxValue / 2;
                break;
            case DrawTool.Counter:
                drawable = new Counter (MoveStart, 3 * LineWidth, 0);
                drawable.FillColor = Color.Copy ();
                (drawable as Counter).TextColor = Color.Grey2;
                resize = false;
                break;
            case DrawTool.Text:
            case DrawTool.Player:
                {
                    int width, heigth;
                    Text text = new Text (MoveStart, 1, 1, "");
                    if (ConfigureObjectEvent != null) {
                        ConfigureObjectEvent (text, Tool);
                    }
                    if (text.Value == null) {
                        return;
                    }
                    Config.DrawingToolkit.MeasureText (text.Value, out width, out heigth,
                        Config.Style.Font, FontSize, FontWeight.Normal);
                    text.Update (new Point (MoveStart.X - width / 2, MoveStart.Y - heigth / 2),
                        width, heigth);
                    text.TextColor = TextColor.Copy ();
                    text.FillColor = text.StrokeColor = TextBackgroundColor.Copy ();
                    text.TextSize = FontSize;
                    resize = copycolor = sele = false;
                    drawable = text;
                    break;
                }
            case DrawTool.Pen:
            case DrawTool.Eraser:
                handdrawing = true;
                break;
            case DrawTool.Zoom:
                {
                    double newZoom = currentZoom;

                    if (modifier == ButtonModifier.Shift) {
                        newZoom -= 0.1;
                    } else {
                        newZoom += 0.1;
                    }
                    newZoom = Math.Max (newZoom, MinZoom);
                    newZoom = Math.Min (newZoom, MaxZoom);
                    Zoom (newZoom, MoveStart);
                    break;
                }
            }

            if (drawable != null) {
                if (copycolor) {
                    drawable.StrokeColor = Color.Copy ();
                }
                drawable.LineWidth = LineWidth;
                drawable.Style = LineStyle;
                var selo = Add (drawable);
                drawing.Drawables.Add (drawable);
                if (Tool == DrawTool.Counter) {
                    UpdateCounters ();
                }
                if (sele) {
                    if (resize) {
                        UpdateSelection (new Selection (selo, pos, 5));
                    } else {
                        UpdateSelection (new Selection (selo, SelectionPosition.All, 5));
                    }
                    inObjectCreation = true;
                }
                widget.ReDraw ();
            }
        }
Beispiel #5
0
 public void Move(Selection s, Point dst, Point start)
 {
 }
Beispiel #6
0
        /// <summary>
        /// Updates the current selection. If <paramref name="sel"/> is <c>null</c>,
        /// it clears the current selection. If <paramref name="sel"/> wasn't previously
        /// selected, it's added to the list of selected objects, otherwise it's removed
        /// from the list.
        /// </summary>
        /// <param name="sel">The selection.</param>
        /// <param name="notify">If set to <c>true</c>, notifies about the changes.</param>
        protected void UpdateSelection(Selection sel, bool notify = true)
        {
            ICanvasSelectableObject so;
            Selection seldup;

            if (sel == null) {
                ClearSelection ();
                if (notify) {
                    SelectionChanged (Selections);
                }
                return;
            }

            so = sel.Drawable as ICanvasSelectableObject;
            if (Selections.Count > 0) {
                if (SingleSelectionObjects.Contains (so.GetType ()) ||
                    SingleSelectionObjects.Contains (Selections [0].Drawable.GetType ())) {
                    return;
                }
            }

            seldup = Selections.FirstOrDefault (s => s.Drawable == sel.Drawable);

            if (seldup != null) {
                so.Selected = false;
                Selections.Remove (seldup);
            } else {
                so.Selected = true;
                Selections.Add (sel);
            }
            if (notify) {
                SelectionChanged (Selections);
            }
        }
Beispiel #7
0
 /// <summary>
 /// Notifies subclasses when an object has been moved.
 /// </summary>
 /// <param name="sel">The selection moved.</param>
 protected virtual void SelectionMoved(Selection sel)
 {
 }
Beispiel #8
0
 public void Move(Selection s, Point p, Point start)
 {
     if (s.Position == SelectionPosition.All) {
         X = Math.Max (p.X, 0);
     }
 }
Beispiel #9
0
 public override void Move(Selection sel, Point p, Point start)
 {
     throw new System.NotImplementedException ();
 }
Beispiel #10
0
 public void Move(Selection sel, Point p, Point start)
 {
     switch (sel.Position) {
     case SelectionPosition.LineStart:
         Start = new Point (Math.Max (p.X, 0), Math.Max (p.Y, 0));
         break;
     case SelectionPosition.LineStop:
         Stop = new Point (Math.Max (p.X, 0), Math.Max (p.Y, 0));
         break;
     default:
         throw new Exception ("Unsupported move for circle:  " + sel.Position);
     }
 }
Beispiel #11
0
 public void Move(Selection s, Point dst, Point start)
 {
     line.Move (s, dst, start);
     stop = line.Stop;
 }
Beispiel #12
0
 public virtual void Move(Selection s, Point p, Point start)
 {
     switch (s.Position) {
     case SelectionPosition.Right:
         Width = (int)(p.X - Position.X);
         Width = (int)Math.Max (10, Width);
         break;
     case SelectionPosition.Bottom:
         Height = (int)(p.Y - Position.Y);
         Height = (int)Math.Max (10, Height);
         break;
     case SelectionPosition.BottomRight:
         Width = (int)(p.X - Position.X);
         Height = (int)(p.Y - Position.Y);
         Width = Math.Max (10, Width);
         Height = Math.Max (10, Height);
         break;
     case SelectionPosition.All:
         Position.X += p.X - start.X;
         Position.Y += p.Y - start.Y;
         Position.X = Math.Max (Position.X, 0);
         Position.Y = Math.Max (Position.Y, 0);
         break;
     default:
         throw new Exception ("Unsupported move for tagger object:  " + s.Position);
     }
     Width = Math.Max (MinWidth, Width);
     Height = Math.Max (MinHeight, Height);
     ResetBackbuffer ();
 }
Beispiel #13
0
        protected override void SelectionMoved(Selection sel)
        {
            if (TimeNodeChanged != null) {
                Time moveTime;
                TimeNode tn = (sel.Drawable as TimeNodeObject).TimeNode;

                if (sel.Position == SelectionPosition.Right) {
                    moveTime = tn.Stop;
                } else {
                    moveTime = tn.Start;
                }
                TimeNodeChanged (tn, moveTime);
            }
        }
Beispiel #14
0
 public void Move(Selection sel, Point p, Point start)
 {
 }
Beispiel #15
0
 public override void Move(Selection sel, Point p, Point moveStart)
 {
     switch (sel.Position) {
     case SelectionPosition.TopLeft:
         Start = p;
         break;
     case SelectionPosition.BottomRight:
         Stop = p;
         break;
     case SelectionPosition.TopRight:
         Start.Y = p.Y;
         Stop.X = p.X;
         break;
     case SelectionPosition.BottomLeft:
         Start.X = p.X;
         Stop.Y = p.Y;
         break;
     case SelectionPosition.Top:
         Start.Y = p.Y;
         break;
     case SelectionPosition.Bottom:
         Stop.Y = p.Y;
         break;
     case SelectionPosition.Left:
         Start.X = p.X;
         break;
     case SelectionPosition.Right:
         Stop.X = p.X;
         break;
     case SelectionPosition.All:
         Start.X += p.X - moveStart.X;
         Start.Y += p.Y - moveStart.Y;
         Stop.X += p.X - moveStart.X;
         Stop.Y += p.Y - moveStart.Y;
         break;
     default:
         throw new Exception ("Unsupported move for line:  " + sel.Position);
     }
 }
Beispiel #16
0
 public override void Move(Selection sel, Point p, Point moveStart)
 {
     switch (sel.Position) {
     case SelectionPosition.Top:
     case SelectionPosition.Bottom: {
         AxisY = Math.Abs (p.Y - Center.Y);
         break;
     }
     case SelectionPosition.Left:
     case SelectionPosition.Right: {
         AxisX = Math.Abs (p.X - Center.X);
         break;
     }
     case SelectionPosition.TopLeft:
     case SelectionPosition.TopRight:
     case SelectionPosition.BottomLeft:
     case SelectionPosition.BottomRight: {
         AxisX = Math.Abs (p.X - Center.X);
         AxisY = Math.Abs (p.Y - Center.Y);
         break;
     }
     case SelectionPosition.All: {
         Center.X += p.X - moveStart.X;
         Center.Y += p.Y - moveStart.Y;
         break;
     }
     default:
         throw new Exception ("Unsupported move for line:  " + sel.Position);
     }
 }
Beispiel #17
0
 public override void Move(Selection sel, Point p, Point start)
 {
     switch (sel.Position) {
     case SelectionPosition.AngleStart:
         Start = p;
         break;
     case SelectionPosition.AngleStop:
         Stop = p;
         break;
     case SelectionPosition.AngleCenter:
         Center = p;
         break;
     default:
         throw new Exception ("Unsupported move for angle:  " + sel.Position);
     }
 }
Beispiel #18
0
        protected virtual void HandleLeftButton(Point coords, ButtonModifier modif)
        {
            Selection sel;

            sel = GetSelection (coords);

            clickedSel = sel;
            if (sel != null) {
                (sel.Drawable as ICanvasObject).ClickPressed (coords, modif);
            }

            if ((SelectionMode == MultiSelectionMode.Multiple) ||
                (SelectionMode == MultiSelectionMode.MultipleWithModifier &&
                (modif == ButtonModifier.Control ||
                modif == ButtonModifier.Shift))) {
                if (sel != null) {
                    sel.Position = SelectionPosition.All;
                    UpdateSelection (sel);
                }
            } else {
                ClearSelection ();
                MoveStart = coords;
                UpdateSelection (sel);
                StartMove (sel);
                Moving = Selections.Count > 0 && ObjectsCanMove;
            }
        }
Beispiel #19
0
        protected override void SelectionMoved(Selection sel)
        {
            Time moveTime;
            CanvasObject co;
            TimelineEvent play;

            co = (sel.Drawable as CanvasObject);

            if (co is TimelineEventObject) {
                play = (co as TimelineEventObject).Event;

                if (sel.Position == SelectionPosition.Right) {
                    moveTime = play.Stop;
                } else {
                    moveTime = play.Start;
                }
                Config.EventsBroker.EmitTimeNodeChanged (play, moveTime);
            } else if (co is TimeNodeObject) {
                TimeNode to = (co as TimeNodeObject).TimeNode;

                if (sel.Position == SelectionPosition.Right) {
                    moveTime = to.Stop;
                } else {
                    moveTime = to.Start;
                }
                Config.EventsBroker.EmitSeekEvent (moveTime, true);
            }
        }
Beispiel #20
0
 /// <summary>
 /// Notifies subclasses when an object starts to be moved.
 /// </summary>
 /// <param name="sel">The selection moved.</param>
 protected virtual void StartMove(Selection sel)
 {
 }
Beispiel #21
0
        protected override void StartMove(Selection sel)
        {
            if (sel == null)
                return;

            if (sel.Position != SelectionPosition.All) {
                widget.SetCursor (CursorType.DoubleArrow);
            }
            if (sel.Drawable is TimeNodeObject) {
                movingTimeNode = true;
                Config.EventsBroker.EmitTogglePlayEvent (false);
            }
        }
Beispiel #22
0
 void HandleButtonReleasedEvent(Point coords, ButtonType type, ButtonModifier modifier)
 {
     Moving = false;
     if (clickedSel != null) {
         (clickedSel.Drawable as ICanvasSelectableObject).ClickReleased ();
         clickedSel = null;
     }
     StopMove (Moved);
     Moved = false;
 }
Beispiel #23
0
        protected override void SelectionMoved(Selection sel)
        {
            if (sel.Drawable is CameraObject) {
                if (CameraDragged != null) {
                    CameraObject co = sel.Drawable as CameraObject;
                    // Adjust offset
                    co.MediaFile.Offset = new Time (-co.TimeNode.Start.MSeconds);
                    // And notify
                    CameraDragged (co.MediaFile, co.TimeNode);
                }
            } else {
                if (TimeNodeChanged != null) {
                    Time moveTime;
                    TimeNode tn = (sel.Drawable as TimeNodeObject).TimeNode;

                    if (sel.Position == SelectionPosition.Right) {
                        moveTime = tn.Stop;
                    } else {
                        moveTime = tn.Start;
                    }
                    TimeNodeChanged (tn, moveTime);
                }
            }
        }
Beispiel #24
0
 public void Move(Selection s, Point p, Point start)
 {
     s.Drawable.Move (s, p, start);
 }
Beispiel #25
0
 public override void Move(Selection s, Point p, Point start)
 {
     base.Move (s, p, start);
     moved = true;
     SelectedTags.Clear ();
     switch (s.Position) {
     case SelectionPosition.Right:
     case SelectionPosition.Bottom:
     case SelectionPosition.BottomRight:
         CreateBackBufferSurface ();
         break;
     }
 }