From: <cn...@us...> - 2009-11-18 23:04:02
|
Revision: 625 http://hgengine.svn.sourceforge.net/hgengine/?rev=625&view=rev Author: cnlohr Date: 2009-11-18 23:03:51 +0000 (Wed, 18 Nov 2009) Log Message: ----------- tweak UI (And make MessageManager more const'ed) Modified Paths: -------------- Mercury2/modules/Cu2.cpp Mercury2/modules/Cu2.h Mercury2/src/MercuryMessageManager.cpp Mercury2/src/MercuryMessageManager.h Modified: Mercury2/modules/Cu2.cpp =================================================================== --- Mercury2/modules/Cu2.cpp 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/modules/Cu2.cpp 2009-11-18 23:03:51 UTC (rev 625) @@ -45,7 +45,7 @@ SetSize( m_fOrigW, m_fOrigH ); } -bool Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) +int Cu2Element::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) { if( IsHidden() ) return false; @@ -87,11 +87,11 @@ { //Break on the first one that is a hit, that way we don't pass mouse info to buttons below. if( sa->MouseMotion( x - int(sa->m_fX), y - int(sa->m_fY), iCurrentButtonMask, iLastButtonMask ) ) - return bIsInside; + return 2; } } - return bIsInside; + return bIsInside?1:0; } void Cu2Element::PropogateReleaseOut( int x, int y, int iWhichButton ) @@ -278,7 +278,10 @@ } else { - MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask ); + if( MouseMotion( m.dx, MercuryWindow::GetCurrentWindow()->Height()-m.dy, m.buttons.data, m_iLastButtonMask ) != 2 ) + { + MESSAGEMAN.BroadcastMessage( "UIMissMouse", &data ); + } } m_iLastButtonMask = m.buttons.data; @@ -318,6 +321,7 @@ LOAD_FROM_XML( "clickMessage", m_sMessageToSend, ); LOAD_FROM_XML( "text", m_sText, ); LOAD_FROM_XML( "autoSize", m_bAutoSize, StrToBool ); + LOAD_FROM_XML( "clickPayload", m_sValueToSend, ); if( m_pText ) { @@ -338,6 +342,7 @@ void Cu2Button::SaveToXMLTag( MString & sXMLStream ) { if( m_sMessageToSend.length() ) sXMLStream += ssprintf( "clickMessage=\"%s\" ", m_sMessageToSend.c_str() ); + if( m_sValueToSend.length() ) sXMLStream += ssprintf( "clickPayload=\"%s\" ", m_sValueToSend.c_str() ); if( m_bAutoSize ) sXMLStream += ssprintf( "autoSize=\"%d\" ", m_bAutoSize ); if( !m_pText ) @@ -498,8 +503,8 @@ glColor3f( .3, .3, .3 ); glBegin( GL_QUADS ); - glVertex2f( 2., GetH()-18 ); - glVertex2f( GetW()-2, GetH()-18 ); + glVertex2f( 2., GetH()-19 ); + glVertex2f( GetW()-2, GetH()-19 ); glVertex2f( GetW()-2, GetH()-3 ); glVertex2f( 2., GetH()-3 ); glEnd(); @@ -527,14 +532,18 @@ Cu2Element::MouseAction( x, y, c, iWhichButton ); } -bool Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) +int Cu2Dialog::MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ) { if( m_bDragging ) { float ix = GetX() - ( m_iClickX - x ); float iy = GetY() - ( m_iClickY - y ); + int dx = x - m_iClickX; + int dy = y - m_iClickY; + SetXY( ix, iy ); + return Cu2Element::MouseMotion( x - dx, y - dy, iCurrentButtonMask, iLastButtonMask ); } return Cu2Element::MouseMotion( x, y, iCurrentButtonMask, iLastButtonMask ); } Modified: Mercury2/modules/Cu2.h =================================================================== --- Mercury2/modules/Cu2.h 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/modules/Cu2.h 2009-11-18 23:03:51 UTC (rev 625) @@ -37,7 +37,10 @@ ///Push raw mouse event. Generally, this calls MouseAction, and is only called internally. ///You may override this if you want to take actions that require mouse motion. - virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); + ///Return value 2: Has hit a child. + ///Return value 1: Has hit self. + ///Return value 0: Has missed self. + virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); ///Called when a key is pressed - down the focus line. virtual void GetKeypress( int key, bool bDown, bool bRepeat ); @@ -155,11 +158,14 @@ void SetAutoSize( bool bAutoSize ) { m_bAutoSize = bAutoSize; Refresh(); } void Refresh(); + MString & Payload() { return m_sValueToSend; } + TextNode * GetTextNodeHandle() { return m_pText; } GENRTTI( Cu2Button ); private: MString m_sMessageToSend; + MString m_sValueToSend; MString m_sText; bool m_bAutoSize; bool m_bDown; @@ -177,7 +183,7 @@ virtual void LoadFromXML(const XMLNode& node); virtual void SaveToXMLTag( MString & sXMLStream ); virtual void Render( const MercuryMatrix& m ); - virtual bool MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); + virtual int MouseMotion( int x, int y, unsigned char iCurrentButtonMask, unsigned char iLastButtonMask ); virtual void MouseAction( int x, int y, Cu2Action c, int iWhichButton ); void SetText( const MString & sText ); Modified: Mercury2/src/MercuryMessageManager.cpp =================================================================== --- Mercury2/src/MercuryMessageManager.cpp 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/src/MercuryMessageManager.cpp 2009-11-18 23:03:51 UTC (rev 625) @@ -46,7 +46,7 @@ } } -void MercuryMessageManager::BroadcastMessage( const MString & message, MessageData * data ) +void MercuryMessageManager::BroadcastMessage( const MString & message, const MessageData * data ) { std::list< MessagePair > recipients; { Modified: Mercury2/src/MercuryMessageManager.h =================================================================== --- Mercury2/src/MercuryMessageManager.h 2009-11-18 22:11:44 UTC (rev 624) +++ Mercury2/src/MercuryMessageManager.h 2009-11-18 23:03:51 UTC (rev 625) @@ -40,7 +40,7 @@ void PostMessage(const MString& message, MessageData* data, float delay); ///Immediately dispatch message - void BroadcastMessage( const MString & message, MessageData * data ); + void BroadcastMessage( const MString & message, const MessageData * data ); void PumpMessages(const uint64_t& currTime); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |