Commit eb176036 authored by Cyril Deguet's avatar Cyril Deguet

* all: replaced remaining C callbacks by commands

parent a3eb8858
......@@ -27,14 +27,15 @@
#include "../src/os_timer.hpp"
AsyncQueue::AsyncQueue( intf_thread_t *pIntf ): SkinObject( pIntf )
AsyncQueue::AsyncQueue( intf_thread_t *pIntf ): SkinObject( pIntf ),
m_cmdFlush( this )
{
// Initialize the mutex
vlc_mutex_init( pIntf, &m_lock );
// Create a timer
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pTimer = pOsFactory->createOSTimer( Callback( this, &doFlush ) );
m_pTimer = pOsFactory->createOSTimer( m_cmdFlush );
// Flush the queue every 10 ms
m_pTimer->start( 10, false );
......@@ -129,9 +130,8 @@ void AsyncQueue::flush()
}
void AsyncQueue::doFlush( SkinObject *pObj )
void AsyncQueue::CmdFlush::execute()
{
AsyncQueue *pThis = (AsyncQueue*)pObj;
// Flush the queue
pThis->flush();
m_pParent->flush();
}
......@@ -65,8 +65,8 @@ class AsyncQueue: public SkinObject
AsyncQueue( intf_thread_t *pIntf );
virtual ~AsyncQueue();
/// Callback for the timer
static void doFlush( SkinObject *pObj );
// Callback to flush the queue
DEFINE_CALLBACK( AsyncQueue, Flush );
};
......
......@@ -44,6 +44,23 @@ class Cmd##name: public CmdGeneric \
};
/// Macro to define a "callback" command inside a class
#define DEFINE_CALLBACK( parent, action ) \
class Cmd##action: public CmdGeneric \
{ \
public: \
Cmd##action( parent *pParent ): \
CmdGeneric( pParent->getIntf() ), m_pParent( pParent ) {} \
virtual ~Cmd##action() {} \
virtual void execute(); \
virtual string getType() const { return "Cmd" #parent #action; } \
private: \
parent *m_pParent; \
\
} m_cmd##action; \
friend class Cmd##action;
/// Base class for skins commands
class CmdGeneric: public SkinObject
{
......
......@@ -37,11 +37,11 @@ CtrlButton::CtrlButton( intf_thread_t *pIntf, const GenericBitmap &rBmpUp,
VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rCommand( rCommand ), m_tooltip( rTooltip ),
m_cmdUpOverDownOver( pIntf, this ), m_cmdDownOverUpOver( pIntf, this ),
m_cmdDownOverDown( pIntf, this ), m_cmdDownDownOver( pIntf, this ),
m_cmdUpOverUp( pIntf, this ), m_cmdUpUpOver( pIntf, this ),
m_cmdDownUp( pIntf, this ), m_cmdUpHidden( pIntf, this ),
m_cmdHiddenUp( pIntf, this )
m_cmdUpOverDownOver( this ), m_cmdDownOverUpOver( this ),
m_cmdDownOverDown( this ), m_cmdDownDownOver( this ),
m_cmdUpOverUp( this ), m_cmdUpUpOver( this ),
m_cmdDownUp( this ), m_cmdUpHidden( this ),
m_cmdHiddenUp( this )
{
// Build the images of the button
OSFactory *pOsFactory = OSFactory::instance( pIntf );
......@@ -127,74 +127,74 @@ void CtrlButton::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlButton::CmdUpOverDownOver::execute()
{
m_pControl->captureMouse();
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgDown;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
m_pParent->captureMouse();
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgDown;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdDownOverUpOver::execute()
{
m_pControl->releaseMouse();
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
m_pParent->releaseMouse();
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
// Execute the command associated to this button
m_pControl->m_rCommand.execute();
m_pParent->m_rCommand.execute();
}
void CtrlButton::CmdDownOverDown::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdDownDownOver::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgDown;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgDown;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdUpUpOver::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgOver;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgOver;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdUpOverUp::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdDownUp::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
}
void CtrlButton::CmdUpHidden::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = NULL;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = NULL;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
void CtrlButton::CmdHiddenUp::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImg;
m_pControl->m_pImg = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImg );
const OSGraphics *pOldImg = m_pParent->m_pImg;
m_pParent->m_pImg = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImg );
}
......@@ -47,11 +47,11 @@ CtrlCheckbox::CtrlCheckbox( intf_thread_t *pIntf,
m_rVariable( rVariable ),
m_rCommand1( rCommand1 ), m_rCommand2( rCommand2 ),
m_tooltip1( rTooltip1 ), m_tooltip2( rTooltip2 ),
m_cmdUpOverDownOver( pIntf, this ), m_cmdDownOverUpOver( pIntf, this ),
m_cmdDownOverDown( pIntf, this ), m_cmdDownDownOver( pIntf, this ),
m_cmdUpOverUp( pIntf, this ), m_cmdUpUpOver( pIntf, this ),
m_cmdDownUp( pIntf, this ), m_cmdUpHidden( pIntf, this ),
m_cmdHiddenUp( pIntf, this )
m_cmdUpOverDownOver( this ), m_cmdDownOverUpOver( this ),
m_cmdDownOverDown( this ), m_cmdDownDownOver( this ),
m_cmdUpOverUp( this ), m_cmdUpUpOver( this ),
m_cmdDownUp( this ), m_cmdUpHidden( this ),
m_cmdHiddenUp( this )
{
// Build the images of the checkbox
OSFactory *pOsFactory = OSFactory::instance( pIntf );
......@@ -171,78 +171,78 @@ void CtrlCheckbox::draw( OSGraphics &rImage, int xDest, int yDest )
void CtrlCheckbox::CmdUpOverDownOver::execute()
{
m_pControl->captureMouse();
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgDown;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
m_pParent->captureMouse();
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgDown;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdDownOverUpOver::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
// Invert the state variable
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
// Execute the command
m_pControl->m_pCommand->execute();
m_pParent->m_pCommand->execute();
}
void CtrlCheckbox::CmdDownOverDown::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdDownDownOver::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgDown;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgDown;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdUpUpOver::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgOver;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgOver;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdUpOverUp::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdDownUp::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
}
void CtrlCheckbox::CmdUpHidden::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = NULL;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = NULL;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
void CtrlCheckbox::CmdHiddenUp::execute()
{
const OSGraphics *pOldImg = m_pControl->m_pImgCurrent;
m_pControl->m_pImgCurrent = m_pControl->m_pImgUp;
m_pControl->notifyLayoutMaxSize( pOldImg, m_pControl->m_pImgCurrent );
const OSGraphics *pOldImg = m_pParent->m_pImgCurrent;
m_pParent->m_pImgCurrent = m_pParent->m_pImgUp;
m_pParent->notifyLayoutMaxSize( pOldImg, m_pParent->m_pImgCurrent );
}
......
......@@ -134,21 +134,4 @@ class CtrlGeneric: public SkinObject, public Observer<VarBool>
typedef CountedPtr<CtrlGeneric> CtrlGenericPtr;
// Macro to define a control action command
#define DEFINE_CALLBACK( control, action ) \
class Cmd##action: public CmdGeneric \
{ \
public: \
Cmd##action( intf_thread_t *pIntf, control *pControl ): \
CmdGeneric( pIntf ), m_pControl( pControl) {} \
virtual ~Cmd##action() {} \
virtual void execute(); \
virtual string getType() const { return "Cmd" #control #action; } \
private: \
control *m_pControl; \
\
} m_cmd##action; \
friend class Cmd##action;
#endif
......@@ -37,9 +37,9 @@ CtrlMove::CtrlMove( intf_thread_t *pIntf, WindowManager &rWindowManager,
CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rWindowManager( rWindowManager ),
m_rCtrl( rCtrl ), m_rWindow( rWindow ),
m_cmdMovingMoving( pIntf, this ),
m_cmdStillMoving( pIntf, this ),
m_cmdMovingStill( pIntf, this )
m_cmdMovingMoving( this ),
m_cmdStillMoving( this ),
m_cmdMovingStill( this )
{
m_pEvt = NULL;
m_xPos = 0;
......@@ -98,33 +98,33 @@ void CtrlMove::handleEvent( EvtGeneric &rEvent )
void CtrlMove::CmdStillMoving::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
m_pControl->m_xPos = pEvtMouse->getXPos();
m_pControl->m_yPos = pEvtMouse->getYPos();
m_pParent->m_xPos = pEvtMouse->getXPos();
m_pParent->m_yPos = pEvtMouse->getYPos();
m_pControl->captureMouse();
m_pParent->captureMouse();
m_pControl->m_rWindowManager.startMove( m_pControl->m_rWindow );
m_pParent->m_rWindowManager.startMove( m_pParent->m_rWindow );
}
void CtrlMove::CmdMovingMoving::execute()
{
EvtMotion *pEvtMotion = (EvtMotion*)m_pControl->m_pEvt;
EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt;
int xNewLeft = pEvtMotion->getXPos() - m_pControl->m_xPos +
m_pControl->m_rWindow.getLeft();
int yNewTop = pEvtMotion->getYPos() - m_pControl->m_yPos +
m_pControl->m_rWindow.getTop();
int xNewLeft = pEvtMotion->getXPos() - m_pParent->m_xPos +
m_pParent->m_rWindow.getLeft();
int yNewTop = pEvtMotion->getYPos() - m_pParent->m_yPos +
m_pParent->m_rWindow.getTop();
m_pControl->m_rWindowManager.move( m_pControl->m_rWindow, xNewLeft, yNewTop );
m_pParent->m_rWindowManager.move( m_pParent->m_rWindow, xNewLeft, yNewTop );
}
void CtrlMove::CmdMovingStill::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
m_pControl->m_rWindowManager.stopMove();
m_pParent->m_rWindowManager.stopMove();
}
......@@ -40,8 +40,8 @@ CtrlRadialSlider::CtrlRadialSlider( intf_thread_t *pIntf,
VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_numImg( numImg ),
m_rVariable( rVariable ), m_minAngle( minAngle ), m_maxAngle( maxAngle ),
m_cmdUpDown( pIntf, this ), m_cmdDownUp( pIntf, this ),
m_cmdMove( pIntf, this )
m_cmdUpDown( this ), m_cmdDownUp( this ),
m_cmdMove( this )
{
// Build the images of the sequence
OSFactory *pOsFactory = OSFactory::instance( getIntf() );
......@@ -107,27 +107,27 @@ void CtrlRadialSlider::onUpdate( Subject<VarPercent> &rVariable )
void CtrlRadialSlider::CmdUpDown::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Change the position of the cursor, in non-blocking mode
m_pControl->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), false );
m_pParent->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), false );
m_pControl->captureMouse();
m_pParent->captureMouse();
}
void CtrlRadialSlider::CmdDownUp::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
}
void CtrlRadialSlider::CmdMove::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Change the position of the cursor, in blocking mode
m_pControl->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), true );
m_pParent->setCursor( pEvtMouse->getXPos(), pEvtMouse->getYPos(), true );
}
......
......@@ -37,12 +37,12 @@ CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
GenericLayout &rLayout, const UString &rHelp,
VarBool *pVisible ):
CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ),
m_rLayout( rLayout ), m_cmdOutStill( pIntf, this ),
m_cmdStillOut( pIntf, this ),
m_cmdStillStill( pIntf, this ),
m_cmdStillResize( pIntf, this ),
m_cmdResizeStill( pIntf, this ),
m_cmdResizeResize( pIntf, this )
m_rLayout( rLayout ), m_cmdOutStill( this ),
m_cmdStillOut( this ),
m_cmdStillStill( this ),
m_cmdStillResize( this ),
m_cmdResizeStill( this ),
m_cmdResizeResize( this )
{
m_pEvt = NULL;
m_xPos = 0;
......@@ -105,87 +105,87 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
void CtrlResize::CmdOutStill::execute()
{
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
}
void CtrlResize::CmdStillOut::execute()
{
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kDefaultArrow );
}
void CtrlResize::CmdStillStill::execute()
{
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
}
void CtrlResize::CmdStillResize::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
m_pControl->m_xPos = pEvtMouse->getXPos();
m_pControl->m_yPos = pEvtMouse->getYPos();
m_pParent->m_xPos = pEvtMouse->getXPos();
m_pParent->m_yPos = pEvtMouse->getYPos();
m_pControl->captureMouse();
m_pParent->captureMouse();
m_pControl->m_width = m_pControl->m_rLayout.getWidth();
m_pControl->m_height = m_pControl->m_rLayout.getHeight();
m_pParent->m_width = m_pParent->m_rLayout.getWidth();
m_pParent->m_height = m_pParent->m_rLayout.getHeight();
}
void CtrlResize::CmdResizeStill::execute()
{
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
m_pControl->releaseMouse();
m_pParent->releaseMouse();
}
void CtrlResize::CmdResizeResize::execute()
{
EvtMotion *pEvtMotion = (EvtMotion*)m_pControl->m_pEvt;
EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt;
// Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pControl->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
int newWidth = pEvtMotion->getXPos() - m_pControl->m_xPos + m_pControl->m_width;
int newHeight = pEvtMotion->getYPos() - m_pControl->m_yPos + m_pControl->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_pControl->m_rLayout.getMinWidth() )
if( newWidth < m_pParent->m_rLayout.getMinWidth() )
{
newWidth = m_pControl->m_rLayout.getMinWidth();
newWidth = m_pParent->m_rLayout.getMinWidth();
}
if( newWidth > m_pControl->m_rLayout.getMaxWidth() )
if( newWidth > m_pParent->m_rLayout.getMaxWidth() )
{
newWidth = m_pControl->m_rLayout.getMaxWidth();
newWidth = m_pParent->m_rLayout.getMaxWidth();
}
if( newHeight < m_pControl->m_rLayout.getMinHeight() )
if( newHeight < m_pParent->m_rLayout.getMinHeight() )
{
newHeight = m_pControl->m_rLayout.getMinHeight();
newHeight = m_pParent->m_rLayout.getMinHeight();
}
if( newHeight > m_pControl->m_rLayout.getMaxHeight() )
if( newHeight > m_pParent->m_rLayout.getMaxHeight() )
{
newHeight = m_pControl->m_rLayout.getMaxHeight();
newHeight = m_pParent->m_rLayout.getMaxHeight();
}
// Create a resize command
CmdGeneric *pCmd = new CmdResize( m_pControl->getIntf(), m_pControl->m_rLayout,
CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(), m_pParent->m_rLayout,
newWidth, newHeight );
// Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( m_pControl->getIntf() );
AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() );
pQueue->remove( "resize" );
pQueue->push( CmdGenericPtr( pCmd ) );
}
......@@ -50,9 +50,9 @@ CtrlSliderCursor::CtrlSliderCursor( intf_thread_t *pIntf,
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rVariable( rVariable ), m_tooltip( rTooltip ),
m_width( rCurve.getWidth() ), m_height( rCurve.getHeight() ),
m_cmdOverDown( pIntf, this ), m_cmdDownOver( pIntf, this ),
m_cmdOverUp( pIntf, this ), m_cmdUpOver( pIntf, this ),
m_cmdMove( pIntf, this ), m_cmdScroll( pIntf, this ),
m_cmdOverDown( this ), m_cmdDownOver( this ),
m_cmdOverUp( this ), m_cmdUpOver( this ),
m_cmdMove( this ), m_cmdScroll( this ),
m_lastPercentage( 0 ), m_xOffset( 0 ), m_yOffset( 0 ),
m_pEvt( NULL ), m_rCurve( rCurve )
{
......@@ -176,128 +176,128 @@ void CtrlSliderCursor::onUpdate( Subject<VarPercent> &rVariable )
void CtrlSliderCursor::CmdOverDown::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Compute the resize factors
float factorX, factorY;
m_pControl->getResizeFactors( factorX, factorY );
m_pParent->getResizeFactors( factorX, factorY );
// Get the position of the control
const Position *pPos = m_pControl->getPosition();
const Position *pPos = m_pParent->getPosition();
// Compute the offset
int tempX, tempY;
m_pControl->m_rCurve.getPoint( m_pControl->m_rVariable.get(), tempX, tempY );
m_pControl->m_xOffset = pEvtMouse->getXPos() - pPos->getLeft()
m_pParent->m_rCurve.getPoint( m_pParent->m_rVariable.get(), tempX, tempY );
m_pParent->m_xOffset = pEvtMouse->getXPos() - pPos->getLeft()
- (int)(tempX * factorX);
m_pControl->m_yOffset = pEvtMouse->getYPos() - pPos->getTop()
m_pParent->m_yOffset = pEvtMouse->getYPos() - pPos->getTop()
- (int)(tempY * factorY);
m_pControl->captureMouse();
m_pControl->m_pImg = m_pControl->m_pImgDown;
if( m_pControl->m_pImg )
m_pParent->captureMouse();
m_pParent->m_pImg = m_pParent->m_pImgDown;
if( m_pParent->m_pImg )
{
m_pControl->notifyLayout(
m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
- m_pControl->m_pImg->getWidth() / 2,
- m_pControl->m_pImg->getHeight() / 2 );
m_pParent->notifyLayout(
m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
- m_pParent->m_pImg->getWidth() / 2,
- m_pParent->m_pImg->getHeight() / 2 );
}
else
m_pControl->notifyLayout();
m_pParent->notifyLayout();
}
void CtrlSliderCursor::CmdDownOver::execute()
{
// Save the position
m_pControl->m_lastPercentage = m_pControl->m_rVariable.get();
m_pParent->m_lastPercentage = m_pParent->m_rVariable.get();
m_pControl->releaseMouse();
m_pControl->m_pImg = m_pControl->m_pImgUp;
if( m_pControl->m_pImg )
m_pParent->releaseMouse();
m_pParent->m_pImg = m_pParent->m_pImgUp;
if( m_pParent->m_pImg )
{
m_pControl->notifyLayout(
m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
- m_pControl->m_pImg->getWidth() / 2,
- m_pControl->m_pImg->getHeight() / 2 );
m_pParent->notifyLayout(
m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
- m_pParent->m_pImg->getWidth() / 2,
- m_pParent->m_pImg->getHeight() / 2 );
}
else
m_pControl->notifyLayout();
m_pParent->notifyLayout();
}
void CtrlSliderCursor::CmdUpOver::execute()
{
m_pControl->m_pImg = m_pControl->m_pImgOver;
if( m_pControl->m_pImg )
m_pParent->m_pImg = m_pParent->m_pImgOver;
if( m_pParent->m_pImg )
{
m_pControl->notifyLayout(
m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
- m_pControl->m_pImg->getWidth() / 2,
- m_pControl->m_pImg->getHeight() / 2 );
m_pParent->notifyLayout(
m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
- m_pParent->m_pImg->getWidth() / 2,
- m_pParent->m_pImg->getHeight() / 2 );
}
else
m_pControl->notifyLayout();
m_pParent->notifyLayout();
}
void CtrlSliderCursor::CmdOverUp::execute()
{
m_pControl->m_pImg = m_pControl->m_pImgUp;
if( m_pControl->m_pImg )
m_pParent->m_pImg = m_pParent->m_pImgUp;
if( m_pParent->m_pImg )
{
m_pControl->notifyLayout(
m_pControl->m_rCurve.getWidth() + m_pControl->m_pImg->getWidth(),
m_pControl->m_rCurve.getHeight() + m_pControl->m_pImg->getHeight(),
- m_pControl->m_pImg->getWidth() / 2,
- m_pControl->m_pImg->getHeight() / 2 );
m_pParent->notifyLayout(
m_pParent->m_rCurve.getWidth() + m_pParent->m_pImg->getWidth(),
m_pParent->m_rCurve.getHeight() + m_pParent->m_pImg->getHeight(),
- m_pParent->m_pImg->getWidth() / 2,
- m_pParent->m_pImg->getHeight() / 2 );
}
else
m_pControl->notifyLayout();
m_pParent->notifyLayout();
}
void CtrlSliderCursor::CmdMove::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Get the position of the control
const Position *pPos = m_pControl->getPosition();
const Position *pPos = m_pParent->getPosition();
// Compute the resize factors
float factorX, factorY;
m_pControl->getResizeFactors( factorX, factorY );
m_pParent->getResizeFactors( factorX, factorY );
// Compute the relative position of the centre of the cursor
float relX = pEvtMouse->getXPos() - pPos->getLeft() - m_pControl->m_xOffset;
float relY = pEvtMouse->getYPos() - pPos->getTop() - m_pControl->m_yOffset;
float relX = pEvtMouse->getXPos() - pPos->getLeft() - m_pParent->m_xOffset;
float relY = pEvtMouse->getYPos() - pPos->getTop() - m_pParent->m_yOffset;
// Ponderate with the resize factors
int relXPond = (int)(relX / factorX);
int relYPond = (int)(relY / factorY);
// Update the position
if( m_pControl->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE )
if( m_pParent->m_rCurve.getMinDist( relXPond, relYPond ) < RANGE )
{
float percentage = m_pControl->m_rCurve.getNearestPercent( relXPond,
float percentage = m_pParent->m_rCurve.getNearestPercent( relXPond,
relYPond );
m_pControl->m_rVariable.set( percentage );
m_pParent->m_rVariable.set( percentage );
}
else
{
m_pControl->m_rVariable.set( m_pControl->m_lastPercentage );
m_pParent->m_rVariable.set( m_pParent->m_lastPercentage );
}
}
void CtrlSliderCursor::CmdScroll::execute()
{
EvtScroll *pEvtScroll = (EvtScroll*)m_pControl->m_pEvt;
EvtScroll *pEvtScroll = (EvtScroll*)m_pParent->m_pEvt;
int direction = pEvtScroll->getDirection();
float percentage = m_pControl->m_rVariable.get();
float percentage = m_pParent->m_rVariable.get();
if( direction == EvtScroll::kUp )
{
percentage += SCROLL_STEP;
......@@ -307,7 +307,7 @@ void CtrlSliderCursor::CmdScroll::execute()
percentage -= SCROLL_STEP;
}
m_pControl->m_rVariable.set( percentage );
m_pParent->m_rVariable.set( percentage );
}
......
......@@ -44,14 +44,14 @@ CtrlText::CtrlText( intf_thread_t *pIntf, VarText &rVariable,
const GenericFont &rFont, const UString &rHelp,
uint32_t color, VarBool *pVisible ):
CtrlGeneric( pIntf, rHelp, pVisible ), m_fsm( pIntf ),
m_rVariable( rVariable ), m_cmdToManual( pIntf, this ),
m_cmdManualMoving( pIntf, this ), m_cmdManualStill( pIntf, this ),
m_cmdMove( pIntf, this ), m_pEvt( NULL ), m_rFont( rFont ),
m_rVariable( rVariable ), m_cmdToManual( this ),
m_cmdManualMoving( this ), m_cmdManualStill( this ),
m_cmdMove( this ), m_pEvt( NULL ), m_rFont( rFont ),
m_color( color ), m_pImg( NULL ), m_pImgDouble( NULL ),
m_pCurrImg( NULL ), m_xPos( 0 ), m_xOffset( 0 )
m_pCurrImg( NULL ), m_xPos( 0 ), m_xOffset( 0 ),
m_cmdUpdateText( this )
{
m_pTimer = OSFactory::instance( getIntf() )->createOSTimer(
Callback( this, &updateText ) );
m_pTimer = OSFactory::instance( pIntf )->createOSTimer( m_cmdUpdateText );
// States
m_fsm.addState( "still" );
......@@ -254,72 +254,70 @@ void CtrlText::onChangePosition()
void CtrlText::CmdToManual::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Compute the offset
m_pControl->m_xOffset = pEvtMouse->getXPos() - m_pControl->m_xPos;
m_pParent->m_xOffset = pEvtMouse->getXPos() - m_pParent->m_xPos;
m_pControl->m_pTimer->stop();
m_pControl->captureMouse();
m_pParent->m_pTimer->stop();
m_pParent->captureMouse();
}
void CtrlText::CmdManualMoving::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
// Start the automatic movement, but only if the text is wider than the
// control
if( m_pControl->m_pImg &&
m_pControl->m_pImg->getWidth() >= m_pControl->getPosition()->getWidth() )
if( m_pParent->m_pImg &&
m_pParent->m_pImg->getWidth() >= m_pParent->getPosition()->getWidth() )
{
// The current image may have been set incorrectly in displayText(), so
// set the correct value
m_pControl->m_pCurrImg = m_pControl->m_pImgDouble;
m_pParent->m_pCurrImg = m_pParent->m_pImgDouble;
m_pControl->m_pTimer->start( MOVING_TEXT_DELAY, false );
m_pParent->m_pTimer->start( MOVING_TEXT_DELAY, false );
}
}
void CtrlText::CmdManualStill::execute()
{
m_pControl->releaseMouse();
m_pParent->releaseMouse();
}
void CtrlText::CmdMove::execute()
{
EvtMouse *pEvtMouse = (EvtMouse*)m_pControl->m_pEvt;
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Do nothing if the text fits in the control
if( m_pControl->m_pImg &&
m_pControl->m_pImg->getWidth() >= m_pControl->getPosition()->getWidth() )
if( m_pParent->m_pImg &&
m_pParent->m_pImg->getWidth() >= m_pParent->getPosition()->getWidth() )
{
// The current image may have been set incorrectly in displayText(), so
// we set the correct value
m_pControl->m_pCurrImg = m_pControl->m_pImgDouble;
m_pParent->m_pCurrImg = m_pParent->m_pImgDouble;
// Compute the new position of the left side, and make sure it is
// in the correct range
m_pControl->m_xPos = (pEvtMouse->getXPos() - m_pControl->m_xOffset);
m_pControl->adjust( m_pControl->m_xPos );
m_pParent->m_xPos = (pEvtMouse->getXPos() - m_pParent->m_xOffset);
m_pParent->adjust( m_pParent->m_xPos );
m_pControl->notifyLayout( m_pControl->getPosition()->getWidth(),
m_pControl->getPosition()->getHeight() );
m_pParent->notifyLayout( m_pParent->getPosition()->getWidth(),
m_pParent->getPosition()->getHeight() );
}
}
void CtrlText::updateText( SkinObject *pCtrl )
void CtrlText::CmdUpdateText::execute()
{
CtrlText *m_pControl = (CtrlText*)pCtrl;
m_pParent->m_xPos -= MOVING_TEXT_STEP;
m_pParent->adjust( m_pParent->m_xPos );
m_pControl->m_xPos -= MOVING_TEXT_STEP;
m_pControl->adjust( m_pControl->m_xPos );
m_pControl->notifyLayout( m_pControl->getPosition()->getWidth(),
m_pControl->getPosition()->getHeight() );
m_pParent->notifyLayout( m_pParent->getPosition()->getWidth(),
m_pParent->getPosition()->getHeight() );
}
......
......@@ -95,7 +95,7 @@ class CtrlText: public CtrlGeneric, public Observer<VarText>
OSTimer *m_pTimer;
/// Callback for the timer
static void updateText( SkinObject *pCtrl );
DEFINE_CALLBACK( CtrlText, UpdateText );
/// Method called when the observed variable is modified
virtual void onUpdate( Subject<VarText> &rVariable );
......
......@@ -31,6 +31,7 @@
#include <list>
class GenericWindow;
class CmdGeneric;
class OSBitmap;
class OSGraphics;
class OSLoop;
......@@ -75,8 +76,8 @@ class OSFactory: public SkinObject
///
virtual void minimize() = 0;
/// Instantiate an OSTimer with the given callback
virtual OSTimer *createOSTimer( const Callback &rCallback ) = 0;
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd ) = 0;
/// Instantiate an object OSWindow.
virtual OSWindow *createOSWindow( GenericWindow &rWindow,
......
......@@ -114,28 +114,6 @@ class SkinObject
/// interface)
intf_thread_t *getIntf() const { return m_pIntf; }
/// Class for callbacks
class Callback {
public:
/// Type for callback methods
typedef void (*CallbackFunc_t)( SkinObject* );
/// Create a callback with the given object and function
Callback( SkinObject *pObj, CallbackFunc_t pFunc ):
m_pObj( pObj ), m_pFunc( pFunc ) {}
~Callback() {}
/// Getters
SkinObject *getObj() const { return m_pObj; }
CallbackFunc_t getFunc() const { return m_pFunc; }
private:
/// Pointer on the callback object
SkinObject *const m_pObj;
/// Pointer on the callback method
CallbackFunc_t m_pFunc;
};
private:
intf_thread_t *m_pIntf;
};
......
......@@ -35,10 +35,10 @@
Tooltip::Tooltip( intf_thread_t *pIntf, const GenericFont &rFont, int delay ):
SkinObject( pIntf ), m_rFont( rFont ), m_delay( delay ), m_pImage( NULL ),
m_xPos( -1 ), m_yPos( -1 )
m_xPos( -1 ), m_yPos( -1 ), m_cmdShow( this )
{
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pTimer = pOsFactory->createOSTimer( Callback( this, &doShow ) );
m_pTimer = pOsFactory->createOSTimer( m_cmdShow );
m_pOsTooltip = pOsFactory->createOSTooltip();
// Observe the tooltip text variable
......@@ -119,22 +119,20 @@ void Tooltip::makeImage( const UString &rText )
}
void Tooltip::doShow( SkinObject *pObj )
void Tooltip::CmdShow::execute()
{
Tooltip *pThis = (Tooltip*)pObj;
if( pThis->m_pImage )
if( m_pParent->m_pImage )
{
if( pThis->m_xPos == -1 )
if( m_pParent->m_xPos == -1 )
{
// Get the mouse coordinates and the image size
OSFactory *pOsFactory = OSFactory::instance( pThis->getIntf() );
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() );
int x, y;
pOsFactory->getMousePos( x, y );
int scrWidth = pOsFactory->getScreenWidth();
int scrHeight = pOsFactory->getScreenHeight();
int w = pThis->m_pImage->getWidth();
int h = pThis->m_pImage->getHeight();
int w = m_pParent->m_pImage->getWidth();
int h = m_pParent->m_pImage->getHeight();
// Compute the position of the tooltip
x -= (w / 2 + 4);
......@@ -146,13 +144,13 @@ void Tooltip::doShow( SkinObject *pObj )
if( y + h > scrHeight )
y -= (2 * h + 20);
pThis->m_xPos = x;
pThis->m_yPos = y;
m_pParent->m_xPos = x;
m_pParent->m_yPos = y;
}
// Show the tooltip window
pThis->m_pOsTooltip->show( pThis->m_xPos, pThis->m_yPos,
*(pThis->m_pImage) );
m_pParent->m_pOsTooltip->show( m_pParent->m_xPos, m_pParent->m_yPos,
*(m_pParent->m_pImage) );
}
}
......@@ -26,6 +26,7 @@
#define TOOLTIP_HPP
#include "../utils/var_text.hpp"
#include "../commands/cmd_generic.hpp"
class GenericFont;
class OSTooltip;
......@@ -72,8 +73,8 @@ class Tooltip: public SkinObject, public Observer<VarText>
/// Build m_pImage with the given text
void makeImage( const UString &rText );
/// Show the tooltip window
static void doShow( SkinObject *pObj );
/// Callback to show the tooltip window
DEFINE_CALLBACK( Tooltip, Show );
};
......
......@@ -60,11 +60,12 @@ void VlcProc::destroy( intf_thread_t *pIntf )
}
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL )
VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ), m_pVout( NULL ),
m_cmdManage( this )
{
// Create a timer to poll the status of the vlc
OSFactory *pOsFactory = OSFactory::instance( pIntf );
m_pTimer = pOsFactory->createOSTimer( Callback( this, &doManage ) );
m_pTimer = pOsFactory->createOSTimer( m_cmdManage );
m_pTimer->start( 100, false );
// Create and register VLC variables
......@@ -272,10 +273,10 @@ void VlcProc::manage()
}
void VlcProc::doManage( SkinObject *pObj )
void VlcProc::CmdManage::execute()
{
VlcProc *pThis = (VlcProc*)pObj;
pThis->manage();
// Just forward to VlcProc
m_pParent->manage();
}
......
......@@ -31,6 +31,7 @@
#include "../vars/time.hpp"
#include "../vars/volume.hpp"
#include "../utils/var_text.hpp"
#include "../commands/cmd_generic.hpp"
class OSTimer;
class VarBool;
......@@ -123,13 +124,12 @@ class VlcProc: public SkinObject
*/
void manage();
/// Define the command that calls manage()
DEFINE_CALLBACK( VlcProc, Manage );
/// Update the stream name variable
void updateStreamName( playlist_t *p_playlist );
/// This function directly calls manage(), because it's boring to
/// always write "pThis->"
static void doManage( SkinObject *pObj );
/// Callback for intf-change variable
static int onIntfChange( vlc_object_t *pObj, const char *pVariable,
vlc_value_t oldVal, vlc_value_t newVal,
......
......@@ -237,9 +237,9 @@ void Win32Factory::minimize()
ShowWindow( m_hParentWindow, SW_MINIMIZE );
}
OSTimer *Win32Factory::createOSTimer( const Callback &rCallback )
OSTimer *Win32Factory::createOSTimer( CmdGeneric &rCmd )
{
return new Win32Timer( getIntf(), rCallback, m_hParentWindow );
return new Win32Timer( getIntf(), rCmd, m_hParentWindow );
}
......
......@@ -56,8 +56,8 @@ class Win32Factory: public OSFactory
///
virtual void minimize();
/// Instantiate an OSTimer with the given callback
virtual OSTimer *createOSTimer( const Callback &rCallback );
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
/// Instantiate an OSWindow object
virtual OSWindow *createOSWindow( GenericWindow &rWindow,
......
......@@ -25,6 +25,7 @@
#ifdef WIN32_SKINS
#include "win32_timer.hpp"
#include "../commands/cmd_generic.hpp"
void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
......@@ -38,9 +39,8 @@ void CALLBACK CallbackTimer( HWND hwnd, UINT uMsg,
}
Win32Timer::Win32Timer( intf_thread_t *pIntf, const Callback &rCallback,
HWND hWnd ):
OSTimer( pIntf ), m_callback( rCallback ), m_hWnd( hWnd )
Win32Timer::Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd ):
OSTimer( pIntf ), m_rCommand( rCmd ), m_hWnd( hWnd )
{
}
......@@ -68,7 +68,7 @@ void Win32Timer::stop()
void Win32Timer::execute()
{
// Execute the callback
(*(m_callback.getFunc()))( m_callback.getObj() );
m_rCommand.execute();
// Restart the timer if needed
if( ! m_oneShot )
......
......@@ -27,13 +27,13 @@
#include "../src/os_timer.hpp"
class CmdGeneric;
// Win32 specific timer
class Win32Timer: public OSTimer
{
public:
Win32Timer( intf_thread_t *pIntf, const Callback &rCallback,
HWND hWnd );
Win32Timer( intf_thread_t *pIntf, CmdGeneric &rCmd, HWND hWnd );
virtual ~Win32Timer();
/// (Re)start the timer with the given delay (in ms). If oneShot is
......@@ -47,8 +47,8 @@ class Win32Timer: public OSTimer
void execute();
private:
/// Callback to execute
Callback m_callback;
/// Command to execute
CmdGeneric &m_rCommand;
/// Delay between two execute
mtime_t m_interval;
......
......@@ -102,9 +102,9 @@ void X11Factory::minimize()
DefaultScreen( m_pDisplay->getDisplay() ) );
}
OSTimer *X11Factory::createOSTimer( const Callback &rCallback )
OSTimer *X11Factory::createOSTimer( CmdGeneric &rCmd )
{
return new X11Timer( getIntf(), rCallback );
return new X11Timer( getIntf(), rCmd );
}
......
......@@ -59,8 +59,8 @@ class X11Factory: public OSFactory
/// Destroy the instance of OSLoop.
virtual void destroyOSLoop();
/// Instantiate an OSTimer with the given callback
virtual OSTimer *createOSTimer( const Callback &rCallback );
/// Instantiate an OSTimer with the given command
virtual OSTimer *createOSTimer( CmdGeneric &rCmd );
///
virtual void minimize();
......
......@@ -29,10 +29,11 @@
#include "x11_timer.hpp"
#include "x11_factory.hpp"
#include "../commands/cmd_generic.hpp"
X11Timer::X11Timer( intf_thread_t *pIntf, const Callback &rCallback ):
OSTimer( pIntf ), m_callback( rCallback )
X11Timer::X11Timer( intf_thread_t *pIntf, CmdGeneric &rCmd ):
OSTimer( pIntf ), m_rCommand( rCmd )
{
// Get the instance of timer loop
X11Factory *m_pOsFactory = (X11Factory*)(OSFactory::instance( pIntf ) );
......@@ -71,7 +72,7 @@ bool X11Timer::execute()
{
m_nextDate += m_interval;
// Execute the callback
(*(m_callback.getFunc()))( m_callback.getObj() );
m_rCommand.execute();
return !m_oneShot;
}
......
......@@ -31,13 +31,14 @@
// Forward declaration
class X11TimerLoop;
class CmdGeneric;
// X11 specific timer
class X11Timer: public OSTimer
{
public:
X11Timer( intf_thread_t *pIntf, const Callback &rCallback );
X11Timer( intf_thread_t *pIntf, CmdGeneric &rCmd );
virtual ~X11Timer();
/// (Re)start the timer with the given delay (in ms). If oneShot is
......@@ -54,8 +55,8 @@ class X11Timer: public OSTimer
bool execute();
private:
/// Callback to execute
Callback m_callback;
/// Command to execute
CmdGeneric m_rCommand;
/// Timer loop
X11TimerLoop *m_pTimerLoop;
/// Delay between two execute
......
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