Beispiel #1
0
UIWindow* UI::push (const std::string& windowID)
{
	if (_noPushAllowed)
		return nullptr;

	if (!_stack.empty()) {
		UIWindow* activeWindow = *_stack.rbegin();
		if (activeWindow->getId() == windowID) {
			// don't push the same window twice onto
			// the stack just after each other
			return activeWindow;
		}
	}

	UIWindow* window = getWindow(windowID);
	if (!window) {
		error(LOG_CLIENT, "could not find window '" + windowID + "'");
		return nullptr;
	}

	if (_stack.empty() && !window->isRoot())
		return nullptr;

	if (!window->onPush())
		return nullptr;

	info(LOG_CLIENT, "push window " + windowID);
	System.track("pushwindow", window->getId());
	if (!_stack.empty()) {
		UIWindow* activeWindow = *_stack.rbegin();
		activeWindow->onPushedOver();
	}
	_stack.push_back(window);
	_stack.back()->onActive();
	return window;
}