[longomatch] Add a new CamerasTimeline widget.
- From: Andoni Morales Alastruey <amorales src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [longomatch] Add a new CamerasTimeline widget.
- Date: Wed, 18 Mar 2015 14:38:30 +0000 (UTC)
commit b7a131fd8d2e1a2428b288442e582b3be4e86a1b
Author: Julien Moutte <julien fluendo com>
Date: Tue Mar 10 19:36:25 2015 +0100
Add a new CamerasTimeline widget.
It will replace TimersTimeline widget when ready. Also add the CameraObject to the csproj file which I
forgot.
LongoMatch.Drawing/LongoMatch.Drawing.csproj | 7 +-
LongoMatch.Drawing/Makefile.am | 1 +
LongoMatch.Drawing/Widgets/CamerasTimeline.cs | 177 +++++++++++++++++++++++++
3 files changed, 181 insertions(+), 4 deletions(-)
---
diff --git a/LongoMatch.Drawing/LongoMatch.Drawing.csproj b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
index 99f6078..87aa27c 100644
--- a/LongoMatch.Drawing/LongoMatch.Drawing.csproj
+++ b/LongoMatch.Drawing/LongoMatch.Drawing.csproj
@@ -67,15 +67,14 @@
<Compile Include="CanvasObjects\LabelObject.cs" />
<Compile Include="Widgets\TimelineLabels.cs" />
<Compile Include="CanvasObjects\NeedleObject.cs" />
+ <Compile Include="CanvasObjects\CameraObject.cs" />
+ <Compile Include="Widgets\CamerasTimeline.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Mono.Posix" />
- <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <Private>False</Private>
- <Package>gtk-sharp-2.0</Package>
- </Reference>
+ <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\LongoMatch.Core\LongoMatch.Core.csproj">
diff --git a/LongoMatch.Drawing/Makefile.am b/LongoMatch.Drawing/Makefile.am
index 5010017..07510cc 100644
--- a/LongoMatch.Drawing/Makefile.am
+++ b/LongoMatch.Drawing/Makefile.am
@@ -35,6 +35,7 @@ SOURCES = Canvas.cs \
PlayslistCellRenderer.cs \
Utils.cs \
Widgets/Blackboard.cs \
+ Widgets/CamerasTimeline.cs \
Widgets/DashboardCanvas.cs \
Widgets/PlaysTimeline.cs \
Widgets/PositionTagger.cs \
diff --git a/LongoMatch.Drawing/Widgets/CamerasTimeline.cs b/LongoMatch.Drawing/Widgets/CamerasTimeline.cs
new file mode 100644
index 0000000..2a94fd8
--- /dev/null
+++ b/LongoMatch.Drawing/Widgets/CamerasTimeline.cs
@@ -0,0 +1,177 @@
+//
+// Copyright (C) 2014 Andoni Morales Alastruey
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+using System.Linq;
+using LongoMatch.Core.Store;
+using LongoMatch.Drawing.CanvasObjects;
+using LongoMatch.Core.Common;
+using LongoMatch.Core.Handlers;
+using LongoMatch.Core.Interfaces.Drawing;
+using LongoMatch.Core.Store.Drawables;
+using System.Collections.Generic;
+
+namespace LongoMatch.Drawing.Widgets
+{
+ public class CamerasTimeline: SelectionCanvas
+ {
+ public event TimeNodeChangedHandler TimeNodeChanged;
+ public event ShowTimerMenuHandler ShowTimerMenuEvent;
+
+ double secondsPerPixel;
+ Time duration;
+
+ List<TimelineObject> timelines;
+ List<Timer> timers;
+
+ MediaFileSet fileSet;
+
+ public CamerasTimeline (IWidget widget): base(widget)
+ {
+ secondsPerPixel = 0.1;
+ Accuracy = Constants.TIMELINE_ACCURACY;
+ SelectionMode = MultiSelectionMode.MultipleWithModifier;
+ }
+
+ public void Load (List<Period> periods, MediaFileSet fileSet, Time duration)
+ {
+ timelines = new List<TimelineObject> ();
+ // Store periods as a list of timers
+ this.timers = periods.Select (p => p as Timer).ToList ();
+ // And the file set
+ this.fileSet = fileSet;
+ this.duration = duration;
+
+ ClearObjects ();
+ FillCanvas ();
+ widget.ReDraw ();
+ }
+
+ public TimerTimeline TimerTimeline {
+ get {
+ return PeriodsTimeline;
+ }
+ }
+
+ public TimerTimeline PeriodsTimeline {
+ get;
+ set;
+ }
+
+ public Time CurrentTime {
+ set {
+ foreach (TimelineObject tl in timelines) {
+ tl.CurrentTime = value;
+ }
+ }
+ }
+
+ public double SecondsPerPixel {
+ set {
+ secondsPerPixel = value;
+ Update ();
+ }
+ get {
+ return secondsPerPixel;
+ }
+ }
+
+ void Update ()
+ {
+ double width;
+
+ if (duration == null)
+ return;
+ width = duration.TotalSeconds / SecondsPerPixel;
+ widget.Width = width + 10;
+ foreach (TimelineObject tl in timelines) {
+ tl.Width = width + 10;
+ tl.SecondsPerPixel = SecondsPerPixel;
+ }
+ }
+
+ void AddTimeLine (TimelineObject tl)
+ {
+ AddObject (tl);
+ timelines.Add (tl);
+ }
+
+ void FillCanvas ()
+ {
+ // Calculate height depending on number of cameras - 1 (for the main camera) + the
line for periods
+ widget.Height = Constants.TIMER_HEIGHT * fileSet.Count;
+
+ // Add the timeline for periods
+ PeriodsTimeline = new TimerTimeline (timers, true, NodeSelectionMode.All, true,
duration, 0,
+ Config.Style.PaletteBackground,
+ Config.Style.PaletteBackgroundLight);
+ AddTimeLine (PeriodsTimeline);
+
+ // And for the cameras
+ for (int i = 1; i < fileSet.Count; i++) {
+ CameraTimeline cameraTimeLine = new CameraTimeline (fileSet [i], true,
NodeSelectionMode.Segment, true, duration, i * StyleConf.TimelineCategoryHeight,
+ Config.Style.PaletteBackground,
+ Config.Style.PaletteBackgroundLight);
+ AddTimeLine (cameraTimeLine);
+ }
+ Update ();
+ }
+
+ protected override void StartMove (Selection sel)
+ {
+ if (sel == null)
+ return;
+
+ if (sel.Position == SelectionPosition.All) {
+ widget.SetCursor (CursorType.Selection);
+ } else {
+ widget.SetCursor (CursorType.DoubleArrow);
+ }
+ }
+
+ protected override void StopMove (bool moved)
+ {
+ widget.SetCursor (CursorType.Arrow);
+ }
+
+ protected override void SelectionMoved (Selection sel)
+ {
+ if (TimeNodeChanged != null) {
+ Time moveTime;
+ TimeNode tn = (sel.Drawable as TimeNodeObject).TimeNode;
+
+ if (sel.Position == SelectionPosition.Right) {
+ moveTime = tn.Stop;
+ } else {
+ moveTime = tn.Start;
+ }
+ TimeNodeChanged (tn, moveTime);
+ }
+ }
+
+ protected override void ShowMenu (Point coords)
+ {
+ if (ShowTimerMenuEvent != null) {
+ Timer t = null;
+ if (Selections.Count > 0) {
+ TimerTimeNodeObject to = Selections.Last ().Drawable as
TimerTimeNodeObject;
+ t = to.Timer;
+ }
+ ShowTimerMenuEvent (t, Utils.PosToTime (coords, SecondsPerPixel));
+ }
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]