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


C++ GHOST_Rect::wrapPoint方法代码示例

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


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

示例1: if

void
GHOST_SystemSDL::processEvent(SDL_Event *sdl_event)
{
	GHOST_Event * g_event= NULL;

	switch(sdl_event->type) {
	case SDL_WINDOWEVENT:
		{
			SDL_WindowEvent &sdl_sub_evt= sdl_event->window;
			GHOST_WindowSDL *window= findGhostWindow(SDL_GetWindowFromID(sdl_sub_evt.windowID));
			//assert(window != NULL); // can be NULL on close window.

			switch (sdl_sub_evt.event) {
			case SDL_WINDOWEVENT_EXPOSED:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window);
				break;
			case SDL_WINDOWEVENT_RESIZED:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window);
				break;
			case SDL_WINDOWEVENT_MOVED:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window);
				break;
			case SDL_WINDOWEVENT_FOCUS_GAINED:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window);
				break;
			case SDL_WINDOWEVENT_FOCUS_LOST:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window);
				break;
			case SDL_WINDOWEVENT_CLOSE:
				g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window);
				break;
			}
		}
		break;
	case SDL_QUIT:
		g_event= new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL);
		break;

	case SDL_MOUSEMOTION:
		{
			SDL_MouseMotionEvent &sdl_sub_evt= sdl_event->motion;
			SDL_Window *sdl_win= SDL_GetWindowFromID(sdl_sub_evt.windowID);
			GHOST_WindowSDL *window= findGhostWindow(sdl_win);
			assert(window != NULL);

			int x_win, y_win;
			SDL_GetWindowPosition(sdl_win, &x_win, &y_win);

			GHOST_TInt32 x_root= sdl_sub_evt.x + x_win;
			GHOST_TInt32 y_root= sdl_sub_evt.y + y_win;

#if 0
			if(window->getCursorGrabMode() != GHOST_kGrabDisable && window->getCursorGrabMode() != GHOST_kGrabNormal)
			{
				GHOST_TInt32 x_new= x_root;
				GHOST_TInt32 y_new= y_root;
				GHOST_TInt32 x_accum, y_accum;
				GHOST_Rect bounds;

				/* fallback to window bounds */
				if(window->getCursorGrabBounds(bounds)==GHOST_kFailure)
					window->getClientBounds(bounds);

				/* could also clamp to screen bounds
				 * wrap with a window outside the view will fail atm  */
				bounds.wrapPoint(x_new, y_new, 8); /* offset of one incase blender is at screen bounds */
				window->getCursorGrabAccum(x_accum, y_accum);

				// cant use setCursorPosition because the mouse may have no focus!
				if(x_new != x_root || y_new != y_root) {
					if (1 ) { //xme.time > m_last_warp) {
						/* when wrapping we don't need to add an event because the
						 * setCursorPosition call will cause a new event after */
						SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win); /* wrap */
						window->setCursorGrabAccum(x_accum + (x_root - x_new), y_accum + (y_root - y_new));
						// m_last_warp= lastEventTime(xme.time);
					} else {
						// setCursorPosition(x_new, y_new); /* wrap but don't accumulate */
						SDL_WarpMouseInWindow(sdl_win, x_new - x_win, y_new - y_win);
					}

					g_event = new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_new, y_new);
				}
				else {
					g_event = new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root + x_accum, y_root + y_accum);
				}
			}
			else
#endif
			{
				g_event= new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, x_root, y_root);
			}
			break;
		}
	case SDL_MOUSEBUTTONUP:
	case SDL_MOUSEBUTTONDOWN:
		{
			SDL_MouseButtonEvent &sdl_sub_evt= sdl_event->button;
			GHOST_TButtonMask gbmask= GHOST_kButtonMaskLeft;
			GHOST_TEventType type= (sdl_sub_evt.state==SDL_PRESSED) ? GHOST_kEventButtonDown : GHOST_kEventButtonUp;
//.........这里部分代码省略.........
开发者ID:BHCLL,项目名称:blendocv,代码行数:101,代码来源:GHOST_SystemSDL.cpp


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