#include "cmd_resize.hpp"
#include "../src/generic_layout.hpp"
+#include "../src/vlcproc.hpp"
CmdResize::CmdResize( intf_thread_t *pIntf, GenericLayout &rLayout, int width,
void CmdResizeVout::execute()
{
- // TODO
- msg_Dbg( getIntf(), "New vout size requested: %d x %d", m_width,
- m_height );
+ VarBox &rVoutSize = VlcProc::instance( getIntf() )->getVoutSizeVar();
+ rVoutSize.setSize( m_width, m_height );
}
int newWidth = pEvtMotion->getXPos() - m_pParent->m_xPos + m_pParent->m_width;
int newHeight = pEvtMotion->getYPos() - m_pParent->m_yPos + m_pParent->m_height;
- // Check boundaries
- if( newWidth < m_pParent->m_rLayout.getMinWidth() )
- {
- newWidth = m_pParent->m_rLayout.getMinWidth();
- }
- if( newWidth > m_pParent->m_rLayout.getMaxWidth() )
- {
- newWidth = m_pParent->m_rLayout.getMaxWidth();
- }
- if( newHeight < m_pParent->m_rLayout.getMinHeight() )
- {
- newHeight = m_pParent->m_rLayout.getMinHeight();
- }
- if( newHeight > m_pParent->m_rLayout.getMaxHeight() )
- {
- newHeight = m_pParent->m_rLayout.getMaxHeight();
- }
-
// Create a resize command
CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(), m_pParent->m_rLayout,
newWidth, newHeight );
#include "../commands/cmd_generic.hpp"
#include "../utils/fsm.hpp"
-class GenericLayout;
-
/// Control decorator for resizing windows
class CtrlResize: public CtrlFlat
#include "../src/theme.hpp"
#include "../src/vout_window.hpp"
#include "../src/os_graphics.hpp"
+#include "../src/vlcproc.hpp"
+#include "../commands/async_queue.hpp"
+#include "../commands/cmd_resize.hpp"
-CtrlVideo::CtrlVideo( intf_thread_t *pIntf, const UString &rHelp,
+CtrlVideo::CtrlVideo( intf_thread_t *pIntf, GenericLayout &rLayout,
+ bool autoResize, const UString &rHelp,
VarBool *pVisible ):
- CtrlGeneric( pIntf, rHelp, pVisible ), m_pVout( NULL )
+ CtrlGeneric( pIntf, rHelp, pVisible ), m_pVout( NULL ),
+ m_rLayout( rLayout ), m_xShift( 0 ), m_yShift( 0 )
{
+ // Observe the vout size variable if the control is auto-resizable
+ if( autoResize )
+ {
+ VarBox &rVoutSize = VlcProc::instance( pIntf )->getVoutSizeVar();
+ rVoutSize.addObserver( this );
+ }
}
CtrlVideo::~CtrlVideo()
{
+ VarBox &rVoutSize = VlcProc::instance( getIntf() )->getVoutSizeVar();
+ rVoutSize.delObserver( this );
+
if( m_pVout )
{
delete m_pVout;
}
+void CtrlVideo::onPositionChange()
+{
+ // Compute the difference between layout size and video size
+ m_xShift = m_rLayout.getWidth() - getPosition()->getWidth();
+ m_yShift = m_rLayout.getHeight() - getPosition()->getHeight();
+}
+
+
void CtrlVideo::draw( OSGraphics &rImage, int xDest, int yDest )
{
GenericWindow *pParent = getWindow();
}
}
}
+
+
+void CtrlVideo::onUpdate( Subject<VarBox> &rVoutSize )
+{
+ int newWidth = ((VarBox&)rVoutSize).getWidth() + m_xShift;
+ int newHeight = ((VarBox&)rVoutSize).getHeight() + m_yShift;
+
+ // Create a resize command
+ CmdGeneric *pCmd = new CmdResize( getIntf(), m_rLayout, newWidth,
+ newHeight );
+ // Push the command in the asynchronous command queue
+ AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
+ pQueue->remove( "resize" );
+ pQueue->push( CmdGenericPtr( pCmd ) );
+}
+
#define CTRL_VIDEO_HPP
#include "ctrl_generic.hpp"
+#include "../utils/position.hpp"
class VoutWindow;
/// Control video
-class CtrlVideo: public CtrlGeneric
+class CtrlVideo: public CtrlGeneric, public Observer<VarBox>
{
public:
- CtrlVideo( intf_thread_t *pIntf, const UString &rHelp,
- VarBool *pVisible );
+ CtrlVideo( intf_thread_t *pIntf, GenericLayout &rLayout,
+ bool autoResize, const UString &rHelp, VarBool *pVisible );
virtual ~CtrlVideo();
/// Handle an event on the control
/// Callback for layout resize
virtual void onResize();
+ /// Called when the Position is set
+ virtual void onPositionChange();
+
/// Draw the control on the given graphics
virtual void draw( OSGraphics &rImage, int xDest, int yDest );
/// Get the type of control (custom RTTI)
virtual string getType() const { return "video"; }
+ /// Method called when the vout size is updated
+ virtual void onUpdate( Subject<VarBox> &rVoutSize );
+
private:
/// Vout window
VoutWindow *m_pVout;
+ /// Associated layout
+ GenericLayout &m_rLayout;
+ /// Difference between layout size and video size
+ int m_xShift, m_yShift;
};
#endif
Interpreter *pInterpreter = Interpreter::instance( getIntf() );
VarBool *pVisible = pInterpreter->getVarBool( rData.m_visible, m_pTheme );
- CtrlVideo *pVideo = new CtrlVideo( getIntf(),
- UString( getIntf(), rData.m_help.c_str() ), pVisible );
+ CtrlVideo *pVideo = new CtrlVideo( getIntf(), *pLayout,
+ rData.m_autoResize, UString( getIntf(), rData.m_help.c_str() ),
+ pVisible );
// Compute the position of the control
const Position pos = makePosition( rData.m_leftTop, rData.m_rightBottom,
Slider id:string visible:string xPos:int yPos:int leftTop:string rightBottom:string upId:string downId:string overId:string points:string thickness:int value:string tooltip:string help:string layer:int windowId:string layoutId:string
List id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
Tree id:string xPos:int yPos:int visible:string width:int height:int leftTop:string rightBottom:string fontId:string var:string bgImageId:string itemImageId:string openImageId:string closedImageId:string fgColor:uint32_t playColor:uint32_t bgColor1:uint32_t bgColor2:uint32_t selColor:uint32_t help:string layer:int windowId:string layoutId:string
-Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string help:string layer:int windowId:string layoutId:string
+Video id:string xPos:int yPos:int width:int height:int leftTop:string rightBottom:string visible:string autoResize:bool help:string layer:int windowId:string layoutId:string
/// Type definition
struct Video
{
- Video( const string & id, int xPos, int yPos, int width, int height, const string & leftTop, const string & rightBottom, const string & visible, const string & help, int layer, const string & windowId, const string & layoutId ):
-m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
+ Video( const string & id, int xPos, int yPos, int width, int height, const string & leftTop, const string & rightBottom, const string & visible, bool autoResize, const string & help, int layer, const string & windowId, const string & layoutId ):
+m_id( id ), m_xPos( xPos ), m_yPos( yPos ), m_width( width ), m_height( height ), m_leftTop( leftTop ), m_rightBottom( rightBottom ), m_visible( visible ), m_autoResize( autoResize ), m_help( help ), m_layer( layer ), m_windowId( windowId ), m_layoutId( layoutId ) {}
const string m_id;
int m_xPos;
const string m_leftTop;
const string m_rightBottom;
const string m_visible;
+ bool m_autoResize;
const string m_help;
int m_layer;
const string m_windowId;
CheckDefault( "height", "0" );
CheckDefault( "lefttop", "lefttop" );
CheckDefault( "rightbottom", "lefttop" );
+ CheckDefault( "autoresize", "false" );
CheckDefault( "help", "" );
const BuilderData::Video videoData( uniqueId( attr["id"] ),
atoi( attr["x"] ) + m_xOffset, atoi( attr["y"] ) + m_yOffset,
atoi( attr["width"] ), atoi( attr["height" ]),
attr["lefttop"], attr["rightbottom"],
- attr["visible"], attr["help"], m_curLayer,
- m_curWindowId, m_curLayoutId );
+ attr["visible"], convertBoolean( attr["autoresize"] ),
+ attr["help"], m_curLayer, m_curWindowId, m_curLayoutId );
m_curLayer++;
m_data.m_listVideo.push_back( videoData );
}
return;
}
+ // Check boundaries
+ if( width < m_minWidth )
+ {
+ width = m_minWidth;
+ }
+ if( width > m_maxWidth )
+ {
+ width = m_maxWidth;
+ }
+ if( height < m_minHeight )
+ {
+ height = m_minHeight;
+ }
+ if( height > m_maxHeight )
+ {
+ height = m_maxHeight;
+ }
+
// Update the window size
m_width = width;
m_height = height;
if( p_intf->p_sys->p_playlist == NULL )
{
msg_Err( p_intf, "No playlist object found" );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
if( OSFactory::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot initialize OSFactory" );
- vlc_object_release( p_intf->p_sys->p_playlist );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_object_release( p_intf->p_sys->p_playlist );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
if( AsyncQueue::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot initialize AsyncQueue" );
- vlc_object_release( p_intf->p_sys->p_playlist );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_object_release( p_intf->p_sys->p_playlist );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
if( Interpreter::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot instanciate Interpreter" );
- vlc_object_release( p_intf->p_sys->p_playlist );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_object_release( p_intf->p_sys->p_playlist );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
if( VarManager::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot instanciate VarManager" );
- vlc_object_release( p_intf->p_sys->p_playlist );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_object_release( p_intf->p_sys->p_playlist );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
if( VlcProc::instance( p_intf ) == NULL )
{
msg_Err( p_intf, "Cannot initialize VLCProc" );
- vlc_object_release( p_intf->p_sys->p_playlist );
- msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
+ vlc_object_release( p_intf->p_sys->p_playlist );
+ msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
return VLC_EGENERIC;
}
Dialogs::instance( p_intf );
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL ),
- m_cmdManage( this )
+ m_cmdManage( this ), m_varVoutSize( pIntf )
{
// Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
#include "../vars/playtree.hpp"
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
+#include "../utils/position.hpp"
#include "../utils/var_text.hpp"
#include "../commands/cmd_generic.hpp"
VarText &getStreamURIVar()
{ return *((VarText*)(m_cVarStreamURI.get())); }
+ /// Getter for the vout size variable
+ VarBox &getVoutSizeVar() { return m_varVoutSize; }
+
/// Set the vout window handle
void registerVoutWindow( void *pVoutWindow );
VariablePtr m_cVarStopped;
VariablePtr m_cVarPaused;
VariablePtr m_cVarSeekable;
+ /// Variable for the vout
+ VarBox m_varVoutSize;
/// Set of handles of vout windows
/**
#include "position.hpp"
+const string VarBox::m_type = "box";
+
+
Rect::Rect( int left, int top, int right, int bottom ):
m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom )
{
return getBottom() - getTop() + 1;
}
+
+VarBox::VarBox( intf_thread_t *pIntf, int width, int height ):
+ Variable( pIntf ), m_width( width ), m_height( height )
+{
+}
+
+
+int VarBox::getWidth() const
+{
+ return m_width;
+}
+
+
+int VarBox::getHeight() const
+{
+ return m_height;
+}
+
+
+void VarBox::setSize( int width, int height )
+{
+ m_width = width;
+ m_height = height;
+ notify();
+}
+
#ifndef POSITION_HPP
#define POSITION_HPP
+#include "variable.hpp"
+#include "observer.hpp"
+
/// Interface for rectangular objects
class Box
};
+/// Variable implementing the Box interface
+class VarBox: public Variable, public Box, public Subject<VarBox>
+{
+ public:
+ VarBox( intf_thread_t *pIntf, int width = 0, int height = 0 );
+
+ virtual ~VarBox() {}
+
+ /// Get the variable type
+ virtual const string &getType() const { return m_type; }
+
+ /// Get the size of the box
+ virtual int getWidth() const;
+ virtual int getHeight() const;
+
+ /// Change the size of the box
+ void setSize( int width, int height );
+
+ private:
+ /// Variable type
+ static const string m_type;
+ /// Size
+ int m_width, m_height;
+};
+
+
#endif
height CDATA "0"
lefttop CDATA "lefttop"
rightbottom CDATA "lefttop"
+ autoresize CDATA "false"
help CDATA ""
>