]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/window_manager.cpp
* skins2: support for custom popup menus, and win32 implementation.
[vlc] / modules / gui / skins2 / src / window_manager.cpp
old mode 100755 (executable)
new mode 100644 (file)
index bbc5ca4..db36429
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * window_manager.cpp
  *****************************************************************************
- * Copyright (C) 2003 VideoLAN
+ * Copyright (C) 2003 the VideoLAN team
  * $Id$
  *
  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
 #include "anchor.hpp"
 #include "tooltip.hpp"
 #include "../utils/position.hpp"
+#include "../src/var_manager.hpp"
 
 
 WindowManager::WindowManager( intf_thread_t *pIntf ):
-    SkinObject( pIntf ), m_isOnTop( false ), m_magnet( 0 ), m_pTooltip( NULL )
+    SkinObject( pIntf ), m_magnet( 0 ), m_pTooltip( NULL ), m_pPopup( NULL )
 {
+    // Create and register a variable for the "on top" status
+    VarManager *pVarManager = VarManager::instance( getIntf() );
+    m_cVarOnTop = VariablePtr( new VarBoolImpl( getIntf() ) );
+    pVarManager->registerVar( m_cVarOnTop, "vlc.isOnTop" );
 }
 
 
@@ -65,12 +70,25 @@ void WindowManager::startMove( TopWindow &rWindow )
     m_movingWindows.clear();
     buildDependSet( m_movingWindows, &rWindow );
 
-    // Change the opacity of the moving windows
-    WinSet_t::const_iterator it;
-    for( it = m_movingWindows.begin(); it != m_movingWindows.end(); it++ )
+#ifdef WIN32
+    if( config_GetInt( getIntf(), "skins2-transparency" ) )
     {
-        (*it)->setOpacity( m_moveAlpha );
+        // Change the opacity of the moving windows
+        WinSet_t::const_iterator it;
+        for( it = m_movingWindows.begin(); it != m_movingWindows.end(); it++ )
+        {
+            (*it)->setOpacity( m_moveAlpha );
+        }
+
+        // FIXME: We need to refresh the windows, because if 2 windows overlap
+        // and one of them becomes transparent, the other one is not refreshed
+        // automatically. I don't know why... -- Ipkiss
+        for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
+        {
+            (*it)->refresh( 0, 0, (*it)->getWidth(), (*it)->getHeight() );
+        }
     }
+#endif
 }
 
 
@@ -79,12 +97,17 @@ void WindowManager::stopMove()
     WinSet_t::const_iterator itWin1, itWin2;
     AncList_t::const_iterator itAnc1, itAnc2;
 
-    // Restore the opacity of the moving windows
-    WinSet_t::const_iterator it;
-    for( it = m_movingWindows.begin(); it != m_movingWindows.end(); it++ )
+#ifdef WIN32
+    if( config_GetInt( getIntf(), "skins2-transparency" ) )
     {
-        (*it)->setOpacity( m_alpha );
+        // Restore the opacity of the moving windows
+        WinSet_t::const_iterator it;
+        for( it = m_movingWindows.begin(); it != m_movingWindows.end(); it++ )
+        {
+            (*it)->setOpacity( m_alpha );
+        }
     }
+#endif
 
     // Delete the dependencies
     m_dependencies.clear();
@@ -147,29 +170,43 @@ void WindowManager::move( TopWindow &rWindow, int left, int top ) const
 }
 
 
-void WindowManager::raiseAll( TopWindow &rWindow ) const
+void WindowManager::synchVisibility() const
 {
-    // Raise all the windows
     WinSet_t::const_iterator it;
     for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
     {
-        if( *it !=  &rWindow )
+        // Show the window if it has to be visible
+        if( (*it)->getVisibleVar().get() )
         {
-            (*it)->raise();
+            (*it)->innerShow();
         }
     }
-    // Make sure to raise the given window at the end, so that it is above
-    rWindow.raise();
 }
 
 
-void WindowManager::showAll() const
+void WindowManager::raiseAll() const
+{
+    // Raise all the windows
+    WinSet_t::const_iterator it;
+    for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
+    {
+        (*it)->raise();
+    }
+}
+
+
+void WindowManager::showAll( bool firstTime ) const
 {
     // Show all the windows
     WinSet_t::const_iterator it;
     for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
     {
-        (*it)->show();
+        // When the theme is opened for the first time,
+        // only show the window if set as visible in the XML
+        if ((*it)->isVisible() || !firstTime)
+        {
+            (*it)->show();
+        }
         (*it)->setOpacity( m_alpha );
     }
 }
@@ -187,11 +224,15 @@ void WindowManager::hideAll() const
 
 void WindowManager::toggleOnTop()
 {
-    m_isOnTop = !m_isOnTop;
+    // Update the boolean variable
+    VarBoolImpl *pVarOnTop = (VarBoolImpl*)m_cVarOnTop.get();
+    pVarOnTop->set( !pVarOnTop->get() );
+
+    // Toggle the "on top" status
     WinSet_t::const_iterator it;
     for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
     {
-        (*it)->toggleOnTop( m_isOnTop );
+        (*it)->toggleOnTop( pVarOnTop->get() );
     }
 }
 
@@ -228,6 +269,12 @@ void WindowManager::checkAnchors( TopWindow *pWindow,
     for( itMov = m_movingWindows.begin();
          itMov != m_movingWindows.end(); itMov++ )
     {
+        // Skip the invisible windows
+        if( ! (*itMov)->getVisibleVar().get() )
+        {
+            continue;
+        }
+
         int newLeft = (*itMov)->getLeft() + xOffset;
         int newTop = (*itMov)->getTop() + yOffset;
         if( newLeft > workArea.getLeft() - m_magnet &&