Exemplo n.º 1
0
        public StringTrackView(TLStringTrack track, TimelineView tv, RulerView rv)
            : base(track, tv, rv)
        {
            Keyframes = new EditableList <StringKeyframeView>();

            KFSyncer = Keyframes.SyncWith(Model.Keyframes,
                                          kf =>
            {
                var kv = new StringKeyframeView(kf, this);
                kf.NeighbourChanged += NeedsRebuild;
                var kfs              = Model.Keyframes.ToList();
                var prev             = kfs.FindLastIndex(x => x.Time.Value < kf.Time.Value);
                kv.AddToSceneGraphAt(KeyframeGroup, Keyframes.Count - 1 - prev);
                return(kv);
            },
                                          kv =>
            {
                kv.Dispose();
            });


            Background.Click += Background_MouseClick;

            KeyframeDefinition.StartX     = 0;
            KeyframeDefinition.StartY     = -25f;
            KeyframeDefinition.EndX       = 0;
            KeyframeDefinition.EndY       = 25f;
            KeyframeDefinition.ID         = Model.GetID() + "_KF";
            KeyframeDefinition.Transforms = new SvgTransformCollection();
            KeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            CollapsedKeyframeDefinition.ID         = Model.GetID() + "_CKF";
            CollapsedKeyframeDefinition.StartX     = 0;
            CollapsedKeyframeDefinition.StartY     = -25f;
            CollapsedKeyframeDefinition.EndX       = 0;
            CollapsedKeyframeDefinition.EndY       = 25f;
            CollapsedKeyframeDefinition.Transforms = new SvgTransformCollection();
            CollapsedKeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            KeyframeGroup.ID = "Keyframes";

            CurrentValue.FontSize = 12;
            CurrentValue.X        = 5;
            CurrentValue.CustomAttributes["class"]          = "trackfont";
            CurrentValue.CustomAttributes["pointer-events"] = "none";
            CurrentValue.Y = 24;

            UpdateScene();
        }
Exemplo n.º 2
0
        public StringTrackView(TLStringTrack track, TimelineView tv, RulerView rv)
            : base(track, tv, rv)
        {
            Keyframes = new EditableList<StringKeyframeView>();

            KFSyncer = Keyframes.SyncWith(Model.Keyframes,
                                          kf =>
                                          {
                                          	var kv = new StringKeyframeView(kf, this);
                                          	kf.NeighbourChanged += NeedsRebuild;
                                          	var kfs = Model.Keyframes.ToList();
                                          	var prev = kfs.FindLastIndex(x => x.Time.Value < kf.Time.Value);
                                          	kv.AddToSceneGraphAt(KeyframeGroup, Keyframes.Count - 1 - prev);
                                          	return kv;
                                          },
                                          kv =>
                                          {
                                          	kv.Dispose();
                                          });

            Background.Click += Background_MouseClick;

            KeyframeDefinition.StartX = 0;
            KeyframeDefinition.StartY = -25f;
            KeyframeDefinition.EndX = 0;
            KeyframeDefinition.EndY = 25f;
            KeyframeDefinition.ID = Model.GetID() + "_KF";
            KeyframeDefinition.Transforms = new SvgTransformCollection();
            KeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            CollapsedKeyframeDefinition.ID = Model.GetID() + "_CKF";
            CollapsedKeyframeDefinition.StartX = 0;
            CollapsedKeyframeDefinition.StartY = -25f;
            CollapsedKeyframeDefinition.EndX = 0;
            CollapsedKeyframeDefinition.EndY = 25f;
            CollapsedKeyframeDefinition.Transforms = new SvgTransformCollection();
            CollapsedKeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            KeyframeGroup.ID = "Keyframes";

            CurrentValue.FontSize = 12;
            CurrentValue.X = 5;
            CurrentValue.CustomAttributes["class"] = "trackfont";
            CurrentValue.CustomAttributes["pointer-events"] = "none";
            CurrentValue.Y = 24;

            UpdateScene();
        }
