]> git.sesse.net Git - vlc/commitdiff
* all: new handling of vout controls to allow serveral layouts/windows
authorCyril Deguet <asmax@videolan.org>
Sat, 22 Apr 2006 23:16:20 +0000 (23:16 +0000)
committerCyril Deguet <asmax@videolan.org>
Sat, 22 Apr 2006 23:16:20 +0000 (23:16 +0000)
 with a vout (if only one is visible at the same time)
 A callback is now called when a layout becomes visible or hidden.
 The vout window is still not reparented correctly if the layout
 is changed while a video is being played...

modules/gui/skins2/controls/ctrl_video.cpp
modules/gui/skins2/controls/ctrl_video.hpp
modules/gui/skins2/src/generic_layout.cpp
modules/gui/skins2/src/generic_layout.hpp
modules/gui/skins2/src/top_window.cpp
modules/gui/skins2/src/top_window.hpp
modules/gui/skins2/src/vlcproc.cpp
modules/gui/skins2/src/vout_window.cpp

index e28b66c9e032a65e5a4d792fac1c78f1a14619a3..10e5721385a954c3bb1b0784d93194947c1f8547 100644 (file)
@@ -96,15 +96,6 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
         // Draw a black rectangle under the video to avoid transparency
         rImage.fillRect( pPos->getLeft(), pPos->getTop(), pPos->getWidth(),
                          pPos->getHeight(), 0 );
-
-        // Create a child window for the vout if it doesn't exist yet
-        if (!m_pVout)
-        {
-            m_pVout = new VoutWindow( getIntf(), pPos->getLeft(),
-                                      pPos->getTop(), false, false, *pParent );
-            m_pVout->resize( pPos->getWidth(), pPos->getHeight() );
-            m_pVout->show();
-        }
     }
 }
 
@@ -122,3 +113,26 @@ void CtrlVideo::onUpdate( Subject<VarBox, void *> &rVoutSize, void *arg )
     pQueue->push( CmdGenericPtr( pCmd ) );
 }
 
+
+void CtrlVideo::setVisible( bool visible )
+{
+    if( visible )
+    {
+        GenericWindow *pParent = getWindow();
+        const Position *pPos = getPosition();
+        // Create a child window for the vout if it doesn't exist yet
+        if( !m_pVout && pParent && pPos )
+        {
+            m_pVout = new VoutWindow( getIntf(), pPos->getLeft(),
+                                      pPos->getTop(), false, false, *pParent );
+            m_pVout->resize( pPos->getWidth(), pPos->getHeight() );
+            m_pVout->show();
+        }
+    }
+    else
+    {
+        delete m_pVout;
+        m_pVout = NULL;
+    }
+}
+
index a27fe814e67391cca14e60cead3e46e92bf63b28..5a1ecb6f5c203e6fc6944e4848bd253e5d64cffe 100644 (file)
@@ -58,6 +58,9 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox, void*>
         /// Method called when the vout size is updated
         virtual void onUpdate( Subject<VarBox,void*> &rVoutSize, void* );
 
+        /// Called by the layout when the control is show/hidden
+        void setVisible( bool visible );
+
     private:
         /// Vout window
         VoutWindow *m_pVout;
index 07608e3f8d9530657fce884103ceda35f50ccf39..8baf3bc80c5f2a0eff02af6eb86d8518d1ec26a1 100644 (file)
@@ -27,6 +27,7 @@
 #include "os_factory.hpp"
 #include "os_graphics.hpp"
 #include "../controls/ctrl_generic.hpp"
+#include "../controls/ctrl_video.hpp"
 
 
 GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
@@ -34,7 +35,7 @@ GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
                               int maxHeight ):
     SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
     m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
