Пример #1
0
bool UINode::addFirstFocus ()
{
	bool focus = false;
	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		nodePtr->removeFocus();
		if (focus)
			continue;
		focus = nodePtr->addFirstFocus();
		if (focus)
			addFocus(0, 0);
	}

	if (_nodes.empty() && isActive()) {
		addFocus(0, 0);
		return true;
	}
	return focus;
}
Пример #2
0
bool UINode::addLastFocus ()
{
	bool focus = false;
	for (UINodeListRevIter i = _nodes.rbegin(); i != _nodes.rend(); ++i) {
		UINode* nodePtr = *i;
		nodePtr->removeFocus();
		if (!focus) {
			focus = nodePtr->addLastFocus();
			if (focus) {
				addFocus(0, 0);
			}
		}
	}

	if (_nodes.empty() && isActive()) {
		addFocus(0, 0);
		return true;
	}
	return focus;
}
Пример #3
0
void UINode::removeFocus ()
{
	if (!_focus)
		return;
	Log::debug(LOG_CLIENT, "remove focus for %s", getId().c_str());
	_focus = false;
	_focusMouseX = -1;
	_focusMouseY = -1;
	for (Listeners::iterator i = _listeners.begin(); i != _listeners.end(); ++i) {
		(*i)->onRemoveFocus();
	}
	if (!fequals(_focusAlpha, 0.0f))
		restoreAlpha();

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* node = *i;
		if (!node->hasFocus())
			continue;
		node->removeFocus();
	}
}
Пример #4
0
bool UINode::nextFocus ()
{
	if (_nodes.empty()) {
		if (!isActive())
			return false;
		if (hasFocus())
			return false;
		addFocus(0, 0);
		return true;
	}

	for (UINodeListIter i = _nodes.begin(); i != _nodes.end(); ++i) {
		UINode* nodePtr = *i;
		// search the node that currently has the focus
		if (!nodePtr->hasFocus())
			continue;

		if (nodePtr->nextFocus()) {
			addFocus(0, 0);
			return true;
		}

		nodePtr->removeFocus();
		for (++i; i != _nodes.end(); ++i) {
			UINode* focusNodePtr = *i;
			if (focusNodePtr->addFirstFocus()) {
				addFocus(0, 0);
				return true;
			}
		}
		break;
	}

	removeFocus();

	return false;
}