Exemplo n.º 3
0
        public AudioTrackView(TLAudioTrack track, TimelineView tv, RulerView rv)
            : base(track, tv, rv)
        {
//			SampleSyncer = Samples.SyncWith(Model.Samples,
//			                              s =>
//			                              {
//			                                var sv = new SampleView(s, this);
//			                                sv.BuildSVGTo(SampleGroup);
//			                                Model.Mapper.Map<AddContext>().DrawList.Add(sv);
//			                                return sv;
//			                              },
//			                              sv =>
//			                              {
//			                                Model.Mapper.Map<RemoveContext>().IDList.Add(sv.MainGroup.ID);
//			                                sv.Dispose();
//			                              });
//
            SampleDefinition.Width  = 5;
            SampleDefinition.Height = 1;
            SampleDefinition.ID     = "Sample";
//			SampleDefinition.Transforms = new SvgTransformCollection();
//			SampleDefinition.Transforms.Add(new SvgScale(1, 1));

            SampleGroup.ID = "Samples";

            Path.ID          = "path";
            Path.Stroke      = new SvgColourServer(Color.Gray);
            Path.StrokeWidth = 1.0f;
            Path.CustomAttributes["vector-effect"]  = "non-scaling-stroke";
            Path.CustomAttributes["pointer-events"] = "none";



//			Model.Minimum.ValueChanged += Model_Range_ValueChanged;
//			Model.Maximum.ValueChanged += Model_Range_ValueChanged;
//
//			MaxValue = new SvgValueWidget("Maximum", 1);
//			MaxValue.OnValueChanged += ChangeMaximum;
//			TrackMenu.AddItem(MaxValue);
//
//			MinValue = new SvgValueWidget("Minimum", -1);
//			MinValue.OnValueChanged += ChangeMinimum;
//			TrackMenu.AddItem(MinValue);
//
            UpdateScene();
        }
Exemplo n.º 4
0
 public PanZoomMenuHandler(TLViewBase view, string sessionID)
     : base(view, sessionID)
 {
     if (Instance is RulerView)
     {
         FRulerView    = Instance as RulerView;
         FTimelineView = FRulerView.Parent;
     }
     else if (Instance is TimelineView)
     {
         FTimelineView = Instance as TimelineView;
         FRulerView    = FTimelineView.Ruler;
     }
     else if (Instance is TrackView)
     {
         FTrackView    = Instance as TrackView;
         FTimelineView = FTrackView.Parent;
         FRulerView    = FTimelineView.Ruler;
     }
 }
