[longomatch] Stack the analysis panel to return from preferences



commit f35d469f71eb9f447b4438108dd1a802e0b4c78f
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Wed Oct 8 14:40:46 2014 +0200

    Stack the analysis panel to return from preferences

 LongoMatch.GUI/Gui/MainWindow.cs |   59 +++++++++++++++++++++++++++++--------
 1 files changed, 46 insertions(+), 13 deletions(-)
---
diff --git a/LongoMatch.GUI/Gui/MainWindow.cs b/LongoMatch.GUI/Gui/MainWindow.cs
index 90b545a..b44fb2a 100644
--- a/LongoMatch.GUI/Gui/MainWindow.cs
+++ b/LongoMatch.GUI/Gui/MainWindow.cs
@@ -51,6 +51,7 @@ namespace LongoMatch.Gui
                Project openedProject;
                ProjectType projectType;
                Widget currentPanel;
+               Widget stackPanel;
 
                #region Constructors
                public MainWindow(IGUIToolkit guiToolkit) :
@@ -85,15 +86,20 @@ namespace LongoMatch.Gui
                        }
                }
                
-               public void SetPanel (Widget panel) {
+               public void SetPanel (Widget panel)
+               {
                        if (panel == null) {
                                ResetGUI ();
                        } else {
-                               RemovePanel ();
+                               if (currentPanel is IAnalysisWindow && panel is PreferencesPanel) {
+                                       RemovePanel (true);
+                               } else {
+                                       RemovePanel (false);
+                               }
                                currentPanel = panel;
                                panel.Show();
                                if (panel is IPanel) {
-                                       (panel as IPanel).BackEvent += ResetGUI;
+                                       (panel as IPanel).BackEvent += BackClicked;
                                }
                                centralbox.PackStart (panel, true, true, 0);
                                welcomepanel.Hide ();
@@ -200,23 +206,50 @@ namespace LongoMatch.Gui
                                Config.EventsBroker.EmitShowFullScreen (FullScreenAction.Active);
                        };
                }
-               
-               void RemovePanel () {
-                       if (currentPanel != null) {
-                               if (currentPanel is IPanel) {
-                                       (currentPanel as IPanel).BackEvent -= ResetGUI;
+
+               void DestroyPanel (Widget panel)
+               {
+                       if (panel is IPanel) {
+                               (panel as IPanel).BackEvent -= BackClicked;
+                       }
+                       panel.Destroy ();
+                       panel.Dispose();
+                       System.GC.Collect();
+               }
+
+               void RemovePanel (bool stack)
+               {
+                       if (currentPanel == null) {
+                               return;
+                       }
+                       if (stack) {
+                               stackPanel = currentPanel;
+                               stackPanel.Visible = false;
+                       } else {
+                               DestroyPanel (currentPanel);
+                               currentPanel = null;
+                               if (stackPanel != null) {
+                                       DestroyPanel (stackPanel);
+                                       stackPanel = null;
                                }
-                               currentPanel.Destroy ();
-                               currentPanel.Dispose();
-                               System.GC.Collect();
                        }
-                       currentPanel = null;
+               }
+
+               void BackClicked ()
+               {
+                       if (stackPanel != null) {
+                               DestroyPanel (currentPanel);
+                               currentPanel = stackPanel;
+                               stackPanel.Visible = true;
+                       } else {
+                               ResetGUI ();
+                       }
                }
                
                private void ResetGUI() {
                        Title = Constants.SOFTWARE_NAME;
                        MakeActionsSensitive(false, projectType);
-                       RemovePanel ();
+                       RemovePanel (false);
                        welcomepanel.Show ();
                }
 


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