-    m_minHeight( minHeight ), m_maxHeight( maxHeight )
+    m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL )
 {
     // Get the OSFactory
     OSFactory *pOsFactory = OSFactory::instance( getIntf() );
@@ -107,6 +108,12 @@ void GenericLayout::addControl( CtrlGeneric *pControl,
         {
             m_controlList.push_back( LayeredControl( pControl, layer ) );
         }
+
+        // Check if it is a video control
+        if( pControl->getType() == "video" )
+        {
+            m_pVideoControl = (CtrlVideo*)pControl;
+        }
     }
     else
     {
@@ -200,7 +207,6 @@ void GenericLayout::resize( int width, int height )
         pWindow->refresh( 0, 0, width, height );
         pWindow->resize( width, height );
         pWindow->refresh( 0, 0, width, height );
-
         // Change the shape of the window and redraw it
         pWindow->updateShape();
         pWindow->refresh( 0, 0, width, height );
@@ -226,10 +232,6 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
         if( pPos && pCtrl->isVisible() )
         {
             pCtrl->draw( *m_pImage, pPos->getLeft(), pPos->getTop() );
-            // Remember the video control (we assume there is at most one video
-            // control per layout)
-            if( pCtrl->getType() == "video" && pCtrl->getPosition() )
-                iterVideo = iter;
         }
     }
 
@@ -248,7 +250,7 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
             height = m_height - y;
 
         // Refresh the window... but do not paint on a video control!
-        if( iterVideo == m_controlList.end() )
+        if( !m_pVideoControl )
         {
             // No video control, we can safely repaint the rectangle
             pWindow->refresh( x, y, width, height );
@@ -263,10 +265,10 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
             // becomes a real mess :)
 
             // Use short variable names for convenience
-            int xx = iterVideo->m_pControl->getPosition()->getLeft();
-            int yy = iterVideo->m_pControl->getPosition()->getTop();
-            int ww = iterVideo->m_pControl->getPosition()->getWidth();
-            int hh = iterVideo->m_pControl->getPosition()->getHeight();
+            int xx = m_pVideoControl->getPosition()->getLeft();
+            int yy = m_pVideoControl->getPosition()->getTop();
+            int ww = m_pVideoControl->getPosition()->getWidth();
+            int hh = m_pVideoControl->getPosition()->getHeight();
 
             // Top part:
             if( y < yy )
@@ -296,3 +298,24 @@ void GenericLayout::addAnchor( Anchor *pAnchor )
     m_anchorList.push_back( pAnchor );
 }
 
+
+void GenericLayout::onShow()
+{
+    refreshAll();
+    // TODO find a better way to handle the vout ?
+    if( m_pVideoControl )
+    {
+        m_pVideoControl->setVisible( true );
+    }
+}
+
+
+void GenericLayout::onHide()
+{
+    // TODO find a better way to handle the vout ?
+    if( m_pVideoControl )
+    {
+        m_pVideoControl->setVisible( false );
+    }
+}
+
index 3fdc8367bb27ce91a3fe0b9a2e20f196f787c950..e0e7846e0c63a3b80d74d99df08667d052a7a233 100644 (file)
@@ -35,6 +35,7 @@
 class Anchor;
 class OSGraphics;
 class CtrlGeneric;
+class CtrlVideo;
 
 
 /// Control and its associated layer
@@ -121,6 +122,12 @@ class GenericLayout: public SkinObject, public Box
         /// Add an anchor to this layout
         virtual void addAnchor( Anchor *pAnchor );
 
+        /// Called when the layout is shown
+        virtual void onShow();
+
+        /// Called when the layout is hidden
+        virtual void onHide();
+
     private:
         /// Parent window of the layout
         TopWindow *m_pWindow;
@@ -132,6 +139,8 @@ class GenericLayout: public SkinObject, public Box
         OSGraphics *m_pImage;
         /// List of the controls in the layout
         list<LayeredControl> m_controlList;
+        //// Video control
+        CtrlVideo *m_pVideoControl;
         /// List of the anchors in the layout
         list<Anchor*> m_anchorList;
 };
index d9c9495be67ff9f63bc8b8c2e2a507c7239263cf..84a4c419fba25b72a534522ebf6c87f9186c7850 100644 (file)
@@ -322,12 +322,22 @@ void TopWindow::refresh( int left, int top, int width, int height )
 
 void TopWindow::setActiveLayout( GenericLayout *pLayout )
 {
+    bool isVisible = getVisibleVar().get();
+    if( m_pActiveLayout && isVisible )
+    {
+        m_pActiveLayout->onHide();
+    }
+
     pLayout->setWindow( this );
     m_pActiveLayout = pLayout;
     // Get the size of the layout and resize the window
     resize( pLayout->getWidth(), pLayout->getHeight() );
+
     updateShape();
-    pLayout->refreshAll();
+    if( isVisible )
+    {
+        pLayout->onShow();
+    }
 }
 
 
@@ -339,17 +349,30 @@ const GenericLayout& TopWindow::getActiveLayout() const
 
 void TopWindow::innerShow()
 {
+    printf("show %x\n", m_pActiveLayout);
     // First, refresh the layout and update the shape of the window
     if( m_pActiveLayout )
     {
         updateShape();
-        m_pActiveLayout->refreshAll();
+        m_pActiveLayout->onShow();
     }
     // Show the window
     GenericWindow::innerShow();
 }
 
+
+void TopWindow::innerHide()
+{
+    if( m_pActiveLayout )
+    {
+        // Notify the active layout
+        m_pActiveLayout->onHide();
+    }
+    // Hide the window
+    GenericWindow::innerShow();
+}
+
+
 void TopWindow::updateShape()
 {
     // Set the shape of the window
index 1f3d8ae2903cb47dc00d903974c8372d801e818f..a31bfee6901adaf6778408bfbf913eb29644c290 100644 (file)
@@ -85,6 +85,9 @@ class TopWindow: public GenericWindow
         /// Actually show the window
         virtual void innerShow();
 
+        /// Actually hide the window
+        virtual void innerHide();
+
     private:
         /// Change the active layout
         virtual void setActiveLayout( GenericLayout *pLayout );
index 5181e93d3aec928a0928127db1f77ee142daa9b3..df80d04400ff9bee33c8f8ba00ff711424070fd7 100644 (file)
@@ -227,7 +227,7 @@ void VlcProc::dropVout()
     {
         if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
             vout_Control( m_pVout, VOUT_CLOSE );
-        m_pVout = NULL;
+      //  m_pVout = NULL;
     }
 }
 
index dec3a312556af24763d677ad43882c44542567d3..81fabaef96beeb654887b243784f25d334ff8efa 100644 (file)
@@ -89,3 +89,4 @@ void VoutWindow::refresh( int left, int top, int width, int height )
         }
     }
 }
+