Exemplo n.º 5
0
        public TrackView(TLTrackBase track, TimelineView tv, RulerView rv)
            : base(track, tv)
        {
            Model  = track;
            Parent = tv;
            FRuler = rv;

            MainGroup.Transforms = new SvgTransformCollection();
            MainGroup.Transforms.Add(new SvgTranslate(0, 0));

            var width = new SvgUnit(SvgUnitType.Percentage, 100);

            Label.FontSize   = 12;
            Label.X          = 5;
            Label.Y          = Label.FontSize;
            Label.Text       = Model.Label.Value;
            Label.ID         = "label";
            Label.MouseDown += Background_MouseDown;
            Label.MouseUp   += Background_MouseUp;
            Label.CustomAttributes["class"] = "trackfont";

            SizeBarDragRect.FillOpacity = 0.3f;
            SizeBarDragRect.Visible     = false;
            SizeBarDragRect.CustomAttributes["pointer-events"] = "none";

            Background.Width  = width;
            Background.Height = 1;             // this is the value range, not the actual track size
            Background.ID     = "bg";

            ClipRect.Width  = width;
            ClipRect.Height = Background.Height;
            ClipRect.ID     = "ClipRect";

            //document roots id is "svg". this is where the trackclips are added to
            TrackClipPath.ID = "svg_clip" + IDGenerator.NewID;
            TrackClipPath.Children.Add(ClipRect);

            TrackGroup.ID         = "Clip";
            TrackGroup.Transforms = new SvgTransformCollection();
            TrackGroup.Transforms.Add(new SvgScale(1, 1));
            var uri = new Uri("url(#" + TrackClipPath.ID + ")", UriKind.Relative);

            TrackGroup.ClipPath = uri;

            PanZoomGroup.ID         = "PanZoom";
            PanZoomGroup.Transforms = new SvgTransformCollection();
            PanZoomGroup.Transforms.Add(FRuler.PanZoomMatrix);            //pan/zoom
            PanZoomGroup.Transforms.Add(new SvgTranslate(0));             //min/max

            SizeBar.Width  = width;
            SizeBar.Height = 3;
            SizeBar.ID     = "SizeBar";
            SizeBar.CustomAttributes["class"] = "sizebar";
            SizeBar.Y = Background.Height.Value;

            //register event handlers
            Background.MouseDown += Background_MouseDown;
            Background.MouseUp   += Background_MouseUp;
            Background.MouseMove += Background_MouseMove;

            SizeBar.MouseDown += Background_MouseDown;
            SizeBar.MouseMove += Background_MouseMove;
            SizeBar.MouseUp   += Background_MouseUp;

            CreateTrackMenu();
            CreateKeyframeMenu();
        }
Exemplo n.º 6
0
        public TimelineView(TLDocument tl, ICommandHistory history, Timer timer)
        {
            History = history;
            History.CommandInserted += History_Changed;
            History.Undone          += History_Changed;
            History.Redone          += History_Changed;

            Document = tl;
            Timer    = timer;

            //replace id manager before any svg element was added
            var caller  = Document.Mapper.Map <ISvgEventCaller>();
            var manager = new SvgIdManager(SvgRoot, caller, Document.Mapper.Map <RemoteContext>());

            SvgRoot.ID = "svg";
            SvgRoot.OverwriteIdManager(manager);

            Background.Width   = new SvgUnit(SvgUnitType.Percentage, 100);
            Background.Height  = 500;
            Background.ID      = Document.GetID() + "_Background";
            Background.Opacity = 0;

            Background.MouseDown += Default_MouseDown;
            Background.MouseMove += Default_MouseMove;
            Background.MouseUp   += Default_MouseUp;

            Selection.ID = "Selection";
            Selection.CustomAttributes["pointer-events"] = "none";
            Selection.CustomAttributes["class"]          = "selection";

            Ruler = new RulerView(Document.Ruler, this);

            MouseTimeLine.ID     = "MouseTime";
            MouseTimeLine.StartX = 0;
            MouseTimeLine.StartY = 0;
            MouseTimeLine.EndX   = 0;

            TimeBar.ID         = "Timebar";
            TimeBar.Y          = -Ruler.Height;
            TimeBar.X          = -1;
            TimeBar.Width      = 2;
            TimeBar.MouseDown += Default_MouseDown;
            TimeBar.MouseMove += Default_MouseMove;
            TimeBar.MouseUp   += Default_MouseUp;

            MainMenu    = new SvgMenuWidget(120);
            MainMenu.ID = "MainMenu";

            var addValueTrack = new SvgButtonWidget(0, 20, "Add Value Track");

            addValueTrack.ValueChanged += AddValueTrack;

            var addStringTrack = new SvgButtonWidget(0, 20, "Add String Track");

            addStringTrack.ValueChanged += AddStringTrack;

            MainMenu.AddItem(addValueTrack, 0);
            MainMenu.AddItem(addStringTrack, 1);

            FRulerGroup.ID = "Ruler";
            FRulerGroup.CustomAttributes["class"] = "fixed";
            FRulerGroup.Transforms = new SvgTransformCollection();
            FRulerGroup.Transforms.Add(new SvgTranslate(0, 0));

            FTrackGroup.ID            = "Tracks";
            FTrackGroup.Transforms    = new SvgTransformCollection();
            FOverlaysGroup.ID         = "Overlays";
            FOverlaysGroup.Transforms = new SvgTransformCollection();

            //initialize svg tree
            BuildSVGRoot();

            Syncer = Tracks.SyncWith(Document.Tracks,
                                     tm =>
            {
                TrackView tv;
                if (tm is TLValueTrack)
                {
                    tv = new ValueTrackView(tm as TLValueTrack, this, Ruler);
                }
                else if (tm is TLStringTrack)
                {
                    tv = new StringTrackView(tm as TLStringTrack, this, Ruler);
                }
                else
                {
                    tv = new AudioTrackView(tm as TLAudioTrack, this, Ruler);
                }

                if (ActiveTrack == null)
                {
                    ActiveTrack = tv;
                }
                tv.AddToSceneGraphAt(FTrackGroup);

                //update Order on all tracks below the one added
                var order = tv.Model.Order.Value;
                foreach (var track in Tracks.Where(x => x.Model.Order.Value >= order))
                {
                    track.Model.Order.Value += 1;
                }

                return(tv);
            },
                                     tv =>
            {
                var order = tv.Model.Order.Value;
                tv.Dispose();

                //update Order on all tracks below the one removed
                foreach (var track in Tracks.Where(x => x.Model.Order.Value > order))
                {
                    track.Model.Order.Value -= 1;
                }
            });
        }
