bool TestStage::onMouse( MouseMsg const& msg ) { if ( !BaseClass::onMouse( msg ) ) return false; GameWindow& window = Global::getDrawEngine()->getWindow(); if ( msg.onLeftDown() ) { Light light; light.pos = Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y ); light.color = Color( float( ::Global::Random() ) / RAND_MAX , float( ::Global::Random() ) / RAND_MAX , float( ::Global::Random() ) / RAND_MAX ); lights.push_back( light ); } else if ( msg.onRightDown() ) { Block block; block.setBox( Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y ) , Vec2f( 50 , 50 ) ); blocks.push_back( block ); } else if ( msg.onMoving() ) { if ( !lights.empty() ) { lights.back().pos = Vec2f( msg.getPos().x , window.getHeight() - msg.getPos().y ); } } return true; }
bool GFrame::onMouseMsg( MouseMsg const& msg ) { BaseClass::onMouseMsg( msg ); static int x , y; static bool needMove = false; if ( msg.onLeftDown() ) { setTop(); if ( msg.getPos().y > getWorldPos().y && msg.getPos().y < getWorldPos().y + TopSideHeight ) { x = msg.x(); y = msg.y(); getManager()->captureMouse( this ); needMove = true; } } else if ( msg.onRightDown() ) { if ( msg.getPos().y > getWorldPos().y && msg.getPos().y < getWorldPos().y + TopSideHeight ) { mbMiniSize = !mbMiniSize; if ( mbMiniSize ) { mPrevSize = getSize(); setSize( Vec2i( mPrevSize.x , TopSideHeight ) ); mClipEnable = true; } else { setSize( mPrevSize ); mClipEnable = false; } } } else if ( msg.onLeftUp() ) { needMove = false; getManager()->releaseMouse(); } if ( needMove ) { if ( msg.isLeftDown() && msg.isDraging() ) { Vec2i pos = getPos() +Vec2i( msg.x() - x , msg.y() - y ); setPos( pos ); x = msg.x(); y = msg.y(); } } return false; }