Commit eacca05e authored by Cyril Deguet's avatar Cyril Deguet

* backport of [15316], [15359] and [15451]

 (hope it works ;)
parent 1237bf88
...@@ -96,15 +96,6 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest ) ...@@ -96,15 +96,6 @@ void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
// Draw a black rectangle under the video to avoid transparency // Draw a black rectangle under the video to avoid transparency
rImage.fillRect( pPos->getLeft(), pPos->getTop(), pPos->getWidth(), rImage.fillRect( pPos->getLeft(), pPos->getTop(), pPos->getWidth(),
pPos->getHeight(), 0 ); 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 ) ...@@ -122,3 +113,26 @@ void CtrlVideo::onUpdate( Subject<VarBox, void *> &rVoutSize, void *arg )
pQueue->push( CmdGenericPtr( pCmd ) ); 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;
}
}
...@@ -58,6 +58,9 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox, void*> ...@@ -58,6 +58,9 @@ class CtrlVideo: public CtrlGeneric, public Observer<VarBox, void*>
/// Method called when the vout size is updated /// Method called when the vout size is updated
virtual void onUpdate( Subject<VarBox,void*> &rVoutSize, void* ); virtual void onUpdate( Subject<VarBox,void*> &rVoutSize, void* );
/// Called by the layout when the control is show/hidden
void setVisible( bool visible );
private: private:
/// Vout window /// Vout window
VoutWindow *m_pVout; VoutWindow *m_pVout;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include "os_factory.hpp" #include "os_factory.hpp"
#include "os_graphics.hpp" #include "os_graphics.hpp"
#include "../controls/ctrl_generic.hpp" #include "../controls/ctrl_generic.hpp"
#include "../controls/ctrl_video.hpp"
GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height, GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
...@@ -34,7 +35,8 @@ GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height, ...@@ -34,7 +35,8 @@ GenericLayout::GenericLayout( intf_thread_t *pIntf, int width, int height,
int maxHeight ): int maxHeight ):
SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ), SkinObject( pIntf ), m_pWindow( NULL ), m_width( width ),
m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ), m_height( height ), m_minWidth( minWidth ), m_maxWidth( maxWidth ),
m_minHeight( minHeight ), m_maxHeight( maxHeight ) m_minHeight( minHeight ), m_maxHeight( maxHeight ), m_pVideoControl( NULL ),
m_visible( false )
{ {
// Get the OSFactory // Get the OSFactory
OSFactory *pOsFactory = OSFactory::instance( getIntf() ); OSFactory *pOsFactory = OSFactory::instance( getIntf() );
...@@ -107,6 +109,12 @@ void GenericLayout::addControl( CtrlGeneric *pControl, ...@@ -107,6 +109,12 @@ void GenericLayout::addControl( CtrlGeneric *pControl,
{ {
m_controlList.push_back( LayeredControl( pControl, layer ) ); m_controlList.push_back( LayeredControl( pControl, layer ) );
} }
// Check if it is a video control
if( pControl->getType() == "video" )
{
m_pVideoControl = (CtrlVideo*)pControl;
}
} }
else else
{ {
...@@ -200,7 +208,6 @@ void GenericLayout::resize( int width, int height ) ...@@ -200,7 +208,6 @@ void GenericLayout::resize( int width, int height )
pWindow->refresh( 0, 0, width, height ); pWindow->refresh( 0, 0, width, height );
pWindow->resize( width, height ); pWindow->resize( width, height );
pWindow->refresh( 0, 0, width, height ); pWindow->refresh( 0, 0, width, height );
// Change the shape of the window and redraw it // Change the shape of the window and redraw it
pWindow->updateShape(); pWindow->updateShape();
pWindow->refresh( 0, 0, width, height ); pWindow->refresh( 0, 0, width, height );
...@@ -216,6 +223,10 @@ void GenericLayout::refreshAll() ...@@ -216,6 +223,10 @@ void GenericLayout::refreshAll()
void GenericLayout::refreshRect( int x, int y, int width, int height ) void GenericLayout::refreshRect( int x, int y, int width, int height )
{ {
// Do nothing if the layout is hidden
if( !m_visible )
return;
// Draw all the controls of the layout // Draw all the controls of the layout
list<LayeredControl>::const_iterator iter; list<LayeredControl>::const_iterator iter;
list<LayeredControl>::const_iterator iterVideo = m_controlList.end(); list<LayeredControl>::const_iterator iterVideo = m_controlList.end();
...@@ -226,10 +237,6 @@ void GenericLayout::refreshRect( int x, int y, int width, int height ) ...@@ -226,10 +237,6 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
if( pPos && pCtrl->isVisible() ) if( pPos && pCtrl->isVisible() )
{ {
pCtrl->draw( *m_pImage, pPos->getLeft(), pPos->getTop() ); 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 +255,7 @@ void GenericLayout::refreshRect( int x, int y, int width, int height ) ...@@ -248,7 +255,7 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
height = m_height - y; height = m_height - y;
// Refresh the window... but do not paint on a video control! // 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 // No video control, we can safely repaint the rectangle
pWindow->refresh( x, y, width, height ); pWindow->refresh( x, y, width, height );
...@@ -263,10 +270,10 @@ void GenericLayout::refreshRect( int x, int y, int width, int height ) ...@@ -263,10 +270,10 @@ void GenericLayout::refreshRect( int x, int y, int width, int height )
// becomes a real mess :) // becomes a real mess :)
// Use short variable names for convenience // Use short variable names for convenience
int xx = iterVideo->m_pControl->getPosition()->getLeft(); int xx = m_pVideoControl->getPosition()->getLeft();
int yy = iterVideo->m_pControl->getPosition()->getTop(); int yy = m_pVideoControl->getPosition()->getTop();
int ww = iterVideo->m_pControl->getPosition()->getWidth(); int ww = m_pVideoControl->getPosition()->getWidth();
int hh = iterVideo->m_pControl->getPosition()->getHeight(); int hh = m_pVideoControl->getPosition()->getHeight();
// Top part: // Top part:
if( y < yy ) if( y < yy )
...@@ -296,3 +303,28 @@ void GenericLayout::addAnchor( Anchor *pAnchor ) ...@@ -296,3 +303,28 @@ void GenericLayout::addAnchor( Anchor *pAnchor )
m_anchorList.push_back( pAnchor ); m_anchorList.push_back( pAnchor );
} }
void GenericLayout::onShow()
{
m_visible = true;
refreshAll();
// TODO find a better way to handle the vout ?
if( m_pVideoControl )
{
m_pVideoControl->setVisible( true );
}
}
void GenericLayout::onHide()
{
m_visible = false;
// TODO find a better way to handle the vout ?
if( m_pVideoControl )
{
m_pVideoControl->setVisible( false );
}
}
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
class Anchor; class Anchor;
class OSGraphics; class OSGraphics;
class CtrlGeneric; class CtrlGeneric;
class CtrlVideo;
/// Control and its associated layer /// Control and its associated layer
...@@ -121,6 +122,12 @@ class GenericLayout: public SkinObject, public Box ...@@ -121,6 +122,12 @@ class GenericLayout: public SkinObject, public Box
/// Add an anchor to this layout /// Add an anchor to this layout
virtual void addAnchor( Anchor *pAnchor ); virtual void addAnchor( Anchor *pAnchor );
/// Called when the layout is shown
virtual void onShow();
/// Called when the layout is hidden
virtual void onHide();
private: private:
/// Parent window of the layout /// Parent window of the layout
TopWindow *m_pWindow; TopWindow *m_pWindow;
...@@ -132,8 +139,12 @@ class GenericLayout: public SkinObject, public Box ...@@ -132,8 +139,12 @@ class GenericLayout: public SkinObject, public Box
OSGraphics *m_pImage; OSGraphics *m_pImage;
/// List of the controls in the layout /// List of the controls in the layout
list<LayeredControl> m_controlList; list<LayeredControl> m_controlList;
//// Video control
CtrlVideo *m_pVideoControl;
/// List of the anchors in the layout /// List of the anchors in the layout
list<Anchor*> m_anchorList; list<Anchor*> m_anchorList;
/// Flag to know if the layout is visible
bool m_visible;
}; };
......
...@@ -322,12 +322,22 @@ void TopWindow::refresh( int left, int top, int width, int height ) ...@@ -322,12 +322,22 @@ void TopWindow::refresh( int left, int top, int width, int height )
void TopWindow::setActiveLayout( GenericLayout *pLayout ) void TopWindow::setActiveLayout( GenericLayout *pLayout )
{ {
bool isVisible = getVisibleVar().get();
if( m_pActiveLayout && isVisible )
{
m_pActiveLayout->onHide();
}
pLayout->setWindow( this ); pLayout->setWindow( this );
m_pActiveLayout = pLayout; m_pActiveLayout = pLayout;
// Get the size of the layout and resize the window // Get the size of the layout and resize the window
resize( pLayout->getWidth(), pLayout->getHeight() ); resize( pLayout->getWidth(), pLayout->getHeight() );
updateShape(); updateShape();
pLayout->refreshAll(); if( isVisible )
{
pLayout->onShow();
}
} }
...@@ -343,13 +353,25 @@ void TopWindow::innerShow() ...@@ -343,13 +353,25 @@ void TopWindow::innerShow()
if( m_pActiveLayout ) if( m_pActiveLayout )
{ {
updateShape(); updateShape();
m_pActiveLayout->refreshAll(); m_pActiveLayout->onShow();
} }
// Show the window // Show the window
GenericWindow::innerShow(); GenericWindow::innerShow();
} }
void TopWindow::innerHide()
{
if( m_pActiveLayout )
{
// Notify the active layout
m_pActiveLayout->onHide();
}
// Hide the window
GenericWindow::innerHide();
}
void TopWindow::updateShape() void TopWindow::updateShape()
{ {
// Set the shape of the window // Set the shape of the window
......
...@@ -85,6 +85,9 @@ class TopWindow: public GenericWindow ...@@ -85,6 +85,9 @@ class TopWindow: public GenericWindow
/// Actually show the window /// Actually show the window
virtual void innerShow(); virtual void innerShow();
/// Actually hide the window
virtual void innerHide();
private: private:
/// Change the active layout /// Change the active layout
virtual void setActiveLayout( GenericLayout *pLayout ); virtual void setActiveLayout( GenericLayout *pLayout );
......
...@@ -216,7 +216,7 @@ void VlcProc::dropVout() ...@@ -216,7 +216,7 @@ void VlcProc::dropVout()
{ {
if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS ) if( vout_Control( m_pVout, VOUT_REPARENT ) != VLC_SUCCESS )
vout_Control( m_pVout, VOUT_CLOSE ); vout_Control( m_pVout, VOUT_CLOSE );
m_pVout = NULL; // m_pVout = NULL;
} }
} }
......
...@@ -89,3 +89,4 @@ void VoutWindow::refresh( int left, int top, int width, int height ) ...@@ -89,3 +89,4 @@ void VoutWindow::refresh( int left, int top, int width, int height )
} }
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment