当前位置: 首页>>代码示例>>C++>>正文


C++ EventCallback::MouseMoved方法代码示例

本文整理汇总了C++中EventCallback::MouseMoved方法的典型用法代码示例。如果您正苦于以下问题:C++ EventCallback::MouseMoved方法的具体用法?C++ EventCallback::MouseMoved怎么用?C++ EventCallback::MouseMoved使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventCallback的用法示例。


在下文中一共展示了EventCallback::MouseMoved方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: InputMouseMove

/**
**  Called if the mouse is moved
**
**  @param callbacks  Callback structure for events.
**  @param ticks      Denotes time-stamp of video-system
**  @param x          X movement
**  @param y          Y movement
*/
void InputMouseMove(const EventCallback &callbacks,
					unsigned ticks, int x, int y)
{
	// Don't reset the mouse state unless we really moved
#ifdef USE_TOUCHSCREEN
	const int buff = 32;
	if (((x - buff) <= MouseX && MouseX <= (x + buff)) == 0
		|| ((y - buff) <= MouseY && MouseY <= (y + buff)) == 0) {
		MouseState = InitialMouseState;
		LastMouseTicks = ticks;
	}
	if (MouseX != x || MouseY != y) {
		MouseX = x;
		MouseY = y;
	}
#else
	if (MouseX != x || MouseY != y) {
		MouseState = InitialMouseState;
		LastMouseTicks = ticks;
		MouseX = x;
		MouseY = y;
	}
#endif
	const PixelPos pos(x, y);
	callbacks.MouseMoved(pos);
}
开发者ID:stefanhendriks,项目名称:stratagus,代码行数:34,代码来源:interface.cpp

示例2: InputMouseMove

/**
**  Called if the mouse is moved
**
**  @param callbacks  Callback structure for events.
**  @param ticks      Denotes time-stamp of video-system
**  @param x          X movement
**  @param y          Y movement
*/
void InputMouseMove(const EventCallback &callbacks,
					unsigned ticks, int x, int y)
{
	PixelPos mousePos(x, y);
	// Don't reset the mouse state unless we really moved
#ifdef USE_TOUCHSCREEN
	const int buff = 32;
	const PixelDiff diff = LastMousePos - mousePos;

	if (abs(diff.x) > buff || abs(diff.y) > buff) {
		MouseState = InitialMouseState;
		LastMouseTicks = ticks;
		// Reset rectangle select cursor state if we moved by a lot
		// - rectangle select should be a drag, not a tap
		if (CursorState == CursorStateRectangle
			&& (abs(diff.x) > 2 * buff || abs(diff.y) > 2 * buff)) {
			CursorState = CursorStatePoint;
		}
	}
	LastMousePos = mousePos;
#else
	if (LastMousePos != mousePos) {
		MouseState = InitialMouseState;
		LastMouseTicks = ticks;
		LastMousePos = mousePos;
	}
#endif
	callbacks.MouseMoved(mousePos);
}
开发者ID:Clemenshemmerling,项目名称:Stratagus,代码行数:37,代码来源:interface.cpp


注:本文中的EventCallback::MouseMoved方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。