[longomatch] Show tags in the events editor



commit 6415234cb6295d883a5382bf9673eca3319b2f1d
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Fri Sep 5 19:31:56 2014 +0200

    Show tags in the events editor

 LongoMatch.Core/Store/Templates/Dashboard.cs       |   18 +----
 LongoMatch.Drawing/Widgets/PlaysTimeline.cs        |    6 --
 LongoMatch.GUI/Gui/Dialog/PlayEditor.cs            |   50 ++++++++++++--
 .../gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs    |   43 +++++++-----
 LongoMatch.GUI/gtk-gui/gui.stetic                  |   73 +++++++++++++++++++-
 5 files changed, 143 insertions(+), 47 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Templates/Dashboard.cs b/LongoMatch.Core/Store/Templates/Dashboard.cs
index d0a7da8..d56f9b0 100644
--- a/LongoMatch.Core/Store/Templates/Dashboard.cs
+++ b/LongoMatch.Core/Store/Templates/Dashboard.cs
@@ -55,7 +55,7 @@ namespace LongoMatch.Core.Store.Templates
                        HalfFieldBackground = Config.HalfFieldBackground;
                        GoalBackground = Config.GoalBackground;
                        ID = Guid.NewGuid ();
-                       List = new ObservableCollection<DashboardButton>();
+                       List = new List<DashboardButton>();
                }
                
                public Guid ID {
@@ -63,7 +63,7 @@ namespace LongoMatch.Core.Store.Templates
                        set;
                }
                
-               public ObservableCollection<DashboardButton> List {
+               public List<DashboardButton> List {
                        get;
                        set;
                }
@@ -99,20 +99,6 @@ namespace LongoMatch.Core.Store.Templates
                }
                
                [JsonIgnore]
-               public List<Score> Scores {
-                       get {
-                               return List.OfType<Score>().ToList();
-                       }
-               }
-               
-               [JsonIgnore]
-               public List<PenaltyCard> PenaltyCards {
-                       get {
-                               return List.OfType<PenaltyCard>().ToList();
-                       }
-               }
-               
-               [JsonIgnore]
                public List<Timer> Timers {
                        get {
                                return List.OfType<Timer>().ToList();
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index a50c328..db706a5 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -63,12 +63,6 @@ namespace LongoMatch.Drawing.Widgets
                        eventsTimelines.Clear ();
                        duration = project.Description.File.Duration;
                        height = project.EventTypes.Count * StyleConf.TimelineCategoryHeight;
-                       if (project.Dashboard.Scores.Count > 0) {
-                               height += StyleConf.TimelineCategoryHeight;
-                       }
-                       if (project.Dashboard.PenaltyCards.Count > 0) {
-                               height += StyleConf.TimelineCategoryHeight;
-                       }
                        widget.Height = height;
                        playsFilter = filter;
                        FillCanvas ();
diff --git a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
index c281272..09445e2 100644
--- a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
+++ b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
@@ -22,11 +22,13 @@ using LongoMatch.Core.Store;
 using LongoMatch.Drawing.Widgets;
 using System.Collections.Generic;
 using LongoMatch.Drawing.Cairo;
+using Gtk;
 
 namespace LongoMatch.Gui.Dialog
 {
        public partial class PlayEditor : Gtk.Dialog
        {
+               const int TAGS_PER_ROW = 5;
                TeamTagger teamtagger;
                TimelineEvent play;
 
@@ -51,10 +53,11 @@ namespace LongoMatch.Gui.Dialog
                        this.play = play;
                        notesframe.Visible = editNotes;
                        tagger.Visible = editPos && (play.EventType.TagFieldPosition ||
-                                                    play.EventType.TagHalfFieldPosition ||
-                                                    play.EventType.TagGoalPosition);
+                               play.EventType.TagHalfFieldPosition ||
+                               play.EventType.TagGoalPosition);
                        drawingarea3.Visible = editPlayers;
                        nameframe.Visible = editTags;
+                       tagstable.Visible = editTags;
 
                        nameentry.Text = play.Name;
                        if (editPos) {
@@ -70,12 +73,49 @@ namespace LongoMatch.Gui.Dialog
                                                      project.Dashboard.FieldBackground);
                                teamtagger.Select (play.Players);
                        }
-               }
                
+                       if (editTags) {
+                               FillTags (project, play);
+                       }
+               }
+
+               void FillTags (Project project, TimelineEvent evt)
+               {
+                       List<Tag> tags;
+                       
+                       if (!(evt.EventType is AnalysisEventType)) {
+                               return;
+                       }
+                       tags = (evt.EventType as AnalysisEventType).Tags.ToList ();
+                       tags.AddRange (project.Dashboard.List.OfType<TagButton> ().Select (t => t.Tag).ToList 
());
+                       tags = tags.Union (evt.Tags).ToList ();
+                       
+                       tagstable.NRows = (uint)(tags.Count / TAGS_PER_ROW);
+                       for (int i=0; i < tags.Count; i++) {
+                               uint row_top, row_bottom, col_left, col_right;
+                               Tag t = tags [i];
+                               ToggleButton tb = new ToggleButton (t.Value);
+                               tb.Active = evt.Tags.Contains (t);
+                               tb.Toggled += (sender, e) => {
+                                       if (tb.Active) {
+                                               evt.Tags.Add (t);
+                                       } else {
+                                               evt.Tags.Remove (t);
+                                       }
+                               };
+                               row_top = (uint)(i / tagstable.NColumns);
+                               row_bottom = (uint)row_top + 1;
+                               col_left = (uint)i % tagstable.NColumns;
+                               col_right = (uint)col_left + 1;
+                               tagstable.Attach (tb, col_left, col_right, row_top, row_bottom);
+                               tb.Show ();
+                       }
+                       
+               }
+
                void HandlePlayersSelectionChangedEvent (List<Player> players)
                {
-                       play.Players = players.ToList(); 
+                       play.Players = players.ToList (); 
                }