Exemplo n.º 7
0
        public ValueTrackView(TLValueTrack track, TimelineView tv, RulerView rv)
            : base(track, tv, rv)
        {
            Keyframes = new EditableList <ValueKeyframeView>();

            KFSyncer = Keyframes.SyncWith(Model.Keyframes,
                                          kf =>
            {
                var kv = new ValueKeyframeView(kf, this);
                kf.NeighbourChanged += NeedsRebuild;
                var kfs              = Model.Keyframes.ToList();
                var prev             = kfs.FindLastIndex(x => x.Time.Value < kf.Time.Value);
                kv.AddToSceneGraphAt(KeyframeGroup, Keyframes.Count - 1 - prev);
                return(kv);
            },
                                          kv =>
            {
                kv.Model.NeighbourChanged -= NeedsRebuild;
                kv.Dispose();
            });

            CurveSyncer = Curves.SyncWith(Model.Curves,
                                          cu =>
            {
                var cv = new CurveView(cu, this);
                cv.AddToSceneGraphAt(CurveGroup);
                return(cv);
            },
                                          cv =>
            {
                cv.Dispose();
            }
                                          );

            Background.Click += Background_MouseClick;

            KeyframeDefinition.CenterX    = 0;
            KeyframeDefinition.CenterY    = 0;
            KeyframeDefinition.Radius     = 3;
            KeyframeDefinition.ID         = Model.GetID() + "_KF";
            KeyframeDefinition.Transforms = new SvgTransformCollection();
            KeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseNoneDefinition.ID         = Model.GetID() + "_NE";
            EaseNoneDefinition.StartX     = 0;
            EaseNoneDefinition.StartY     = -25f;
            EaseNoneDefinition.EndX       = 0;
            EaseNoneDefinition.EndY       = 25f;
            EaseNoneDefinition.Transforms = new SvgTransformCollection();
            EaseNoneDefinition.Transforms.Add(new SvgScale(1, 1));

            var half = Model.CCollapsedHeight / 2f;

            EaseInDefinition.ID     = Model.GetID() + "_EI";
            EaseInDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseInDefinition, new PointF(0, -half));
            AddPoint(EaseInDefinition, new PointF(-half, 0));
            AddPoint(EaseInDefinition, new PointF(0, half));
            EaseInDefinition.Transforms = new SvgTransformCollection();
            EaseInDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseOutDefinition.ID     = Model.GetID() + "_EO";
            EaseOutDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseOutDefinition, new PointF(0, -half));
            AddPoint(EaseOutDefinition, new PointF(half, 0));
            AddPoint(EaseOutDefinition, new PointF(0, half));
            EaseOutDefinition.Transforms = new SvgTransformCollection();
            EaseOutDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseInOutDefinition.ID     = Model.GetID() + "_EIO";
            EaseInOutDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseInOutDefinition, new PointF(0, -half));
            AddPoint(EaseInOutDefinition, new PointF(half, 0));
            AddPoint(EaseInOutDefinition, new PointF(0, half));
            AddPoint(EaseInOutDefinition, new PointF(-half, 0));
            EaseInOutDefinition.Transforms = new SvgTransformCollection();
            EaseInOutDefinition.Transforms.Add(new SvgScale(1, 1));

            CurveGroup.ID    = "Curves";
            KeyframeGroup.ID = "Keyframes";

            CurrentValue.FontSize = 12;
            CurrentValue.X        = 5;
            CurrentValue.CustomAttributes["class"]          = "trackfont";
            CurrentValue.CustomAttributes["pointer-events"] = "none";
            CurrentValue.Y = 24;

            UpdateScene();
        }
