[longomatch] Redesign tags editor
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Redesign tags editor
- Date: Tue, 28 Oct 2014 09:51:43 +0000 (UTC)
commit 62439c90ddb9b972f28b5436feec3e6ea90e2ce4
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed Oct 22 14:56:27 2014 +0200
Redesign tags editor
LongoMatch.Core/Store/Templates/Dashboard.cs | 12 +++-
LongoMatch.GUI/Gui/Component/DashboardWidget.cs | 2 +-
LongoMatch.GUI/Gui/Dialog/PlayEditor.cs | 81 ++++++++++++++------
.../gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs | 15 ++--
LongoMatch.GUI/gtk-gui/gui.stetic | 54 +------------
5 files changed, 80 insertions(+), 84 deletions(-)
---
diff --git a/LongoMatch.Core/Store/Templates/Dashboard.cs b/LongoMatch.Core/Store/Templates/Dashboard.cs
index a482c0b..8941e78 100644
--- a/LongoMatch.Core/Store/Templates/Dashboard.cs
+++ b/LongoMatch.Core/Store/Templates/Dashboard.cs
@@ -133,6 +133,14 @@ namespace LongoMatch.Core.Store.Templates
}
}
+ [JsonIgnore]
+ public Dictionary<string, List<Tag>> CommonTagsByGroup {
+ get {
+ return List.OfType<TagButton>().Select(t=>t.Tag).
+ GroupBy(t => t.Group).ToDictionary (g => g.Key, g => g.ToList ());
+ }
+ }
+
public void Save(string filePath) {
Serializer.Save(this, filePath);
}
@@ -196,12 +204,12 @@ namespace LongoMatch.Core.Store.Templates
template.GamePeriods = periods;
tagbutton = new TagButton {
- Tag = new Tag (Catalog.GetString ("Attack"), Constants.COMMON_TAG),
+ Tag = new Tag (Catalog.GetString ("Attack"), ""),
Position = new Point (10, 10)};
template.List.Add (tagbutton);
tagbutton = new TagButton {
- Tag = new Tag (Catalog.GetString ("Deffense"), Constants.COMMON_TAG),
+ Tag = new Tag (Catalog.GetString ("Deffense"), ""),
Position = new Point (10 + (10 + CAT_WIDTH) * 1, 10)};
template.List.Add (tagbutton);
diff --git a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
index a94ee85..5e1e341 100644
--- a/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/DashboardWidget.cs
@@ -220,7 +220,7 @@ namespace LongoMatch.Gui.Component
} else if (buttontype == "Timer") {
button = new TimerButton {Timer = new Timer {Name = "Timer"}};
} else if (buttontype == "Tag") {
- button = new TagButton {Tag = new Tag ("Tag", Constants.COMMON_TAG)};
+ button = new TagButton {Tag = new Tag ("Tag", "")};
} else if (buttontype == "Category") {
button = template.AddDefaultItem (template.List.Count);
} else {
diff --git a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
index 902b882..98d3c6c 100644
--- a/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
+++ b/LongoMatch.GUI/Gui/Dialog/PlayEditor.cs
@@ -23,6 +23,7 @@ using LongoMatch.Drawing.Widgets;
using System.Collections.Generic;
using LongoMatch.Drawing.Cairo;
using Gtk;
+using Mono.Unix;
namespace LongoMatch.Gui.Dialog
{
@@ -61,7 +62,7 @@ namespace LongoMatch.Gui.Dialog
play.EventType.TagGoalPosition);
drawingarea3.Visible = editPlayers;
nameframe.Visible = editTags;
- tagstable.Visible = editTags;
+ tagsvbox.Visible = editTags;
nameentry.Text = play.Name;
if (editPos) {
@@ -85,43 +86,75 @@ namespace LongoMatch.Gui.Dialog
void FillTags (Project project, TimelineEvent evt)
{
- List<Tag> tags;
+ Dictionary<string, List<Tag>> tagsByGroup;
+ SizeGroup sgroup = new SizeGroup (SizeGroupMode.Horizontal);
if (evt.EventType is AnalysisEventType) {
- tags = (evt.EventType as AnalysisEventType).Tags.ToList ();
+ tagsByGroup = (evt.EventType as AnalysisEventType).TagsByGroup;
} else {
- tags = new List<Tag> ();
+ tagsByGroup = new Dictionary<string, List<Tag>> ();
}
- 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);
+ tagsByGroup = tagsByGroup.Concat (project.Dashboard.CommonTagsByGroup)
+ .ToDictionary (x => x.Key, x => x.Value);
+
+ tagsvbox.PackStart (new HSeparator ());
+ foreach (string grp in tagsByGroup.Keys) {
+ HBox box = new HBox ();
+ Label label = new Label (String.IsNullOrEmpty (grp) ? Catalog.GetString
("Common tags") : grp);
+ List<Tag> tags = tagsByGroup [grp];
+ Table tagstable = new Table ((uint)(tags.Count / TAGS_PER_ROW), TAGS_PER_ROW,
true);
+ RadioButton first = null;
+ Tag noneTag = new Tag (Catalog.GetString ("None"));
+
+ label.WidthRequest = 200;
+ if (!String.IsNullOrEmpty (grp)) {
+ tags.Insert (0, noneTag);
+ }
+
+ for (int i=0; i < tags.Count; i++) {
+ uint row_top, row_bottom, col_left, col_right;
+ Tag t = tags [i];
+ CheckButton tb;
+
+ if (String.IsNullOrEmpty (grp)) {
+ tb = new CheckButton (t.Value);
} else {
- evt.Tags.Remove (t);
+ if (first == null) {
+ tb = first = new RadioButton (t.Value);
+ } else {
+ tb = new RadioButton (first, t.Value);
+ }
}
- };
- 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 ();
+ tb.Active = evt.Tags.Contains (t);
+ tb.Toggled += (sender, e) => {
+ if (tb.Active && t != noneTag) {
+ 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);
+ }
+ sgroup.AddWidget (label);
+ box.PackStart (label, false, true, 0);
+ box.PackEnd (tagstable, true, true, 0);
+ box.Spacing = 5;
+ tagsvbox.PackStart (box, false, true, 0);
+ tagsvbox.PackStart (new HSeparator ());
}
-
+ tagsvbox.ShowAll ();
}
void HandleChanged (object sender, EventArgs e)
{
if (play != null) {
play.Name = nameentry.Text;
+ nameentry.GrabFocus ();
}
}
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
index 3c1fb85..6b60c91 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.PlayEditor.cs
@@ -14,7 +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::Gtk.VBox tagsvbox;
private global::LongoMatch.Gui.Component.PlaysCoordinatesTagger tagger;
private global::Gtk.DrawingArea drawingarea3;
private global::Gtk.Button buttonCancel;
@@ -39,10 +39,12 @@ namespace LongoMatch.Gui.Dialog
w1.BorderWidth = ((uint)(2));
// Container child dialog1_VBox.Gtk.Box+BoxChild
this.hbox4 = new global::Gtk.HBox ();
+ this.hbox4.HeightRequest = 80;
this.hbox4.Name = "hbox4";
this.hbox4.Spacing = 6;
// Container child hbox4.Gtk.Box+BoxChild
this.nameframe = new global::Gtk.Frame ();
+ this.nameframe.WidthRequest = 200;
this.nameframe.Name = "nameframe";
this.nameframe.ShadowType = ((global::Gtk.ShadowType)(0));
// Container child nameframe.Gtk.Container+ContainerChild
@@ -105,12 +107,11 @@ 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]));
+ this.tagsvbox = new global::Gtk.VBox ();
+ this.tagsvbox.Name = "tagsvbox";
+ this.tagsvbox.Spacing = 6;
+ w1.Add (this.tagsvbox);
+ global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(w1 [this.tagsvbox]));
w10.Position = 1;
// Container child dialog1_VBox.Gtk.Box+BoxChild
this.tagger = new global::LongoMatch.Gui.Component.PlaysCoordinatesTagger ();
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 54b7253..242e1ea 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -10889,10 +10889,12 @@ You can continue with the current capture, cancel it or save your project.
<child>
<widget class="Gtk.HBox" id="hbox4">
<property name="MemberName" />
+ <property name="HeightRequest">80</property>
<property name="Spacing">6</property>
<child>
<widget class="Gtk.Frame" id="nameframe">
<property name="MemberName" />
+ <property name="WidthRequest">200</property>
<property name="ShadowType">None</property>
<child>
<widget class="Gtk.Alignment" id="GtkAlignment3">
@@ -10984,57 +10986,9 @@ You can continue with the current capture, cancel it or save your project.
</packing>
</child>
<child>
- <widget class="Gtk.Table" id="tagstable">
+ <widget class="Gtk.VBox" id="tagsvbox">
<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>
+ <property name="Spacing">6</property>
<child>
<placeholder />
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]