/** * @brief Create/remove drag button. */ void UI_Window_SetDragButton (uiNode_t* node, bool value) { if (value) { // create the drag node uiNode_t* control = UI_AllocNode(WINDOW_DRAG_BUTTON_NAME, "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"); /* if there is a close button already on this windown, then insert the drag button before the close button; this is needed so the drag button is "below" the close button; if we don't do this, the drag button recieves input events for the close button first making the close button no longer working */ uiNode_t* close = UI_FindNode(node, WINDOW_CLOSE_BUTTON_NAME); if (close != nullptr) { // get the previous node of close close = UI_GetPrevNode(close); UI_InsertNode(node, close, control); } else { UI_AppendNode(node, control); } } else { // drop the drag node uiNode_t* control = UI_FindNode(node, WINDOW_DRAG_BUTTON_NAME); if (control) { UI_RemoveNode (node, control); } } EXTRADATA(node).dragButton = value; }
/** * @brief add a node at the end of the node child * @param parent The node where newNode is inserted as a child. * @param newNode The node to insert. */ void UI_AppendNode (uiNode_t* const parent, uiNode_t* newNode) { UI_InsertNode(parent, parent->lastChild, newNode); }
/** * @brief add a node at the end of the node child */ void UI_AppendNode (uiNode_t* const node, uiNode_t *newNode) { UI_InsertNode(node, node->lastChild, newNode); }