예제 #1
0
void UI::pop ()
{
	if (_noPushAllowed)
		return;

	if (_stack.size() == 1) {
		UIPopupCallbackPtr c(new UIPopupOkCommandCallback(CMD_QUIT));
		UI::get().popup(tr("Quit"), UIPOPUP_OK | UIPOPUP_CANCEL, c);
		return;
	}

	UIWindow* window = *_stack.rbegin();
	if (!window->onPop())
		return;

	info(LOG_CLIENT, "pop window " + window->getId());
	System.track("popwindow", window->getId());
	_stack.pop_back();
	_stack.back()->onActive();

	if (window->shouldDelete()) {
		delete window;
	}
}
예제 #2
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;
}
예제 #3
0
void UI::popMain ()
{
	_noPushAllowed = true;
	// don't pop the root window
	while (_stack.size() > 1) {
		UIWindow* window = *_stack.rbegin();
		if (window->isMain())
			break;
		info(LOG_CLIENT, "pop window " + window->getId());
		window->onPop();
		_stack.pop_back();
		_stack.back()->onActive();

		if (window->shouldDelete()) {
			delete window;
		}
	}
	_noPushAllowed = false;
}