-               
        }
 }
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
index 95f8343..3c1fb85 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
@@ -14,6 +14,7 @@ namespace LongoMatch.Gui.Dialog
                private global::Gtk.Alignment GtkAlignment;
                private global::LongoMatch.Gui.Component.NotesWidget notes;
                private global::Gtk.Label GtkLabel;
+               private global::Gtk.Table tagstable;
                private global::LongoMatch.Gui.Component.PlaysCoordinatesTagger tagger;
                private global::Gtk.DrawingArea drawingarea3;
                private global::Gtk.Button buttonCancel;
@@ -104,26 +105,34 @@ namespace LongoMatch.Gui.Dialog
                        w9.Expand = false;
                        w9.Fill = false;
                        // Container child dialog1_VBox.Gtk.Box+BoxChild
+                       this.tagstable = new global::Gtk.Table (((uint)(3)), ((uint)(6)), false);
+                       this.tagstable.Name = "tagstable";
+                       this.tagstable.RowSpacing = ((uint)(6));
+                       this.tagstable.ColumnSpacing = ((uint)(6));
+                       w1.Add (this.tagstable);
+                       global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(w1 [this.tagstable]));
+                       w10.Position = 1;
+                       // Container child dialog1_VBox.Gtk.Box+BoxChild
                        this.tagger = new global::LongoMatch.Gui.Component.PlaysCoordinatesTagger ();
                        this.tagger.HeightRequest = 200;
                        this.tagger.Events = ((global::Gdk.EventMask)(256));
                        this.tagger.Name = "tagger";
                        w1.Add (this.tagger);
-                       global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(w1 [this.tagger]));
-                       w10.Position = 1;
+                       global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(w1 [this.tagger]));
+                       w11.Position = 2;
                        // Container child dialog1_VBox.Gtk.Box+BoxChild
                        this.drawingarea3 = new global::Gtk.DrawingArea ();
                        this.drawingarea3.HeightRequest = 200;
                        this.drawingarea3.Name = "drawingarea3";
                        w1.Add (this.drawingarea3);
-                       global::Gtk.Box.BoxChild w11 = ((global::Gtk.Box.BoxChild)(w1 [this.drawingarea3]));
-                       w11.Position = 2;
+                       global::Gtk.Box.BoxChild w12 = ((global::Gtk.Box.BoxChild)(w1 [this.drawingarea3]));
+                       w12.Position = 3;
                        // Internal child LongoMatch.Gui.Dialog.PlayEditor.ActionArea
