/** * @brief Do a star layout with child according to there num * @note 1=top-left 2=top-middle 3=top-right * 4=middle-left 5=middle-middle 6=middle-right * 7=bottom-left 8=bottom-middle 9=bottom-right * 10=fill * @todo Tag it static when it is possible */ void UI_StarLayout (uiNode_t *node) { uiNode_t *child; for (child = node->firstChild; child; child = child->next) { vec2_t source; vec2_t destination; if (child->align <= LAYOUTALIGN_NONE) continue; if (child->align == LAYOUTALIGN_FILL) { child->pos[0] = 0; child->pos[1] = 0; UI_NodeSetSize(child, node->size); child->behaviour->doLayout(child); } else if (child->align < LAYOUTALIGN_SPECIAL) { UI_NodeGetPoint(node, destination, child->align); UI_NodeRelativeToAbsolutePoint(node, destination); UI_NodeGetPoint(child, source, child->align); UI_NodeRelativeToAbsolutePoint(child, source); child->pos[0] += destination[0] - source[0]; child->pos[1] += destination[1] - source[1]; } } }
/** * @brief Console function to push a dropdown window at a position. It work like UI_PushWindow but move the window at the right position * @sa UI_PushWindow * @note The usage is "ui_push_dropdown sourcenode pointposition destinationnode pointposition" * sourcenode must be a node into the window we want to push, * we will move the window to have sourcenode over destinationnode * pointposition select for each node a position (like a corner). */ static void UI_PushDropDownWindow_f (void) { vec2_t source; vec2_t destination; uiNode_t *node; int direction; size_t writtenBytes; int result; if (Cmd_Argc() != 4 && Cmd_Argc() != 5) { Com_Printf("Usage: %s <source-anchor> <point-in-source-anchor> <dest-anchor> <point-in-dest-anchor>\n", Cmd_Argv(0)); return; } /* get the source anchor */ node = UI_GetNodeByPath(Cmd_Argv(1)); if (node == NULL) { Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(1)); return; } result = Com_ParseValue(&direction, Cmd_Argv(2), V_INT, 0, sizeof(direction), &writtenBytes); if (result != RESULT_OK) { Com_Printf("UI_PushDropDownWindow_f: '%s' in not a V_INT\n", Cmd_Argv(2)); return; } UI_NodeGetPoint(node, source, direction); UI_NodeRelativeToAbsolutePoint(node, source); /* get the destination anchor */ if (Q_streq(Cmd_Argv(4), "mouse")) { destination[0] = mousePosX; destination[1] = mousePosY; } else { /* get the source anchor */ node = UI_GetNodeByPath(Cmd_Argv(3)); if (node == NULL) { Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(3)); return; } result = Com_ParseValue(&direction, Cmd_Argv(4), V_INT, 0, sizeof(direction), &writtenBytes); if (result != RESULT_OK) { Com_Printf("UI_PushDropDownWindow_f: '%s' in not a V_INT\n", Cmd_Argv(4)); return; } UI_NodeGetPoint(node, destination, direction); UI_NodeRelativeToAbsolutePoint(node, destination); } /* update the window and push it */ node = UI_GetNodeByPath(Cmd_Argv(1)); if (node == NULL) { Com_Printf("UI_PushDropDownWindow_f: Node '%s' doesn't exist\n", Cmd_Argv(1)); return; } node = node->root; node->box.pos[0] += destination[0] - source[0]; node->box.pos[1] += destination[1] - source[1]; UI_PushWindow(node->name); }