Exemple #1
0
bool SampleBase::onMouse( MouseMsg& msg )
{
	if ( msg.onLeftDown() )
	{
		mLastDownPos = msg.getPos();
	}
	else if ( msg.isDraging() && msg.isLeftDown() )
	{
		Quaternion q;
		q.setMatrix( mMainCamera->getLocalTransform() );
		Vector3 rot = q.getEulerZYX();

		rot.z += 0.01 *( mLastDownPos.x - msg.getPos().x );
		rot.x += 0.01 *( mLastDownPos.y - msg.getPos().y );

		Quaternion q2;
		q2.setEulerZYX( rot.z , rot.y , rot.x );

		Matrix4 mat;
		mat.setTransform( mMainCamera->getLocalPosition() , q2 );

		mMainCamera->setLocalTransform( mat );
		//mMainCamera->rotate( CF_AXIS_Y , 0.01 *( mLastDownPos.x - msg.getPos().x ) , CFTO_LOCAL );
		//mMainCamera->rotate( CF_AXIS_X , -0.01 *( mLastDownPos.y - msg.getPos().y ) , CFTO_LOCAL );
		mLastDownPos = msg.getPos();
	}
	return true;
}
Exemple #2
0
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;
}
Exemple #3
0
bool CPlayButton::onMouseMsg( MouseMsg const& msg )
{
	if ( msg.onLeftDown() )
	{
		if ( m_playInfo.type == PT_NULL )
			return false;

		sDragIcon->removeRectArea( 0 );
		setupPlayIcon( sDragIcon );
		sDragIcon->show( true );
		
		Vec3D pos = mSprite->getWorldPosition();
		pos[2] = -8000;
		sDragIcon->setWorldPosition( pos );

		CUISystem::getInstance().captureMouse( this );
	}
	else if ( msg.onLeftUp() )
	{
		CUISystem::getInstance().releaseMouse();
		sDragIcon->show( false );

		CWidget* ui = CUISystem::getInstance().hitTest( msg.getPos() );

		if ( ui != this )
		{
			if ( ui )
			{
				CPlayButton* playbutton = dynamic_cast< CPlayButton* >( ui ) ;
				if ( playbutton )
					playbutton->onInputItem( this );
			}
			else
			{
				if ( m_cbType ==  CBT_FAST_PLAY_BAR )
					setFunction( NULL , NULL );
			}
			// skip OnClick
			return false;
		}
	}

	if ( msg.isLeftDown() && msg.isDraging() )
	{
		if ( sDragIcon->isShow() )
		{
			Vec2i const& size = getSize();
			MouseMsg const& msg = CUISystem::getInstance().getLastMouseMsg();
			sDragIcon->setWorldPosition( Vec3D( msg.x() - size.x/2 , msg.y() - size.y/2 , -8000 ) );
		}
	}

	CButtonUI::onMouseMsg( msg );

	return false;
}