[longomatch] Add support for manual tagging mode



commit 8a0ac2acb7cbb6dcc01992736a2f57437c8ebf73
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Oct 10 18:06:32 2014 +0200

    Add support for manual tagging mode

 LongoMatch.Core/StyleConf.cs                       |    5 +
 LongoMatch.Drawing/CanvasObjects/CategoryObject.cs |  107 +++++++++++++++++--
 LongoMatch.Drawing/LongoMatch.Drawing.csproj       |    4 +
 LongoMatch.Drawing/Widgets/DashboardCanvas.cs      |    5 +
 build/build.environment.mk                         |    1 +
 5 files changed, 110 insertions(+), 12 deletions(-)
---
diff --git a/LongoMatch.Core/StyleConf.cs b/LongoMatch.Core/StyleConf.cs
index c5b23f9..9f25f8e 100644
--- a/LongoMatch.Core/StyleConf.cs
+++ b/LongoMatch.Core/StyleConf.cs
@@ -92,6 +92,11 @@ namespace LongoMatch.Core.Common
                public const string SubsLock = "hicolor/scalable/actions/longomatch-player-swap-lock.svg";
                public const string SubsUnlock = "hicolor/scalable/actions/longomatch-player-swap-unlock.svg";
 
+               public const string EditButton = "hicolor/scalable/actions/longomatch-apply.svg";
+               public const string ApplyButton = "hicolor/scalable/actions/longomatch-apply.svg";
+               public const string CancelButton = "hicolor/scalable/actions/longomatch-mark.svg";
+               public const string RecordButton = "hicolor/scalable/actions/longomatch-control-record.svg";
+
                public const int NotebookTabIconSize = 18;
                public const int NotebookTabSize = NotebookTabIconSize + 14;
 
diff --git a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs 
b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
index ca8e318..9de5b07 100644
--- a/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/CategoryObject.cs
@@ -22,24 +22,36 @@ using LongoMatch.Core.Interfaces.Drawing;
 using LongoMatch.Core.Store;
 using LongoMatch.Core.Store.Drawables;
 using Mono.Unix;
+using System.IO;
 
 namespace LongoMatch.Drawing.CanvasObjects
 {
        public class CategoryObject: TaggerObject
        {
 
+               static Image RecordSurface = null;
+               static Image CancelSurface = null;
+               static Image EditSurface = null;
+               static Image ApplySurface = null;
+               static bool surfacesCached = false;
+
                Dictionary <Rectangle, object> rects;
                Dictionary <string, List<Tag>> tagsByGroup;
                bool catSelected, tagSelected;
                int nrows;
                const int TIMEOUT_MS = 800;
+               Time currentTime;
                System.Threading.Timer timer;
+               object recordButton = new object();
+               object cancelButton = new object();
 
                public CategoryObject (AnalysisEventButton category): base (category)
                {
                        Button = category;
                        rects = new Dictionary <Rectangle, object> ();
                        SelectedTags = new List<Tag> ();
+                       CurrentTime = new Time (0);
+                       LoadSurfaces ();
                }
 
                protected override void Dispose (bool disposing)
@@ -61,12 +73,43 @@ namespace LongoMatch.Drawing.CanvasObjects
                        set;
                }
 
+               public Time CurrentTime {
+                       get {
+                               return currentTime;
+                       }
+                       set {
+                               currentTime = value;
+                               if (Start != null && currentTime < Start) {
+                                       CancelClicked ();
+                               } else {
+                                       EmitRedrawEvent (this, DrawArea);
+                               }
+                       }
+               }
+
                public override Color BackgroundColor {
                        get {
                                return Tagger.BackgroundColor;
                        }
                }
 
+               void LoadSurfaces ()
+               {
+                       if (!surfacesCached) {
+                               RecordSurface = CreateSurface (StyleConf.RecordButton);
+                               CancelSurface = CreateSurface (StyleConf.CancelButton);
+                               EditSurface = CreateSurface (StyleConf.EditButton);
+                               ApplySurface = CreateSurface (StyleConf.ApplyButton);
+                               surfacesCached = true;
+                       }
+               }
+
+               Image CreateSurface (string name)
+               {
+                       return new Image (Path.Combine (Config.IconsDir, name));
+               }
+
+
                void UpdateRows ()
                {
                        /* Header */
@@ -85,13 +128,18 @@ namespace LongoMatch.Drawing.CanvasObjects
                        }
                }
 
+               void EmitCreateEvent ()
+               {
+                       EmitClickEvent ();
+                       tagSelected = false;
+                       catSelected = false;
+                       SelectedTags.Clear ();
+               }
+
                void TimerCallback (Object state)
                {
                        Config.DrawingToolkit.Invoke (delegate {
-                               EmitClickEvent ();
-                               tagSelected = false;
-                               catSelected = false;
-                               SelectedTags.Clear ();
+                               EmitCreateEvent ();
                        });
                }
 
@@ -128,8 +176,24 @@ namespace LongoMatch.Drawing.CanvasObjects
                        }
                }
 
+               void CancelClicked ()
+               {
+                       Start = null;
+                       EmitRedrawEvent (this, DrawArea);
+               }
+
                void RecordClicked ()
                {
+                       if (Mode == TagMode.Edit) {
+                               return;
+                       }
+                       if (Start == null) {
+                               Start = CurrentTime;
+                       } else {
+                               EmitCreateEvent ();
+                               Start = null;
+                       }
+                       EmitRedrawEvent (this, DrawArea);
                }
 
                void UpdateGroups ()
