Exemple #1
0
/**
 * @brief Remove a node from a parent node
 * @return The removed node, else nullptr
 * @param[in] node Node where is the child
 * @param[in] child Node we want to remove
 */
uiNode_t* UI_RemoveNode (uiNode_t* const node, uiNode_t* child)
{
	assert(node);
	assert(child);
	assert(child->parent == node);
	assert(node->firstChild);

	/** remove the 'child' node */
	for (uiNode_t** anchor = &node->firstChild;; anchor = &(*anchor)->next) {
		if (!*anchor)
			return 0;

		if (*anchor == child) {
			*anchor = child->next;
			break;
		}
	}
	UI_Invalidate(node);

	/** update cache */
	if (node->lastChild == child) {
		node->lastChild = node->firstChild;
		while (node->lastChild && node->lastChild->next)
			node->lastChild = node->lastChild->next;
	}
	if (child->root && child->indexed)
		UI_WindowNodeRemoveIndexedNode(child->root, child);

	child->next = nullptr;
	return child;
}
Exemple #2
0
/**
 * @brief Insert a node next another one into a node. If prevNode is nullptr add the node on the head of the window
 * @param[in] parent Node where the newNode is inserted in
 * @param[in] prevNode previous node, will became before the newNode; else nullptr if newNode will become the first child of the node
 * @param[in] newNode node we insert
 */
void UI_InsertNode (uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* newNode)
{
	/* parent and newNode should be valid, or else insertion doesn't make sense */
	assert(parent);
	assert(newNode);
	/* insert only a single element */
	assert(!newNode->next);

	uiNode_t** const anchor = prevNode ? &prevNode->next : &parent->firstChild;
	newNode->next   = *anchor;
	*anchor         = newNode;
	newNode->parent = parent;

	UI_UpdateRoot (newNode, parent->root);

	if (!parent->firstChild) {
		parent->firstChild = newNode;
	}
	if (!parent->lastChild) {
		parent->lastChild = newNode;
	}

	if (!newNode->next) {
		parent->lastChild = newNode;
	}

	if (newNode->root && newNode->indexed)
		UI_WindowNodeAddIndexedNode(newNode->root, newNode);

	UI_Invalidate(parent);
}
Exemple #3
0
/**
 * @brief Insert a node next another one into a node. If prevNode is NULL add the node on the head of the window
 * @param[in] node Node where inserting a node
 * @param[in] prevNode previous node, will became before the newNode; else NULL if newNode will become the first child of the node
 * @param[in] newNode node we insert
 */
void UI_InsertNode (uiNode_t* const node, uiNode_t *prevNode, uiNode_t *newNode)
{
	if (newNode->root == NULL)
		newNode->root = node->root;

	assert(node);
	assert(newNode);
	/* insert only a single element */
	assert(!newNode->next);
	/* everything come from the same window (force the dev to update himself this links) */
	assert(!prevNode || (prevNode->root == newNode->root));

	uiNode_t** const anchor = prevNode ? &prevNode->next : &node->firstChild;
	newNode->next   = *anchor;
	*anchor         = newNode;
	newNode->parent = node;

	if (!newNode->next)
		node->lastChild = newNode;

	if (newNode->root && newNode->indexed)
		UI_WindowNodeAddIndexedNode(newNode->root, newNode);

	UI_Invalidate(node);
}
Exemple #4
0
static void UI_OptionPropertyChanged (uiNode_t *node, const value_t *property)
{
	if (property == propertyCollapsed) {
		UI_Invalidate(node);
		return;
	}
	ui_optionBehaviour->super->propertyChanged(node, property);
}
Exemple #5
0
void uiOptionNode::onPropertyChanged (uiNode_t* node, const value_t* property)
{
	if (property == propertyCollapsed) {
		UI_Invalidate(node);
		return;
	}
	uiLocatedNode::onPropertyChanged(node, property);
}
Exemple #6
0
/**
 * @brief Invalidate all windows of the current stack.
 */
void UI_InvalidateStack (void)
{
	int pos;
	for (pos = 0; pos < ui_global.windowStackPos; pos++) {
		UI_Invalidate(ui_global.windowStack[pos]);
	}
	Cvar_SetValue("ui_sys_screenwidth", viddef.virtualWidth);
	Cvar_SetValue("ui_sys_screenheight", viddef.virtualHeight);
}
/**
 * @brief Handled after the end of the load of the node from script (all data and/or child are set)
 */
