]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/window_manager.cpp
- modules/control/showintf.c: new control module, able to show the
[vlc] / modules / gui / skins2 / src / window_manager.cpp
index 95bf706a95ef438f89702e9966b10ae4e5ca6537..d8d5621bde36d428f9b9fcb9f89e189ca52a15a0 100755 (executable)
  *****************************************************************************/
 
 #include "window_manager.hpp"
+#include "generic_layout.hpp"
 #include "generic_window.hpp"
 #include "os_factory.hpp"
 #include "anchor.hpp"
+#include "tooltip.hpp"
 #include "../utils/position.hpp"
+#include "../src/var_manager.hpp"
 
 
-void WindowManager::registerWindow( GenericWindow &rWindow )
+WindowManager::WindowManager( intf_thread_t *pIntf ):
+    SkinObject( pIntf ), m_magnet( 0 ), m_pTooltip( 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" );
+}
+
+
+WindowManager::~WindowManager()
+{
+    delete m_pTooltip;
+}
+
+
+void WindowManager::registerWindow( TopWindow &rWindow )
 {
     // Add the window to the set
     m_allWindows.insert( &rWindow );
 }
 
 
-void WindowManager::unregisterWindow( GenericWindow &rWindow )
+void WindowManager::unregisterWindow( TopWindow &rWindow )
 {
     // Erase every possible reference to the window
     m_allWindows.erase( &rWindow );
@@ -45,18 +64,31 @@ void WindowManager::unregisterWindow( GenericWindow &rWindow )
 }
 
 
-void WindowManager::startMove( GenericWindow &rWindow )
+void WindowManager::startMove( TopWindow &rWindow )
 {
     // Rebuild the set of moving windows
     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
 }
 
 
@@ -65,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();
@@ -79,8 +116,9 @@ void WindowManager::stopMove()
     // Iterate through all the windows
     for( itWin1 = m_allWindows.begin(); itWin1 != m_allWindows.end(); itWin1++ )
     {
-        // Get the anchors of the window
-        const AncList_t &ancList1 = (*itWin1)->getAnchorList();
+        // Get the anchors of the layout associated to the window
+        const AncList_t &ancList1 =
+            (*itWin1)->getActiveLayout().getAnchorList();
 
         // Iterate through all the windows, starting with (*itWin1)
         for( itWin2 = itWin1; itWin2 != m_allWindows.end(); itWin2++ )
@@ -90,7 +128,8 @@ void WindowManager::stopMove()
                 continue;
 
             // Now, check for anchoring between the 2 windows
-            const AncList_t &ancList2 = (*itWin2)->getAnchorList();
+            const AncList_t &ancList2 =
+                (*itWin2)->getActiveLayout().getAnchorList();
             for( itAnc1 = ancList1.begin(); itAnc1 != ancList1.end(); itAnc1++ )
             {
                 for( itAnc2 = ancList2.begin();
@@ -113,7 +152,7 @@ void WindowManager::stopMove()
 }
 
 
-void WindowManager::move( GenericWindow &rWindow, int left, int top ) const
+void WindowManager::move( TopWindow &rWindow, int left, int top ) const
 {
     // Compute the real move offset
     int xOffset = left - rWindow.getLeft();
@@ -131,19 +170,28 @@ void WindowManager::move( GenericWindow &rWindow, int left, int top ) const
 }
 
 
-void WindowManager::raiseAll( GenericWindow &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::raiseAll() const
+{
+    // Raise all the windows
+    WinSet_t::const_iterator it;
+    for( it = m_allWindows.begin(); it != m_allWindows.end(); it++ )
+    {
+        (*it)->raise();
+    }
 }
 
 
@@ -171,17 +219,21 @@ 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() );
     }
 }
 
 
 void WindowManager::buildDependSet( WinSet_t &rWinSet,
-                                    GenericWindow *pWindow )
+                                    TopWindow *pWindow )
 {
     // pWindow is in the set
     rWinSet.insert( pWindow );
@@ -200,7 +252,7 @@ void WindowManager::buildDependSet( WinSet_t &rWinSet,
 }
 
 
-void WindowManager::checkAnchors( GenericWindow *pWindow,
+void WindowManager::checkAnchors( TopWindow *pWindow,
                                   int &xOffset, int &yOffset ) const
 {
     WinSet_t::const_iterator itMov, itSta;
@@ -248,8 +300,9 @@ void WindowManager::checkAnchors( GenericWindow *pWindow,
             continue;
         }
 
-        // Get the anchors of this moving window
-        const AncList_t &movAnchors = (*itMov)->getAnchorList();
+        // Get the anchors in the main layout of this moving window
+        const AncList_t &movAnchors =
+            (*itMov)->getActiveLayout().getAnchorList();
 
         // Iterate through the static windows
         for( itSta = m_allWindows.begin();
@@ -262,8 +315,9 @@ void WindowManager::checkAnchors( GenericWindow *pWindow,
                 continue;
             }
 
-            // Get the anchors of this static window
-            const AncList_t &staAnchors = (*itSta)->getAnchorList();
+            // Get the anchors in the main layout of this static window
+            const AncList_t &staAnchors =
+                (*itSta)->getActiveLayout().getAnchorList();
 
             // Check if there is an anchoring between one of the movAnchors
             // and one of the staAnchors
@@ -307,3 +361,48 @@ void WindowManager::checkAnchors( GenericWindow *pWindow,
 }
 
 
+void WindowManager::createTooltip( const GenericFont &rTipFont )
+{
+    // Create the tooltip window
+    if( !m_pTooltip )
+    {
+        m_pTooltip = new Tooltip( getIntf(), rTipFont, 500 );
+    }
+    else
+    {
+        msg_Warn( getIntf(), "Tooltip already created!");
+    }
+}
+
+
+void WindowManager::showTooltip()
+{
+    if( m_pTooltip )
+    {
+        m_pTooltip->show();
+    }
+}
+
+
+void WindowManager::hideTooltip()
+{
+    if( m_pTooltip )
+    {
+        m_pTooltip->hide();
+    }
+}
+
+
+void WindowManager::addLayout( TopWindow &rWindow, GenericLayout &rLayout )
+{
+    rWindow.setActiveLayout( &rLayout );
+}
+
+
+void WindowManager::setActiveLayout( TopWindow &rWindow,
+                                     GenericLayout &rLayout )
+{
+    rWindow.setActiveLayout( &rLayout );
+    // Rebuild the dependencies
+    stopMove();
+}