@@ -166,14 +230,17 @@ namespace LongoMatch.Drawing.CanvasObjects
                public override void ClickPressed (Point p, ButtonModifier modif)
                {
                        foreach (Rectangle rect in rects.Keys) {
+                               object obj = rects [rect];
                                Selection subsel = rect.GetSelection (p, 0);
                                if (subsel != null) {
-                                       if (rects [rect] is AnalysisEventButton) {
+                                       if (obj is AnalysisEventButton) {
                                                CategoryClicked (Button);
-                                       } else if (rects [rect] is Tag) {
-                                               TagClicked (rects [rect] as Tag);
-                                       } else {
+                                       } else if (obj is Tag) {
+                                               TagClicked (obj as Tag);
+                                       } else if (obj == recordButton) {
                                                RecordClicked ();
+                                       } else if (obj == cancelButton) {
+                                               CancelClicked ();
                                        }
                                        break;
                                }
@@ -251,7 +318,9 @@ namespace LongoMatch.Drawing.CanvasObjects
                        start = new Point (Button.Position.X, Button.Position.Y + yptr);
                        tk.DrawLine (start, new Point (start.X + catWidth, start.Y));
                        tk.StrokeColor = Button.TextColor;
-                       tk.DrawText (start, catWidth, heightPerRow, Catalog.GetString ("Edit"));
+                       tk.DrawImage (start, catWidth / 2, heightPerRow, EditSurface, true);
+                       start.X += catWidth / 2;
+                       tk.DrawText (start, catWidth / 2, heightPerRow, Catalog.GetString ("Edit"));
                        rects.Add (new Rectangle (start, catWidth, heightPerRow), tag);
                        yptr += heightPerRow;
                }
@@ -298,13 +367,27 @@ namespace LongoMatch.Drawing.CanvasObjects
                        DrawEditButton (tk, catWidth, heightPerRow, ref yptr);
 
                        if (Button.TagMode == TagMode.Free) {
+                               Point p = new Point (pos.X, pos.Y + yptr);
                                /* Draw Tagger */
                                tk.StrokeColor = Button.DarkColor;
                                tk.LineWidth = 1;
-                               tk.DrawLine (new Point (pos.X, pos.Y + yptr),
-                                            new Point (pos.X + catWidth, pos.Y + yptr));
+                               tk.DrawLine (p, new Point (pos.X + catWidth, pos.Y + yptr));
                                tk.StrokeColor = Button.TextColor;
-                               tk.DrawText (new Point (pos.X, pos.Y + yptr), catWidth, heightPerRow, 
"Record");
+                               if (Start == null) {
+                                       rects.Add (new Rectangle (p, catWidth, heightPerRow), recordButton);
+                                       tk.DrawImage (p, catWidth, heightPerRow, RecordSurface, true);
+                               } else {
+                                       rects.Add (new Rectangle (p, catWidth - 20, heightPerRow), 
recordButton);
+                                       tk.DrawImage (p, 20, heightPerRow, ApplySurface, true);
+                                       p.X += 20;
+                                       tk.DrawText (p, catWidth - 40, heightPerRow, 
(CurrentTime-Start).ToSecondsString());
+                                       p = new Point (pos.X + catWidth - 20, p.Y);
+                                       rects.Add (new Rectangle (p, catWidth, heightPerRow), cancelButton);
+                                       tk.StrokeColor = Button.DarkColor;
+                                       tk.LineWidth = 1;
+                                       tk.DrawLine (new Point (p.X, yptr), new Point (p.X, yptr + 
heightPerRow));
+                                       tk.DrawImage (p, 20, heightPerRow, CancelSurface, true);
+                               }
                        }
                        DrawSelectionArea (tk);
                        tk.End ();
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.csproj b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
index 43683a9..53c9520 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.csproj
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
@@ -72,6 +72,10 @@
     <Reference Include="System" />
     <Reference Include="System.Core" />
     <Reference Include="Mono.Posix" />
+    <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
+      <Private>False</Private>
+      <Package>gtk-sharp-2.0</Package>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">
diff --git a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
index 2ed8a15..a8ce982 100644
--- a/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
+++ b/LongoMatch.Drawing/Widgets/DashboardCanvas.cs
@@ -84,6 +84,11 @@ namespace LongoMatch.Drawing.Widgets
                                foreach (TimerObject to in Objects.OfType<TimerObject>()) {
                                        to.CurrentTime = value;
                                }
+                               foreach (CategoryObject co in Objects.OfType<CategoryObject>()) {
+                                       if (co.Button.TagMode == TagMode.Free) {
+                                               co.CurrentTime = value;
+                                       }
+                               }
                        }
                        get {
                                return currentTime;
diff --git a/build/build.environment.mk b/build/build.environment.mk
index f3d336d..f054fcf 100644
--- a/build/build.environment.mk
+++ b/build/build.environment.mk
@@ -91,6 +91,7 @@ REF_DEP_LONGOMATCH_DRAWING = \
                      $(LINK_SYSTEM) \
                      $(LINK_SYSTEM_CORE) \
                      $(LINK_MONO_POSIX) \
+                     $(LINK_GTK) \
                      $(LINK_LONGOMATCH_CORE)
 
 REF_DEP_LONGOMATCH_DRAWING_CAIRO = \


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