[longomatch] Update current time in the timeline widget



commit 24ac4476fbc6cfe8efef2caaf4df0fec029bb4de
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue May 20 16:59:16 2014 +0200

    Update current time in the timeline widget

 LongoMatch.Drawing/Canvas.cs                       |    1 -
 .../CanvasObject/CategoryTimeline.cs               |   16 ++++++++++++++++
 LongoMatch.Drawing/Widgets/PlaysTimeline.cs        |    3 +++
 LongoMatch.Drawing/Widgets/Timerule.cs             |   11 ++++++++++-
 LongoMatch.GUI/Gui/Component/AnalysisComponent.cs  |    6 +++---
 LongoMatch.GUI/Gui/Component/CodingWidget.cs       |    8 +++++++-
 LongoMatch.GUI/Gui/Component/Timeline.cs           |   10 +++++++++-
 7 files changed, 48 insertions(+), 7 deletions(-)
---
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 1a25ecd..3debde5 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -20,7 +20,6 @@ using System.Collections.Generic;
 using LongoMatch.Interfaces.Drawing;
 using LongoMatch.Interfaces;
 using LongoMatch.Common;
-using LongoMatch.Interfaces.Drawing;
 
 namespace LongoMatch.Drawing
 {
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs 
b/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
index 12a2378..38b2214 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
+++ b/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
@@ -36,6 +36,7 @@ namespace LongoMatch.Drawing.CanvasObject
                        this.background = background;
                        this.plays = new List<PlayObject> ();
                        SecondsPerPixel = 0.1;
+                       CurrentTime = new Time (0);
                        OffsetY  = offsetY;
                        foreach (Play p in plays) {
                                AddPlay (p);
@@ -54,6 +55,11 @@ namespace LongoMatch.Drawing.CanvasObject
                        }
                }
                
+               public Time CurrentTime {
+                       set;
+                       protected get;
+               }
+               
                public double Width {
                        set;
                        protected get;
@@ -81,7 +87,9 @@ namespace LongoMatch.Drawing.CanvasObject
                }
 
                public void Draw (IDrawingToolkit tk, Area area) {
+                       double position;
                        List<PlayObject> selected = new List<PlayObject>();
+
                        tk.Begin ();
                        tk.FillColor = background;
                        tk.StrokeColor = background;
@@ -98,6 +106,14 @@ namespace LongoMatch.Drawing.CanvasObject
                        foreach (PlayObject p in selected) {
                                p.Draw (tk, area);
                        }
+                       
+                       tk.FillColor = Common.TIMELINE_LINE_COLOR;
+                       tk.StrokeColor = Common.TIMELINE_LINE_COLOR;
+                       tk.LineWidth = Common.TIMELINE_LINE_WIDTH;
+                       position = Common.TimeToPos (CurrentTime, secondsPerPixel);
+                       tk.DrawLine (new Point (position, OffsetY),
+                                    new Point (position, OffsetY + Common.CATEGORY_HEIGHT));
+                       
                        tk.End();
                }
                
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index dd5662a..942936b 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -76,6 +76,9 @@ namespace LongoMatch.Drawing.Widgets
                
                public Time CurrentTime {
                        set {
+                               foreach (CategoryTimeline tl in categories.Values) {
+                                       tl.CurrentTime = value;
+                               }
                        }
                }
                
diff --git a/LongoMatch.Drawing/Widgets/Timerule.cs b/LongoMatch.Drawing/Widgets/Timerule.cs
index 91c5c70..1f3e583 100644
--- a/LongoMatch.Drawing/Widgets/Timerule.cs
+++ b/LongoMatch.Drawing/Widgets/Timerule.cs
@@ -32,6 +32,7 @@ namespace LongoMatch.Drawing.Widgets
                public Timerule (IWidget widget):base (widget)
                {
                        SecondsPerPixel = 0.1;
+                       CurrentTime = new Time (0);
                }
                
                public double Scroll {
@@ -44,7 +45,7 @@ namespace LongoMatch.Drawing.Widgets
                        protected get;
                }
 
-               public Time Position {
+               public Time CurrentTime {
                        get;
                        set;
                }
@@ -58,6 +59,7 @@ namespace LongoMatch.Drawing.Widgets
                {
                        double height = widget.Height;
                        double width = widget.Width;
+                       double tpos;
 
                        tk.Context = context;
                        tk.Begin ();
@@ -89,6 +91,13 @@ namespace LongoMatch.Drawing.Widgets
                                tk.DrawLine (new Point (pos, height),
                                             new Point (pos, height - SMALL_LINE_HEIGHT));
                        }
+                       
+                       /* Draw position triangle */
+                       tpos = Common.TimeToPos (CurrentTime, SecondsPerPixel);
+                       tk.FillColor = Common.TIMELINE_LINE_COLOR;
+                       tk.DrawTriangle (new Point (tpos, widget.Height), 8,
+                                        BIG_LINE_HEIGHT, SelectionPosition.Bottom);
+
                        tk.End ();
                        tk.Context = null;
                }
diff --git a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs 
b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
index 464f93f..ff4a91d 100644
--- a/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
+++ b/LongoMatch.GUI/Gui/Component/AnalysisComponent.cs
@@ -384,9 +384,9 @@ namespace LongoMatch.Gui.Component
                void OnTick (Time currentTime, Time streamLength,
                        double currentPosition)
                {
-                       //if (currentTime.MSeconds != 0 && timeline != null && openedProject != null) {
-                       //      timeline.CurrentTime = currentTime;
-                       //}
+                       if (currentTime.MSeconds != 0 && codingwidget != null && openedProject != null) {
+                               codingwidget.CurrentTime = currentTime;
+                       }
                }
                
                void OnMultimediaError(string message)
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 1997ab6..e9207f3 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -73,7 +73,13 @@ namespace LongoMatch.Gui.Component
                public void DeletePlays (List<Play> plays) {
                        timeline.RemovePlays(plays);
                }
-               
+
+               public Time CurrentTime {
+                       set {
+                               timeline.CurrentTime = value;
+                       }
+               }               
+
                public Play SelectedPlay {
                        set {
                                timeline.SelectedTimeNode = value;
diff --git a/LongoMatch.GUI/Gui/Component/Timeline.cs b/LongoMatch.GUI/Gui/Component/Timeline.cs
index ca87d2d..04f2574 100644
--- a/LongoMatch.GUI/Gui/Component/Timeline.cs
+++ b/LongoMatch.GUI/Gui/Component/Timeline.cs
@@ -47,6 +47,7 @@ namespace LongoMatch.Gui.Component
                Timerule timerule;
                CategoriesLabels labels;
                MediaFile projectFile;
+               DateTime lastUpdate;
 
                public Timeline ()
                {
@@ -59,6 +60,7 @@ namespace LongoMatch.Gui.Component
                        hbox1.HeightRequest = TIMERULE_HEIGHT;
                        scrolledwindow1.Vadjustment.ValueChanged += HandleScrollEvent;
                        scrolledwindow1.Hadjustment.ValueChanged += HandleScrollEvent;
+                       lastUpdate = DateTime.Now;
                }
                
                public TimeNode SelectedTimeNode {
@@ -68,7 +70,13 @@ namespace LongoMatch.Gui.Component
                
                public Time CurrentTime {
                        set {
-                               timeline.CurrentTime = value;
+                               DateTime now = DateTime.Now;
+                               if ((now - lastUpdate).TotalMilliseconds > 100) {
+                                       timeline.CurrentTime = value;
+                                       timerule.CurrentTime = value;
+                                       QueueDraw ();
+                                       lastUpdate = now;
+                               }
                        }
                }
                


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]