]> git.sesse.net Git - vlc/commitdiff
* skins2: when restoring the previous skin because a new one failed to load,
authorOlivier Teulière <ipkiss@videolan.org>
Sun, 30 Jul 2006 12:07:45 +0000 (12:07 +0000)
committerOlivier Teulière <ipkiss@videolan.org>
Sun, 30 Jul 2006 12:07:45 +0000 (12:07 +0000)
   show only the windows that were visible before

modules/gui/skins2/commands/cmd_change_skin.cpp
modules/gui/skins2/src/window_manager.cpp
modules/gui/skins2/src/window_manager.hpp

index 9d490b41d58204b23d0d22d42f383f9cdcffb07e..0f389ad034c8df2553694a653e57cbec4a4e20f9 100644 (file)
@@ -38,6 +38,7 @@ void CmdChangeSkin::execute()
 
     if( pOldTheme )
     {
+        pOldTheme->getWindowManager().saveVisibility();
         pOldTheme->getWindowManager().hideAll();
     }
 
@@ -57,7 +58,7 @@ void CmdChangeSkin::execute()
         msg_Warn( getIntf(), "a problem occurred when loading the new theme,"
                   " restoring the previous one" );
         getIntf()->p_sys->p_theme = pOldTheme;
-        pOldTheme->getWindowManager().showAll();
+        pOldTheme->getWindowManager().restoreVisibility();
     }
     else
     {
index f93ffea3da7675b62d58cb29e2ce0baf92e1d804..ccc42ff3bd5917d82f73bbf4444a1291e132c602 100644 (file)
@@ -331,6 +331,37 @@ void WindowManager::synchVisibility() const
 }
 
 
+void WindowManager::saveVisibility()
+{
+    WinSet_t::const_iterator it;
+    m_savedWindows.clear();
+    for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
+    {
+        // Remember the window if it is visible
+        if( (*it)->getVisibleVar().get() )
+        {
+            m_savedWindows.insert( *it );
+        }
+    }
+}
+
+
+void WindowManager::restoreVisibility() const
+{
+    // Warning in case we never called saveVisibility()
+    if( m_savedWindows.size() == 0 )
+    {
+        msg_Warn( getIntf(), "restoring visibility for no window" );
+    }
+
+    WinSet_t::const_iterator it;
+    for( it = m_savedWindows.begin(); it != m_savedWindows.end(); it++)
+    {
+        (*it)->show();
+    }
+}
+
+
 void WindowManager::raiseAll() const
 {
     // Raise all the windows
index ba738f441bec046f12807e646f09a4f5f0d3afe3..433ec11122fe36225d1321027eabfd4fa527e411 100644 (file)
@@ -59,8 +59,10 @@ class WindowManager: public SkinObject
         /// Destructor
         virtual ~WindowManager();
 
-        /// Add a window to the list of known windows. Necessary if you want
-        /// your window to be movable...
+        /**
+         * Add a window to the list of known windows. Necessary if you want
+         * your window to be movable...
+         */
         void registerWindow( TopWindow &rWindow );
 
         /// Remove a previously registered window
@@ -105,6 +107,12 @@ class WindowManager: public SkinObject
         /// Synchronize the windows with their visibility variable
         void synchVisibility() const;
 
+        /// Save the current visibility of the windows
+        void saveVisibility();
+
+        /// Restore the saved visibility of the windows
+        void restoreVisibility() const;
+
         /// Raise the given window
         void raise( TopWindow &rWindow ) const { rWindow.raise(); }
 
@@ -164,8 +172,15 @@ class WindowManager: public SkinObject
         map<TopWindow*, WinSet_t> m_dependencies;
         /// Store all the windows
         WinSet_t m_allWindows;
-        /// Store the moving windows; this set is updated at every start of
-        /// move.
+        /**
+         * Store the windows that were visible when saveVisibility() was
+         * last called.
+         */
+        WinSet_t m_savedWindows;
+        /// Store the moving windows
+        /**
+         * This set is updated at every start of move.
+         */
         WinSet_t m_movingWindows;
         /**
          * Store the moving windows in the context of resizing