[longomatch] Add game units timeline
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add game units timeline
- Date: Sun, 18 Dec 2011 21:41:40 +0000 (UTC)
commit 777c32531c3752c250eefd9a8c2eda26a79c69fd
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date: Tue Nov 29 22:42:33 2011 +0100
Add game units timeline
LongoMatch.GUI/Gui/MainWindow.cs | 64 ++++++++++++++++---
.../gtk-gui/LongoMatch.Gui.MainWindow.cs | 14 ++++-
LongoMatch.GUI/gtk-gui/gui.stetic | 15 ++++-
LongoMatch.Services/Services/GameUnitsManager.cs | 32 ++++++++++-
4 files changed, 110 insertions(+), 15 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index b0a389b..1d7b587 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -83,11 +83,16 @@ namespace LongoMatch.Gui
/* Game Units events */
public event GameUnitHandler GameUnitEvent;
+ public event UnitChangedHandler UnitChanged;
+ public event UnitSelectedHandler UnitSelected;
+ public event UnitsDeletedHandler UnitDeleted;
+ public event UnitAddedHandler UnitAdded;
private static Project openedProject;
private ProjectType projectType;
private TimeNode selectedTimeNode;
TimeLineWidget timeline;
+ GameUnitsTimelineWidget guTimeline;
#region Constructors
public MainWindow() :
@@ -100,15 +105,16 @@ namespace LongoMatch.Gui
timeline = new TimeLineWidget();
downbox.PackStart(timeline, true, true, 0);
+ guTimeline = new GameUnitsTimelineWidget ();
+ downbox.PackStart(guTimeline, true, true, 0);
+
player.SetLogo(System.IO.Path.Combine(Config.ImagesDir(),"background.png"));
player.LogoMode = true;
player.Tick += OnTick;
capturer.Visible = false;
capturer.Logo = System.IO.Path.Combine(Config.ImagesDir(),"background.png");
- capturer.CaptureFinished += delegate {
- CloseCaptureProject();
- };
+ capturer.CaptureFinished += (sender, e) => {CloseCaptureProject();};
buttonswidget.Mode = TagMode.Predifined;
localPlayersList.Team = Team.LOCAL;
@@ -244,6 +250,10 @@ namespace LongoMatch.Gui
/* Game Units event */
gameunitstaggerwidget1.GameUnitEvent += EmitGameUnitEvent;
+ guTimeline.UnitAdded += EmitUnitAdded;;
+ guTimeline.UnitDeleted += EmitUnitDeleted;
+ guTimeline.UnitSelected += EmitUnitSelected;
+ guTimeline.UnitChanged += EmitUnitChanged;
}
private void ConnectMenuSignals() {
@@ -279,6 +289,7 @@ namespace LongoMatch.Gui
" - " + Constants.SOFTWARE_NAME;
player.LogoMode = false;
timeline.Project = project;
+ guTimeline.Project = project;
} else {
Title = Constants.SOFTWARE_NAME;
@@ -346,6 +357,7 @@ namespace LongoMatch.Gui
SaveProjectAction.Sensitive = sensitive;
TaggingViewAction.Sensitive = sensitive2;
ManualTaggingViewAction.Sensitive = sensitive2;
+ GameUnitsViewAction.Sensitive = sensitive2;
TimelineViewAction.Sensitive = sensitive2;
ExportProjectToCSVFileAction.Sensitive = sensitive2;
HideAllWidgetsAction.Sensitive=sensitive2;
@@ -356,9 +368,12 @@ namespace LongoMatch.Gui
if(TaggingViewAction.Active || ManualTaggingViewAction.Active) {
buttonswidget.Show();
gameunitstaggerwidget1.Show();
- }
- else
+ } else if (TimelineViewAction.Active) {
timeline.Show();
+ } else if (GameUnitsViewAction.Active) {
+ gameunitstaggerwidget1.Show();
+ guTimeline.Show();
+ }
}
private void HideWidgets() {
@@ -367,6 +382,7 @@ namespace LongoMatch.Gui
buttonswidget.Hide();
timeline.Hide();
gameunitstaggerwidget1.Hide();
+ guTimeline.Hide();
}
private void ClearWidgets() {
@@ -476,6 +492,9 @@ namespace LongoMatch.Gui
timeline.Visible = !action.Active && TimelineViewAction.Active;
buttonswidget.Visible = !action.Active &&
(TaggingViewAction.Active || ManualTaggingViewAction.Active);
+ guTimeline.Visible = !action.Visible && GameUnitsViewAction.Active;
+ gameunitstaggerwidget1.Visible = !action.Active && (GameUnitsViewAction.Active ||
+ TaggingViewAction.Active || ManualTaggingViewAction.Active);
if(action.Active)
rightvbox.Visible = false;
else if(!action.Active && (playlist.Visible || notes.Visible))
@@ -484,11 +503,16 @@ namespace LongoMatch.Gui
protected virtual void OnViewToggled(object sender, System.EventArgs e)
{
- /* this callback is triggered by Capture and Free Capture */
- ToggleAction view = sender as Gtk.ToggleAction;
- buttonswidget.Visible = view.Active;
- timeline.Visible = !view.Active;
- if(view == ManualTaggingViewAction)
+ ToggleAction action = sender as Gtk.ToggleAction;
+
+ if (!action.Active)
+ return;
+
+ buttonswidget.Visible = action == ManualTaggingViewAction || sender == TaggingViewAction;
+ timeline.Visible = action == TimelineViewAction;
+ guTimeline.Visible = action == GameUnitsViewAction;
+ gameunitstaggerwidget1.Visible = buttonswidget.Visible || guTimeline.Visible;
+ if(action == ManualTaggingViewAction)
buttonswidget.Mode = TagMode.Free;
else
buttonswidget.Mode = TagMode.Predifined;
@@ -759,6 +783,26 @@ namespace LongoMatch.Gui
if (GameUnitEvent != null)
GameUnitEvent(gameUnit, eType);
}
+
+ private void EmitUnitAdded(GameUnit gameUnit, int frame) {
+ if (UnitAdded != null)
+ UnitAdded(gameUnit, frame);
+ }
+
+ private void EmitUnitDeleted(GameUnit gameUnit, List<TimelineNode> units) {
+ if (UnitDeleted != null)
+ UnitDeleted(gameUnit, units);
+ }
+
+ private void EmitUnitSelected(GameUnit gameUnit, TimelineNode unit) {
+ if (UnitSelected != null)
+ UnitSelected(gameUnit, unit);
+ }
+
+ private void EmitUnitChanged(GameUnit gameUnit, TimelineNode unit, Time time) {
+ if (UnitChanged != null)
+ UnitChanged(gameUnit, unit, time);
+ }
#endregion
}
}
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
index 5e5f98e..d0a68c2 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.MainWindow.cs
@@ -28,6 +28,7 @@ namespace LongoMatch.Gui
private global::Gtk.ToggleAction DrawingToolAction;
private global::Gtk.Action ImportProjectAction;
private global::Gtk.RadioAction ManualTaggingViewAction;
+ private global::Gtk.RadioAction GameUnitsViewAction;
private global::Gtk.VBox vbox1;
private global::Gtk.VBox menubox;
private global::Gtk.MenuBar menubar1;
@@ -138,10 +139,15 @@ namespace LongoMatch.Gui
this.ImportProjectAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("_Import Project");
w1.Add (this.ImportProjectAction, "<Control>i");
this.ManualTaggingViewAction = new global::Gtk.RadioAction ("ManualTaggingViewAction", global::Mono.Unix.Catalog.GetString ("Manual tagging view"), null, null, 0);
- this.ManualTaggingViewAction.Group = this.TaggingViewAction.Group;
+ this.ManualTaggingViewAction.Group = this.TimelineViewAction.Group;
this.ManualTaggingViewAction.Sensitive = false;
this.ManualTaggingViewAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Free Capture Mode");
w1.Add (this.ManualTaggingViewAction, "<Control>f");
+ this.GameUnitsViewAction = new global::Gtk.RadioAction ("GameUnitsViewAction", global::Mono.Unix.Catalog.GetString ("Game units view"), null, null, 0);
+ this.GameUnitsViewAction.Group = this.TimelineViewAction.Group;
+ this.GameUnitsViewAction.Sensitive = false;
+ this.GameUnitsViewAction.ShortLabel = global::Mono.Unix.Catalog.GetString ("Game units view");
+ w1.Add (this.GameUnitsViewAction, null);
this.UIManager.InsertActionGroup (w1, 0);
this.AddAccelGroup (this.UIManager.AccelGroup);
this.Name = "LongoMatch.Gui.MainWindow";
@@ -158,7 +164,7 @@ namespace LongoMatch.Gui
this.menubox.Name = "menubox";
this.menubox.Spacing = 6;
// Container child menubox.Gtk.Box+BoxChild
- this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='FileAction' action='FileAction'><menuitem name='NewPojectAction' action='NewPojectAction'/><menuitem name='openAction' action='openAction'/><menuitem name='SaveProjectAction' action='SaveProjectAction'/><menuitem name='CloseProjectAction' action='CloseProjectAction'/><separator/><menuitem name='ImportProjectAction' action='ImportProjectAction'/><separator/><menuitem name='QuitAction' action='QuitAction'/></menu><menu name='ToolsAction' action='ToolsAction'><menuitem name='ProjectsManagerAction' action='ProjectsManagerAction'/><menuitem name='CategoriesTemplatesManagerAction' action='CategoriesTemplatesManagerAction'/><menuitem name='TeamsTemplatesManagerAction' action='TeamsTemplatesManagerAction'/><menuitem name='ExportProjectToCSVFileAction' action='ExportProjectToCSVFileAction'/></menu><menu name='ViewAction' action='ViewAction'><menuitem name='FullScreenAction' action='FullScreenAction'/><menuit
em name='HideAllWidgetsAction' action='HideAllWidgetsAction'/><separator/><menuitem name='PlaylistAction' action='PlaylistAction'/><separator/><menuitem name='TaggingViewAction' action='TaggingViewAction'/><menuitem name='ManualTaggingViewAction' action='ManualTaggingViewAction'/><menuitem name='TimelineViewAction' action='TimelineViewAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='HelpAction1' action='HelpAction1'/></menu></menubar></ui>");
+ this.UIManager.AddUiFromString ("<ui><menubar name='menubar1'><menu name='FileAction' action='FileAction'><menuitem name='NewPojectAction' action='NewPojectAction'/><menuitem name='openAction' action='openAction'/><menuitem name='SaveProjectAction' action='SaveProjectAction'/><menuitem name='CloseProjectAction' action='CloseProjectAction'/><separator/><menuitem name='ImportProjectAction' action='ImportProjectAction'/><separator/><menuitem name='QuitAction' action='QuitAction'/></menu><menu name='ToolsAction' action='ToolsAction'><menuitem name='ProjectsManagerAction' action='ProjectsManagerAction'/><menuitem name='CategoriesTemplatesManagerAction' action='CategoriesTemplatesManagerAction'/><menuitem name='TeamsTemplatesManagerAction' action='TeamsTemplatesManagerAction'/><menuitem name='ExportProjectToCSVFileAction' action='ExportProjectToCSVFileAction'/></menu><menu name='ViewAction' action='ViewAction'><menuitem name='FullScreenAction' action='FullScreenAction'/><menuit
em name='HideAllWidgetsAction' action='HideAllWidgetsAction'/><separator/><menuitem name='PlaylistAction' action='PlaylistAction'/><separator/><menuitem name='TaggingViewAction' action='TaggingViewAction'/><menuitem name='ManualTaggingViewAction' action='ManualTaggingViewAction'/><menuitem name='TimelineViewAction' action='TimelineViewAction'/><menuitem name='GameUnitsViewAction' action='GameUnitsViewAction'/></menu><menu name='HelpAction' action='HelpAction'><menuitem name='AboutAction' action='AboutAction'/><menuitem name='HelpAction1' action='HelpAction1'/></menu></menubar></ui>");
this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1")));
this.menubar1.Name = "menubar1";
this.menubox.Add (this.menubar1);
@@ -359,7 +365,7 @@ namespace LongoMatch.Gui
this.Child.ShowAll ();
}
this.DefaultWidth = 1224;
- this.DefaultHeight = 670;
+ this.DefaultHeight = 681;
this.leftbox.Hide ();
this.drawingtoolbox1.Hide ();
this.buttonswidget.Hide ();
@@ -373,11 +379,13 @@ namespace LongoMatch.Gui
this.FullScreenAction.Toggled += new global::System.EventHandler (this.OnFullScreenActionToggled);
this.PlaylistAction.Toggled += new global::System.EventHandler (this.OnPlaylistActionToggled);
this.TaggingViewAction.Toggled += new global::System.EventHandler (this.OnViewToggled);
+ this.TimelineViewAction.Toggled += new global::System.EventHandler (this.OnViewToggled);
this.AboutAction.Activated += new global::System.EventHandler (this.OnAboutActionActivated);
this.HideAllWidgetsAction.Toggled += new global::System.EventHandler (this.OnHideAllWidgetsActionToggled);
this.HelpAction1.Activated += new global::System.EventHandler (this.OnHelpAction1Activated);
this.DrawingToolAction.Toggled += new global::System.EventHandler (this.OnDrawingToolActionToggled);
this.ManualTaggingViewAction.Toggled += new global::System.EventHandler (this.OnViewToggled);
+ this.GameUnitsViewAction.Toggled += new global::System.EventHandler (this.OnViewToggled);
this.playsList.TimeNodeSelected += new global::LongoMatch.Handlers.PlaySelectedHandler (this.OnTimeNodeSelected);
this.player.Error += new global::LongoMatch.Video.Common.ErrorHandler (this.OnPlayerbin1Error);
this.player.SegmentClosedEvent += new global::LongoMatch.Video.Common.SegmentClosedHandler (this.OnSegmentClosedEvent);
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 64a13c0..ff3d4f5 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -1587,7 +1587,7 @@
</widget>
</child>
</widget>
- <widget class="Gtk.Window" id="LongoMatch.Gui.MainWindow" design-size="1224 670">
+ <widget class="Gtk.Window" id="LongoMatch.Gui.MainWindow" design-size="1224 681">
<action-group name="Default">
<action id="FileAction">
<property name="Type">Action</property>
@@ -1683,6 +1683,7 @@
<property name="Active">True</property>
<property name="Value">0</property>
<property name="Group">group1</property>
+ <signal name="Toggled" handler="OnViewToggled" />
</action>
<action id="SaveProjectAction">
<property name="Type">Action</property>
@@ -1759,6 +1760,17 @@
<property name="Group">group1</property>
<signal name="Toggled" handler="OnViewToggled" />
</action>
+ <action id="GameUnitsViewAction">
+ <property name="Type">Radio</property>
+ <property name="Label" translatable="yes">Game units view</property>
+ <property name="Sensitive">False</property>
+ <property name="ShortLabel" translatable="yes">Game units view</property>
+ <property name="DrawAsRadio">False</property>
+ <property name="Active">False</property>
+ <property name="Value">0</property>
+ <property name="Group">group1</property>
+ <signal name="Toggled" handler="OnViewToggled" />
+ </action>
</action-group>
<property name="MemberName" />
<property name="Title" translatable="yes">LongoMatch</property>
@@ -1802,6 +1814,7 @@
<node type="Menuitem" action="TaggingViewAction" />
<node type="Menuitem" action="ManualTaggingViewAction" />
<node type="Menuitem" action="TimelineViewAction" />
+ <node type="Menuitem" action="GameUnitsViewAction" />
</node>
<node type="Menu" action="HelpAction">
<node type="Menuitem" action="AboutAction" />
diff --git a/LongoMatch.Services/Services/GameUnitsManager.cs b/LongoMatch.Services/Services/GameUnitsManager.cs
index c3af4bc..ee2b56b 100644
--- a/LongoMatch.Services/Services/GameUnitsManager.cs
+++ b/LongoMatch.Services/Services/GameUnitsManager.cs
@@ -39,8 +39,12 @@ namespace LongoMatch.Services
this.player = player;
gameUnitsStarted = new Dictionary<GameUnit, Time>();
mainWindow.GameUnitEvent += HandleMainWindowGameUnitEvent;
+ mainWindow.UnitAdded += HandleUnitAdded;
+ mainWindow.UnitChanged += HandleUnitChanged;
+ mainWindow.UnitDeleted += HandleUnitDeleted;
+ mainWindow.UnitSelected += HandleUnitSelected;
}
-
+
public Project OpenedProject{
set {
openedProject = value;
@@ -114,5 +118,31 @@ namespace LongoMatch.Services
}
}
}
+
+ void HandleUnitSelected (GameUnit gameUnit, TimelineNode unit)
+ {
+ unit.Selected = true;
+ }
+
+ void HandleUnitDeleted (GameUnit gameUnit, List<TimelineNode> units)
+ {
+ foreach (TimelineNode unit in units)
+ gameUnit.Remove(unit);
+ }
+
+ void HandleUnitChanged (GameUnit gameUnit, TimelineNode unit, Time time)
+ {
+ player.CloseActualSegment();
+ player.Pause();
+ player.SeekTo(time.MSeconds, true);
+ }
+
+ void HandleUnitAdded (GameUnit gameUnit, int frame)
+ {
+ var unit = new TimelineNode {Name=gameUnit.Name, Fps=openedProject.Description.File.Fps};
+ unit.StartFrame = (uint)(frame-50);
+ unit.StopFrame = (uint)(frame+50);
+ gameUnit.Add(unit);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]