[longomatch] Add support for timers in the timeline
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add support for timers in the timeline
- Date: Thu, 9 Oct 2014 00:40:36 +0000 (UTC)
commit 0948d1faaf93df42570e7c4dd8ee1a86921c3ec0
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Thu Oct 9 01:48:36 2014 +0200
Add support for timers in the timeline
LongoMatch.Core/Common/EventsBroker.cs | 8 +
LongoMatch.Core/Handlers/Handlers.cs | 1 +
LongoMatch.Core/Handlers/Multimedia.cs | 2 +-
LongoMatch.Core/Store/Project.cs | 16 ++-
LongoMatch.Drawing/Canvas.cs | 15 ++-
.../{CategoryLabel.cs => LabelObject.cs} | 61 +++++++-
LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs | 65 ++++++--
LongoMatch.Drawing/CanvasObjects/TimelineObject.cs | 74 +++++++--
LongoMatch.Drawing/LongoMatch.Drawing.csproj | 4 +-
LongoMatch.Drawing/Makefile.am | 4 +-
LongoMatch.Drawing/Widgets/PlaysTimeline.cs | 166 +++++++++++++++-----
.../{CategoriesLabels.cs => TimelineLabels.cs} | 42 ++++--
LongoMatch.Drawing/Widgets/TimersTimeline.cs | 5 +-
LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs | 3 +-
LongoMatch.GUI/Gui/Component/CodingWidget.cs | 2 +-
LongoMatch.GUI/Gui/Component/Timeline.cs | 67 +++++---
LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs | 2 +-
.../LongoMatch.Gui.Component.CodingWidget.cs | 2 +-
LongoMatch.GUI/gtk-gui/gui.stetic | 3 +-
LongoMatch.Services/Services/EventsManager.cs | 3 +-
LongoMatch.Services/Services/PlaylistManager.cs | 10 ++
LongoMatch.Services/Services/ProjectsManager.cs | 3 +-
22 files changed, 427 insertions(+), 131 deletions(-)
---
diff --git a/LongoMatch.Core/Common/EventsBroker.cs b/LongoMatch.Core/Common/EventsBroker.cs
index 7e98322..e03e340 100644
--- a/LongoMatch.Core/Common/EventsBroker.cs
+++ b/LongoMatch.Core/Common/EventsBroker.cs
@@ -88,6 +88,7 @@ namespace LongoMatch.Core.Common
public event DrawFrameHandler DrawFrame;
public event DetachPlayerHandler Detach;
public event PlaybackRateChangedHandler PlaybackRateChanged;
+ public event SeekEventHandler SeekEvent;
public void EmitNewTag (EventType eventType, List<Player> players = null, Team team =
Team.NONE,
List<Tag> tags = null, Time start = null, Time stop = null,
@@ -389,6 +390,13 @@ namespace LongoMatch.Core.Common
DashboardEditedEvent ();
}
}
+
+ public void EmitSeekEvent (Time time, bool accurate)
+ {
+ if (SeekEvent != null) {
+ SeekEvent (time, accurate);
+ }
+ }
}
}
diff --git a/LongoMatch.Core/Handlers/Handlers.cs b/LongoMatch.Core/Handlers/Handlers.cs
index 90fa2eb..f686862 100644
--- a/LongoMatch.Core/Handlers/Handlers.cs
+++ b/LongoMatch.Core/Handlers/Handlers.cs
@@ -126,6 +126,7 @@ namespace LongoMatch.Core.Handlers
public delegate void AnalysisModeChangedHandler (VideoAnalysisMode mode);
public delegate void TagSubcategoriesChangedHandler (bool tagsubcategories);
public delegate void ShowTimelineMenuHandler (List<TimelineEvent> plays,EventType cat,Time time);
+ public delegate void ShowTimersMenuHandler (List<TimeNode> timenodes);
public delegate void ShowTaggerMenuHandler (List<TimelineEvent> plays);
public delegate void ShowDrawToolMenuHandler (IBlackboardObject drawable);
public delegate void ConfigureDrawingObjectHandler (IBlackboardObject drawable, DrawTool tool);
diff --git a/LongoMatch.Core/Handlers/Multimedia.cs b/LongoMatch.Core/Handlers/Multimedia.cs
index 5de6447..9cce712 100644
--- a/LongoMatch.Core/Handlers/Multimedia.cs
+++ b/LongoMatch.Core/Handlers/Multimedia.cs
@@ -26,7 +26,7 @@ namespace LongoMatch.Core.Handlers
public delegate void PlayListSegmentDoneHandler();
public delegate void SegmentClosedHandler();
public delegate void SegmentDoneHandler();
- public delegate void SeekEventHandler(Time pos);
+ public delegate void SeekEventHandler(Time pos, bool accurate);
public delegate void VolumeChangedHandler(double level);
public delegate void NextButtonClickedHandler();
public delegate void PrevButtonClickedHandler();
diff --git a/LongoMatch.Core/Store/Project.cs b/LongoMatch.Core/Store/Project.cs
index a1cf6d7..3793174 100644
--- a/LongoMatch.Core/Store/Project.cs
+++ b/LongoMatch.Core/Store/Project.cs
@@ -195,7 +195,7 @@ namespace LongoMatch.Core.Store
}
public TimelineEvent AddEvent (EventType type, Time start, Time stop, Time eventTime, Image
miniature,
- Score score, PenaltyCard card, bool addToTimeline=true)
+ Score score, PenaltyCard card, bool addToTimeline=true)
{
TimelineEvent evt;
string count;
@@ -262,8 +262,20 @@ namespace LongoMatch.Core.Store
}
}
- public void UpdateEventTypes ()
+ public void CleanupTimers ()
{
+ foreach (Timer t in Timers) {
+ t.Nodes.RemoveAll (tn => tn.Start == null || tn.Stop == null);
+ }
+ }
+
+ public void UpdateEventTypesAndTimers ()
+ {
+ /* Timers */
+ IEnumerable<Timer> timers = Dashboard.List.OfType<TimerButton> ().Select (b =>
b.Timer);
+ Timers.AddRange (timers.Except (Timers));
+
+ /* Event Types */
IEnumerable<EventType> types = Dashboard.List.OfType<EventButton> ().Select (b =>
b.EventType);
EventTypes.AddRange (types.Except (EventTypes));
types = Timeline.Select (t => t.EventType).Distinct ().Except (EventTypes);
diff --git a/LongoMatch.Drawing/Canvas.cs b/LongoMatch.Drawing/Canvas.cs
index 4070bd0..5c5a1e8 100644
--- a/LongoMatch.Drawing/Canvas.cs
+++ b/LongoMatch.Drawing/Canvas.cs
@@ -156,6 +156,7 @@ namespace LongoMatch.Drawing
ClickRepeatMS = 100;
MoveWithoutSelection = false;
ObjectsCanMove = true;
+ SingleSelectionObjects = new List<Type> ();
widget.ButtonPressEvent += HandleButtonPressEvent;
widget.ButtonReleasedEvent += HandleButtonReleasedEvent;
@@ -185,6 +186,11 @@ namespace LongoMatch.Drawing
set;
}
+ public List<Type> SingleSelectionObjects {
+ get;
+ set;
+ }
+
protected bool MoveWithoutSelection {
get;
set;
@@ -267,8 +273,15 @@ namespace LongoMatch.Drawing
}
return;
}
-
+
so = sel.Drawable as ICanvasSelectableObject;
+ if (Selections.Count > 0) {
+ if (SingleSelectionObjects.Contains (so.GetType ()) ||
+ SingleSelectionObjects.Contains (Selections [0].Drawable.GetType ()))
{
+ return;
+ }
+ }
+
seldup = Selections.FirstOrDefault (s => s.Drawable == sel.Drawable);
if (seldup != null) {
diff --git a/LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
b/LongoMatch.Drawing/CanvasObjects/LabelObject.cs
similarity index 68%
rename from LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
rename to LongoMatch.Drawing/CanvasObjects/LabelObject.cs
index 5c664cf..729b398 100644
--- a/LongoMatch.Drawing/CanvasObjects/CategoryLabel.cs
+++ b/LongoMatch.Drawing/CanvasObjects/LabelObject.cs
@@ -22,17 +22,26 @@ using System;
namespace LongoMatch.Drawing.CanvasObjects
{
- public class CategoryLabel: CanvasObject, ICanvasObject
+ public class LabelObject: CanvasObject, ICanvasObject
{
- EventType eventType;
double width;
- public CategoryLabel (EventType eventType, double width, double height, double offsetY)
+ public LabelObject (double width, double height, double offsetY)
{
- this.eventType = eventType;
this.Height = height;
this.width = width;
OffsetY = offsetY;
+ Color = Color.Red1;
+ }
+
+ public virtual string Name {
+ get;
+ set;
+ }
+
+ public virtual Color Color {
+ get;
+ set;
}
public double Height {
@@ -73,8 +82,8 @@ namespace LongoMatch.Drawing.CanvasObjects
tk.DrawRectangle (new Point (0, y), width, Height);
/* Draw a rectangle with the category color */
- tk.FillColor = eventType.Color;
- tk.StrokeColor = eventType.Color;
+ tk.FillColor = Color;
+ tk.StrokeColor = Color;
tk.DrawRectangle (new Point (hs, y + vs), rectSize, rectSize);
/* Draw category name */
@@ -84,9 +93,47 @@ namespace LongoMatch.Drawing.CanvasObjects
tk.FillColor = Config.Style.PaletteWidgets;
tk.FontAlignment = FontAlignment.Left;
tk.StrokeColor = Config.Style.PaletteWidgets;
- tk.DrawText (new Point (to, y), width - to, Height, eventType.Name);
+ tk.DrawText (new Point (to, y), width - to, Height, Name);
tk.End ();
}
}
+
+ public class EventTypeLabelObject: LabelObject {
+ EventType eventType;
+
+ public EventTypeLabelObject (EventType eventType, double width, double height, double
offsetY):
+ base (width, height, offsetY)
+ {
+ this.eventType = eventType;
+ }
+
+ public override Color Color {
+ get {
+ return eventType.Color;
+ }
+ }
+
+ public override string Name {
+ get {
+ return eventType.Name;
+ }
+ }
+ }
+
+ public class TimerLabelObject: LabelObject {
+ Timer timer;
+
+ public TimerLabelObject (Timer timer, double width, double height, double offsetY):
+ base (width, height, offsetY)
+ {
+ this.timer = timer;
+ }
+
+ public override string Name {
+ get {
+ return timer.Name;
+ }
+ }
+ }
}
diff --git a/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
b/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
index 5687bed..331276b 100644
--- a/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimeNodeObject.cs
@@ -28,12 +28,14 @@ namespace LongoMatch.Drawing.CanvasObjects
public class TimeNodeObject: CanvasObject, ICanvasSelectableObject
{
ISurface needle;
+ SelectionPosition movingPos;
const int MAX_TIME_SPAN = 1000;
public TimeNodeObject (TimeNode node)
{
TimeNode = node;
SelectWhole = true;
+ LineColor = Config.Style.PaletteBackgroundLight;
}
protected override void Dispose (bool disposing)
@@ -55,6 +57,16 @@ namespace LongoMatch.Drawing.CanvasObjects
set;
}
+ public Color LineColor {
+ get;
+ set;
+ }
+
+ public bool ShowName {
+ get;
+ set;
+ }
+
public Time MaxTime {
set;
protected get;
@@ -155,6 +167,7 @@ namespace LongoMatch.Drawing.CanvasObjects
break;
}
}
+ movingPos = sel.Position;
}
public override void Draw (IDrawingToolkit tk, Area area)
@@ -163,34 +176,54 @@ namespace LongoMatch.Drawing.CanvasObjects
if (!UpdateDrawArea (tk, area, Area)) {
return;
- };
+ }
tk.Begin ();
if (needle == null) {
- string path = Path.Combine (Config.IconsDir, StyleConf.TimelineNeedleUP);
+ string path = Path.Combine (Config.IconsDir, StyleConf.TimelineNeedleUP);
Image img = Image.LoadFromFile (path);
needle = tk.CreateSurface (img.Width, img.Height, img);
}
- tk.FillColor = Config.Style.PaletteBackgroundLight;
- tk.StrokeColor = Config.Style.PaletteBackgroundLight;
+ if (Selected) {
+ tk.FillColor = Config.Style.PaletteActive;
+ tk.StrokeColor = Config.Style.PaletteActive;
+ } else {
+ tk.FillColor = LineColor;
+ tk.StrokeColor = LineColor;
+ }
tk.LineWidth = StyleConf.TimelineLineSize;
linepos = OffsetY + Height - StyleConf.TimelineLineSize;
- tk.DrawLine (new Point (StartX, linepos),
- new Point (StopX, linepos));
- tk.DrawSurface (needle, new Point (StartX - needle.Width / 2, linepos - 9));
- tk.DrawSurface (needle, new Point (StopX - needle.Width / 2, linepos - 9));
-
- tk.FontSize = 16;
- tk.FontWeight = FontWeight.Bold;
- tk.FillColor = Config.Style.PaletteActive;
- tk.StrokeColor = Config.Style.PaletteActive;
- tk.DrawText (new Point (StartX, OffsetY), StopX - StartX,
- Height - StyleConf.TimelineLineSize,
- TimeNode.Name);
+ if (StopX - StartX <= needle.Width / 2) {
+ double c = movingPos == SelectionPosition.Left ? StopX : StartX;
+ tk.DrawSurface (needle, new Point (c - needle.Width / 2, linepos - 9));
+ } else {
+ tk.DrawLine (new Point (StartX, linepos),
+ new Point (StopX, linepos));
+ tk.DrawSurface (needle, new Point (StartX - needle.Width / 2, linepos - 9));
+ tk.DrawSurface (needle, new Point (StopX - needle.Width / 2, linepos - 9));
+ }
+
+
+ if (ShowName) {
+ tk.FontSize = 16;
+ tk.FontWeight = FontWeight.Bold;
+ tk.FillColor = Config.Style.PaletteActive;
+ tk.StrokeColor = Config.Style.PaletteActive;
+ tk.DrawText (new Point (StartX, OffsetY), StopX - StartX,
+ Height - StyleConf.TimelineLineSize,
+ TimeNode.Name);
+ }
tk.End ();
}
}
+
+ public class TimerTimeNodeObject: TimeNodeObject
+ {
+ public TimerTimeNodeObject (TimeNode tn): base (tn)
+ {
+ }
+ }
}
diff --git a/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
index 3843f9a..1e1a462 100644
--- a/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
+++ b/LongoMatch.Drawing/CanvasObjects/TimelineObject.cs
@@ -29,8 +29,8 @@ namespace LongoMatch.Drawing.CanvasObjects
{
public abstract class TimelineObject: CanvasObject, ICanvasSelectableObject
{
- List<TimeNodeObject> nodes;
double secondsPerPixel;
+ protected List<TimeNodeObject> nodes;
protected Time maxTime;
protected ISurface selectionBorderL, selectionBorderR;
@@ -223,6 +223,11 @@ namespace LongoMatch.Drawing.CanvasObjects
}
}
+ public PlayObject Load (TimelineEvent evt)
+ {
+ return nodes.FirstOrDefault (n => (n as PlayObject).Play == evt) as PlayObject;
+ }
+
protected override bool TimeNodeObjectIsVisible (TimeNodeObject tn)
{
return filter.IsVisible ((tn as PlayObject).Play);
@@ -243,33 +248,74 @@ namespace LongoMatch.Drawing.CanvasObjects
public class TimerTimeline: TimelineObject
{
- public TimerTimeline (List<Timer> timers, Time maxTime, double offsetY, Color background):
+ public TimerTimeline (List<Timer> timers, bool showName, bool selectWhole, bool showLine,
+ Time maxTime, double offsetY, Color background, Color lineColor):
base (maxTime, offsetY, background)
{
+ ShowName = showName;
+ SelectWhole = selectWhole;
+ ShowLine = showLine;
+ LineColor = lineColor;
+
foreach (Timer t in timers) {
foreach (TimeNode tn in t.Nodes) {
- TimeNodeObject to = new TimeNodeObject (tn);
- to.OffsetY = OffsetY;
- to.SecondsPerPixel = SecondsPerPixel;
- to.MaxTime = maxTime;
- to.SelectWhole = false;
- AddNode (to);
+ AddTimeNode (tn);
}
}
}
+
+ Color LineColor {
+ get;
+ set;
+ }
+
+ bool ShowLine {
+ get;
+ set;
+ }
+
+ bool ShowName {
+ get;
+ set;
+ }
+ bool SelectWhole {
+ get;
+ set;
+ }
+
+ public bool HasNode (TimeNode tn)
+ {
+ return nodes.FirstOrDefault (n => n.TimeNode == tn) != null;
+ }
+
+ public void AddTimeNode (TimeNode tn)
+ {
+ TimerTimeNodeObject to = new TimerTimeNodeObject (tn);
+ to.OffsetY = OffsetY;
+ to.SecondsPerPixel = SecondsPerPixel;
+ to.MaxTime = maxTime;
+ to.SelectWhole = SelectWhole;
+ to.ShowName = ShowName;
+ to.LineColor = LineColor;
+ AddNode (to);
+ }
+
protected override void DrawBackground (IDrawingToolkit tk, Area area)
{
double linepos;
base.DrawBackground (tk, area);
- linepos = OffsetY + Height - StyleConf.TimelineLineSize;
+ if (ShowLine) {
+ Color c;
- tk.FillColor = Config.Style.PaletteBackgroundDark;
- tk.StrokeColor = Config.Style.PaletteBackgroundDark;
- tk.LineWidth = 4;
- tk.DrawLine (new Point (0, linepos),
- new Point (Width, linepos));
+ linepos = OffsetY + Height - StyleConf.TimelineLineSize;
+ tk.FillColor = Config.Style.PaletteBackgroundDark;
+ tk.StrokeColor = Config.Style.PaletteBackgroundDark;
+ tk.LineWidth = 4;
+ tk.DrawLine (new Point (0, linepos),
+ new Point (Width, linepos));
+ }
}
}
}
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.csproj b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
index d1dd21d..43683a9 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.csproj
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
@@ -32,9 +32,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Canvas.cs" />
- <Compile Include="CanvasObjects\CategoryLabel.cs" />
<Compile Include="Widgets\Timerule.cs" />
- <Compile Include="Widgets\CategoriesLabels.cs" />
<Compile Include="CanvasObjects\PlayObject.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Widgets\PlaysTimeline.cs" />
@@ -67,6 +65,8 @@
<Compile Include="PlayslistCellRenderer.cs" />
<Compile Include="Widgets\DashboardCanvas.cs" />
<Compile Include="CanvasObjects\ButtonObject.cs" />
+ <Compile Include="CanvasObjects\LabelObject.cs" />
+ <Compile Include="Widgets\TimelineLabels.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
diff --git a/LongoMatch.Drawing/Makefile.am b/LongoMatch.Drawing/Makefile.am
index e25f19f..d20b93f 100644
--- a/LongoMatch.Drawing/Makefile.am
+++ b/LongoMatch.Drawing/Makefile.am
@@ -9,12 +9,12 @@ SOURCES = Canvas.cs \
CanvasObjects/ButtonObject.cs \
CanvasObjects/CanvasObject.cs \
CanvasObjects/CardObject.cs \
- CanvasObjects/CategoryLabel.cs \
CanvasObjects/CategoryObject.cs \
CanvasObjects/CounterObject.cs \
CanvasObjects/CrossObject.cs \
CanvasObjects/EllipseObject.cs \
CanvasObjects/FieldObject.cs \
+ CanvasObjects/LabelObject.cs \
CanvasObjects/LineObject.cs \
CanvasObjects/PlayObject.cs \
CanvasObjects/PlayerObject.cs \
@@ -33,11 +33,11 @@ SOURCES = Canvas.cs \
PlayslistCellRenderer.cs \
Utils.cs \
Widgets/Blackboard.cs \
- Widgets/CategoriesLabels.cs \
Widgets/DashboardCanvas.cs \
Widgets/PlaysTimeline.cs \
Widgets/PositionTagger.cs \
Widgets/TeamTagger.cs \
+ Widgets/TimelineLabels.cs \
Widgets/TimersTimeline.cs \
Widgets/Timerule.cs
diff --git a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
index 7cd7e7a..f082611 100644
--- a/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/PlaysTimeline.cs
@@ -31,21 +31,27 @@ namespace LongoMatch.Drawing.Widgets
{
public event ShowTimelineMenuHandler ShowMenuEvent;
+ public event ShowTimersMenuHandler ShowTimersMenuEvent;
Project project;
EventsFilter playsFilter;
double secondsPerPixel;
Time duration;
+ TimelineEvent loadedEvent;
+ TimerTimeline periodsTimeline;
+ Dictionary<TimelineObject, object> timelineToFilter;
Dictionary<EventType, CategoryTimeline> eventsTimelines;
public PlaysTimeline (IWidget widget): base(widget)
{
eventsTimelines = new Dictionary<EventType, CategoryTimeline> ();
+ timelineToFilter = new Dictionary<TimelineObject, object> ();
secondsPerPixel = 0.1;
Accuracy = Constants.TIMELINE_ACCURACY;
SelectionMode = MultiSelectionMode.MultipleWithModifier;
+ SingleSelectionObjects.Add (typeof (TimerTimeNodeObject));
}
-
+
protected override void Dispose (bool disposing)
{
foreach (CategoryTimeline ct in eventsTimelines.Values) {
@@ -71,7 +77,7 @@ namespace LongoMatch.Drawing.Widgets
public Time CurrentTime {
set {
- foreach (CategoryTimeline tl in eventsTimelines.Values) {
+ foreach (TimelineObject tl in Objects) {
tl.CurrentTime = value;
}
}
@@ -87,11 +93,37 @@ namespace LongoMatch.Drawing.Widgets
}
}
+ public void LoadPlay (TimelineEvent play)
+ {
+ if (play == this.loadedEvent) {
+ return;
+ }
+
+ foreach (CategoryTimeline tl in eventsTimelines.Values) {
+ PlayObject loaded = tl.Load (play);
+ if (loaded != null) {
+ ClearSelection ();
+ UpdateSelection (new Selection (loaded, SelectionPosition.All, 0),
false);
+ break;
+ }
+ }
+ }
+
public void AddPlay (TimelineEvent play)
{
eventsTimelines [play.EventType].AddPlay (play);
}
+ public void RemoveTimers (List<TimeNode> nodes)
+ {
+ foreach (TimerTimeline tl in Objects.OfType<TimerTimeline>()) {
+ foreach (TimeNode node in nodes) {
+ tl.RemoveNode (node);
+ }
+ }
+ widget.ReDraw ();
+ }
+
public void RemovePlays (List<TimelineEvent> plays)
{
foreach (TimelineEvent p in plays) {
@@ -104,23 +136,46 @@ namespace LongoMatch.Drawing.Widgets
{
double width = duration.Seconds / SecondsPerPixel;
widget.Width = width + 10;
- foreach (TimelineObject tl in eventsTimelines.Values) {
+ foreach (TimelineObject tl in Objects) {
tl.Width = width + 10;
tl.SecondsPerPixel = SecondsPerPixel;
}
}
+ void AddTimeline (TimelineObject tl, object filter)
+ {
+ AddObject (tl);
+ timelineToFilter[tl] = filter;
+ if (tl is CategoryTimeline) {
+ eventsTimelines [filter as EventType] = tl as CategoryTimeline;
+ }
+ }
+
void FillCanvas ()
{
- CategoryTimeline tl;
+ TimelineObject tl;
int i = 0;
+ tl = new TimerTimeline (project.Periods.Select (p => p as Timer).ToList(),
+ false, true, false, duration,
+ i * StyleConf.TimelineCategoryHeight,
+ Utils.ColorForRow (i), Config.Style.PaletteBackgroundDark);
+ AddTimeline (tl, null);
+ periodsTimeline = tl as TimerTimeline;
+ i++;
+
+ foreach (Timer t in project.Timers) {
+ tl = new TimerTimeline (new List<Timer> {t}, false, true, false, duration,
+ i * StyleConf.TimelineCategoryHeight,
+ Utils.ColorForRow (i), Config.Style.PaletteBackgroundDark);
+ AddTimeline (tl, t);
+ }
+
foreach (EventType type in project.EventTypes) {
tl = new CategoryTimeline (project.EventsByType (type), duration,
i * StyleConf.TimelineCategoryHeight,
Utils.ColorForRow (i), playsFilter);
- eventsTimelines [type] = tl;
- AddObject (tl);
+ AddTimeline (tl, type);
i++;
}
UpdateVisibleCategories ();
@@ -130,9 +185,8 @@ namespace LongoMatch.Drawing.Widgets
void UpdateVisibleCategories ()
{
int i = 0;
- foreach (EventType type in project.EventTypes) {
- CategoryTimeline timeline = eventsTimelines [type];
- if (playsFilter.VisibleEventTypes.Contains (type)) {
+ foreach (TimelineObject timeline in Objects) {
+ if (playsFilter.IsVisible (timelineToFilter[timeline])) {
timeline.OffsetY = i * timeline.Height;
timeline.Visible = true;
timeline.BackgroundColor = Utils.ColorForRow (i);
@@ -144,18 +198,51 @@ namespace LongoMatch.Drawing.Widgets
widget.ReDraw ();
}
- void RedrawSelection (Selection sel)
+ void ShowTimersMenu (Point coords)
{
- PlayObject po = sel.Drawable as PlayObject;
- widget.ReDraw (eventsTimelines [po.Play.EventType]);
+ List<TimeNode> nodes = Selections.Select (p => (p.Drawable as
TimeNodeObject).TimeNode).ToList ();
+ if (nodes.Count > 0 && ShowTimersMenuEvent != null) {
+ /* Periods are not deletable */
+ if (!periodsTimeline.HasNode (nodes[0])) {
+ ShowTimersMenuEvent (nodes);
+ }
+ }
+ }
+
+ void ShowPlaysMenu (Point coords) {
+ EventType ev = null;
+ List<TimelineEvent> plays;
+
+ plays = Selections.Select (p => (p.Drawable as PlayObject).Play).ToList ();
+
+ foreach (EventType evType in eventsTimelines.Keys) {
+ TimelineObject tl;
+
+ tl = eventsTimelines [evType];
+ if (!tl.Visible)
+ continue;
+ if (coords.Y >= tl.OffsetY && coords.Y < tl.OffsetY + tl.Height) {
+ ev = evType;
+ break;
+ }
+ }
+
+ if ((ev != null || plays.Count > 0) && ShowMenuEvent != null) {
+ ShowMenuEvent (plays, ev, Utils.PosToTime (coords, SecondsPerPixel));
+ }
}
protected override void SelectionChanged (List<Selection> selections)
{
+ TimelineEvent ev = null;
if (selections.Count > 0) {
- PlayObject po = selections.Last ().Drawable as PlayObject;
- Config.EventsBroker.EmitLoadEvent (po.Play);
+ CanvasObject d = selections.Last ().Drawable as CanvasObject;
+ if (d is PlayObject) {
+ ev = (d as PlayObject).Play;
+ loadedEvent = ev;
+ }
}
+ Config.EventsBroker.EmitLoadEvent (ev);
}
protected override void StartMove (Selection sel)
@@ -175,39 +262,44 @@ namespace LongoMatch.Drawing.Widgets
protected override void ShowMenu (Point coords)
{
- EventType ev = null;
- List<TimelineEvent> plays = Selections.Select (p => (p.Drawable as
PlayObject).Play).ToList ();
-
- foreach (EventType evType in eventsTimelines.Keys) {
- TimelineObject tl;
-
- tl = eventsTimelines [evType];
- if (!tl.Visible)
- continue;
- if (coords.Y >= tl.OffsetY && coords.Y < tl.OffsetY + tl.Height) {
- ev = evType;
- break;
+ if (Selections.Count > 0) {
+ if (Selections.Last ().Drawable is PlayObject) {
+ ShowPlaysMenu (coords);
+ } else {
+ ShowTimersMenu (coords);
}
}
-
- if ((ev != null || plays.Count > 0) && ShowMenuEvent != null) {
- ShowMenuEvent (plays, ev, Utils.PosToTime (coords, SecondsPerPixel));
- }
}
protected override void SelectionMoved (Selection sel)
{
Time moveTime;
- TimelineEvent play = (sel.Drawable as PlayObject).Play;
+ CanvasObject co;
+ TimelineEvent play;
- if (sel.Position == SelectionPosition.Right) {
- moveTime = play.Stop;
- } else {
- moveTime = play.Start;
+ co = (sel.Drawable as CanvasObject);
+
+ if (co is PlayObject) {
+ play = (co as PlayObject).Play;
+
+ if (sel.Position == SelectionPosition.Right) {
+ moveTime = play.Stop;
+ } else {
+ moveTime = play.Start;
+ }
+ Config.EventsBroker.EmitTimeNodeChanged (play, moveTime);
+ } else if (co is TimeNodeObject) {
+ TimeNode to = (co as TimeNodeObject).TimeNode;
+
+ if (sel.Position == SelectionPosition.Right) {
+ moveTime = to.Stop;
+ } else {
+ moveTime = to.Start;
+ }
+ Config.EventsBroker.EmitSeekEvent (moveTime, true);
}
- Config.EventsBroker.EmitTimeNodeChanged (play, moveTime);
}
-
+
public override void Draw (IContext context, Area area)
{
tk.Context = context;
diff --git a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs b/LongoMatch.Drawing/Widgets/TimelineLabels.cs
similarity index 73%
rename from LongoMatch.Drawing/Widgets/CategoriesLabels.cs
rename to LongoMatch.Drawing/Widgets/TimelineLabels.cs
index 2360d27..6170185 100644
--- a/LongoMatch.Drawing/Widgets/CategoriesLabels.cs
+++ b/LongoMatch.Drawing/Widgets/TimelineLabels.cs
@@ -25,21 +25,21 @@ using Mono.Unix;
namespace LongoMatch.Drawing.Widgets
{
- public class CategoriesLabels: Canvas
+ public class TimelineLabels: Canvas
{
Project project;
EventsFilter filter;
- Dictionary<EventType, CategoryLabel> eventsLabels;
+ Dictionary<LabelObject, object> labelToObject;
- public CategoriesLabels (IWidget widget): base (widget)
+ public TimelineLabels (IWidget widget): base (widget)
{
- eventsLabels = new Dictionary<EventType, CategoryLabel> ();
+ labelToObject = new Dictionary<LabelObject, object>();
}
public double Scroll {
set {
foreach (var o in Objects) {
- CategoryLabel cl = o as CategoryLabel;
+ LabelObject cl = o as LabelObject;
cl.Scroll = value;
}
}
@@ -57,20 +57,36 @@ namespace LongoMatch.Drawing.Widgets
}
}
+ void AddLabel (LabelObject label, object obj)
+ {
+ Objects.Add (label);
+ labelToObject[label] = obj;
+ }
+
void FillCanvas ()
{
- CategoryLabel l;
+ LabelObject l;
int i = 0, w, h;
w = StyleConf.TimelineLabelsWidth;
h = StyleConf.TimelineCategoryHeight;
widget.Width = w;
-
+
+ l = new LabelObject (w, h, i * h);
+ l.Name = Catalog.GetString ("Periods");
+ AddLabel (l, null);
+ i++;
+
+ foreach (Timer t in project.Timers) {
+ l = new TimerLabelObject (t, w, h, i * h);
+ AddLabel (l, t);
+ i++;
+ }
+
foreach (EventType eventType in project.EventTypes) {
/* Add the category label */
- l = new CategoryLabel (eventType, w, h, i * h);
- eventsLabels [eventType] = l;
- AddObject (l);
+ l = new EventTypeLabelObject (eventType, w, h, i * h);
+ AddLabel (l, eventType);
i++;
}
}
@@ -78,10 +94,8 @@ namespace LongoMatch.Drawing.Widgets
void UpdateVisibleCategories ()
{
int i = 0;
-
- foreach (EventType type in project.EventTypes) {
- CategoryLabel label = eventsLabels [type];
- if (filter.VisibleEventTypes.Contains (type)) {
+ foreach (LabelObject label in Objects) {
+ if (filter.IsVisible (labelToObject[label])) {
label.OffsetY = i * label.Height;
label.Visible = true;
label.BackgroundColor = Utils.ColorForRow (i);
diff --git a/LongoMatch.Drawing/Widgets/TimersTimeline.cs b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
index a4bdf65..8c7c058 100644
--- a/LongoMatch.Drawing/Widgets/TimersTimeline.cs
+++ b/LongoMatch.Drawing/Widgets/TimersTimeline.cs
@@ -74,8 +74,9 @@ namespace LongoMatch.Drawing.Widgets
{
if (!splitTimers) {
widget.Height = Constants.TIMER_HEIGHT;
- TimerTimeline tl = new TimerTimeline (timers, duration, 0,
- Config.Style.PaletteBackground);
+ TimerTimeline tl = new TimerTimeline (timers, true, false, true, duration, 0,
+ Config.Style.PaletteBackground,
+ Config.Style.PaletteBackgroundLight);
foreach (Timer t in timers) {
this.timers [t] = tl;
}
diff --git a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
index 13b659a..7e98a2b 100644
--- a/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
+++ b/LongoMatch.GUI.Multimedia/Gui/PlayerBin.cs
@@ -333,7 +333,6 @@ namespace LongoMatch.Gui
//timescale.Sensitive = true;
loadedPlay = null;
ImageLoaded = false;
- Config.EventsBroker.EmitLoadEvent (null);
}
public void SetSensitive ()
@@ -747,7 +746,7 @@ namespace LongoMatch.Gui
void OnClosebuttonClicked (object sender, System.EventArgs e)
{
- CloseSegment ();
+ Config.EventsBroker.EmitLoadEvent (null);
Play ();
}
diff --git a/LongoMatch.GUI/Gui/Component/CodingWidget.cs b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
index 354e984..f0ff770 100644
--- a/LongoMatch.GUI/Gui/Component/CodingWidget.cs
+++ b/LongoMatch.GUI/Gui/Component/CodingWidget.cs
@@ -228,7 +228,7 @@ namespace LongoMatch.Gui.Component
void HandlePlayLoaded (TimelineEvent play)
{
loadedPlay = play;
- timeline.SelectedTimeNode = play;
+ timeline.LoadPlay (play);
}
void HandleCapturerTick (Time currentTime)
diff --git a/LongoMatch.GUI/Gui/Component/Timeline.cs b/LongoMatch.GUI/Gui/Component/Timeline.cs
index 691951c..3f08e15 100644
--- a/LongoMatch.GUI/Gui/Component/Timeline.cs
+++ b/LongoMatch.GUI/Gui/Component/Timeline.cs
@@ -34,10 +34,9 @@ namespace LongoMatch.Gui.Component
public partial class Timeline : Gtk.Bin
{
const uint TIMEOUT_MS = 100;
-
PlaysTimeline timeline;
Timerule timerule;
- CategoriesLabels labels;
+ TimelineLabels labels;
MediaFile projectFile;
double secondsPerPixel;
uint timeoutID;
@@ -49,8 +48,8 @@ namespace LongoMatch.Gui.Component
{
this.Build ();
this.timerule = new Timerule (new WidgetWrapper (timerulearea));
- this.timeline = new PlaysTimeline (new WidgetWrapper(timelinearea));
- this.labels = new CategoriesLabels (new WidgetWrapper (labelsarea));
+ this.timeline = new PlaysTimeline (new WidgetWrapper (timelinearea));
+ this.labels = new TimelineLabels (new WidgetWrapper (labelsarea));
focusbuttonimage.Pixbuf = Helpers.Misc.LoadIcon ("longomatch-dash-center-view",
Gtk.IconSize.Menu, 0);
@@ -71,7 +70,7 @@ namespace LongoMatch.Gui.Component
zoominimage.HeightRequest = zoomoutimage.HeightRequest = focusscale.HeightRequest =
16;
menu = new PlaysMenu ();
}
-
+
protected override void OnDestroyed ()
{
timerule.Dispose ();
@@ -79,12 +78,7 @@ namespace LongoMatch.Gui.Component
labels.Dispose ();
base.OnDestroyed ();
}
-
- public TimeNode SelectedTimeNode {
- set {
- }
- }
-
+
public Time CurrentTime {
set {
nextCurrentTime = value;
@@ -93,13 +87,14 @@ namespace LongoMatch.Gui.Component
return currentTime;
}
}
-
- public void SetProject (Project project, EventsFilter filter) {
+
+ public void SetProject (Project project, EventsFilter filter)
+ {
this.project = project;
timeline.LoadProject (project, filter);
labels.LoadProject (project, filter);
- if(project == null) {
+ if (project == null) {
if (timeoutID != 0) {
GLib.Source.Remove (timeoutID);
timeoutID = 0;
@@ -114,20 +109,29 @@ namespace LongoMatch.Gui.Component
projectFile = project.Description.FileSet.GetAngle (MediaFileAngle.Angle1);
timerule.Duration = project.Description.FileSet.GetAngle
(MediaFileAngle.Angle1).Duration;
timeline.ShowMenuEvent += HandleShowMenu;
+ timeline.ShowTimersMenuEvent += HandleShowTimersMenu;
QueueDraw ();
}
- public void AddPlay(TimelineEvent play) {
+ public void LoadPlay (TimelineEvent evt)
+ {
+ timeline.LoadPlay (evt);
+ }
+
+ public void AddPlay (TimelineEvent play)
+ {
timeline.AddPlay (play);
QueueDraw ();
}
- public void RemovePlays(List<TimelineEvent> plays) {
+ public void RemovePlays (List<TimelineEvent> plays)
+ {
timeline.RemovePlays (plays);
QueueDraw ();
}
-
- bool UpdateTime () {
+
+ bool UpdateTime ()
+ {
if (nextCurrentTime != currentTime) {
currentTime = nextCurrentTime;
timeline.CurrentTime = currentTime;
@@ -136,12 +140,12 @@ namespace LongoMatch.Gui.Component
}
return true;
}
-
- void HandleScrollEvent(object sender, System.EventArgs args)
+
+ void HandleScrollEvent (object sender, System.EventArgs args)
{
- if(sender == scrolledwindow1.Vadjustment)
+ if (sender == scrolledwindow1.Vadjustment)
labels.Scroll = scrolledwindow1.Vadjustment.Value;
- else if(sender == scrolledwindow1.Hadjustment)
+ else if (sender == scrolledwindow1.Hadjustment)
timerule.Scroll = scrolledwindow1.Hadjustment.Value;
QueueDraw ();
}
@@ -168,16 +172,31 @@ namespace LongoMatch.Gui.Component
secondsPer100Pixels = (value - 5) * 60;
}
- secondsPerPixel = secondsPer100Pixels / 100 ;
+ secondsPerPixel = secondsPer100Pixels / 100;
timerule.SecondsPerPixel = secondsPerPixel;
timeline.SecondsPerPixel = secondsPerPixel;
QueueDraw ();
}
-
+
void HandleShowMenu (List<TimelineEvent> plays, EventType eventType, Time time)
{
menu.ShowTimelineMenu (project, plays, eventType, time);
}
+
+ void HandleShowTimersMenu (List<TimeNode> nodes)
+ {
+ Menu m = new Menu ();
+ MenuItem item = new MenuItem (Catalog.GetString ("Delete"));
+ item.Activated += (object sender, EventArgs e) => {
+ foreach (Timer t in project.Timers) {
+ t.Nodes.RemoveAll (nodes.Contains);
+ }
+ timeline.RemoveTimers (nodes);
+ };
+ m.Add (item);
+ m.ShowAll ();
+ m.Popup ();
+ }
}
}
diff --git a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
index b849dd1..f44fe66 100644
--- a/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
+++ b/LongoMatch.GUI/Gui/Panel/NewProjectPanel.cs
@@ -319,7 +319,7 @@ namespace LongoMatch.Gui.Panel
project.Description.LocalName = project.LocalTeamTemplate.TeamName;
project.Description.VisitorName = project.VisitorTeamTemplate.TeamName;
project.Description.FileSet = mediafilesetselection1.FileSet;
- project.UpdateEventTypes ();
+ project.UpdateEventTypesAndTimers ();
encSettings = new EncodingSettings ();
captureSettings = new CaptureSettings ();
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
index 62b2123..da93f26 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.CodingWidget.cs
@@ -25,7 +25,7 @@ namespace LongoMatch.Gui.Component
this.notebook = new global::Gtk.Notebook ();
this.notebook.CanFocus = true;
this.notebook.Name = "notebook";
- this.notebook.CurrentPage = 0;
+ this.notebook.CurrentPage = 1;
this.notebook.TabPos = ((global::Gtk.PositionType)(0));
this.notebook.ShowBorder = false;
// Container child notebook.Gtk.Notebook+NotebookChild
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index ca6b2ed..d53e81e 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -5850,6 +5850,7 @@ You can continue with the current capture, cancel it or save your project.
<property name="MemberName" />
<property name="CanFocus">True</property>
<property name="Label" translatable="yes">Histogram</property>
+ <property name="Active">True</property>
<property name="DrawIndicator">True</property>
<property name="HasLabel">True</property>
<property name="UseUnderline">True</property>
@@ -10285,7 +10286,7 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Notebook" id="notebook">
<property name="MemberName" />
<property name="CanFocus">True</property>
- <property name="CurrentPage">0</property>
+ <property name="CurrentPage">1</property>
<property name="TabPos">Left</property>
<property name="ShowBorder">False</property>
<child>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index fa09382..16f2d0b 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -307,7 +307,6 @@ namespace LongoMatch.Services
openedProject.RemovePlays (plays);
if (projectType == ProjectType.FileProject) {
- player.CloseSegment ();
Save (openedProject);
}
filter.Update ();
@@ -347,7 +346,7 @@ namespace LongoMatch.Services
void HandleDashboardEditedEvent ()
{
- openedProject.UpdateEventTypes ();
+ openedProject.UpdateEventTypesAndTimers ();
analysisWindow.ReloadProject ();
}
diff --git a/LongoMatch.Services/Services/PlaylistManager.cs b/LongoMatch.Services/Services/PlaylistManager.cs
index be326dc..1547000 100644
--- a/LongoMatch.Services/Services/PlaylistManager.cs
+++ b/LongoMatch.Services/Services/PlaylistManager.cs
@@ -57,6 +57,7 @@ namespace LongoMatch.Services
Config.EventsBroker.PlaylistElementSelectedEvent += HandlePlaylistElementSelected;
Config.EventsBroker.PlaybackRateChanged += HandlePlaybackRateChanged;
Config.EventsBroker.TimeNodeChanged += HandlePlayChanged;
+ Config.EventsBroker.SeekEvent += HandleSeekEvent;
}
void LoadPlay (TimelineEvent play, Time seekTime, bool playing)
@@ -124,6 +125,8 @@ namespace LongoMatch.Services
Switch (play, null, null);
if (play != null) {
LoadPlay (play, play.Start, true);
+ } else {
+ player.CloseSegment ();
}
Config.EventsBroker.EmitEventLoaded (play);
}
@@ -200,5 +203,12 @@ namespace LongoMatch.Services
foreach (Job job in jobs)
videoRenderer.AddJob (job);
}
+
+ void HandleSeekEvent (Time pos, bool accurate)
+ {
+ if (player != null) {
+ player.Seek (pos, accurate);
+ }
+ }
}
}
diff --git a/LongoMatch.Services/Services/ProjectsManager.cs b/LongoMatch.Services/Services/ProjectsManager.cs
index b17ec63..b564dfb 100644
--- a/LongoMatch.Services/Services/ProjectsManager.cs
+++ b/LongoMatch.Services/Services/ProjectsManager.cs
@@ -171,6 +171,7 @@ namespace LongoMatch.Services
Log.Debug ("Loading project " + project.ID + " " + projectType);
PlaysFilter = new EventsFilter (project);
+ project.CleanupTimers ();
guiToolkit.OpenProject (project, projectType, props, PlaysFilter,
out analysisWindow);
Player = analysisWindow.Player;
@@ -374,7 +375,7 @@ namespace LongoMatch.Services
return;
}
}
- project.UpdateEventTypes ();
+ project.UpdateEventTypesAndTimers ();
SetProject (project, ProjectType.FileProject, new CaptureSettings ());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]