[longomatch] Add menu to edit and delete drawings



commit 400f50dcc691b14d6b8c535c3e80e93b7b865b4a
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Mon Jun 30 14:27:48 2014 +0200

    Add menu to edit and delete drawings

 LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs      |    2 +-
 LongoMatch.GUI/Gui/Dialog/DrawingTool.cs           |   12 ++++---
 LongoMatch.GUI/Gui/GUIToolkit.cs                   |    4 +-
 LongoMatch.GUI/Gui/Menu/PlaysMenu.cs               |   32 +++++++++++++++++++-
 .../gtk-gui/LongoMatch.Gui.Dialog.DrawingTool.cs   |    2 -
 LongoMatch.GUI/gtk-gui/gui.stetic                  |    2 -
 LongoMatch.Services/Services/EventsManager.cs      |   24 +++++++-------
 7 files changed, 53 insertions(+), 25 deletions(-)
---
diff --git a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
index 62869ca..6d61c44 100644
--- a/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
+++ b/LongoMatch.Core/Interfaces/GUI/IGUIToolkit.cs
@@ -78,7 +78,7 @@ namespace LongoMatch.Interfaces.GUI
                void ManageJobs ();
                
                void TagPlay (Play play, Project project);
-               void DrawingTool(Image pixbuf, Play play, int drawingIndex);
+               void DrawingTool(Image pixbuf, Play play, FrameDrawing drawing);
                
                string RemuxFile (string filePath, string outputFile, VideoMuxerType muxer);
                
diff --git a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
index 9688b12..e8ed3fc 100644
--- a/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
+++ b/LongoMatch.GUI/Gui/Dialog/DrawingTool.cs
@@ -42,11 +42,12 @@ namespace LongoMatch.Gui.Dialog
                Blackboard blackboard;
                FrameDrawing drawing;
                Drawable selectedDrawable;
-               int drawingIndex;
 
                public DrawingTool()
                {
                        this.Build();
+                       savebutton.Clicked += OnSavebuttonClicked;
+                       savetoprojectbutton.Clicked += OnSavetoprojectbuttonClicked;
                        blackboard = new Blackboard(new WidgetWrapper (drawingarea));
                        blackboard.ConfigureObjectEvent += HandleConfigureObjectEvent;
                        blackboard.ShowMenuEvent += HandleShowMenuEvent;
@@ -268,12 +269,11 @@ namespace LongoMatch.Gui.Dialog
                        }
                }
                
-               public void LoadPlay (Play play, Image frame, int drawingIndex) {
+               public void LoadPlay (Play play, Image frame, FrameDrawing drawing) {
                        this.play = play;
-                       this.drawingIndex = drawingIndex;
+                       this.drawing = drawing;
                        blackboard.Background = frame;
                        savetoprojectbutton.Visible = true;
-                       drawing = play.Drawings [drawingIndex].Clone ();
                        blackboard.Drawing = drawing;
                }
                
@@ -299,7 +299,9 @@ namespace LongoMatch.Gui.Dialog
 
                void OnSavetoprojectbuttonClicked(object sender, System.EventArgs e)
                {
-                       play.Drawings[drawingIndex] = drawing;
+                       if (!play.Drawings.Contains (drawing)) {
+                               play.Drawings.Add (drawing);
+                       }
                        play.Miniature = blackboard.Save ();
                        play.Miniature.Scale (Constants.MAX_THUMBNAIL_SIZE,
                                              Constants.MAX_THUMBNAIL_SIZE);
diff --git a/LongoMatch.GUI/Gui/GUIToolkit.cs b/LongoMatch.GUI/Gui/GUIToolkit.cs
index 9eeb260..27bfe16 100644
--- a/LongoMatch.GUI/Gui/GUIToolkit.cs
+++ b/LongoMatch.GUI/Gui/GUIToolkit.cs
@@ -215,7 +215,7 @@ namespace LongoMatch.Gui
                        d.Destroy();
                }
 
-               public void DrawingTool (Image image, Play play, int drawingIndex) {
+               public void DrawingTool (Image image, Play play, FrameDrawing drawing) {
                        DrawingTool dialog = new DrawingTool();
                        dialog.Show ();
 
@@ -223,7 +223,7 @@ namespace LongoMatch.Gui
                        if (play == null) {
                                dialog.LoadFrame (image);
                        } else {
-                               dialog.LoadPlay (play, image, drawingIndex);
+                               dialog.LoadPlay (play, image, drawing);
                        }
                        dialog.TransientFor = mainWindow as Gtk.Window;
                        dialog.Run();
diff --git a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
index 09d1e44..9464b77 100644
--- a/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
+++ b/LongoMatch.GUI/Gui/Menu/PlaysMenu.cs
@@ -30,7 +30,8 @@ namespace LongoMatch.Gui.Menus
        
                public event EventHandler EditNameEvent;
 
-               MenuItem edit, newPlay, del, addPLN, snapshot, render, duplicate, moveCat;
+               MenuItem edit, newPlay, del, addPLN, snapshot, render;
+               MenuItem duplicate, moveCat, drawings;
                List<Play> plays;
                Category cat;
                Time time;
@@ -79,6 +80,7 @@ namespace LongoMatch.Gui.Menus
                        edit.Visible = editableName;
                        snapshot.Visible = plays.Count == 1;
                        moveCat.Visible = plays.Count == 1 && categories != null;
+                       drawings.Visible = plays.Count == 1 && plays[0].Drawings.Count > 0;
                        del.Visible = plays.Count > 0;
                        addPLN.Visible = plays.Count > 0;
                        render.Visible = plays.Count > 0;
@@ -110,6 +112,31 @@ namespace LongoMatch.Gui.Menus
                                moveCat.Submenu = catMenu;
                        }
                        
+                       if (drawings.Visible) {
+                               Menu drawingsMenu = new Menu();
+                               for (int i=0; i < plays[0].Drawings.Count; i++) {
+                                       int index = i;
+                                       MenuItem drawingItem = new MenuItem (Catalog.GetString ("Drawing ") + 
(i + 1));
+                                       MenuItem editItem = new MenuItem (Catalog.GetString ("Edit"));
+                                       MenuItem deleteItem = new MenuItem (Catalog.GetString ("Delete"));
+                                       Menu drawingMenu = new Menu();
+
+                                       drawingsMenu.Append (drawingItem);
+                                       drawingMenu.Append  (editItem);
+                                       drawingMenu.Append (deleteItem);
+                                       editItem.Activated += (sender, e) => {
+                                               Config.EventsBroker.EmitDrawFrame (plays[0], index);
+                                       }; 
+                                       deleteItem.Activated += (sender, e) => {
+                                               plays[0].Drawings.RemoveAt (index);
+                                       }; 
+                                       drawingItem.Submenu = drawingMenu;
+                                       drawingMenu.ShowAll ();
+                               }
+                               drawingsMenu.ShowAll();
+                               drawings.Submenu = drawingsMenu;
+                       }
+                       
                        Popup();
                }
                
@@ -137,6 +164,9 @@ namespace LongoMatch.Gui.Menus
                        duplicate.Activated += (sender, e) => Config.EventsBroker.EmitDuplicatePlay (plays);
                        Add (duplicate);
 
+                       drawings = new MenuItem (Catalog.GetString ("Drawings"));
+                       Add (drawings);
+
                        addPLN = new MenuItem ("");
                        addPLN.Activated += (sender, e) => Config.EventsBroker.EmitPlayListNodeAdded (plays);
                        Add (addPLN);
diff --git a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DrawingTool.cs 
b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DrawingTool.cs
index 9ed50e2..5058524 100644
--- a/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DrawingTool.cs
+++ b/LongoMatch.GUI/gtk-gui/LongoMatch.Gui.Dialog.DrawingTool.cs
@@ -622,8 +622,6 @@ namespace LongoMatch.Gui.Dialog
                        this.savetoprojectbutton.Hide ();
                        this.closebutton.Hide ();
                        this.Show ();
-                       this.savebutton.Clicked += new global::System.EventHandler (this.OnSavebuttonClicked);
-                       this.savetoprojectbutton.Clicked += new global::System.EventHandler 
(this.OnSavetoprojectbuttonClicked);
                }
        }
 }
