UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ui_node.cpp
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #include <typeinfo>
27 #include "ui_main.h"
28 #include "ui_behaviour.h"
29 #include "ui_nodes.h"
30 #include "ui_node.h"
34 #include "node/ui_node_panel.h"
35 #include "ui_parse.h"
36 #include "ui_components.h"
37 #include "ui_internal.h"
38 
39 #include "../../common/hashtable.h"
40 
41 
42 bool UI_Node_IsVirtual (uiNode_t const* node)
43 {
44  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
45  return b == nullptr;
46 }
47 
48 bool UI_Node_IsDrawable (uiNode_t const* node)
49 {
50  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
51  return b != nullptr;
52 }
53 
55 {
56  uiAbstractOptionNode* b = dynamic_cast<uiAbstractOptionNode*>(node->behaviour->manager.get());
57  return b != nullptr;
58 }
59 
60 bool UI_Node_IsWindow (uiNode_t const* node)
61 {
62  uiWindowNode* b = dynamic_cast<uiWindowNode*>(node->behaviour->manager.get());
63  return b != nullptr;
64 }
65 
66 bool UI_Node_IsBattleScape (uiNode_t const* node)
67 {
68  uiBattleScapeNode* b = dynamic_cast<uiBattleScapeNode*>(node->behaviour->manager.get());
69  return b != nullptr;
70 }
71 
72 bool UI_Node_IsAbstract (uiNode_t const* node)
73 {
74  return node->behaviour->isAbstract;
75 }
76 
78 {
79  return node->behaviour->drawItselfChild;
80 }
81 
85 bool UI_Node_IsFunction (uiNode_t const* node)
86 {
87  return node->behaviour->isFunction;
88 }
89 
94 {
96  return b != nullptr;
97 }
98 
99 const char* UI_Node_GetWidgetName (uiNode_t const* node)
100 {
101  return node->behaviour->name;
102 }
103 
104 intptr_t UI_Node_GetMemorySize (uiNode_t const* node)
105 {
106  return sizeof(*node) + node->behaviour->extraDataSize;
107 }
108 
109 void UI_Node_Draw (uiNode_t* node)
110 {
111  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
112  b->draw(node);
113 }
114 
115 void UI_Node_DrawTooltip (const uiNode_t* node, int x, int y)
116 {
117  const uiLocatedNode* b = dynamic_cast<const uiLocatedNode*>(node->behaviour->manager.get());
118  b->drawTooltip(node, x, y);
119 }
120 
122 {
123  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
124  b->drawOverWindow(node);
125 }
126 
127 /* mouse events */
128 void UI_Node_LeftClick (uiNode_t* node, int x, int y)
129 {
130  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
131  b->onLeftClick(node, x, y);
132 }
133 
134 void UI_Node_RightClick (uiNode_t* node, int x, int y)
135 {
136  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
137  b->onRightClick(node, x, y);
138 }
139 
140 void UI_Node_MiddleClick (uiNode_t* node, int x, int y)
141 {
142  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
143  b->onMiddleClick(node, x, y);
144 }
145 
146 bool UI_Node_Scroll (uiNode_t* node, int deltaX, int deltaY)
147 {
148  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
149  return b->onScroll(node, deltaX, deltaY);
150 }
151 
152 void UI_Node_MouseMove (uiNode_t* node, int x, int y)
153 {
154  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
155  b->onMouseMove(node, x, y);
156 }
157 
158 void UI_Node_MouseDown (uiNode_t* node, int x, int y, int button)
159 {
160  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
161  b->onMouseDown(node, x, y, button);
162 }
163 
164 void UI_Node_MouseUp (uiNode_t* node, int x, int y, int button)
165 {
166  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
167  b->onMouseUp(node, x, y, button);
168 }
169 
171 {
172  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
173  b->onMouseEnter(node);
174 }
175 
177 {
178  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
179  b->onMouseLeave(node);
180 }
181 
182 bool UI_Node_MouseLongPress (uiNode_t* node, int x, int y, int button)
183 {
184  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
185  return b->onMouseLongPress(node, x, y, button);
186 }
187 
188 bool UI_Node_StartDragging (uiNode_t* node, int startX, int startY, int currentX, int currentY, int button)
189 {
190  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
191  return b->onStartDragging(node, startX, startY, currentX, currentY, button);
192 }
193 
194 void UI_Node_CapturedMouseMove (uiNode_t* node, int x, int y)
195 {
196  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
197  b->onCapturedMouseMove(node, x, y);
198 }
199 
201 {
202  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
203  b->onCapturedMouseLost(node);
204 }
205 
206 /* system allocation */
207 
209 {
210  uiNode* b = node->behaviour->manager.get();
211  b->onLoading(node);
212 }
213 
215 {
216  uiNode* b = node->behaviour->manager.get();
217  b->onLoaded(node);
218 }
219 
220 void UI_Node_Clone (uiNode_t const* source, uiNode_t* clone)
221 {
222  uiNode* b = source->behaviour->manager.get();
223  b->clone(source, clone);
224 }
225 
227  uiNode* b = node->behaviour->manager.get();
228  b->initNodeDynamic(node);
229 }
230 
232 {
233  uiNode* b = node->behaviour->manager.get();
234  b->initNode(node);
235 }
236 
238 {
239  uiNode* b = node->behaviour->manager.get();
240  b->deleteNode(node);
241 }
242 
243 /* system callback */
244 
246 {
247  uiNode* b = node->behaviour->manager.get();
248  b->onWindowOpened(node, params);
249 }
250 
252 {
253  uiNode* b = node->behaviour->manager.get();
254  b->onWindowClosed(node);
255 }
256 
258 {
259  uiNode* b = node->behaviour->manager.get();
260  b->onWindowActivate(node);
261 }
262 
264 {
265  if (UI_Node_IsDrawable(node)) {
266  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
267  b->doLayout(node);
268  }
269 }
270 
272 {
273  uiNode* b = node->behaviour->manager.get();
274  b->onActivate(node);
275 }
276 
277 void UI_Node_PropertyChanged (uiNode_t* node, const value_t* property)
278 {
279  uiNode* b = node->behaviour->manager.get();
280  b->onPropertyChanged(node, property);
281 }
282 
284 {
285  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
286  b->onSizeChanged(node);
287 }
288 
290 {
291  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
292  b->onSizeChanged(node);
293 }
294 
295 void UI_Node_GetClientPosition (uiNode_t const* node, vec2_t position)
296 {
298  b->getClientPosition(node, position);
299 }
300 
301 /* drag and drop callback */
302 
304 {
305  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
306  return b->onDndEnter(node);
307 }
308 
309 bool UI_Node_DndMove (uiNode_t* node, int x, int y)
310 {
311  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
312  return b->onDndMove(node, x, y);
313 }
314 
316 {
317  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
318  b->onDndLeave(node);
319 }
320 
321 bool UI_Node_DndDrop (uiNode_t* node, int x, int y)
322 {
323  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
324  return b->onDndDrop(node, x, y);
325 }
326 
327 bool UI_Node_DndFinished (uiNode_t* node, bool isDroped)
328 {
329  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
330  return b->onDndFinished(node, isDroped);
331 }
332 
333 /* focus and keyboard events */
334 
336 {
337  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
338  b->onFocusGained(node);
339 }
340 
342 {
343  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
344  b->onFocusLost(node);
345 }
346 
347 bool UI_Node_KeyPressed (uiNode_t* node, unsigned int key, unsigned short unicode)
348 {
349  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
350  return b->onKeyPressed(node, key, unicode);
351 }
352 
353 bool UI_Node_KeyReleased (uiNode_t* node, unsigned int key, unsigned short unicode)
354 {
355  uiLocatedNode* b = dynamic_cast<uiLocatedNode*>(node->behaviour->manager.get());
356  return b->onKeyReleased(node, key, unicode);
357 }
358 
359 /* cell size */
360 
362 {
364  return b->getCellWidth(node);
365 }
366 
368 {
370  return b->getCellHeight(node);
371 }
372 
373 const char* UI_Node_GetText (uiNode_t* node) {
374  #ifdef DEBUG
375  if (node->text == nullptr) {
376  Com_Printf("warning: requesting uninitialized node->text from [%s]\n", UI_GetPath(node));
377  }
378  #endif // DEBUG
379  return (node->text? node->text : "");
380 }
381 
382 void UI_Node_SetText (uiNode_t* node, const char* text) {
384  node->text = Mem_PoolStrDup(text, ui_dynStringPool, 0);
385 }
386 
387 void UI_Node_SetFont (uiNode_t* node, const char* name) {
389  node->font = Mem_PoolStrDup(name, ui_dynStringPool, 0);
390 }
391 
392 void UI_Node_SetImage (uiNode_t* node, const char* name) {
394  node->image = Mem_PoolStrDup(name, ui_dynStringPool, 0);
395 }
396 
397 const char* UI_Node_GetTooltip (uiNode_t* node) {
398  return node->tooltip;
399 }
400 
401 void UI_Node_SetTooltip (uiNode_t* node, const char* tooltip) {
402  UI_FreeStringProperty((void*)node->tooltip);
403  node->tooltip = Mem_PoolStrDup(tooltip, ui_dynStringPool, 0);
404 }
405 
406 bool UI_Node_IsDisabled (uiNode_t const* node) {
407  return node->disabled;
408 }
409 
410 bool UI_Node_IsInvisible (uiNode_t const* node) {
411  return node->invis;
412 }
413 
414 bool UI_Node_IsGhost (uiNode_t const* node) {
415  return node->ghost;
416 }
417 
418 bool UI_Node_IsFlashing (uiNode_t const* node) {
419  return node->flash;
420 }
421 
422 void UI_Node_SetDisabled (uiNode_t* node, const bool value) {
423  node->disabled = value;
424 }
425 
426 #ifdef DEBUG
427 
428 void UI_Node_DebugCountWidget (uiNode_t* node, int count)
429 {
430  node->behaviour->count += count;
431 }
432 
433 #endif
434 
441 bool UI_NodeInstanceOf (const uiNode_t* node, const char* behaviourName)
442 {
443  for (const uiBehaviour_t* behaviour = node->behaviour; behaviour; behaviour = behaviour->super) {
444  if (Q_streq(behaviour->name, behaviourName))
445  return true;
446  }
447  return false;
448 }
449 
456 bool UI_NodeInstanceOfPointer (const uiNode_t* node, const uiBehaviour_t* behaviour)
457 {
458  for (const uiBehaviour_t* b = node->behaviour; b; b = b->super) {
459  if (b == behaviour)
460  return true;
461  }
462  return false;
463 }
464 
472 void UI_NodeGetPoint (const uiNode_t* node, vec2_t pos, int direction)
473 {
474  switch (UI_GET_HORIZONTAL_ALIGN(direction)) {
475  case LAYOUTALIGN_H_LEFT:
476  pos[0] = 0;
477  break;
479  pos[0] = (int)(node->box.size[0] / 2);
480  break;
481  case LAYOUTALIGN_H_RIGHT:
482  pos[0] = node->box.size[0];
483  break;
484  default:
485  Com_Printf("UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
486  pos[0] = 0;
487  pos[1] = 0;
488  return;
489  }
490 
491  switch (UI_GET_VERTICAL_ALIGN(direction)) {
492  case LAYOUTALIGN_V_TOP:
493  pos[1] = 0;
494  break;
496  pos[1] = (int)(node->box.size[1] / 2);
497  break;
499  pos[1] = node->box.size[1];
500  break;
501  default:
502  Com_Printf("UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
503  pos[0] = 0;
504  pos[1] = 0;
505  return;
506  }
507 }
508 
514 void UI_GetNodeAbsPos (const uiNode_t* node, vec2_t pos)
515 {
516  assert(node);
517  assert(pos);
518 
519  /* if we request the position of a non drawable node, there is a problem */
520  if (node->behaviour->isVirtual)
521  Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' doesn't have a position", node->name);
522 
523  Vector2Set(pos, 0, 0);
524  while (node) {
525 #ifdef DEBUG
526  if (node->box.pos[0] != (int)node->box.pos[0] || node->box.pos[1] != (int)node->box.pos[1])
527  Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' position %f,%f is not integer", UI_GetPath(node), node->box.pos[0], node->box.pos[1]);
528 #endif
529  pos[0] += node->box.pos[0];
530  pos[1] += node->box.pos[1];
531  node = node->parent;
532  }
533 }
534 
542 void UI_GetNodeScreenPos (const uiNode_t* node, vec2_t pos)
543 {
544  assert(node);
545  assert(pos);
546 
547  /* if we request the position of a non drawable node, there is a problem */
548  if (node->behaviour->isVirtual)
549  Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' doesn't have a position", node->name);
550 
551  Vector2Set(pos, 0, 0);
552  while (node) {
553 #ifdef DEBUG
554  if (node->box.pos[0] != (int)node->box.pos[0] || node->box.pos[1] != (int)node->box.pos[1])
555  Com_Error(ERR_FATAL, "UI_GetNodeAbsPos: Node '%s' position %f,%f is not integer", UI_GetPath(node), node->box.pos[0], node->box.pos[1]);
556 #endif
557  pos[0] += node->box.pos[0];
558  pos[1] += node->box.pos[1];
559  node = node->parent;
560 
561  if (node && UI_Node_IsScrollableContainer(node)) {
562  vec2_t clientPosition = {0, 0};
563  UI_Node_GetClientPosition(node, clientPosition);
564  pos[0] += clientPosition[0];
565  pos[1] += clientPosition[1];
566  }
567  }
568 }
569 
576 {
577  assert(node);
578  assert(pos);
579  while (node) {
580  pos[0] += node->box.pos[0];
581  pos[1] += node->box.pos[1];
582  node = node->parent;
583  }
584 }
585 
592 void UI_NodeAbsoluteToRelativePos (const uiNode_t* node, int* x, int* y)
593 {
594  assert(node != nullptr);
595  /* if we request the position of an undrawable node, there is a problem */
596  assert(node->behaviour->isVirtual == false);
597  assert(x != nullptr);
598  assert(y != nullptr);
599 
600  /* if we request the position of an undrawable node, there is a problem */
601  if (node->behaviour->isVirtual)
602  Com_Error(ERR_DROP, "UI_NodeAbsoluteToRelativePos: Node '%s' doesn't have a position", node->name);
603 
604  while (node) {
605  *x -= node->box.pos[0];
606  *y -= node->box.pos[1];
607 
608  if (UI_Node_IsScrollableContainer(node)) {
609  vec2_t clientPosition = {0, 0};
610  UI_Node_GetClientPosition(node, clientPosition);
611  *x -= clientPosition[0];
612  *y -= clientPosition[1];
613  }
614 
615  node = node->parent;
616  }
617 }
618 
623 void UI_HideNode (uiNode_t* node)
624 {
625  if (node)
626  node->invis = true;
627  else
628  Com_Printf("UI_HideNode: No node given\n");
629 }
630 
636 {
637  if (node)
638  node->invis = false;
639  else
640  Com_Printf("UI_UnHideNode: No node given\n");
641 }
642 
646 void UI_NodeSetPos(uiNode_t* node, vec2_t pos) {
647  if (Vector2Equal(node->box.pos, pos))
648  return;
649  node->box.pos[0] = pos[0];
650  node->box.pos[1] = pos[1];
651  UI_Node_PosChanged(node);
652 }
653 
657 void UI_NodeSetPos(uiNode_t* node, float x, float y) {
658  vec2_t p;
659  p[0] = x; p[1] = y;
660  UI_NodeSetPos(node, p);
661 }
662 
667 {
668  if (Vector2Equal(node->box.size, size))
669  return;
670  node->box.size[0] = size[0];
671  node->box.size[1] = size[1];
672  UI_Node_SizeChanged(node);
673 }
677 void UI_NodeSetSize (uiNode_t* node, float w, float h) {
678  vec2_t s;
679  s[0] = w; s[1] = h;
680  UI_NodeSetSize(node, s);
681 }
682 
687 void UI_NodeSetBox (uiNode_t* node, float x, float y, float w, float h) {
688  vec2_t p;
689  vec2_t s;
690  if (x != -1) p[0] = x; else p[0] = node->box.pos[0];
691  if (y != -1) p[1] = y; else p[1] = node->box.pos[1];
692  if (w != -1) s[0] = w; else s[0] = node->box.size[0];
693  if (h != -1) s[1] = h; else s[1] = node->box.size[1];
694  UI_NodeSetPos(node, p);
695  UI_NodeSetSize(node, s);
696 }
697 
702 uiNode_t* UI_GetNode(const uiNode_t* node, const char* name) {
703  uiNode_t* current = nullptr;
704 
705  if (!node)
706  return nullptr;
707 
708  for (current = node->firstChild; current; current = current->next)
709  if (Q_streq(name, current->name))
710  break;
711 
712  return current;
713 }
714 
722  uiNode_t* current = nullptr;
723  for (current = node->parent->firstChild; current; current = current->next) {
724  if (node == current->next) break;
725  }
726  return current;
727 }
728 
733 uiNode_t* UI_FindNode(const uiNode_t* node, const char* name) {
734  /* search current level */
735  uiNode_t* result = UI_GetNode(node, name);
736  if (!result) {
737  /* iterate child nodes and search next level */
738  for(uiNode_t* current = node->firstChild; current; current = current->next) {
739  result = UI_FindNode(current, name);
740  if (result) break;
741  }
742  }
743  return result;
744 }
745 
752 void UI_InsertNode (uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* newNode)
753 {
754  /* parent and newNode should be valid, or else insertion doesn't make sense */
755  assert(parent);
756  assert(newNode);
757  /* insert only a single element */
758  assert(!newNode->next);
759 
760  uiNode_t** const anchor = prevNode ? &prevNode->next : &parent->firstChild;
761  newNode->next = *anchor;
762  *anchor = newNode;
763  newNode->parent = parent;
764 
765  UI_UpdateRoot (newNode, parent->root);
766 
767  if (!parent->firstChild) {
768  parent->firstChild = newNode;
769  }
770  if (!parent->lastChild) {
771  parent->lastChild = newNode;
772  }
773 
774  if (!newNode->next) {
775  parent->lastChild = newNode;
776  }
777 
778  if (newNode->root && newNode->indexed)
779  UI_WindowNodeAddIndexedNode(newNode->root, newNode);
780 
781  UI_Invalidate(parent);
782 }
783 
790 uiNode_t* UI_RemoveNode (uiNode_t* const node, uiNode_t* child)
791 {
792  assert(node);
793  assert(child);
794  assert(child->parent == node);
795  assert(node->firstChild);
796 
798  for (uiNode_t** anchor = &node->firstChild;; anchor = &(*anchor)->next) {
799  if (!*anchor)
800  return 0;
801 
802  if (*anchor == child) {
803  *anchor = child->next;
804  break;
805  }
806  }
807  UI_Invalidate(node);
808 
810  if (node->lastChild == child) {
811  node->lastChild = node->firstChild;
812  while (node->lastChild && node->lastChild->next)
813  node->lastChild = node->lastChild->next;
814  }
815  if (child->root && child->indexed)
816  UI_WindowNodeRemoveIndexedNode(child->root, child);
817 
818  child->next = nullptr;
819  return child;
820 }
821 
828 void UI_MoveNode (uiNode_t* const parent, uiNode_t* prevNode, uiNode_t* node)
829 {
830  /* parent and newNode should be valid, or else insertion doesn't make sense */
831  assert(parent);
832  assert(node);
833 
834  if (!UI_RemoveNode(parent, node))
835  return;
836  UI_InsertNode(parent, prevNode, node);
837 
838  UI_Invalidate(parent);
839 }
840 
841 void UI_UpdateRoot (uiNode_t* node, uiNode_t* newRoot)
842 {
843  node->root = newRoot;
844  node = node->firstChild;
845  while (node) {
846  UI_UpdateRoot(node, newRoot);
847  node = node->next;
848  }
849 }
850 
856 void UI_AppendNode (uiNode_t* const parent, uiNode_t* newNode)
857 {
858  UI_InsertNode(parent, parent->lastChild, newNode);
859 }
860 
861 void UI_NodeSetPropertyFromRAW (uiNode_t* node, const value_t* property, const void* rawValue, int rawType)
862 {
863  if (property->type != rawType) {
864  Com_Printf("UI_NodeSetPropertyFromRAW: type %i expected, but @%s type %i found. Property setter to '%s@%s' skipped\n", rawType, property->string, property->type, UI_GetPath(node), property->string);
865  return;
866  }
867 
868  if ((property->type & V_UI_MASK) == V_NOT_UI)
869  Com_SetValue(node, rawValue, property->type, property->ofs, property->size);
870  else if ((property->type & V_UI_MASK) == V_UI_CVAR) {
871  UI_FreeStringProperty(Com_GetValue<void*>(node, property));
872  switch (property->type & V_BASETYPEMASK) {
873  case V_FLOAT: *Com_GetValue<float* >(node, property) = *static_cast<float const*>(rawValue); break;
874  case V_INT: *Com_GetValue<int* >(node, property) = *static_cast<int const*>(rawValue); break;
875  default: Com_GetValue<byte const*>(node, property) = static_cast<byte const*>(rawValue); break;
876  }
877  } else if (property->type == V_UI_ACTION) {
878  Com_GetValue<uiAction_t const*>(node, property) = static_cast<uiAction_t const*>(rawValue);
879  } else if (property->type == V_UI_SPRITEREF) {
880  Com_GetValue<uiSprite_t const*>(node, property) = static_cast<uiSprite_t const*>(rawValue);
881  } else {
882  Com_Error(ERR_FATAL, "UI_NodeSetPropertyFromRAW: Property type '%d' unsupported", property->type);
883  }
884  UI_Node_PropertyChanged(node, property);
885 }
886 
890 bool UI_NodeSetProperty (uiNode_t* node, const value_t* property, const char* value)
891 {
892  const int specialType = property->type & V_UI_MASK;
893  int result;
894  size_t bytes;
895 
896  switch (specialType) {
897  case V_NOT_UI: /* common type */
898  result = Com_ParseValue(node, value, property->type, property->ofs, property->size, &bytes);
899  if (result != RESULT_OK) {
900  Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError());
901  return false;
902  }
903  UI_Node_PropertyChanged(node, property);
904  return true;
905 
906  case V_UI_CVAR: /* cvar */
907  switch ((int)property->type) {
908  case V_UI_CVAR:
909  if (Q_strstart(value, "*cvar:")) {
910  char*& b = Com_GetValue<char*>(node, property);
912  b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
913  UI_Node_PropertyChanged(node, property);
914  return true;
915  }
916  break;
917  case V_CVAR_OR_FLOAT:
918  {
919  float f;
920 
921  if (Q_strstart(value, "*cvar:")) {
922  char*& b = Com_GetValue<char*>(node, property);
924  b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
925  UI_Node_PropertyChanged(node, property);
926  return true;
927  }
928 
929  result = Com_ParseValue(&f, value, V_FLOAT, 0, sizeof(f), &bytes);
930  if (result != RESULT_OK) {
931  Com_Printf("UI_NodeSetProperty: Invalid value for property '%s': %s\n", property->string, Com_GetLastParseError());
932  return false;
933  }
934 
935  void* const b = Com_GetValue<void*>(node, property);
936  if (char const* const cvar = Q_strstart((char const*)b, "*cvar:"))
937  Cvar_SetValue(cvar, f);
938  else
939  *(float*) b = f;
940  UI_Node_PropertyChanged(node, property);
941  return true;
942  }
944  case V_CVAR_OR_STRING:
945  {
946  char*& b = Com_GetValue<char*>(node, property);
948  b = Mem_PoolStrDup(value, ui_dynStringPool, 0);
949  UI_Node_PropertyChanged(node, property);
950  return true;
951  }
952  }
953  break;
954 
955  case V_UI:
956  switch ((int)property->type) {
957  case V_UI_SPRITEREF:
958  {
959  uiSprite_t* sprite = UI_GetSpriteByName(value);
960  Com_GetValue<uiSprite_t const*>(node, property) = sprite;
961  UI_Node_PropertyChanged(node, property);
962  return true;
963  }
964  }
965  break;
966  }
967 
968  Com_Printf("UI_NodeSetProperty: Unimplemented type for property '%s@%s'\n", UI_GetPath(node), property->string);
969  return false;
970 }
971 
978 const char* UI_GetStringFromNodeProperty (const uiNode_t* node, const value_t* property)
979 {
980  const int baseType = property->type & V_UI_MASK;
981  assert(node);
982  assert(property);
983 
984  switch (baseType) {
985  case V_NOT_UI: /* common type */
986  return Com_ValueToStr(node, property->type, property->ofs);
987  case V_UI_CVAR:
988  switch ((int)property->type) {
989  case V_CVAR_OR_FLOAT:
990  {
991  const float f = UI_GetReferenceFloat(node, Com_GetValue<void*>(node, property));
992  const int i = f;
993  if (f == i)
994  return va("%i", i);
995  else
996  return va("%f", f);
997  }
999  case V_CVAR_OR_STRING:
1000  case V_UI_CVAR:
1001  return UI_GetReferenceString(node, Com_GetValue<char*>(node, property));
1002  }
1003  break;
1004  default:
1005  break;
1006  }
1007 
1008  Com_Printf("UI_GetStringFromNodeProperty: Unsupported string getter for property type 0x%X (%s@%s)\n", property->type, UI_GetPath(node), property->string);
1009  return nullptr;
1010 }
1011 
1019 float UI_GetFloatFromNodeProperty (const uiNode_t* node, const value_t* property)
1020 {
1021  assert(node);
1022 
1023  if (property->type == V_FLOAT) {
1024  return Com_GetValue<float>(node, property);
1025  } else if ((property->type & V_UI_MASK) == V_UI_CVAR) {
1026  void* const b = Com_GetValue<void*>(node, property);
1027  if (char const* const cvarName = Q_strstart((char const*)b, "*cvar:")) {
1028  const cvar_t* cvar = Cvar_Get(cvarName, "", 0, "UI script cvar property");
1029  return cvar->value;
1030  } else if (property->type == V_CVAR_OR_FLOAT) {
1031  return *(const float*) b;
1032  } else if (property->type == V_CVAR_OR_STRING) {
1033  return atof((const char*)b);
1034  }
1035  } else if (property->type == V_INT) {
1036  return Com_GetValue<int>(node, property);
1037  } else if (property->type == V_BOOL) {
1038  return Com_GetValue<bool>(node, property);
1039  } else {
1040 #ifdef DEBUG
1041  Com_Printf("UI_GetFloatFromNodeProperty: Unimplemented float getter for property '%s@%s'. If it should return a float, request it.\n", UI_GetPath(node), property->string);
1042 #else
1043  Com_Printf("UI_GetFloatFromNodeProperty: Property '%s@%s' can't return a float\n", UI_GetPath(node), property->string);
1044 #endif
1045  }
1046 
1047  return 0;
1048 }
1049 
1054 {
1055  while (node) {
1056  if (node->invalidated)
1057  return;
1058  node->invalidated = true;
1059  node = node->parent;
1060  }
1061 }
1062 
1066 void UI_Validate (uiNode_t* node)
1067 {
1068  if (node->invalidated)
1069  UI_Node_DoLayout(node);
1070 }
1071 
1082 void UI_AddNodeMethod (uiNode_t* node, const char* name, LUA_METHOD fcn) {
1083  //Com_Printf ("UI_AddNodeMethod: registering node method [%s] on node [%s]\n", name, UI_GetPath(node));
1084 
1085  /* the first method, so create a method table on this node */
1086  if (!node->nodeMethods) {
1087  node->nodeMethods = HASH_NewTable(true, true, false);
1088  }
1089  /* add the method */
1090  if (!HASH_Insert(node->nodeMethods, name, strlen(name), &fcn, sizeof(fcn))) {
1091  Com_Printf("UI_AddNodeMethod: method [%s] already defined on this behaviour [%s]\n", name, node->name);
1092  }
1093 }
1094 
1104 bool UI_GetNodeMethod (const uiNode_t* node, const char* name, LUA_METHOD &fcn) {
1105  fcn = LUA_NOREF;
1106  // search the instance methods
1107  for(const uiNode_t* ref=node;ref;ref = ref->super) {
1108  if (ref->nodeMethods) {
1109  void* val=HASH_Get(ref->nodeMethods, name, strlen(name));
1110  if (val != nullptr) {
1111  fcn = *((LUA_METHOD *)val);
1112  return true;
1113  }
1114  }
1115  }
1116  // no instance method found, now scan for behaviour method
1117  return UI_GetBehaviourMethod(node->behaviour, name, fcn);
1118 }
1119 
1127 bool UI_HasNodeMethod (uiNode_t* node, const char* name) {
1128  LUA_METHOD fn;
1129  // search the instance methods
1130  if (UI_GetNodeMethod(node, name, fn)) {
1131  return true;
1132  }
1133  // nothing found, now check behaviour methods
1134  return UI_GetBehaviourMethod(node->behaviour, name, fn);
1135 }
1136 
1137 
1138 
1147 void UI_Node_SetItem (uiNode_t* node, const char* name, LUA_METHOD fcn) {
1148  UI_AddNodeMethod(node, name, fcn);
1149 }
1150 
1159 LUA_METHOD UI_Node_GetItem (uiNode_t* node, const char* name) {
1160  LUA_METHOD fcn;
1161  if (UI_GetNodeMethod(node, name, fcn)) {
1162  return fcn;
1163  }
1164  return LUA_NOREF;
1165 }
void UI_Node_Clone(uiNode_t const *source, uiNode_t *clone)
Definition: ui_node.cpp:220
void UI_Node_PropertyChanged(uiNode_t *node, const value_t *property)
Definition: ui_node.cpp:277
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
Definition: ui_node.cpp:1019
bool invalidated
Definition: ui_nodes.h:104
vec2_t size
Definition: ui_nodes.h:52
const char * UI_Node_GetTooltip(uiNode_t *node)
Definition: ui_node.cpp:397
const char * Com_GetLastParseError(void)
Definition: scripts.cpp:431
static int startX
virtual bool onDndDrop(uiNode_t *node, int x, int y)
virtual void onWindowActivate(uiNode_t *node)
#define Vector2Equal(a, b)
Definition: vector.h:67
void UI_Validate(uiNode_t *node)
Validate a node tree.
Definition: ui_node.cpp:1066
virtual void onMouseLeave(uiNode_t *node)
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
Definition: ui_node.cpp:890
uiNode_t * parent
Definition: ui_nodes.h:92
virtual bool onDndMove(uiNode_t *node, int x, int y)
virtual void initNodeDynamic(uiNode_t *node)
void UI_Node_MouseUp(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:164
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
Definition: ui_node.cpp:441
void UI_Node_PosChanged(uiNode_t *node)
Definition: ui_node.cpp:283
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
Definition: ui_node.cpp:245
virtual void getClientPosition(uiNode_t const *node, vec2_t position)
uiNode_t * next
Definition: ui_nodes.h:91
void UI_Node_CapturedMouseLost(uiNode_t *node)
Definition: ui_node.cpp:200
const char * va(const char *format,...)
does a varargs printf into a temp buffer, so I don't need to have varargs versions of all text functi...
Definition: shared.cpp:410
#define V_BASETYPEMASK
Allow to add extra bit into the type.
Definition: scripts.h:41
const char * name
Definition: ui_behaviour.h:41
void UI_UpdateRoot(uiNode_t *node, uiNode_t *newRoot)
Definition: ui_node.cpp:841
virtual void onRightClick(uiNode_t *node, int x, int y)
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
bool UI_Node_IsInvisible(uiNode_t const *node)
Definition: ui_node.cpp:410
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
Definition: ui_node.cpp:1053
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Definition: cvar.h:71
virtual void onFocusGained(uiNode_t *node)
virtual void onDndLeave(uiNode_t *node)
bool UI_Node_IsVirtual(uiNode_t const *node)
Definition: ui_node.cpp:42
void UI_Node_SetFont(uiNode_t *node, const char *name)
Definition: ui_node.cpp:387
#define UI_GET_HORIZONTAL_ALIGN(align)
void UI_Node_InitNode(uiNode_t *node)
Definition: ui_node.cpp:231
bool UI_Node_IsOptionContainer(uiNode_t const *node)
Definition: ui_node.cpp:54
virtual bool onMouseLongPress(uiNode_t *node, int x, int y, int button)
Send mouse event when a pressed mouse button is dragged.
virtual void onLoaded(uiNode_t *node)
bool UI_Node_MouseLongPress(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:182
bool UI_Node_StartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Definition: ui_node.cpp:188
void UI_InsertNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *newNode)
Insert a node next another one into a node. If prevNode is nullptr add the node on the head of the wi...
Definition: ui_node.cpp:752
bool UI_Node_Scroll(uiNode_t *node, int deltaX, int deltaY)
Definition: ui_node.cpp:146
char name[MAX_VAR]
Definition: ui_nodes.h:82
uiBehaviour_t * behaviour
Definition: ui_nodes.h:83
virtual void onWindowOpened(uiNode_t *node, linkedList_t *params)
UINodePtr manager
Definition: ui_behaviour.h:43
#define V_UI_SPRITEREF
Definition: ui_parse.h:56
virtual void onMouseUp(uiNode_t *node, int x, int y, int button)
float value
Definition: cvar.h:80
void UI_Node_MouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:152
const char * UI_Node_GetText(uiNode_t *node)
Definition: ui_node.cpp:373
virtual void onMouseMove(uiNode_t *node, int x, int y)
void UI_AddNodeMethod(uiNode_t *node, const char *name, LUA_METHOD fcn)
Adds a lua based method to the list of available node methods for calling.
Definition: ui_node.cpp:1082
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
Definition: ui_node.cpp:93
void UI_UnHideNode(uiNode_t *node)
Unhides a given node.
Definition: ui_node.cpp:635
bool UI_NodeInstanceOfPointer(const uiNode_t *node, const uiBehaviour_t *behaviour)
Check the node inheritance.
Definition: ui_node.cpp:456
void UI_Node_DrawOverWindow(uiNode_t *node)
Definition: ui_node.cpp:121
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
Definition: ui_node.cpp:856
void UI_Node_WindowClosed(uiNode_t *node)
Definition: ui_node.cpp:251
valueTypes_t type
Definition: scripts.h:170
virtual void onLoading(uiNode_t *node)
bool UI_WindowNodeRemoveIndexedNode(uiNode_t *const node, uiNode_t *const child)
Remove a node from the child index.
char * tooltip
Definition: ui_nodes.h:99
bool UI_Node_IsFlashing(uiNode_t const *node)
Definition: ui_node.cpp:418
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
Definition: hashtable.cpp:287
void UI_Node_SetText(uiNode_t *node, const char *text)
Definition: ui_node.cpp:382
virtual void clone(uiNode_t const *source, uiNode_t *clone)
unsigned short unicode
Definition: cl_input.cpp:69
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
Definition: ui_actions.cpp:778
#define ERR_FATAL
Definition: common.h:210
void UI_NodeSetBox(uiNode_t *node, float x, float y, float w, float h)
Update the node size and height and fire callbacks.
Definition: ui_node.cpp:687
void UI_Node_RightClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:134
void UI_Node_FocusLost(uiNode_t *node)
Definition: ui_node.cpp:341
bool UI_Node_DndFinished(uiNode_t *node, bool isDroped)
Definition: ui_node.cpp:327
Internal data use by the UI package.
C interface to allow to access to cpp node code.
virtual void drawTooltip(const uiNode_t *node, int x, int y) const
void Com_Error(int code, const char *fmt,...)
Definition: common.cpp:417
uiNode_t * UI_RemoveNode(uiNode_t *const node, uiNode_t *child)
Remove a node from a parent node.
Definition: ui_node.cpp:790
#define V_UI
Definition: ui_parse.h:52
bool UI_Node_DndEnter(uiNode_t *node)
Definition: ui_node.cpp:303
bool invis
Definition: ui_nodes.h:101
uiNode_t * root
Definition: ui_nodes.h:93
unsigned int key
Definition: cl_input.cpp:68
bool UI_Node_IsDrawable(uiNode_t const *node)
Definition: ui_node.cpp:48
void UI_MoveNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *node)
Moves a node in the tree.
Definition: ui_node.cpp:828
#define ERR_DROP
Definition: common.h:211
virtual void onCapturedMouseMove(uiNode_t *node, int x, int y)
static int startY
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
Definition: cvar.cpp:342
GLsizei size
Definition: r_gl.h:152
char * font
Definition: ui_nodes.h:122
#define V_UI_CVAR
Definition: ui_parse.h:59
uiNode_t * lastChild
Definition: ui_nodes.h:90
bool ghost
Definition: ui_nodes.h:105
void UI_Node_SetImage(uiNode_t *node, const char *name)
Definition: ui_node.cpp:392
void UI_Node_FocusGained(uiNode_t *node)
Definition: ui_node.cpp:335
#define Vector2Set(v, x, y)
Definition: vector.h:61
memPool_t * ui_dynStringPool
Definition: ui_main.cpp:40
void UI_Node_Loaded(uiNode_t *node)
Definition: ui_node.cpp:214
int Com_SetValue(void *base, const void *set, valueTypes_t type, int ofs, size_t size)
Definition: scripts.cpp:1023
bool UI_Node_KeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:347
uiNode_t * UI_FindNode(const uiNode_t *node, const char *name)
Recursive searches for a child node by name in the entire subtree.
Definition: ui_node.cpp:733
virtual int getCellWidth(uiNode_t *node)
bool UI_Node_DndMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:309
void UI_Node_Activate(uiNode_t *node)
Definition: ui_node.cpp:271
int UI_Node_GetCellHeight(uiNode_t *node)
Definition: ui_node.cpp:367
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
Definition: scripts.cpp:1189
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
Definition: ui_nodes.cpp:174
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
Definition: ui_node.cpp:295
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
Definition: shared.cpp:587
bool indexed
Definition: ui_nodes.h:86
bool UI_Node_IsWindow(uiNode_t const *node)
Definition: ui_node.cpp:60
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
Definition: hashtable.cpp:467
virtual bool onScroll(uiNode_t *node, int deltaX, int deltaY)
bool drawItselfChild
Definition: ui_behaviour.h:50
bool flash
Definition: ui_nodes.h:107
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:472
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
Definition: ui_parse.cpp:1406
void UI_HideNode(uiNode_t *node)
Hides a given node.
Definition: ui_node.cpp:623
PointerType get() const
Definition: sharedptr.h:197
uiNode_t * UI_GetPrevNode(const uiNode_t *node)
Returns the previous node based on the order of nodes in the parent.
Definition: ui_node.cpp:721
int LUA_METHOD
holds a reference to a lua event handler
Definition: scripts_lua.h:53
void UI_Node_SetDisabled(uiNode_t *node, const bool value)
Definition: ui_node.cpp:422
Atomic structure used to define most of the UI.
Definition: ui_nodes.h:80
const char * string
Definition: scripts.h:169
void UI_Node_MouseLeave(uiNode_t *node)
Definition: ui_node.cpp:176
intptr_t UI_Node_GetMemorySize(uiNode_t const *node)
Definition: ui_node.cpp:104
bool UI_HasNodeMethod(uiNode_t *node, const char *name)
Returns true if a node method of given name is available on this node or its super.
Definition: ui_node.cpp:1127
bool disabled
Definition: ui_nodes.h:102
resultStatus_t Com_ParseValue(void *base, const char *token, valueTypes_t type, int ofs, size_t size, size_t *writtenBytes)
Parse a value from a string.
Definition: scripts.cpp:659
virtual bool onStartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
Send mouse event when a pressed mouse button is dragged.
bool UI_Node_DndDrop(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:321
LUA_METHOD UI_Node_GetItem(uiNode_t *node, const char *name)
This functions queries a lua based method in the internal uiNode behaviour.
Definition: ui_node.cpp:1159
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
Definition: ui_node.cpp:514
float UI_GetReferenceFloat(const uiNode_t *const node, const void *ref)
Returns the value of the reference variable.
Definition: ui_parse.cpp:1434
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
Definition: ui_node.cpp:77
QGL_EXTERN GLuint count
Definition: r_gl.h:99
hashTable_s * nodeMethods
Definition: ui_nodes.h:132
size_t ofs
Definition: scripts.h:171
void UI_NodeSetPropertyFromRAW(uiNode_t *node, const value_t *property, const void *rawValue, int rawType)
Definition: ui_node.cpp:861
QGL_EXTERN GLfloat f
Definition: r_gl.h:114
virtual void drawOverWindow(uiNode_t *node)
bool UI_Node_IsDisabled(uiNode_t const *node)
Definition: ui_node.cpp:406
virtual bool onDndEnter(uiNode_t *node)
void UI_Node_Draw(uiNode_t *node)
Definition: ui_node.cpp:109
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
Definition: ui_node.cpp:115
void UI_Node_WindowActivate(uiNode_t *node)
Definition: ui_node.cpp:257
virtual void draw(uiNode_t *node)
bool UI_Node_IsAbstract(uiNode_t const *node)
Definition: ui_node.cpp:72
virtual void onMiddleClick(uiNode_t *node, int x, int y)
virtual bool onKeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
#define UI_GET_VERTICAL_ALIGN(align)
Definition: ui_node_panel.h:97
void UI_Node_SizeChanged(uiNode_t *node)
Definition: ui_node.cpp:289
#define V_CVAR_OR_LONGSTRING
Definition: ui_parse.h:70
uiBehaviour_t * super
Definition: ui_behaviour.h:55
virtual void initNode(uiNode_t *node)
void UI_NodeSetPos(uiNode_t *node, vec2_t pos)
Update the node size and fire the pos callback.
Definition: ui_node.cpp:646
void UI_Node_SetItem(uiNode_t *node, const char *name, LUA_METHOD fcn)
This functions adds a lua based method to the internal uiNode behaviour.
Definition: ui_node.cpp:1147
intptr_t extraDataSize
Definition: ui_behaviour.h:54
QGL_EXTERN GLint i
Definition: r_gl.h:113
virtual void onFocusLost(uiNode_t *node)
virtual void onMouseDown(uiNode_t *node, int x, int y, int button)
Definition: scripts.h:50
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
Definition: ui_node.cpp:702
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
Definition: ui_node.cpp:592
node behaviour, how a node work
Definition: ui_behaviour.h:39
virtual void onWindowClosed(uiNode_t *node)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
Definition: r_gl.h:110
virtual void onCapturedMouseLost(uiNode_t *node)
void UI_Node_InitNodeDynamic(uiNode_t *node)
Definition: ui_node.cpp:226
void UI_Node_DndLeave(uiNode_t *node)
Definition: ui_node.cpp:315
virtual void onSizeChanged(uiNode_t *node)
Callback stub.
bool UI_GetNodeMethod(const uiNode_t *node, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this node or its super.
Definition: ui_node.cpp:1104
bool UI_Node_IsGhost(uiNode_t const *node)
Definition: ui_node.cpp:414
size_t size
Definition: scripts.h:172
bool UI_Node_KeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
Definition: ui_node.cpp:353
bool UI_Node_IsBattleScape(uiNode_t const *node)
Definition: ui_node.cpp:66
void UI_Node_LeftClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:128
vec_t vec2_t[2]
Definition: ufotypes.h:38
uiNode_t const * super
Definition: ui_nodes.h:84
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
Definition: scripts.h:52
char * image
Definition: ui_nodes.h:123
virtual void deleteNode(uiNode_t *node)
#define V_CVAR_OR_FLOAT
Definition: ui_parse.h:68
void UI_Node_DoLayout(uiNode_t *node)
Definition: ui_node.cpp:263
void UI_Node_MiddleClick(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:140
virtual int getCellHeight(uiNode_t *node)
const char * UI_Node_GetWidgetName(uiNode_t const *node)
Definition: ui_node.cpp:99
virtual void onMouseEnter(uiNode_t *node)
uiNode_t * firstChild
Definition: ui_nodes.h:89
#define V_CVAR_OR_STRING
Definition: ui_parse.h:69
#define V_UI_ACTION
Definition: ui_parse.h:54
#define Q_streq(a, b)
Definition: shared.h:136
#define Mem_PoolStrDup(in, pool, tagNum)
Definition: mem.h:50
#define V_NOT_UI
Definition: ui_parse.h:53
bool UI_WindowNodeAddIndexedNode(uiNode_t *const node, uiNode_t *const child)
Add a node to the child index.
void UI_Node_MouseDown(uiNode_t *node, int x, int y, int button)
Definition: ui_node.cpp:158
uiBox_t box
Definition: ui_nodes.h:96
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
Definition: ui_node.cpp:978
void UI_Node_Loading(uiNode_t *node)
Definition: ui_node.cpp:208
bool UI_Node_IsFunction(uiNode_t const *node)
Definition: ui_node.cpp:85
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
Definition: ui_sprite.cpp:115
#define V_UI_MASK
Definition: ui_parse.h:51
virtual void onLeftClick(uiNode_t *node, int x, int y)
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
Definition: cvar.cpp:671
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual bool onDndFinished(uiNode_t *node, bool isDropped)
void UI_Node_SetTooltip(uiNode_t *node, const char *tooltip)
Definition: ui_node.cpp:401
int UI_Node_GetCellWidth(uiNode_t *node)
Definition: ui_node.cpp:361
void UI_Node_DeleteNode(uiNode_t *node)
Definition: ui_node.cpp:237
virtual void onActivate(uiNode_t *node)
Activate the node. Can be used without the mouse (ie. a button will execute onClick) ...
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
Definition: ui_node.cpp:666
void UI_Node_CapturedMouseMove(uiNode_t *node, int x, int y)
Definition: ui_node.cpp:194
bool HASH_Insert(hashTable_s *t, const void *key, int nkey, const void *value, int nvalue)
Inserts a new value with given key into the hash table.
Definition: hashtable.cpp:369
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
Definition: ui_node.cpp:575
char * text
Definition: ui_nodes.h:121
void UI_GetNodeScreenPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node in the screen. Screen position is not used for the node rende...
Definition: ui_node.cpp:542
void UI_Node_MouseEnter(uiNode_t *node)
Definition: ui_node.cpp:170
vec2_t pos
Definition: ui_nodes.h:51
virtual bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)