Ejemplo n.º 1
0
/**
 * @brief Return the first visible node at a position
 */
uiNode_t *UI_GetNodeAtPosition (int x, int y)
{
	int pos;

	/* find the first window under the mouse */
	for (pos = ui_global.windowStackPos - 1; pos >= 0; pos--) {
		uiNode_t *window = ui_global.windowStack[pos];
		uiNode_t *find;

		/* update the layout */
		UI_Validate(window);

		find = UI_GetNodeInTreeAtPosition(window, x, y);
		if (find)
			return find;

		/* we must not search anymore */
		if (UI_WindowIsDropDown(window))
			break;
		if (UI_WindowIsModal(window))
			break;
		if (UI_WindowIsFullScreen(window))
			break;
	}

	return NULL;
}
Ejemplo n.º 2
0
/**
 * @brief Is called every time one clicks on a window/screen. Then checks if anything needs to be executed in the area of the click
 * (e.g. button-commands, inventory-handling, geoscape-stuff, etc...)
 * @sa UI_ExecuteEventActions
 * @sa UI_RightClick
 * @sa Key_Message
 */
static void UI_LeftClick (int x, int y)
{
	if (UI_IsMouseInvalidate())
		return;

	/* send it to the captured mouse node */
	if (capturedNode) {
		UI_Node_LeftClick(capturedNode, x, y);
		return;
	}

	/* if we click outside a dropdown window, we close it */
	/** @todo need to refactoring it with the focus code (cleaner) */
	/** @todo at least should be moved on the mouse down event (when the focus should change) */
	/** @todo this code must be on mouse down */
	if (!pressedNode && ui_global.windowStackPos != 0) {
		uiNode_t* window = ui_global.windowStack[ui_global.windowStackPos - 1];
		if (UI_WindowIsDropDown(window)) {
			UI_PopWindow();
		}
	}

	const bool disabled = (pressedNode == nullptr) || (pressedNode->disabled) || (pressedNode->parent && pressedNode->parent->disabled);
	if (!disabled) {
		UI_Node_LeftClick(pressedNode, x, y);
	}
}