[longomatch/redesign: 41/47] Use drawings list for plays, even if we don't support it yet



commit d16908221aa7f382cd8f6a5b55e146bb179a294f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Jan 2 19:14:30 2011 +0100

    Use drawings list for plays, even if we don't support it yet

 LongoMatch/Gui/Component/TimeScale.cs       |    6 +++---
 LongoMatch/Gui/Dialog/DrawingTool.cs        |    2 +-
 LongoMatch/Gui/TreeView/ListTreeViewBase.cs |    2 +-
 LongoMatch/Gui/TreeView/PlayersTreeView.cs  |    2 +-
 LongoMatch/Gui/TreeView/PlaysTreeView.cs    |    2 +-
 LongoMatch/Store/DrawingsList.cs            |    2 +-
 LongoMatch/Store/Play.cs                    |   27 ++++++++++++++++++++-------
 7 files changed, 28 insertions(+), 15 deletions(-)
---
diff --git a/LongoMatch/Gui/Component/TimeScale.cs b/LongoMatch/Gui/Component/TimeScale.cs
index 3ffdaec..fa0dc97 100644
--- a/LongoMatch/Gui/Component/TimeScale.cs
+++ b/LongoMatch/Gui/Component/TimeScale.cs
@@ -206,7 +206,7 @@ namespace LongoMatch.Gui.Component
 					//Then we draw the selected TimeNode over the others
 					if (hasSelectedTimeNode) {
 						DrawRoundedRectangle(g,selected.StartFrame/pixelRatio,3,selected.TotalFrames/pixelRatio,height-6,SECTION_HEIGHT/7);
-						if (selected.HasKeyFrame) {
+						if (selected.HasDrawings) {
 							g.MoveTo(selected.KeyFrame/pixelRatio,3);
 							g.LineTo(selected.KeyFrame/pixelRatio,SECTION_HEIGHT-3);
 							g.StrokePreserve();
@@ -357,7 +357,7 @@ namespace LongoMatch.Gui.Component
 			}
 			//Moving Start time
 			else if (candidateStart) {
-				if (candidateTN.HasKeyFrame && pos > 0 && pos > candidateTN.KeyFrame-10)
+				if (candidateTN.HasDrawings && pos > 0 && pos > candidateTN.KeyFrame-10)
 					candidateTN.StartFrame = candidateTN.KeyFrame-10;
 				//Check not to go under start time nor 0
 				else if (pos  > 0 && pos < candidateTN.StopFrame-10)
@@ -367,7 +367,7 @@ namespace LongoMatch.Gui.Component
 			}
 			//Moving Stop time
 			else if (!candidateStart) {
-				if (candidateTN.HasKeyFrame &&  pos < candidateTN.KeyFrame+10)
+				if (candidateTN.HasDrawings &&  pos < candidateTN.KeyFrame+10)
 					candidateTN.StopFrame = candidateTN.KeyFrame+10;
 				//Check not to go under start time nor 0
 				else if (pos < frames && pos > candidateTN.StartFrame+10)
diff --git a/LongoMatch/Gui/Dialog/DrawingTool.cs b/LongoMatch/Gui/Dialog/DrawingTool.cs
index d2f27b0..022a3b8 100644
--- a/LongoMatch/Gui/Dialog/DrawingTool.cs
+++ b/LongoMatch/Gui/Dialog/DrawingTool.cs
@@ -118,7 +118,7 @@ namespace LongoMatch.Gui.Dialog
 			string tempFile = System.IO.Path.GetTempFileName();
 			drawingwidget1.SaveDrawings(tempFile);
 			Pixbuf frame = new Pixbuf(tempFile);
-			play.KeyFrameDrawing =new Drawing{ Pixbuf=frame, RenderTime = stopTime};
+			play.Drawings.Add(new Drawing{ Pixbuf=frame, RenderTime = stopTime});
 			drawingwidget1.SaveAll(tempFile);
 			frame.Dispose();
 			play.Miniature = new Pixbuf(tempFile);
diff --git a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
index c838beb..ca3bea5 100644
--- a/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
+++ b/LongoMatch/Gui/TreeView/ListTreeViewBase.cs
@@ -339,7 +339,7 @@ namespace LongoMatch.Gui.Component
 				TreePath[] paths = Selection.GetSelectedRows();
 				for (int i=0; i<paths.Length; i++){	
 					Play tNode = (Play)GetValueFromPath(paths[i]);
-					tNode.KeyFrameDrawing = null;
+					tNode.Drawings.Clear();
 				}
 				// Refresh the thumbnails
 				QueueDraw();
diff --git a/LongoMatch/Gui/TreeView/PlayersTreeView.cs b/LongoMatch/Gui/TreeView/PlayersTreeView.cs
index c8574ad..8e4c0d8 100644
--- a/LongoMatch/Gui/TreeView/PlayersTreeView.cs
+++ b/LongoMatch/Gui/TreeView/PlayersTreeView.cs
@@ -129,7 +129,7 @@ namespace LongoMatch.Gui.Component
 				if (paths.Length == 1) {
 					TimeNode selectedTimeNode = GetValueFromPath(paths[0]) as TimeNode;
 					if (selectedTimeNode is Play) {
-						deleteKeyFrame.Sensitive = (selectedTimeNode as Play).KeyFrameDrawing != null;
+						deleteKeyFrame.Sensitive = (selectedTimeNode as Play).HasDrawings;
 						MultiSelectMenu(false);
 						menu.Popup();
 					} else {
diff --git a/LongoMatch/Gui/TreeView/PlaysTreeView.cs b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
index 8c79534..bf70cd7 100644
--- a/LongoMatch/Gui/TreeView/PlaysTreeView.cs
+++ b/LongoMatch/Gui/TreeView/PlaysTreeView.cs
@@ -225,7 +225,7 @@ namespace LongoMatch.Gui.Component
 				if (paths.Length == 1) {
 					TimeNode selectedTimeNode = GetValueFromPath(paths[0]) as TimeNode;
 					if (selectedTimeNode is Play) {
-						deleteKeyFrame.Sensitive = (selectedTimeNode as Play).KeyFrameDrawing != null;
+						deleteKeyFrame.Sensitive = (selectedTimeNode as Play).HasDrawings;
 						MultiSelectMenu(false);
 						menu.Popup();
 					}
diff --git a/LongoMatch/Store/DrawingsList.cs b/LongoMatch/Store/DrawingsList.cs
index 7e543cc..9b8041d 100644
--- a/LongoMatch/Store/DrawingsList.cs
+++ b/LongoMatch/Store/DrawingsList.cs
@@ -68,7 +68,7 @@ namespace LongoMatch.Store
 		/// <summary>
 		/// Clear the drawing list
 		/// </summary>
-		protected void Clear() {
+		public void Clear() {
 			drawingsList.Clear();
 		}
 
diff --git a/LongoMatch/Store/Play.cs b/LongoMatch/Store/Play.cs
index 6352a62..b8a4f2d 100644
--- a/LongoMatch/Store/Play.cs
+++ b/LongoMatch/Store/Play.cs
@@ -40,6 +40,7 @@ namespace LongoMatch.Store
 		public Play(){
 			LocalPlayers = new List<Player>();
 			VisitorPlayers = new List<Player>();
+			Drawings = new DrawingsList();
 			Tags = new List<Tag>();
 		}
 		#endregion
@@ -89,7 +90,7 @@ namespace LongoMatch.Store
 		/// </summary>
 		public uint KeyFrame {
 			get {
-				if (HasKeyFrame)
+				if (HasDrawings)
 					return (uint) KeyFrameDrawing.RenderTime * Fps / 1000;
 				else return 0;
 			}
@@ -111,15 +112,27 @@ namespace LongoMatch.Store
 		public List<Player> VisitorPlayers {get; set;}
 
 		/// <summary>
-		/// Get/Set the key frame's <see cref="LongoMatch.Store.Drawing"/>
+		/// List of drawings for this play
 		/// </summary>
-		public Drawing KeyFrameDrawing {get; set;}
-
+		public DrawingsList Drawings {get; set;}
+		
+		/* FIXME: Keep this until we support multiple drawings */
+		public Drawing KeyFrameDrawing {
+			get{
+				if (Drawings.Count > 0)
+					return Drawings.List[0];
+				else
+					return null;
+			}
+		}
+		
 		/// <summary>
-		/// Get wether the play has defined a key frame
+		/// Get wether the play has at least a frame drawing
 		/// </summary>
-		public bool HasKeyFrame {
-			get {return KeyFrameDrawing != null;}
+		public bool HasDrawings {
+			get {
+				return Drawings.Count > 0;
+			}
 		}
 		
 		/// <summary>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]