*****************************************************************************/
#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 );
}
-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
}
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();
// 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++ )
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();
}
-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();
}
-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();
+ }
}
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 );
}
-void WindowManager::checkAnchors( GenericWindow *pWindow,
+void WindowManager::checkAnchors( TopWindow *pWindow,
int &xOffset, int &yOffset ) const
{
WinSet_t::const_iterator itMov, itSta;
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();
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
}
+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();
+}