static void UI_PanelNodeLoaded (uiNode_t *node)
{
#ifdef DEBUG
	if (node->size[0] < CORNER_SIZE + MID_SIZE + CORNER_SIZE || node->size[1] < CORNER_SIZE + MID_SIZE + CORNER_SIZE)
		Com_DPrintf(DEBUG_CLIENT, "Node '%s' too small. It can create graphical glitches\n", UI_GetPath(node));
#endif
	if (EXTRADATA(node).layout != LAYOUT_NONE)
		UI_Invalidate(node);
}
Exemple #8
0
/**
 * @brief Called when we init the node on the screen
 */
void uiWindowNode::onWindowOpened (uiNode_t* node, linkedList_t* params)
{
	uiLocatedNode::onWindowOpened(node, nullptr);

	/* script callback */
	if (EXTRADATA(node).onWindowOpened)
		UI_ExecuteEventActionsEx(node, EXTRADATA(node).onWindowOpened, params);

	UI_Invalidate(node);
}
Exemple #9
0
/**
 * @brief Called at the end of the load from script
 */
void uiWindowNode::onLoaded (uiNode_t* node)
{
	/* note: the order here is important, first the drag button, then the close button otherwise the drag button
	   will be over the close button and the close button will no longer recieve input events */
	UI_Window_SetDragButton(node, EXTRADATA(node).dragButton);
	UI_Window_SetCloseButton (node, EXTRADATA(node).closeButton);
	UI_Window_FlagFullscreen(node);

	if (EXTRADATA(node).starLayout)
		UI_Invalidate(node);
}
static void UI_PanelPropertyChanged (uiNode_t *node, const value_t *property)
{
	/** @todo move it to registration code when it is possible */
	if (propertyPadding == NULL) {
		propertyPadding = UI_GetPropertyFromBehaviour(node->behaviour, "padding");
	}

	if (property == propertyLayoutColumns ||property == propertyLayoutMargin || property == propertyPadding) {
		UI_Invalidate(node);
		return;
	}
	localBehaviour->super->propertyChanged(node, property);
}
Exemple #11
0
/**
 * @brief Called when we init the node on the screen
 */
void uiWindowNode::onWindowOpened (uiNode_t* node, linkedList_t* params)
{
	uiLocatedNode::onWindowOpened(node, nullptr);

	/* script callback */
	if (EXTRADATA(node).onWindowOpened) {
		UI_ExecuteEventActionsEx(node, EXTRADATA(node).onWindowOpened, params);
	}
	if (EXTRADATA(node).lua_onWindowOpened != LUA_NOREF) {
		UI_ExecuteLuaEventScript_ParamList(node, EXTRADATA(node).lua_onWindowOpened, params);
	}

	UI_Invalidate(node);
}
Exemple #12
0
/**
 * @brief Called at the end of the load from script
 */
void uiWindowNode::onLoaded (uiNode_t* node)
{
	/* create a drag zone, if it is requested */
	if (EXTRADATA(node).dragButton) {
		uiNode_t* control = UI_AllocNode("move_window_button", "controls", node->dynamic);
		control->root = node;
		control->box.size[0] = node->box.size[0];
		control->box.size[1] = TOP_HEIGHT;
		control->box.pos[0] = 0;
		control->box.pos[1] = 0;
		control->tooltip = _("Drag to move window");
		UI_AppendNode(node, control);
	}

	/* create a close button, if it is requested */
	if (EXTRADATA(node).closeButton) {
		uiNode_t* button = UI_AllocNode("close_window_button", "button", node->dynamic);
		const int positionFromRight = CONTROLS_PADDING;
		static const char* closeCommand = "ui_close <path:root>;";

		button->root = node;
		UI_NodeSetProperty(button, UI_GetPropertyFromBehaviour(button->behaviour, "icon"), "icons/system_close");
		/** @todo Once @c image_t is known on the client, use @c image->width resp. @c image->height here */
		button->box.size[0] = CONTROLS_IMAGE_DIMENSIONS;
		button->box.size[1] = CONTROLS_IMAGE_DIMENSIONS;
		button->box.pos[0] = node->box.size[0] - positionFromRight - button->box.size[0];
		button->box.pos[1] = CONTROLS_PADDING;
		button->tooltip = _("Close the window");
		button->onClick = UI_AllocStaticCommandAction(closeCommand);
		UI_AppendNode(node, button);
	}

	EXTRADATA(node).isFullScreen = node->box.size[0] == VID_NORM_WIDTH
			&& node->box.size[1] == VID_NORM_HEIGHT;

	if (EXTRADATA(node).starLayout)
		UI_Invalidate(node);
}
static void UI_AbstractNodeVisibilityChange (uiNode_t* node)
{
	if (node->parent != nullptr)
		UI_Invalidate(node->parent);
}
/**
 * @brief Callback stub
 */
void uiLocatedNode::onSizeChanged (uiNode_t* node)
{
	if (node->firstChild != nullptr)
		UI_Invalidate(node);
}