예제 #1
0
bool LayoutManager::ProcessPointer(float x, float y, float z, Msg msg, int button, PointerType pointerType, unsigned int pointerID)
{
#ifndef NDEBUG
    _lastPointerLocation[pointerID] = Vector2(x, y);
#endif

	if(UIWindow *captured = GetCapture(pointerID) )
	{
		// calc relative mouse position and route message to captured window
		for(UIWindow *wnd = captured; _desktop.Get() != wnd; wnd = wnd->GetParent() )
		{
			assert(wnd);
			x -= wnd->GetX();
			y -= wnd->GetY();
		}
		if( ProcessPointerInternal(captured, x, y, z, msg, button, pointerType, pointerID, true) ||
            ProcessPointerInternal(captured, x, y, z, msg, button, pointerType, pointerID, false))
			return true;
	}
	else
	{
		// handle all children of the desktop recursively; offer to topmost windows first
		if( ProcessPointerInternal(_desktop.Get(), x, y, z, msg, button, pointerType, pointerID, true) ||
            ProcessPointerInternal(_desktop.Get(), x, y, z, msg, button, pointerType, pointerID, false))
			return true;
	}
	if( _hotTrackWnd.Get() )
	{
		_hotTrackWnd->OnMouseLeave();
		_hotTrackWnd.Set(nullptr);
	}
	return false;
}
예제 #2
0
bool LayoutManager::SetFocusWnd(UIWindow* wnd)
{
	assert(!_dbgFocusIsChanging);
	if( _focusWnd.Get() != wnd )
	{
		WindowWeakPtr wp(wnd);
		WindowWeakPtr oldFocusWnd(_focusWnd.Get());

		// try setting new focus. it should not change _focusWnd
#ifndef NDEBUG
		_dbgFocusIsChanging = true;
#endif
		bool focusAccepted = wnd && wnd->GetEnabledCombined() && wnd->GetVisibleCombined() && wnd->OnFocus(true);
#ifndef NDEBUG
		_dbgFocusIsChanging = false;
#endif
		if( !focusAccepted && wp.Get() && oldFocusWnd.Get() )
		{
			for(UIWindow *w = wp.Get()->GetParent(); w; w = w->GetParent() )
			{
				if( w == oldFocusWnd.Get() )
				{
					// don't reset focus from parent
					return false;
				}
			}
		}

		// set new focus
		_focusWnd.Set(focusAccepted ? wp.Get() : nullptr);
		assert(!_focusWnd.Get() || _focusWnd->GetEnabledCombined() && _focusWnd->GetVisibleCombined());

		// reset old focus
		if( oldFocusWnd.Get() && oldFocusWnd.Get() != _focusWnd.Get() )
		{
			oldFocusWnd->OnFocus(false); // _focusWnd may be destroyed here
			if( oldFocusWnd.Get() && oldFocusWnd->eventLostFocus )
				oldFocusWnd->eventLostFocus();
		}
	}
	return nullptr != _focusWnd.Get();
}