Exemplo n.º 8
0
        public ValueTrackView(TLValueTrack track, TimelineView tv, RulerView rv)
            : base(track, tv, rv)
        {
            Keyframes = new EditableList<ValueKeyframeView>();

            KFSyncer = Keyframes.SyncWith(Model.Keyframes,
                                          kf =>
                                          {
                                          	var kv = new ValueKeyframeView(kf, this);
                                          	kf.NeighbourChanged += NeedsRebuild;
                                          	var kfs = Model.Keyframes.ToList();
                                          	var prev = kfs.FindLastIndex(x => x.Time.Value < kf.Time.Value);
                                          	kv.AddToSceneGraphAt(KeyframeGroup, Keyframes.Count - 1 - prev);
                                          	return kv;
                                          },
                                          kv =>
                                          {
                                          	kv.Model.NeighbourChanged -= NeedsRebuild;
                                          	kv.Dispose();
                                          });

            CurveSyncer = Curves.SyncWith(Model.Curves,
                                          cu =>
                                          {
                                          	var cv = new CurveView(cu, this);
                                          	cv.AddToSceneGraphAt(CurveGroup);
                                          	return cv;
                                          },
                                          cv =>
                                          {
                                          	cv.Dispose();
                                          }
                                         );

            Background.Click += Background_MouseClick;

            KeyframeDefinition.CenterX = 0;
            KeyframeDefinition.CenterY = 0;
            KeyframeDefinition.Radius = 3;
            KeyframeDefinition.ID = Model.GetID() + "_KF";
            KeyframeDefinition.Transforms = new SvgTransformCollection();
            KeyframeDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseNoneDefinition.ID = Model.GetID() + "_NE";
            EaseNoneDefinition.StartX = 0;
            EaseNoneDefinition.StartY = -25f;
            EaseNoneDefinition.EndX = 0;
            EaseNoneDefinition.EndY = 25f;
            EaseNoneDefinition.Transforms = new SvgTransformCollection();
            EaseNoneDefinition.Transforms.Add(new SvgScale(1, 1));

            var half = Model.CCollapsedHeight / 2f;

            EaseInDefinition.ID = Model.GetID() + "_EI";
            EaseInDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseInDefinition, new PointF(0, -half));
            AddPoint(EaseInDefinition, new PointF(-half, 0));
            AddPoint(EaseInDefinition, new PointF(0, half));
            EaseInDefinition.Transforms = new SvgTransformCollection();
            EaseInDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseOutDefinition.ID = Model.GetID() + "_EO";
            EaseOutDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseOutDefinition, new PointF(0, -half));
            AddPoint(EaseOutDefinition, new PointF(half, 0));
            AddPoint(EaseOutDefinition, new PointF(0, half));
            EaseOutDefinition.Transforms = new SvgTransformCollection();
            EaseOutDefinition.Transforms.Add(new SvgScale(1, 1));

            EaseInOutDefinition.ID = Model.GetID() + "_EIO";
            EaseInOutDefinition.Points = new SvgUnitCollection();
            AddPoint(EaseInOutDefinition, new PointF(0, -half));
            AddPoint(EaseInOutDefinition, new PointF(half, 0));
            AddPoint(EaseInOutDefinition, new PointF(0, half));
            AddPoint(EaseInOutDefinition, new PointF(-half, 0));
            EaseInOutDefinition.Transforms = new SvgTransformCollection();
            EaseInOutDefinition.Transforms.Add(new SvgScale(1, 1));

            CurveGroup.ID = "Curves";
            KeyframeGroup.ID = "Keyframes";

            CurrentValue.FontSize = 12;
            CurrentValue.X = 5;
            CurrentValue.CustomAttributes["class"] = "trackfont";
            CurrentValue.CustomAttributes["pointer-events"] = "none";
            CurrentValue.Y = 24;

            UpdateScene();
        }
