UFO: Alien Invasion
Loading...
Searching...
No Matches
ui_node_panel.cpp
Go to the documentation of this file.
1
4
5/*
6Copyright (C) 2002-2025 UFO: Alien Invasion.
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17See the GNU General Public License for more details.
18
19You should have received a copy of the GNU General Public License
20along with this program; if not, write to the Free Software
21Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
23*/
24
25#include "../ui_main.h"
26#include "../ui_parse.h"
27#include "../ui_behaviour.h"
28#include "../ui_render.h"
29#include "../ui_actions.h"
30#include "../ui_input.h"
31#include "../ui_sprite.h"
32#include "../ui_lua.h"
33
35#include "ui_node_panel.h"
37#include "../../input/cl_keys.h"
38
40
41#define EXTRADATA_TYPE panelExtraData_t
42#define EXTRADATA(node) UI_EXTRADATA(node, EXTRADATA_TYPE)
43#define EXTRADATACONST(node) UI_EXTRADATACONST(node, EXTRADATA_TYPE)
44
48
50
55{
56 vec2_t pos;
57
58 UI_GetNodeAbsPos(node, pos);
59
60 if (EXTRADATA(node).background) {
61 UI_DrawSpriteInBox(false, EXTRADATA(node).background, SPRITE_STATUS_NORMAL, pos[0], pos[1], node->box.size[0], node->box.size[1]);
62 }
63}
64
73static void UI_TopDownFlowLayout (uiNode_t* node, int margin)
74{
75 const int width = node->box.size[0] - node->padding - node->padding;
76 int positionY = node->padding;
77 uiNode_t* child = node->firstChild;
78 vec2_t newSize = Vector2FromInt(width, 0);
79
80 while (child) {
81 if (!UI_Node_IsDrawable(child)) {
82 child = child->next;
83 continue;
84 }
85 newSize[1] = child->box.size[1];
86 UI_NodeSetSize(child, newSize);
87 child->box.pos[0] = node->padding;
88 child->box.pos[1] = positionY;
89 positionY += child->box.size[1] + margin;
90 child = child->next;
91 }
92
93 /* fix scroll */
94 {
95 bool updated;
96
97 updated = EXTRADATA(node).super.scrollX.set(-1, node->box.size[0], node->box.size[0]);
98 updated = EXTRADATA(node).super.scrollY.set(-1, node->box.size[1], positionY + node->padding) || updated;
99 if (updated) {
100 if (EXTRADATA(node).super.onViewChange) {
101 UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
102 }
103 else if (EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
104 UI_ExecuteLuaEventScript (node, EXTRADATA(node).super.lua_onViewChange);
105 }
106 }
107 }
108}
109
117static void UI_LeftRightFlowLayout (uiNode_t* node, int margin)
118{
119 const int height = node->box.size[1] - node->padding - node->padding;
120 int positionX = node->padding;
121 uiNode_t* child = node->firstChild;
122 vec2_t newSize = Vector2FromInt(0, height);
123
124 while (child) {
125 if (!UI_Node_IsDrawable(child)) {
126 child = child->next;
127 continue;
128 }
129 newSize[0] = child->box.size[0];
130 UI_NodeSetSize(child, newSize);
131 child->box.pos[0] = positionX;
132 child->box.pos[1] = node->padding;
133 positionX += child->box.size[0] + margin;
134 child = child->next;
135 }
136}
137
149static void UI_BorderLayout (uiNode_t* node, int margin)
150{
151 uiNode_t* child;
152 vec2_t newSize;
153 int minX = node->padding;
154 int maxX = node->box.size[0] - node->padding;
155 int minY = node->padding;
156 int maxY = node->box.size[1] - node->padding;
157
158 /* top */
159 for (child = node->firstChild; child; child = child->next) {
160 if (child->align != LAYOUTALIGN_TOP)
161 continue;
162 if (child->invis)
163 continue;
164 newSize[0] = maxX - minX;
165 newSize[1] = child->box.size[1];
166 UI_NodeSetSize(child, newSize);
167 child->box.pos[0] = minX;
168 child->box.pos[1] = minY;
169 minY += child->box.size[1] + margin;
170 }
171
172 /* bottom */
173 for (child = node->firstChild; child; child = child->next) {
174 if (child->align != LAYOUTALIGN_BOTTOM)
175 continue;
176 if (child->invis)
177 continue;
178 newSize[0] = maxX - minX;
179 newSize[1] = child->box.size[1];
180 UI_NodeSetSize(child, newSize);
181 child->box.pos[0] = minX;
182 child->box.pos[1] = maxY - child->box.size[1];
183 maxY -= child->box.size[1] + margin;
184 }
185
186 /* left */
187 for (child = node->firstChild; child; child = child->next) {
188 if (child->align != LAYOUTALIGN_LEFT)
189 continue;
190 if (child->invis)
191 continue;
192 newSize[0] = child->box.size[0];
193 newSize[1] = maxY - minY;
194 UI_NodeSetSize(child, newSize);
195 child->box.pos[0] = minX;
196 child->box.pos[1] = minY;
197 minX += child->box.size[0] + margin;
198 }
199
200 /* right */
201 for (child = node->firstChild; child; child = child->next) {
202 if (child->align != LAYOUTALIGN_RIGHT)
203 continue;
204 if (child->invis)
205 continue;
206 newSize[0] = child->box.size[0];
207 newSize[1] = maxY - minY;
208 UI_NodeSetSize(child, newSize);
209 child->box.pos[0] = maxX - child->box.size[0];
210 child->box.pos[1] = minY;
211 maxX -= child->box.size[0] + margin;
212 }
213
214 /* middle */
215 for (child = node->firstChild; child; child = child->next) {
216 if (child->align != LAYOUTALIGN_MIDDLE)
217 continue;
218 if (child->invis)
219 continue;
220 newSize[0] = maxX - minX;
221 newSize[1] = maxY - minY;
222 UI_NodeSetSize(child, newSize);
223 child->box.pos[0] = minX;
224 child->box.pos[1] = minY;
225 }
226}
227
238static void UI_PackLayout (uiNode_t* node, int margin)
239{
240 vec2_t newSize;
241 int minX = node->padding;
242 int maxX = node->box.size[0] - node->padding;
243 int minY = node->padding;
244 int maxY = node->box.size[1] - node->padding;
245
246 /* top */
247 for (uiNode_t* child = node->firstChild; child; child = child->next) {
248 if (child->invis)
249 continue;
250 switch (child->align) {
251 case LAYOUTALIGN_TOP:
252 newSize[0] = maxX - minX;
253 newSize[1] = child->box.size[1];
254 UI_NodeSetSize(child, newSize);
255 child->box.pos[0] = minX;
256 child->box.pos[1] = minY;
257 minY += child->box.size[1] + margin;
258 break;
260 newSize[0] = maxX - minX;
261 newSize[1] = child->box.size[1];
262 UI_NodeSetSize(child, newSize);
263 child->box.pos[0] = minX;
264 child->box.pos[1] = maxY - child->box.size[1];
265 maxY -= child->box.size[1] + margin;
266 break;
267 case LAYOUTALIGN_LEFT:
268 newSize[0] = child->box.size[0];
269 newSize[1] = maxY - minY;
270 UI_NodeSetSize(child, newSize);
271 child->box.pos[0] = minX;
272 child->box.pos[1] = minY;
273 minX += child->box.size[0] + margin;
274 break;
276 newSize[0] = child->box.size[0];
277 newSize[1] = maxY - minY;
278 UI_NodeSetSize(child, newSize);
279 child->box.pos[0] = maxX - child->box.size[0];
280 child->box.pos[1] = minY;
281 maxX -= child->box.size[0] + margin;
282 break;
283 case LAYOUTALIGN_FILL:
284 newSize[0] = maxX - minX;
285 newSize[1] = maxY - minY;
286 UI_NodeSetSize(child, newSize);
287 child->box.pos[0] = minX;
288 child->box.pos[1] = minY;
289 break;
290 default:
291 break;
292 }
293 }
294}
295
305{
306 for (uiNode_t* child = node->firstChild; child; child = child->next) {
307 if (child->align <= LAYOUTALIGN_NONE)
308 continue;
309
310 if (child->align == LAYOUTALIGN_FILL) {
311 child->box.pos[0] = 0;
312 child->box.pos[1] = 0;
313 UI_NodeSetSize(child, node->box.size);
314 UI_Node_DoLayout(child);
315 } else if (child->align < LAYOUTALIGN_SPECIAL) {
316 vec2_t source;
317 vec2_t destination;
318
319 UI_NodeGetPoint(node, destination, child->align);
320 UI_NodeRelativeToAbsolutePoint(node, destination);
321 UI_NodeGetPoint(child, source, child->align);
322 UI_NodeRelativeToAbsolutePoint(child, source);
323 child->box.pos[0] += destination[0] - source[0];
324 child->box.pos[1] += destination[1] - source[1];
325 }
326 }
327}
328
332static void UI_ClientLayout (uiNode_t* node)
333{
334 int width = 0;
335 int height = 0;
336 for (uiNode_t* child = node->firstChild; child; child = child->next) {
337 int value;
338 value = child->box.pos[0] + child->box.size[0];
339 if (value > width)
340 width = value;
341 value = child->box.pos[1] + child->box.size[1];
342 if (value > height)
343 height = value;
344 }
345
346 width += node->padding;
347 height += node->padding;
348
349 bool updated = EXTRADATA(node).super.scrollX.set(-1, node->box.size[0], width);
350 updated = EXTRADATA(node).super.scrollY.set(-1, node->box.size[1], height) || updated;
351 if (updated) {
352 if (EXTRADATA(node).super.onViewChange) {
353 UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
354 }
355 else if (EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
356 UI_ExecuteLuaEventScript (node, EXTRADATA(node).super.lua_onViewChange);
357 }
358 }
359}
360
368static void UI_ColumnLayout (uiNode_t* node)
369{
370 int rowHeight = 0;
371 int i;
372 int y;
373 uiNode_t* child;
374
375 if (EXTRADATA(node).layoutColumns <= 0) {
376 Com_Printf("UI_ColumnLayout: Column number must be positive (%s). Layout ignored.", UI_GetPath(node));
377 return;
378 }
379
380 int* columnPos = Mem_AllocTypeN(int, EXTRADATA(node).layoutColumns);
381 int* columnSize = Mem_AllocTypeN(int, EXTRADATA(node).layoutColumns);
382
383 /* check the first row */
384 child = node->firstChild;
385 for (i = 0; i < EXTRADATA(node).layoutColumns; i++) {
386 if (child == nullptr)
387 break;
388 columnSize[i] = child->box.size[0];
389 if (child->box.size[1] > rowHeight) {
390 rowHeight = child->box.size[1];
391 }
392 child = child->next;
393 }
394
395 /* compute column position */
396 columnPos[0] = node->padding;
397 for (i = 1; i < EXTRADATA(node).layoutColumns; i++) {
398 columnPos[i] = columnPos[i - 1] + columnSize[i - 1] + EXTRADATA(node).layoutMargin;
399 }
400
401 /* fix child position */
402 i = 0;
403 y = -1;
404 for (child = node->firstChild; child; child = child->next) {
405 const int column = i % EXTRADATA(node).layoutColumns;
406 if (column == 0) {
407 if (y < 0) {
408 y = node->padding;
409 } else {
410 y += rowHeight + EXTRADATA(node).layoutMargin;
411 }
412 }
413 child->box.pos[0] = columnPos[column];
414 child->box.pos[1] = y;
415 /*UI_NodeSetSize(child, node->box.size);*/
416 UI_Node_DoLayout(child);
417 i++;
418 }
419
420 /* fix scroll */
421 {
422 const int column = EXTRADATA(node).layoutColumns;
423 int width = columnPos[column - 1] + columnSize[column - 1] + node->padding;
424 int height = y + rowHeight + node->padding;
425 bool updated;
426
427 updated = EXTRADATA(node).super.scrollX.set(-1, node->box.size[0], width);
428 updated = EXTRADATA(node).super.scrollY.set(-1, node->box.size[1], height) || updated;
429 if (updated) {
430 if (EXTRADATA(node).super.onViewChange) {
431 UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
432 }
433 else if (EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
434 UI_ExecuteLuaEventScript (node, EXTRADATA(node).super.lua_onViewChange);
435 }
436 }
437 }
438
439 Mem_Free(columnPos);
440 Mem_Free(columnSize);
441}
442
444{
445 if (!node->invalidated)
446 return;
447
448 switch (EXTRADATA(node).layout) {
449 case LAYOUT_NONE:
450 break;
452 UI_TopDownFlowLayout(node, EXTRADATA(node).layoutMargin);
453 break;
455 UI_LeftRightFlowLayout(node, EXTRADATA(node).layoutMargin);
456 break;
457 case LAYOUT_BORDER:
458 UI_BorderLayout(node, EXTRADATA(node).layoutMargin);
459 break;
460 case LAYOUT_PACK:
461 UI_PackLayout(node, EXTRADATA(node).layoutMargin);
462 break;
463 case LAYOUT_STAR:
464 UI_StarLayout(node);
465 break;
466 case LAYOUT_CLIENT:
467 UI_ClientLayout(node);
468 break;
469 case LAYOUT_COLUMN:
470 UI_ColumnLayout(node);
471 break;
472 default:
473 Com_Printf("UI_PanelNodeDoLayout: layout '%d' unsupported.", EXTRADATA(node).layout);
474 break;
475 }
476
478}
479
484{
486 EXTRADATA(node).wheelScrollable = true;
487}
488
489/* Used for drag&drop-like scrolling */
490static int mouseScrollX;
491static int mouseScrollY;
492
493bool uiPanelNode::onMouseLongPress(uiNode_t* node, int x, int y, int button)
494{
495 bool hasSomethingToScroll = EXTRADATA(node).super.scrollX.fullSize > EXTRADATA(node).super.scrollX.viewSize
496 || EXTRADATA(node).super.scrollY.fullSize > EXTRADATA(node).super.scrollY.viewSize;
497 if (!UI_GetMouseCapture() && button == K_MOUSE1 && hasSomethingToScroll) {
498 UI_SetMouseCapture(node);
499 mouseScrollX = x;
500 mouseScrollY = y;
501 return true;
502 }
503 return false;
504}
505
506bool uiPanelNode::onStartDragging(uiNode_t* node, int startX, int startY, int x, int y, int button)
507{
508 return onMouseLongPress(node, startX, startY, button);
509}
510
511void uiPanelNode::onMouseUp (uiNode_t* node, int x, int y, int button)
512{
513 if (UI_GetMouseCapture() == node) /* More checks can never hurt */
515}
516
518{
520 if (mouseScrollY != y) {
521 scrollY(node, mouseScrollY - y);
522 mouseScrollX = x;
523 mouseScrollY = y;
524 }
525}
526
531{
532 if (EXTRADATA(node).layout != LAYOUT_NONE)
533 UI_Invalidate(node);
534}
535
537{
538 position[0] = -EXTRADATACONST(node).super.scrollX.viewPos;
539 position[1] = -EXTRADATACONST(node).super.scrollY.viewPos;
540}
541
543{
545 if (propertyPadding == nullptr) {
547 }
548
549 if (property == propertyLayoutColumns ||property == propertyLayoutMargin || property == propertyPadding) {
550 UI_Invalidate(node);
551 return;
552 }
554}
555
562bool uiPanelNode::onScroll (uiNode_t* node, int deltaX, int deltaY)
563{
564 bool updated;
565
566 /* @todo remove wheelScrollable after 2.4 release */
567 if (!EXTRADATA(node).wheelScrollable || deltaY == 0)
568 return false;
569
570 updated = EXTRADATA(node).super.scrollX.moveDelta(deltaX * 50);
571 updated |= EXTRADATA(node).super.scrollY.moveDelta(deltaY * 50);
572 if (updated) {
573 if (EXTRADATA(node).super.onViewChange) {
574 UI_ExecuteEventActions(node, EXTRADATA(node).super.onViewChange);
575 }
576 else if (EXTRADATA(node).super.lua_onViewChange != LUA_NOREF) {
577 UI_ExecuteLuaEventScript (node, EXTRADATA(node).super.lua_onViewChange);
578 }
579 }
580
581 /* @todo use super behaviour */
582 if (node->onWheelUp && deltaY < 0) {
584 updated = true;
585 }
586 if (node->onWheelDown && deltaY > 0) {
588 updated = true;
589 }
590 if (node->onWheel) {
591 UI_ExecuteEventActions(node, node->onWheel);
592 updated = true;
593 }
594 return updated;
595}
596
599 UI_EXTRADATA(node, panelExtraData_t).background = sprite;
600}
601
603{
604 localBehaviour = behaviour;
605 behaviour->extends = "abstractscrollable";
606 behaviour->name = "panel";
607 behaviour->extraDataSize = sizeof(EXTRADATA_TYPE);
608 behaviour->manager = UINodePtr(new uiPanelNode());
609 behaviour->lua_SWIG_typeinfo = UI_SWIG_TypeQuery("uiPanelNode_t *");
610
624 UI_RegisterExtradataNodeProperty(behaviour, "layout", V_INT, panelExtraData_t, layout);
628 propertyLayoutMargin = UI_RegisterExtradataNodeProperty(behaviour, "layoutMargin", V_INT, panelExtraData_t, layoutMargin);
632 propertyLayoutColumns = UI_RegisterExtradataNodeProperty(behaviour, "layoutColumns", V_INT, panelExtraData_t, layoutColumns);
636 UI_RegisterExtradataNodeProperty(behaviour, "wheelscrollable", V_BOOL, panelExtraData_t, wheelScrollable);
637
638 /* Sprite used to display the background */
639 UI_RegisterExtradataNodeProperty(behaviour, "background", V_UI_SPRITEREF, EXTRADATA_TYPE, background);
640
641 Com_RegisterConstInt("LAYOUTALIGN_TOPLEFT", LAYOUTALIGN_TOPLEFT);
642 Com_RegisterConstInt("LAYOUTALIGN_TOP", LAYOUTALIGN_TOP);
643 Com_RegisterConstInt("LAYOUTALIGN_TOPRIGHT", LAYOUTALIGN_TOPRIGHT);
644 Com_RegisterConstInt("LAYOUTALIGN_LEFT", LAYOUTALIGN_LEFT);
645 Com_RegisterConstInt("LAYOUTALIGN_MIDDLE", LAYOUTALIGN_MIDDLE);
646 Com_RegisterConstInt("LAYOUTALIGN_RIGHT", LAYOUTALIGN_RIGHT);
647 Com_RegisterConstInt("LAYOUTALIGN_BOTTOMLEFT", LAYOUTALIGN_BOTTOMLEFT);
648 Com_RegisterConstInt("LAYOUTALIGN_BOTTOM", LAYOUTALIGN_BOTTOM);
649 Com_RegisterConstInt("LAYOUTALIGN_BOTTOMRIGHT", LAYOUTALIGN_BOTTOMRIGHT);
650 Com_RegisterConstInt("LAYOUTALIGN_FILL", LAYOUTALIGN_FILL);
651
652 Com_RegisterConstInt("LAYOUT_TOP_DOWN_FLOW", LAYOUT_TOP_DOWN_FLOW);
653 Com_RegisterConstInt("LAYOUT_LEFT_RIGHT_FLOW", LAYOUT_LEFT_RIGHT_FLOW);
654 Com_RegisterConstInt("LAYOUT_BORDER", LAYOUT_BORDER);
655 Com_RegisterConstInt("LAYOUT_PACK", LAYOUT_PACK);
656 Com_RegisterConstInt("LAYOUT_STAR", LAYOUT_STAR);
657 Com_RegisterConstInt("LAYOUT_CLIENT", LAYOUT_CLIENT);
658 Com_RegisterConstInt("LAYOUT_COLUMN", LAYOUT_COLUMN);
659}
Header file for keyboard handler.
@ K_MOUSE1
Definition cl_keys.h:46
bool scrollY(uiNode_t *node, int offset)
Scroll the Y scroll with a relative position, and call event if need.
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
virtual void onLoading(uiNode_t *node)
void onLoading(uiNode_t *node) override
Handled after the end of the load of the node from script (all data and/or child are set).
void getClientPosition(uiNode_t const *node, vec2_t position) override
bool onMouseLongPress(uiNode_t *node, int x, int y, int button) override
Send mouse event when a pressed mouse button is dragged.
void draw(uiNode_t *node) override
Handles Button draw.
void onPropertyChanged(uiNode_t *node, const value_t *property) override
void onLoaded(uiNode_t *node) override
Handled after the end of the load of the node from script (all data and/or child are set).
void onMouseUp(uiNode_t *node, int x, int y, int button) override
bool onScroll(uiNode_t *node, int deltaX, int deltaY) override
Handle mouse wheel scrolling.
bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button) override
Send mouse event when a pressed mouse button is dragged.
void onCapturedMouseMove(uiNode_t *node, int x, int y) override
void doLayout(uiNode_t *node) override
Call to update the node layout. This common code revalidates the node tree.
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
#define Mem_Free(ptr)
Definition mem.h:35
#define Mem_AllocTypeN(type, n)
Definition mem.h:38
QGL_EXTERN GLint i
Definition r_gl.h:113
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition r_gl.h:110
void Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
Definition scripts.cpp:198
Header for script parsing functions.
@ V_BOOL
Definition scripts.h:50
@ V_INT
Definition scripts.h:52
Header for lua script functions.
extradata for the panel node
node behaviour, how a node work
const char * name
void * lua_SWIG_typeinfo
UINodePtr manager
const char * extends
intptr_t extraDataSize
vec2_t size
Definition ui_nodes.h:52
vec2_t pos
Definition ui_nodes.h:51
Atomic structure used to define most of the UI.
Definition ui_nodes.h:80
struct uiAction_s * onWheelDown
Definition ui_nodes.h:142
uiNode_t * firstChild
Definition ui_nodes.h:89
bool invis
Definition ui_nodes.h:101
uiNode_t * next
Definition ui_nodes.h:91
bool invalidated
Definition ui_nodes.h:104
uiBehaviour_t * behaviour
Definition ui_nodes.h:83
struct uiAction_s * onWheel
Definition ui_nodes.h:138
int align
Definition ui_nodes.h:110
uiBox_t box
Definition ui_nodes.h:96
int padding
Definition ui_nodes.h:109
struct uiAction_s * onWheelUp
Definition ui_nodes.h:141
vec_t vec2_t[2]
Definition ufotypes.h:38
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
const value_t * UI_GetPropertyFromBehaviour(const uiBehaviour_t *behaviour, const char *name)
Get a property from a behaviour or his inheritance It use a dichotomic search.
#define UI_RegisterExtradataNodeProperty(BEHAVIOUR, NAME, TYPE, EXTRADATATYPE, ATTRIBUTE)
Initialize a property from extradata of node.
void UI_SetMouseCapture(uiNode_t *node)
Captured the mouse into a node.
Definition ui_input.cpp:516
uiNode_t * UI_GetMouseCapture(void)
Return the captured node.
Definition ui_input.cpp:508
void UI_MouseRelease(void)
Release the captured node.
Definition ui_input.cpp:526
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
Definition ui_lua.cpp:71
Basic lua initialization for the ui.
void * UI_SWIG_TypeQuery(const char *name)
This function queries the SWIG type table for a type information structure. It is used in combination...
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
Definition ui_node.cpp:587
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
Definition ui_node.cpp:678
void UI_Node_DoLayout(uiNode_t *node)
Definition ui_node.cpp:263
bool UI_Node_IsDrawable(uiNode_t const *node)
Definition ui_node.cpp:48
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition ui_node.cpp:1065
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int direction)
return a relative position of a point into a node.
Definition ui_node.cpp:484
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition ui_node.cpp:526
SharedPtr< uiNode > UINodePtr
#define EXTRADATA_TYPE
#define EXTRADATA(node)
#define EXTRADATACONST(node)
static int startY
static int startX
static int mouseScrollY
static int mouseScrollX
static const uiBehaviour_t * localBehaviour
static void UI_PackLayout(uiNode_t *node, int margin)
Create a pack layout with child of the node. Set position and size of nodes one by one....
static void UI_LeftRightFlowLayout(uiNode_t *node, int margin)
Create a left-right flow layout with child of the node. Child position is automatically set,...
void UI_Panel_SetBackgroundByName(uiNode_t *node, const char *name)
void UI_StarLayout(uiNode_t *node)
Do a star layout with child according to there num.
#define EXTRADATA(node)
static const value_t * propertyLayoutColumns
static void UI_TopDownFlowLayout(uiNode_t *node, int margin)
Create a top-down flow layout with child of the node. Child position is automatically set,...
void UI_RegisterPanelNode(uiBehaviour_t *behaviour)
static void UI_BorderLayout(uiNode_t *node, int margin)
Create a border layout with child of the node. Child with BORDERLAYOUT_TOP and BORDERLAYOUT_BOTTOM nu...
static const value_t * propertyLayoutMargin
static const value_t * propertyPadding
static void UI_ColumnLayout(uiNode_t *node)
Do column layout. A grid layout according to a fixed number of column. Check to first row to see the ...
static void UI_ClientLayout(uiNode_t *node)
void UI_StarLayout(uiNode_t *node)
Do a star layout with child according to there num.
@ LAYOUTALIGN_BOTTOMLEFT
@ LAYOUTALIGN_LEFT
@ LAYOUTALIGN_TOPRIGHT
@ LAYOUTALIGN_TOPLEFT
@ LAYOUTALIGN_BOTTOM
@ LAYOUTALIGN_RIGHT
@ LAYOUTALIGN_NONE
@ LAYOUTALIGN_SPECIAL
@ LAYOUTALIGN_BOTTOMRIGHT
@ LAYOUTALIGN_TOP
@ LAYOUTALIGN_FILL
@ LAYOUTALIGN_MIDDLE
@ LAYOUT_COLUMN
@ LAYOUT_PACK
@ LAYOUT_LEFT_RIGHT_FLOW
@ LAYOUT_CLIENT
@ LAYOUT_BORDER
@ LAYOUT_TOP_DOWN_FLOW
@ LAYOUT_NONE
@ LAYOUT_STAR
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition ui_nodes.cpp:174
#define UI_EXTRADATA(NODE, TYPE)
Definition ui_nodes.h:185
#define V_UI_SPRITEREF
Definition ui_parse.h:56
void UI_DrawSpriteInBox(bool flip, const uiSprite_t *sprite, uiSpriteStatus_t status, int posX, int posY, int sizeX, int sizeY)
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
@ SPRITE_STATUS_NORMAL
Definition ui_sprite.h:33
#define Vector2FromInt(x, y)
Definition vector.h:40