Commit 549afc38 authored by Olivier Teulière's avatar Olivier Teulière

* skins2/controls/ctrl_resize.cpp: The action of a Image control can now be

   resizeS or resizeE, in addition to the good old resizeSE.
parent 163bf2de
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl, CtrlResize::CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
GenericLayout &rLayout, const UString &rHelp, GenericLayout &rLayout, const UString &rHelp,
VarBool *pVisible ): VarBool *pVisible, Direction_t direction ):
CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ), CtrlFlat( pIntf, rHelp, pVisible ), m_fsm( pIntf ), m_rCtrl( rCtrl ),
m_rLayout( rLayout ), m_cmdOutStill( this ), m_rLayout( rLayout ), m_direction( direction ), m_cmdOutStill( this ),
m_cmdStillOut( this ), m_cmdStillOut( this ),
m_cmdStillStill( this ), m_cmdStillStill( this ),
m_cmdStillResize( this ), m_cmdStillResize( this ),
...@@ -103,24 +103,35 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent ) ...@@ -103,24 +103,35 @@ void CtrlResize::handleEvent( EvtGeneric &rEvent )
} }
void CtrlResize::CmdOutStill::execute() void CtrlResize::changeCursor( Direction_t direction ) const
{ {
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); OSFactory *pOsFactory = OSFactory::instance( getIntf() );
if( direction == kResizeSE )
pOsFactory->changeCursor( OSFactory::kResizeNWSE ); pOsFactory->changeCursor( OSFactory::kResizeNWSE );
else if( direction == kResizeS )
pOsFactory->changeCursor( OSFactory::kResizeNS );
else if( direction == kResizeE )
pOsFactory->changeCursor( OSFactory::kResizeWE );
else if( direction == kNone )
pOsFactory->changeCursor( OSFactory::kDefaultArrow );
}
void CtrlResize::CmdOutStill::execute()
{
m_pParent->changeCursor( m_pParent->m_direction );
} }
void CtrlResize::CmdStillOut::execute() void CtrlResize::CmdStillOut::execute()
{ {
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); m_pParent->changeCursor( kNone );
pOsFactory->changeCursor( OSFactory::kDefaultArrow );
} }
void CtrlResize::CmdStillStill::execute() void CtrlResize::CmdStillStill::execute()
{ {
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); m_pParent->changeCursor( m_pParent->m_direction );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
} }
...@@ -129,8 +140,7 @@ void CtrlResize::CmdStillResize::execute() ...@@ -129,8 +140,7 @@ void CtrlResize::CmdStillResize::execute()
EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt; EvtMouse *pEvtMouse = (EvtMouse*)m_pParent->m_pEvt;
// Set the cursor // Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); m_pParent->changeCursor( m_pParent->m_direction );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
m_pParent->m_xPos = pEvtMouse->getXPos(); m_pParent->m_xPos = pEvtMouse->getXPos();
m_pParent->m_yPos = pEvtMouse->getYPos(); m_pParent->m_yPos = pEvtMouse->getYPos();
...@@ -145,8 +155,7 @@ void CtrlResize::CmdStillResize::execute() ...@@ -145,8 +155,7 @@ void CtrlResize::CmdStillResize::execute()
void CtrlResize::CmdResizeStill::execute() void CtrlResize::CmdResizeStill::execute()
{ {
// Set the cursor // Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); m_pParent->changeCursor( m_pParent->m_direction );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
m_pParent->releaseMouse(); m_pParent->releaseMouse();
} }
...@@ -157,14 +166,18 @@ void CtrlResize::CmdResizeResize::execute() ...@@ -157,14 +166,18 @@ void CtrlResize::CmdResizeResize::execute()
EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt; EvtMotion *pEvtMotion = (EvtMotion*)m_pParent->m_pEvt;
// Set the cursor // Set the cursor
OSFactory *pOsFactory = OSFactory::instance( m_pParent->getIntf() ); m_pParent->changeCursor( m_pParent->m_direction );
pOsFactory->changeCursor( OSFactory::kResizeNWSE );
int newWidth = pEvtMotion->getXPos() - m_pParent->m_xPos + m_pParent->m_width; int newWidth = m_pParent->m_width;
int newHeight = pEvtMotion->getYPos() - m_pParent->m_yPos + m_pParent->m_height; int newHeight = m_pParent->m_height;
if( m_pParent->m_direction != kResizeS )
newWidth += pEvtMotion->getXPos() - m_pParent->m_xPos;
if( m_pParent->m_direction != kResizeE )
newHeight += pEvtMotion->getYPos() - m_pParent->m_yPos;
// Create a resize command // Create a resize command
CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(), m_pParent->m_rLayout, CmdGeneric *pCmd = new CmdResize( m_pParent->getIntf(),
m_pParent->m_rLayout,
newWidth, newHeight ); newWidth, newHeight );
// Push the command in the asynchronous command queue // Push the command in the asynchronous command queue
AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() ); AsyncQueue *pQueue = AsyncQueue::instance( m_pParent->getIntf() );
......
...@@ -34,9 +34,17 @@ ...@@ -34,9 +34,17 @@
class CtrlResize: public CtrlFlat class CtrlResize: public CtrlFlat
{ {
public: public:
enum Direction_t
{
kResizeE, // East
kResizeSE, // South-East
kResizeS, // South
kNone // Reserved for internal use
};
CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl, CtrlResize( intf_thread_t *pIntf, CtrlFlat &rCtrl,
GenericLayout &rLayout, const UString &rHelp, GenericLayout &rLayout, const UString &rHelp,
VarBool *pVisible ); VarBool *pVisible, Direction_t direction );
virtual ~CtrlResize() {} virtual ~CtrlResize() {}
/// Handle an event /// Handle an event
...@@ -68,6 +76,11 @@ class CtrlResize: public CtrlFlat ...@@ -68,6 +76,11 @@ class CtrlResize: public CtrlFlat
EvtGeneric *m_pEvt; EvtGeneric *m_pEvt;
/// Position of the click that started the resizing /// Position of the click that started the resizing
int m_xPos, m_yPos; int m_xPos, m_yPos;
/// Direction of the resizing
Direction_t m_direction;
/// Change the cursor, based on the given direction
void changeCursor( Direction_t direction ) const;
/// Callback objects /// Callback objects
DEFINE_CALLBACK( CtrlResize, OutStill ) DEFINE_CALLBACK( CtrlResize, OutStill )
......
...@@ -485,10 +485,25 @@ void Builder::addImage( const BuilderData::Image &rData ) ...@@ -485,10 +485,25 @@ void Builder::addImage( const BuilderData::Image &rData )
NULL); NULL);
pLayout->addControl( pMove, pos, rData.m_layer ); pLayout->addControl( pMove, pos, rData.m_layer );
} }
else if( rData.m_actionId == "resizeS" )
{
CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
UString( getIntf(), rData.m_help.c_str() ), NULL,
CtrlResize::kResizeS );
pLayout->addControl( pResize, pos, rData.m_layer );
}
else if( rData.m_actionId == "resizeE" )
{
CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
UString( getIntf(), rData.m_help.c_str() ), NULL,
CtrlResize::kResizeE );
pLayout->addControl( pResize, pos, rData.m_layer );
}
else if( rData.m_actionId == "resizeSE" ) else if( rData.m_actionId == "resizeSE" )
{ {
CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout, CtrlResize *pResize = new CtrlResize( getIntf(), *pImage, *pLayout,
UString( getIntf(), rData.m_help.c_str() ), NULL ); UString( getIntf(), rData.m_help.c_str() ), NULL,
CtrlResize::kResizeSE );
pLayout->addControl( pResize, pos, rData.m_layer ); pLayout->addControl( pResize, pos, rData.m_layer );
} }
else else
......
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