Exemple #1
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 #2
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);
}