[longomatch] Add offset in the camera label, support frame by frame sync.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add offset in the camera label, support frame by frame sync.
- Date: Wed, 18 Mar 2015 14:43:58 +0000 (UTC)
commit 0470edbb189625749d0534aa2b49f32450772df2
Author: Julien Moutte <julien fluendo com>
Date: Sun Mar 15 11:05:29 2015 +0100
Add offset in the camera label, support frame by frame sync.
Hot Keys for nex/prev frame will trigger frame by frame sync for the secondary player. We show the offset
in the label using markup.
LongoMatch.GUI/Gui/Component/ProjectPeriods.cs | 104 ++++++++++++++------
.../LongoMatch.Gui.Component.ProjectPeriods.cs | 1 +
LongoMatch.GUI/gtk-gui/gui.stetic | 1 +
3 files changed, 76 insertions(+), 30 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
index d0b196f..8103a63 100644
--- a/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
+++ b/LongoMatch.GUI/Gui/Component/ProjectPeriods.cs
@@ -100,6 +100,7 @@ namespace LongoMatch.Gui.Component
// Listen for seek events from the timerule
Config.EventsBroker.SeekEvent += Seek;
+ Config.EventsBroker.KeyPressed += HandleKeyPressed;
// Handle dragging of cameras and periods
camerasTimeline.CameraDragged += HandleCameraDragged;
camerasTimeline.SelectedCameraChanged += HandleSelectedCameraChanged;
@@ -307,6 +308,44 @@ namespace LongoMatch.Gui.Component
}
}
+ void HandleKeyPressed (object sender, HotKey key)
+ {
+ KeyAction action;
+
+ try {
+ action = Config.Hotkeys.ActionsHotkeys.GetKeyByValue (key);
+ } catch (Exception ex) {
+ /* The dictionary contains 2 equal values for different keys */
+ Log.Exception (ex);
+ return;
+ }
+
+ if (action == KeyAction.None) {
+ return;
+ }
+
+ switch (action) {
+ case KeyAction.FrameUp:
+ case KeyAction.FrameDown:
+ CameraObject camera = camerasTimeline.SelectedCamera;
+ if (camera != null) {
+ Pause ();
+ Time before = sec_cam_playerbin.CurrentTime;
+ if (action == KeyAction.FrameUp)
+ sec_cam_playerbin.SeekToNextFrame ();
+ else
+ sec_cam_playerbin.SeekToPreviousFrame ();
+ Time diff = sec_cam_playerbin.CurrentTime - before;
+
+ // Reflect change in offset
+ camera.MediaFile.Offset += diff.MSeconds;
+ UpdateLabels ();
+ // TODO: Reflect the change in the timeline position without
triggering a seek.
+ }
+ return;
+ }
+ }
+
/// <summary>
/// Configure players' audio volume based on toggle buttons.
/// </summary>
@@ -405,33 +444,46 @@ namespace LongoMatch.Gui.Component
}
}
- void HandleSelectedCameraChanged (object sender, EventArgs args)
+ void UpdateLabels ()
{
CameraObject camera = camerasTimeline.SelectedCamera;
+
if (camera != null) {
- // If we are in scope, show player. Didactic message otherwise
- if (IsInScope (camera)) {
- // Check if we need to reopen the player
- if (!sec_cam_playerbin.Opened ||
- sec_cam_playerbin.MediaFileSet.FirstOrDefault () !=
camera.MediaFile) {
- MediaFileSet fileSet = new MediaFileSet ();
- fileSet.Add (camera.MediaFile);
+ sec_cam_label.Markup = String.Format ("<b>{0}</b> - <span foreground=\"red\"
size=\"smaller\">{1}: {2}</span>", camera.MediaFile.Name, Catalog.GetString ("Offset"),
camera.MediaFile.Offset.ToMSecondsString ());
+ }
+ }
+
+ void HandleCameraUpdate (CameraObject camera)
+ {
+ UpdateLabels ();
+ // If we are in scope, show player. Didactic message otherwise
+ if (IsInScope (camera)) {
+ ShowSecondaryPlayer ();
+ // And resync
+ SyncSecondaryPlayer ();
+ } else {
+ ShowDidactic (DidacticMessage.CameraOutOfScope);
+ }
+ }
- // Reload player with new cam
- sec_cam_label.Text = camera.MediaFile.Name;
- sec_cam_playerbin.ShowControls = false;
- sec_cam_playerbin.Open (fileSet);
+ void HandleSelectedCameraChanged (object sender, EventArgs args)
+ {
+ CameraObject camera = camerasTimeline.SelectedCamera;
+ if (camera != null) {
+ // Check if we need to reopen the player
+ if (!sec_cam_playerbin.Opened ||
+ sec_cam_playerbin.MediaFileSet.FirstOrDefault () != camera.MediaFile)
{
+ MediaFileSet fileSet = new MediaFileSet ();
+ fileSet.Add (camera.MediaFile);
- // Configure audio
- HandleAudioToggled (sec_cam_audio_button, new EventArgs ());
+ sec_cam_playerbin.ShowControls = false;
+ sec_cam_playerbin.Open (fileSet);
- // And resync
- SyncSecondaryPlayer ();
- }
- ShowSecondaryPlayer ();
- } else {
- ShowDidactic (DidacticMessage.CameraOutOfScope);
+ // Configure audio
+ HandleAudioToggled (sec_cam_audio_button, new EventArgs ());
}
+ // And update
+ HandleCameraUpdate (camera);
} else {
// When no camera is selected show the initial didactic message.
ShowDidactic (DidacticMessage.Initial);
@@ -442,16 +494,8 @@ namespace LongoMatch.Gui.Component
{
// Start by pausing players
Pause ();
-
- // Check if the CurrentTime of the time rule is in that node
- if (IsInScope (camerasTimeline.SelectedCamera)) {
- // Show the player if needed
- ShowSecondaryPlayer ();
- // Seek to position accurately.
- sec_cam_playerbin.Seek (timerule.CurrentTime, true);
- } else {
- ShowDidactic (DidacticMessage.CameraOutOfScope);
- }
+ // And update
+ HandleCameraUpdate (camerasTimeline.SelectedCamera);
}
/// <summary>
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
index 3df7171..d9f1995 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Component.ProjectPeriods.cs
@@ -156,6 +156,7 @@ namespace LongoMatch.Gui.Component
this.sec_cam_label = new global::Gtk.Label ();
this.sec_cam_label.Name = "sec_cam_label";
this.sec_cam_label.Xalign = 0F;
+ this.sec_cam_label.UseMarkup = true;
this.sec_cam_hbox.Add (this.sec_cam_label);
global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.sec_cam_hbox
[this.sec_cam_label]));
w9.Position = 0;
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index bed65a1..4d90416 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -9768,6 +9768,7 @@ You can continue with the current capture, cancel it or save your project.
<widget class="Gtk.Label" id="sec_cam_label">
<property name="MemberName" />
<property name="Xalign">0</property>
+ <property name="UseMarkup">True</property>
</widget>
<packing>
<property name="Position">0</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]