]> git.sesse.net Git - vlc/blobdiff - modules/gui/skins2/src/vout_manager.cpp
skins2: implement relative positioning
[vlc] / modules / gui / skins2 / src / vout_manager.cpp
index 86bd5e1e9c530ab7eaabb993e77c5927239db6f4..3b8197e0f52acd7ef70fc86f9a77477ce64fb562 100644 (file)
@@ -69,11 +69,17 @@ VoutManager::VoutManager( intf_thread_t *pIntf ): SkinObject( pIntf ),
 
     m_pVoutMainWindow->move( 0, 0 );
     m_pVoutMainWindow->resize( width, height );
+
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    rFullscreen.addObserver( this );
 }
 
 
 VoutManager::~VoutManager( )
 {
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    rFullscreen.delObserver( this );
+
     delete m_pVoutMainWindow;
 }
 
@@ -99,7 +105,7 @@ void VoutManager::saveVoutConfig( )
     // Save width/height to be consistent across themes
     // and detach Video Controls
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo )
         {
@@ -129,7 +135,7 @@ void VoutManager::restoreVoutConfig( bool b_success )
 
     // reattach vout(s) to Video Controls
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         CtrlVideo* pCtrlVideo = getBestCtrlVideo();
         if( pCtrlVideo )
@@ -144,7 +150,7 @@ void VoutManager::restoreVoutConfig( bool b_success )
 void VoutManager::discardVout( CtrlVideo* pCtrlVideo )
 {
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo == pCtrlVideo )
         {
@@ -162,7 +168,7 @@ void VoutManager::discardVout( CtrlVideo* pCtrlVideo )
 void VoutManager::requestVout( CtrlVideo* pCtrlVideo )
 {
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pCtrlVideo == NULL )
         {
@@ -180,7 +186,7 @@ CtrlVideo* VoutManager::getBestCtrlVideo( )
     // try to find an unused useable VideoControl
 
     vector<CtrlVideo*>::const_iterator it;
-    for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); it++ )
+    for( it = m_pCtrlVideoVec.begin(); it != m_pCtrlVideoVec.end(); ++it )
     {
         if( (*it)->isUseable() && !(*it)->isUsed() )
         {
@@ -230,7 +236,7 @@ void VoutManager::releaseWnd( vout_window_t *pWnd )
 {
     // remove vout thread from savedVec
     vector<SavedWnd>::iterator it;
-    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+    for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
     {
         if( (*it).pWnd == pWnd )
         {
@@ -249,6 +255,9 @@ void VoutManager::releaseWnd( vout_window_t *pWnd )
             break;
         }
     }
+
+    // force fullscreen to false so that user regains control
+    VlcProc::instance( getIntf() )->setFullscreenVar( false );
 }
 
 
@@ -258,7 +267,7 @@ void VoutManager::setSizeWnd( vout_window_t *pWnd, int width, int height )
                   width, height );
 
    vector<SavedWnd>::iterator it;
-   for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); it++ )
+   for( it = m_SavedWndVec.begin(); it != m_SavedWndVec.end(); ++it )
    {
        if( (*it).pWnd == pWnd )
        {
@@ -277,23 +286,29 @@ void VoutManager::setSizeWnd( vout_window_t *pWnd, int width, int height )
    }
 }
 
+
 void VoutManager::setFullscreenWnd( vout_window_t *pWnd, bool b_fullscreen )
 {
-    msg_Dbg( pWnd, "setFullscreen (%d) received from vout thread",
-                    b_fullscreen ? 1 : 0 );
+    msg_Dbg( pWnd, "setFullscreen (%i) received from vout thread",
+                   b_fullscreen );
 
     VlcProc::instance( getIntf() )->setFullscreenVar( b_fullscreen );
+}
 
-    if( b_fullscreen )
-    {
-        m_pVoutMainWindow->show();
-    }
-    else
+
+void VoutManager::onUpdate( Subject<VarBool> &rVariable, void *arg  )
+{
+    VarBool &rFullscreen = VlcProc::instance( getIntf() )->getFullscreenVar();
+    if( &rVariable == &rFullscreen )
     {
-        m_pVoutMainWindow->hide();
+        if( rFullscreen.get() )
+            m_pVoutMainWindow->show();
+        else
+            m_pVoutMainWindow->hide();
     }
 }
 
+
 // Functions called by window provider
 // ///////////////////////////////////