diff --git a/LongoMatch.GUI/gtk-gui/gui.stetic b/LongoMatch.GUI/gtk-gui/gui.stetic
index 6ac0b04..6b5be49 100644
--- a/LongoMatch.GUI/gtk-gui/gui.stetic
+++ b/LongoMatch.GUI/gtk-gui/gui.stetic
@@ -3204,7 +3204,6 @@ Hotkeys with a single key are also allowed with Ctrl+key.</property>
                     <property name="Icon">stock:gtk-save Menu</property>
                     <property name="Label" translatable="yes">Save to Project</property>
                     <property name="UseUnderline">True</property>
-                    <signal name="Clicked" handler="OnSavetoprojectbuttonClicked" />
                   </widget>
                   <packing>
                     <property name="PackType">End</property>
@@ -3222,7 +3221,6 @@ Hotkeys with a single key are also allowed with Ctrl+key.</property>
                     <property name="Icon">stock:gtk-save Menu</property>
                     <property name="Label" translatable="yes">Save to File</property>
                     <property name="UseUnderline">True</property>
-                    <signal name="Clicked" handler="OnSavebuttonClicked" />
                   </widget>
                   <packing>
                     <property name="PackType">End</property>
diff --git a/LongoMatch.Services/Services/EventsManager.cs b/LongoMatch.Services/Services/EventsManager.cs
index 437e6b6..a8d0029 100644
--- a/LongoMatch.Services/Services/EventsManager.cs
+++ b/LongoMatch.Services/Services/EventsManager.cs
@@ -355,25 +355,25 @@ namespace LongoMatch.Services
                {
                }
 
-               protected virtual void OnTimeline2PositionChanged(Time pos)
-               {
-                       player.Seek (pos, false);
-               }
-
                protected virtual void OnDrawFrame (Play play, int drawingIndex) {
                        Image pixbuf;
+                       FrameDrawing drawing = null;
+
                        player.Pause();
-                       pixbuf = player.CurrentFrame;
                        if (play == null) {
                                play = loadedPlay as Play;
                        }
-                       if (play != null && drawingIndex == -1) {
-                               FrameDrawing drawing = new FrameDrawing ();
-                               drawing.Render = player.CurrentTime;
-                               play.Drawings.Add (drawing);
-                               drawingIndex = play.Drawings.Count - 1;
+                       if (play != null) {
+                               if (drawingIndex == -1) {
+                                       drawing = new FrameDrawing ();
+                                       drawing.Render = player.CurrentTime;
+                               } else {
+                                       drawing = play.Drawings[drawingIndex];
+                               }
+                               player.Seek (drawing.Render, true);
                        }
-                       guiToolkit.DrawingTool (pixbuf, play, drawingIndex);
+                       pixbuf = player.CurrentFrame;
+                       guiToolkit.DrawingTool (pixbuf, play, drawing);
                }
 
                protected virtual void OnPlayCategoryChanged(Play play, Category cat)


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