Exemplo n.º 9
0
        public TrackView(TLTrackBase track, TimelineView tv, RulerView rv)
            : base(track, tv)
        {
            Model = track;
            Parent = tv;
            FRuler = rv;

            MainGroup.Transforms = new SvgTransformCollection();
            MainGroup.Transforms.Add(new SvgTranslate(0, 0));

            var width = new SvgUnit(SvgUnitType.Percentage, 100);

            Label.FontSize = 12;
            Label.X = 5;
            Label.Y = Label.FontSize;
            Label.Text = Model.Label.Value;
            Label.ID = "label";
            Label.MouseDown += Background_MouseDown;
            Label.MouseUp += Background_MouseUp;
            Label.CustomAttributes["class"] = "trackfont";

            SizeBarDragRect.FillOpacity = 0.3f;
            SizeBarDragRect.Visible = false;
            SizeBarDragRect.CustomAttributes["pointer-events"] = "none";

            Background.Width = width;
            Background.Height = 1; // this is the value range, not the actual track size
            Background.ID ="bg";

            ClipRect.Width = width;
            ClipRect.Height = Background.Height;
            ClipRect.ID = "ClipRect";

            //document roots id is "svg". this is where the trackclips are added to
            TrackClipPath.ID = "svg_clip" + IDGenerator.NewID;
            TrackClipPath.Children.Add(ClipRect);

            TrackGroup.ID = "Clip";
            TrackGroup.Transforms = new SvgTransformCollection();
            TrackGroup.Transforms.Add(new SvgScale(1, 1));
            var uri = new Uri("url(#" + TrackClipPath.ID + ")", UriKind.Relative);
            TrackGroup.ClipPath = uri;

            PanZoomGroup.ID = "PanZoom";
            PanZoomGroup.Transforms = new SvgTransformCollection();
            PanZoomGroup.Transforms.Add(FRuler.PanZoomMatrix); //pan/zoom
            PanZoomGroup.Transforms.Add(new SvgTranslate(0)); //min/max

            SizeBar.Width = width;
            SizeBar.Height = 3;
            SizeBar.ID = "SizeBar";
            SizeBar.CustomAttributes["class"] = "sizebar";
            SizeBar.Y = Background.Height.Value;

            //register event handlers
            Background.MouseDown += Background_MouseDown;
            Background.MouseUp += Background_MouseUp;
            Background.MouseMove += Background_MouseMove;

            SizeBar.MouseDown += Background_MouseDown;
            SizeBar.MouseMove += Background_MouseMove;
            SizeBar.MouseUp += Background_MouseUp;

            CreateTrackMenu();
            CreateKeyframeMenu();
        }