-                       global::Gtk.HButtonBox w12 = this.ActionArea;
-                       w12.Name = "dialog1_ActionArea";
-                       w12.Spacing = 10;
-                       w12.BorderWidth = ((uint)(5));
-                       w12.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
+                       global::Gtk.HButtonBox w13 = this.ActionArea;
+                       w13.Name = "dialog1_ActionArea";
+                       w13.Spacing = 10;
+                       w13.BorderWidth = ((uint)(5));
+                       w13.LayoutStyle = ((global::Gtk.ButtonBoxStyle)(4));
                        // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
                        this.buttonCancel = new global::Gtk.Button ();
                        this.buttonCancel.CanDefault = true;
@@ -133,9 +142,9 @@ namespace LongoMatch.Gui.Dialog
                        this.buttonCancel.UseUnderline = true;
                        this.buttonCancel.Label = "gtk-cancel";
                        this.AddActionWidget (this.buttonCancel, -6);
-                       global::Gtk.ButtonBox.ButtonBoxChild w13 = 
((global::Gtk.ButtonBox.ButtonBoxChild)(w12 [this.buttonCancel]));
-                       w13.Expand = false;
-                       w13.Fill = false;
+                       global::Gtk.ButtonBox.ButtonBoxChild w14 = 
((global::Gtk.ButtonBox.ButtonBoxChild)(w13 [this.buttonCancel]));
+                       w14.Expand = false;
+                       w14.Fill = false;
                        // Container child dialog1_ActionArea.Gtk.ButtonBox+ButtonBoxChild
                        this.buttonOk = new global::Gtk.Button ();
                        this.buttonOk.CanDefault = true;
@@ -145,15 +154,15 @@ namespace LongoMatch.Gui.Dialog
                        this.buttonOk.UseUnderline = true;
                        this.buttonOk.Label = "gtk-ok";
                        this.AddActionWidget (this.buttonOk, -5);
-                       global::Gtk.ButtonBox.ButtonBoxChild w14 = 
((global::Gtk.ButtonBox.ButtonBoxChild)(w12 [this.buttonOk]));
-                       w14.Position = 1;
-                       w14.Expand = false;
-                       w14.Fill = false;
+                       global::Gtk.ButtonBox.ButtonBoxChild w15 = 
((global::Gtk.ButtonBox.ButtonBoxChild)(w13 [this.buttonOk]));
+                       w15.Position = 1;
+                       w15.Expand = false;
+                       w15.Fill = false;
                        if ((this.Child != null)) {
                                this.Child.ShowAll ();
                        }
                        this.DefaultWidth = 1021;
-                       this.DefaultHeight = 639;
+                       this.DefaultHeight = 651;
                        this.Show ();
                }
        }
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 333b92d..069d514 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -10548,7 +10548,7 @@ You can continue with the current capture, cancel it or save your project.
       </widget>
     </child>
   </widget>
-  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.PlayEditor" design-size="1021 639">
+  <widget class="Gtk.Dialog" id="LongoMatch.Gui.Dialog.PlayEditor" design-size="1021 651">
     <property name="MemberName" />
     <property name="Title" translatable="yes">Edit play details</property>
     <property name="Icon">stock:longomatch Menu</property>
@@ -10662,13 +10662,80 @@ You can continue with the current capture, cancel it or save your project.
           </packing>
         </child>
         <child>
+          <widget class="Gtk.Table" id="tagstable">
+            <property name="MemberName" />
+            <property name="NRows">3</property>
+            <property name="NColumns">6</property>
+            <property name="RowSpacing">6</property>
+            <property name="ColumnSpacing">6</property>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+            <child>
+              <placeholder />
+            </child>
+          </widget>
+          <packing>
+            <property name="Position">1</property>
+            <property name="AutoSize">True</property>
+          </packing>
+        </child>
+        <child>
           <widget class="LongoMatch.Gui.Component.PlaysCoordinatesTagger" id="tagger">
             <property name="MemberName" />
             <property name="HeightRequest">200</property>
             <property name="Events">ButtonPressMask</property>
           </widget>
           <packing>
-            <property name="Position">1</property>
+            <property name="Position">2</property>
             <property name="AutoSize">True</property>
           </packing>
         </child>
@@ -10678,7 +10745,7 @@ You can continue with the current capture, cancel it or save your project.
             <property name="HeightRequest">200</property>
           </widget>
           <packing>
-            <property name="Position">2</property>
+            <property name="Position">3</property>
             <property name="AutoSize">True</property>
           </packing>
         </child>


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