[longomatch] Continue work with the timeline and the UI
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Continue work with the timeline and the UI
- Date: Mon, 7 Jul 2014 11:22:20 +0000 (UTC)
commit 0162377af0d7cbc570cecf873bd11ffada61383c
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Wed May 21 12:53:48 2014 +0200
Continue work with the timeline and the UI
.../Interfaces/Drawing/ICanvasObject.cs | 1 +
LongoMatch.Drawing.Cairo/WidgetWrapper.cs | 3 +
LongoMatch.Drawing/Canvas.cs | 4 +-
LongoMatch.Drawing/CanvasObject/CategoryLabel.cs | 20 +++++---
.../CanvasObject/CategoryTimeline.cs | 9 +++-
LongoMatch.Drawing/CanvasObject/PlayObject.cs | 4 +-
LongoMatch.Drawing/LongoMatch.Drawing.mdp | 1 +
LongoMatch.Drawing/Widgets/CategoriesLabels.cs | 47 ++++++++++++++-----
LongoMatch.Drawing/Widgets/PlaysTimeline.cs | 26 ++++++++---
LongoMatch.GUI/Gui/Component/Timeline.cs | 29 ++++++++++---
.../LongoMatch.Gui.Component.CodingWidget.cs | 12 +++---
LongoMatch.GUI/gtk-gui/gui.stetic | 2 +-
12 files changed, 113 insertions(+), 45 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/Drawing/ICanvasObject.cs
b/LongoMatch.Core/Interfaces/Drawing/ICanvasObject.cs
index e7396f0..f107c91 100644
--- a/LongoMatch.Core/Interfaces/Drawing/ICanvasObject.cs
+++ b/LongoMatch.Core/Interfaces/Drawing/ICanvasObject.cs
@@ -26,6 +26,7 @@ namespace LongoMatch.Interfaces.Drawing
public interface ICanvasObject
{
void Draw (IDrawingToolkit tk, Area area);
+ bool Visible {set; get;}
}
public interface ICanvasSelectableObject: ICanvasObject, IDrawable
diff --git a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
index b440e8c..d0942f9 100644
--- a/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
+++ b/LongoMatch.Drawing.Cairo/WidgetWrapper.cs
@@ -70,6 +70,9 @@ namespace LongoMatch.Drawing.Cairo
}
public void ReDraw (Area area = null) {
+ if (widget.GdkWindow == null) {
+ return;
+ }
if (area == null) {
Gdk.Region region = widget.GdkWindow.ClipRegion;
widget.GdkWindow.InvalidateRegion(region,true);
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 3debde5..5521f8b 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -54,7 +54,9 @@ namespace LongoMatch.Drawing
protected virtual void HandleDraw (object context, Area area) {
tk.Context = context;
foreach (ICanvasObject o in Objects) {
- o.Draw (tk, area);
+ if (o.Visible) {
+ o.Draw (tk, area);
+ }
}
tk.Context = null;
}
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
b/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
index 9a6da67..07ebbd4 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
+++ b/LongoMatch.Drawing/CanvasObject/CategoryLabel.cs
@@ -23,28 +23,34 @@ using LongoMatch.Common;
namespace LongoMatch.Drawing.CanvasObject
{
- public class CategoryLabel: ICanvasObject
+ public class CategoryLabel: BaseCanvasObject, ICanvasObject
{
Category category;
double width, height;
- Point offset;
public CategoryLabel (Category category, double width, double height,
- Point offset)
+ double offsetY)
{
this.category = category;
this.height = height;
this.width = width;
- this.offset = offset;
+ OffsetY = offsetY;
}
public double Scroll {
get;
set;
}
-
- public void Draw (IDrawingToolkit tk, Area area) {
- double y = offset.Y - Scroll;
+
+ public double OffsetY {
+ set;
+ protected get;
+ }
+
+ public override void Draw (IDrawingToolkit tk, Area area) {
+ double y;
+
+ y = OffsetY - Scroll;
tk.Begin();
tk.FillColor = category.Color;
tk.StrokeColor = category.Color;
diff --git a/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
b/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
index 38b2214..a1a0a51 100644
--- a/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
+++ b/LongoMatch.Drawing/CanvasObject/CategoryTimeline.cs
@@ -25,7 +25,7 @@ using LongoMatch.Store.Drawables;
namespace LongoMatch.Drawing.CanvasObject
{
- public class CategoryTimeline: ICanvasSelectableObject
+ public class CategoryTimeline: BaseCanvasObject, ICanvasSelectableObject
{
Color background;
List<PlayObject> plays;
@@ -35,6 +35,7 @@ namespace LongoMatch.Drawing.CanvasObject
{
this.background = background;
this.plays = new List<PlayObject> ();
+ Visible = true;
SecondsPerPixel = 0.1;
CurrentTime = new Time (0);
OffsetY = offsetY;
@@ -86,9 +87,11 @@ namespace LongoMatch.Drawing.CanvasObject
plays.RemoveAll (po => po.Play == play);
}
- public void Draw (IDrawingToolkit tk, Area area) {
+ public override void Draw (IDrawingToolkit tk, Area area) {
double position;
- List<PlayObject> selected = new List<PlayObject>();
+ List<PlayObject> selected;
+
+ selected = new List<PlayObject>();
tk.Begin ();
tk.FillColor = background;
diff --git a/LongoMatch.Drawing/CanvasObject/PlayObject.cs b/LongoMatch.Drawing/CanvasObject/PlayObject.cs
index 874bc62..e6e0fe2 100644
--- a/LongoMatch.Drawing/CanvasObject/PlayObject.cs
+++ b/LongoMatch.Drawing/CanvasObject/PlayObject.cs
@@ -24,7 +24,7 @@ using LongoMatch.Store.Drawables;
namespace LongoMatch.Drawing.CanvasObject
{
- public class PlayObject: ICanvasSelectableObject
+ public class PlayObject: BaseCanvasObject, ICanvasSelectableObject
{
const int MAX_TIME_SPAN=1000;
@@ -72,7 +72,7 @@ namespace LongoMatch.Drawing.CanvasObject
}
}
- public void Draw (IDrawingToolkit tk, Area area) {
+ public override void Draw (IDrawingToolkit tk, Area area) {
Color c = Play.Category.Color;
tk.Begin ();
tk.FillColor = new Color (c.R, c.G, c.B, (ushort) (0.8 * ushort.MaxValue));
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.mdp b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
index 558c431..70fe03c 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.mdp
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.mdp
@@ -26,6 +26,7 @@
<File subtype="Code" buildaction="Compile" name="Common.cs" />
<File subtype="Code" buildaction="Compile" name="Widgets/PlaysTimeline.cs" />
<File subtype="Code" buildaction="Compile" name="CanvasObject/CategoryTimeline.cs" />
+ <File subtype="Code" buildaction="Compile" name="CanvasObject/BaseCanvasObject.cs" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089" />
diff --git a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs b/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
index 340e19d..ac96f99 100644
--- a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
+++ b/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
@@ -16,6 +16,7 @@
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
//
using System;
+using System.Collections.Generic;
using LongoMatch.Store;
using LongoMatch.Interfaces.Drawing;
using LongoMatch.Common;
@@ -26,9 +27,12 @@ namespace LongoMatch.Drawing.Widgets
public class CategoriesLabels: Canvas
{
Project project;
+ PlaysFilter filter;
+ Dictionary<Category, CategoryLabel> categories;
public CategoriesLabels (IWidget widget): base (widget)
{
+ categories = new Dictionary<Category, CategoryLabel>();
}
public double Scroll {
@@ -40,34 +44,51 @@ namespace LongoMatch.Drawing.Widgets
}
}
- public Project Project {
- set {
- Objects.Clear ();
- project = value;
- if (project != null)
- FillCanvas ();
+ public void LoadProject (Project project, PlaysFilter filter) {
+ Objects.Clear ();
+ this.project = project;
+ this.filter = filter;
+ if (project != null) {
+ FillCanvas ();
+ UpdateVisibleCategories ();
+ filter.FilterUpdated += UpdateVisibleCategories;
}
}
void FillCanvas () {
- Point offset;
+ int i = 0;
widget.Width = Common.CATEGORY_WIDTH;
- offset = new Point (0, 0);
-
/* Start from bottom to top with categories */
foreach (Category cat in project.Categories) {
CategoryLabel l;
- Point cOffset;
/* Add the category label */
- cOffset = new Point (offset.X, offset.Y);
l = new CategoryLabel (cat, Common.CATEGORY_WIDTH,
- Common.CATEGORY_HEIGHT, cOffset);
+ Common.CATEGORY_HEIGHT,
+ i * Common.CATEGORY_HEIGHT);
+ categories[cat] = l;
Objects.Add (l);
- offset.Y += Common.CATEGORY_HEIGHT;
+ i++;
+ }
+ }
+
+ void UpdateVisibleCategories () {
+ int i = 0;
+
+ foreach (Category cat in categories.Keys) {
+ CategoryLabel label = categories[cat];
+
+ if (filter.VisibleCategories.Contains (cat)) {
+ label.OffsetY = i * Common.CATEGORY_HEIGHT;
+ label.Visible = true;
+ i++;
+ } else {
+ label.Visible = false;
+ }
}
+ widget.ReDraw ();
}
}
}
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index 58ca10a..d55a9f5 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -43,6 +43,7 @@ namespace LongoMatch.Drawing.Widgets
public event ShowTimelineMenuHandler ShowMenu;
Project project;
+ PlaysFilter playsFilter;
double secondsPerPixel;
Time duration;
uint lastTime;
@@ -67,11 +68,9 @@ namespace LongoMatch.Drawing.Widgets
categories.Clear();
duration= new Time ((int)project.Description.File.Length);
widget.Height = project.Categories.Count * Common.CATEGORY_HEIGHT;
+ playsFilter = filter;
FillCanvas ();
- filter.FilterUpdated += () => {
- //Visible = filter.VisibleCategories.Contains (category);
- //QueueDraw();
- };
+ filter.FilterUpdated += UpdateVisibleCategories;
}
public Time CurrentTime {
@@ -106,8 +105,7 @@ namespace LongoMatch.Drawing.Widgets
void Update () {
double width = duration.Seconds / SecondsPerPixel;
widget.Width = width;
- foreach (object o in Objects) {
- CategoryTimeline tl = o as CategoryTimeline;
+ foreach (CategoryTimeline tl in categories.Values) {
tl.Width = width;
tl.SecondsPerPixel = SecondsPerPixel;
}
@@ -131,9 +129,25 @@ namespace LongoMatch.Drawing.Widgets
categories[cat] = tl;
Objects.Add (tl);
}
+ UpdateVisibleCategories ();
Update ();
}
+ void UpdateVisibleCategories () {
+ int i=0;
+ foreach (Category cat in categories.Keys) {
+ CategoryTimeline timeline = categories[cat];
+ if (playsFilter.VisibleCategories.Contains (cat)) {
+ timeline.OffsetY = i * Common.CATEGORY_HEIGHT;
+ timeline.Visible = true;
+ i++;
+ } else {
+ timeline.Visible = false;
+ }
+ }
+ widget.ReDraw ();
+ }
+
void RedrawSelection (Selection sel)
{
PlayObject po = sel.Drawable as PlayObject;
diff --git a/LongoMatch.GUI/Gui/Component/Timeline.cs b/LongoMatch.GUI/Gui/Component/Timeline.cs
index 904a569..69c4262 100644
--- a/LongoMatch.GUI/Gui/Component/Timeline.cs
+++ b/LongoMatch.GUI/Gui/Component/Timeline.cs
@@ -48,6 +48,8 @@ namespace LongoMatch.Gui.Component
CategoriesLabels labels;
MediaFile projectFile;
DateTime lastUpdate;
+ double secondsPerPixel;
+ Time currentTime;
public Timeline ()
{
@@ -56,9 +58,10 @@ namespace LongoMatch.Gui.Component
this.timeline = new PlaysTimeline (new WidgetWrapper(timelinearea));
this.labels = new CategoriesLabels (new WidgetWrapper (labelsarea));
focusbutton.CanFocus = false;
+ focusbutton.Clicked += HandleFocusClicked;
focusscale.CanFocus = false;
focusscale.Adjustment.Lower = 0;
- focusscale.Adjustment.Upper = 16;
+ focusscale.Adjustment.Upper = 12;
focusscale.ValueChanged += HandleValueChanged;
timerulearea.HeightRequest = TIMERULE_HEIGHT;
labelsarea.WidthRequest = LongoMatch.Drawing.Common.CATEGORY_WIDTH;
@@ -76,6 +79,7 @@ namespace LongoMatch.Gui.Component
public Time CurrentTime {
set {
DateTime now = DateTime.Now;
+ this.currentTime = value;
if ((now - lastUpdate).TotalMilliseconds > 100) {
timeline.CurrentTime = value;
timerule.CurrentTime = value;
@@ -83,19 +87,22 @@ namespace LongoMatch.Gui.Component
lastUpdate = now;
}
}
+ protected get {
+ return currentTime;
+ }
}
public void SetProject (Project project, PlaysFilter filter) {
timeline.LoadProject (project, filter);
- projectFile = project.Description.File;
+ labels.LoadProject (project, filter);
if(project == null) {
return;
}
- focusscale.Value = 10;
+ focusscale.Value = 6;
+ projectFile = project.Description.File;
timerule.Duration = new Time ((int)project.Description.File.Length);
- labels.Project = project;
timeline.TimeNodeChanged += HandleTimeNodeChanged;
timeline.TimeNodeSelected += HandleTimeNodeSelected;
@@ -122,6 +129,15 @@ namespace LongoMatch.Gui.Component
QueueDraw ();
}
+ void HandleFocusClicked (object sender, EventArgs e)
+ {
+ double pos = CurrentTime.Seconds / secondsPerPixel;
+ double maxPos = timelinearea.Allocation.Width - scrolledwindow1.Allocation.Width;
+
+ pos = Math.Min (pos, maxPos);
+ scrolledwindow1.Hadjustment.Value = pos;
+ }
+
void HandleValueChanged (object sender, EventArgs e)
{
double secondsPer100Pixels, value;
@@ -135,8 +151,9 @@ namespace LongoMatch.Gui.Component
secondsPer100Pixels = (value - 5) * 60;
}
- timerule.SecondsPerPixel = secondsPer100Pixels / 100 ;
- timeline.SecondsPerPixel = secondsPer100Pixels / 100;
+ secondsPerPixel = secondsPer100Pixels / 100 ;
+ timerule.SecondsPerPixel = secondsPerPixel;
+ timeline.SecondsPerPixel = secondsPerPixel;
QueueDraw ();
}
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
index dd0fb9a..a28cb15 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
@@ -21,17 +21,17 @@ namespace LongoMatch.Gui.Component
// Widget LongoMatch.Gui.Component.CodingWidget
Stetic.BinContainer w1 = global::Stetic.BinContainer.Attach (this);
this.UIManager = new global::Gtk.UIManager ();
- global::Gtk.ActionGroup w2 = new global::Gtk.ActionGroup ("Default");
+ global::Gtk.ActionGroup w2 = new global::Gtk.ActionGroup ("Timeline");
+ this.UIManager.InsertActionGroup (w2, 0);
+ global::Gtk.ActionGroup w3 = new global::Gtk.ActionGroup ("Default");
this.timelineMode = new global::Gtk.RadioAction ("timelineMode", null,
global::Mono.Unix.Catalog.GetString ("Timeline view"), "gtk-justify-fill", 0);
this.timelineMode.Group = new global::GLib.SList (global::System.IntPtr.Zero);
- w2.Add (this.timelineMode, null);
+ w3.Add (this.timelineMode, null);
this.autoTaggingMode = new global::Gtk.RadioAction ("autoTaggingMode", null,
global::Mono.Unix.Catalog.GetString ("Automatic tagging view"), "gtk-select-color", 0);
this.autoTaggingMode.Group = this.timelineMode.Group;
- w2.Add (this.autoTaggingMode, null);
+ w3.Add (this.autoTaggingMode, null);
this.zoomFitAction = new global::Gtk.Action ("zoomFitAction", null, null,
"gtk-zoom-fit");
- w2.Add (this.zoomFitAction, null);
- this.UIManager.InsertActionGroup (w2, 0);
- global::Gtk.ActionGroup w3 = new global::Gtk.ActionGroup ("Timeline");
+ w3.Add (this.zoomFitAction, null);
this.UIManager.InsertActionGroup (w3, 1);
this.Name = "LongoMatch.Gui.Component.CodingWidget";
// Container child LongoMatch.Gui.Component.CodingWidget.Gtk.Container+ContainerChild
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 8da7172..779c1ca 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -10185,6 +10185,7 @@ Defining <b> Game Units </b> will help you during the analysis to in
</child>
</widget>
<widget class="Gtk.Bin" id="LongoMatch.Gui.Component.CodingWidget" design-size="673 300">
+ <action-group name="Timeline" />
<action-group name="Default">
<action id="timelineMode">
<property name="Type">Radio</property>
@@ -10212,7 +10213,6 @@ Defining <b> Game Units </b> will help you during the analysis to in
<property name="StockId">gtk-zoom-fit</property>
</action>
</action-group>
- <action-group name="Timeline" />
<property name="MemberName" />
<property name="Visible">False</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]