149 return b->
onScroll(node, deltaX, deltaY);
223 b->
clone(source, clone);
375 if (node->
text ==
nullptr) {
379 return (node->
text? node->
text :
"");
387 node->
text =
nullptr;
395 node->
font =
nullptr;
403 node->
image =
nullptr;
412 if (tooltip !=
nullptr)
456 if (
Q_streq(behaviour->name, behaviourName))
497 Com_Printf(
"UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
514 Com_Printf(
"UI_NodeGetPoint: Align '%d' (0x%X) is not a common alignment", direction, direction);
541 pos[0] += node->
box.
pos[0];
542 pos[1] += node->
box.
pos[1];
569 pos[0] += node->
box.
pos[0];
570 pos[1] += node->
box.
pos[1];
574 vec2_t clientPosition = {0, 0};
576 pos[0] += clientPosition[0];
577 pos[1] += clientPosition[1];
592 pos[0] += node->
box.
pos[0];
593 pos[1] += node->
box.
pos[1];
606 assert(node !=
nullptr);
609 assert(x !=
nullptr);
610 assert(y !=
nullptr);
621 vec2_t clientPosition = {0, 0};
623 *x -= clientPosition[0];
624 *y -= clientPosition[1];
661 node->
box.
pos[0] = pos[0];
662 node->
box.
pos[1] = pos[1];
702 if (x != -1) p[0] = x;
else p[0] = node->
box.
pos[0];
703 if (y != -1) p[1] = y;
else p[1] = node->
box.
pos[1];
704 if (w != -1) s[0] = w;
else s[0] = node->
box.
size[0];
705 if (h != -1) s[1] = h;
else s[1] = node->
box.
size[1];
720 for (current = node->
firstChild; current; current = current->
next)
736 if (node == current->
next)
break;
770 assert(!newNode->
next);
773 newNode->
next = *anchor;
786 if (!newNode->
next) {
806 assert(child->
parent == node);
814 if (*anchor == child) {
815 *anchor = child->
next;
830 child->
next =
nullptr;
855 node->
root = newRoot;
875 if (property->
type != rawType) {
876 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);
904 const int specialType =
property->type &
V_UI_MASK;
908 switch (specialType) {
919 switch ((
int)property->
type) {
948 if (
char const*
const cvar =
Q_strstart((
char const*)b,
"*cvar:"))
968 switch ((
int)property->
type) {
992 const int baseType =
property->type &
V_UI_MASK;
1000 switch ((
int)property->
type) {
1020 Com_Printf(
"UI_GetStringFromNodeProperty: Unsupported string getter for property type 0x%X (%s@%s)\n", property->
type,
UI_GetPath(node), property->
string);
1039 if (
char const*
const cvarName =
Q_strstart((
char const*)b,
"*cvar:")) {
1040 const cvar_t* cvar =
Cvar_Get(cvarName,
"", 0,
"UI script cvar property");
1043 return *(
const float*) b;
1045 return atof((
const char*)b);
1053 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);
1103 Com_Printf(
"UI_AddNodeMethod: method [%s] already defined on this behaviour [%s]\n",
name, node->
name);
1120 if (ref->nodeMethods) {
1122 if (val !=
nullptr) {
virtual bool onKeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
virtual void onMouseUp(uiNode_t *node, int x, int y, int button)
virtual int getCellHeight(uiNode_t *node)
virtual void onMouseEnter(uiNode_t *node)
virtual void onMouseDown(uiNode_t *node, int x, int y, int button)
virtual int getCellWidth(uiNode_t *node)
virtual bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
virtual void onFocusGained(uiNode_t *node)
virtual void drawOverWindow(uiNode_t *node)
virtual bool onDndMove(uiNode_t *node, int x, int y)
virtual void onCapturedMouseLost(uiNode_t *node)
virtual bool onDndFinished(uiNode_t *node, bool isDropped)
virtual void onDndLeave(uiNode_t *node)
virtual void draw(uiNode_t *node)
virtual void drawTooltip(const uiNode_t *node, int x, int y) const
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.
virtual bool onMouseLongPress(uiNode_t *node, int x, int y, int button)
Send mouse event when a pressed mouse button is dragged.
virtual void onMouseMove(uiNode_t *node, int x, int y)
virtual void onSizeChanged(uiNode_t *node)
Callback stub.
virtual void onMiddleClick(uiNode_t *node, int x, int y)
virtual void onLeftClick(uiNode_t *node, int x, int y)
virtual void onFocusLost(uiNode_t *node)
virtual void onRightClick(uiNode_t *node, int x, int y)
virtual void onMouseLeave(uiNode_t *node)
virtual bool onScroll(uiNode_t *node, int deltaX, int deltaY)
virtual void onCapturedMouseMove(uiNode_t *node, int x, int y)
virtual void getClientPosition(uiNode_t const *node, vec2_t position)
virtual bool onDndEnter(uiNode_t *node)
virtual void doLayout(uiNode_t *node)
Call to update the node layout. This common code revalidates the node tree.
virtual bool onDndDrop(uiNode_t *node, int x, int y)
virtual void onWindowClosed(uiNode_t *node)
virtual void initNodeDynamic(uiNode_t *node)
virtual void onWindowOpened(uiNode_t *node, linkedList_t *params)
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
virtual void onLoading(uiNode_t *node)
virtual void onLoaded(uiNode_t *node)
virtual void deleteNode(uiNode_t *node)
virtual void onWindowActivate(uiNode_t *node)
virtual void clone(uiNode_t const *source, uiNode_t *clone)
virtual void initNode(uiNode_t *node)
virtual void onActivate(uiNode_t *node)
Activate the node. Can be used without the mouse (ie. a button will execute onClick).
void Com_Error(int code, const char *fmt,...)
void Com_Printf(const char *const fmt,...)
void Cvar_SetValue(const char *varName, float value)
Expands value to a string and calls Cvar_Set.
cvar_t * Cvar_Get(const char *var_name, const char *var_value, int flags, const char *desc)
Init or return a cvar.
void * HASH_Get(hashTable_s *t, const void *key, int nkey)
Returns the value for a given key.
hashTable_s * HASH_NewTable(bool ownsKeys, bool ownsValues, bool duplicateOverwrite)
Creates a new hash table and sets it initial capacity.
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.
Header file for hashtable.
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque
#define Mem_PoolStrDup(in, pool, tagNum)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
int Com_SetValue(void *base, const void *set, valueTypes_t type, int ofs, size_t size)
const char * Com_GetLastParseError(void)
const char * Com_ValueToStr(const void *base, const valueTypes_t type, const int ofs)
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.
#define V_BASETYPEMASK
Allow to add extra bit into the type.
T & Com_GetValue(void *const object, value_t const *const value)
int LUA_METHOD
holds a reference to a lua event handler
char const * Q_strstart(char const *str, char const *start)
Matches the start of a string.
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...
This is a cvar definition. Cvars can be user modified and used in our menus e.g.
Atomic element to store UI scripts The parser use this atom to translate script action into many tree...
node behaviour, how a node work
Atomic structure used to define most of the UI.
uiBehaviour_t * behaviour
hashTable_s * nodeMethods
void UI_FreeStringProperty(void *pointer)
Free a string property if it is allocated into ui_dynStringPool.
bool UI_GetBehaviourMethod(const uiBehaviour_t *behaviour, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this behaviour or its super.
Internal data use by the UI package.
void UI_HideNode(uiNode_t *node)
Hides a given node.
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.
void UI_Node_WindowClosed(uiNode_t *node)
bool UI_NodeInstanceOf(const uiNode_t *node, const char *behaviourName)
Check the node inheritance.
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.
void UI_NodeRelativeToAbsolutePoint(const uiNode_t *node, vec2_t pos)
Update a relative point to an absolute one.
bool UI_Node_IsFunction(uiNode_t const *node)
void UI_Validate(uiNode_t *node)
Validate a node tree.
bool UI_Node_IsVirtual(uiNode_t const *node)
void UI_MoveNode(uiNode_t *const parent, uiNode_t *prevNode, uiNode_t *node)
Moves a node in the tree.
void UI_Node_DrawTooltip(const uiNode_t *node, int x, int y)
void UI_Node_Clone(uiNode_t const *source, uiNode_t *clone)
const char * UI_Node_GetWidgetName(uiNode_t const *node)
void UI_Node_DeleteNode(uiNode_t *node)
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
void UI_Node_SetImage(uiNode_t *node, const char *name)
void UI_Node_PropertyChanged(uiNode_t *node, const value_t *property)
uiNode_t * UI_GetPrevNode(const uiNode_t *node)
Returns the previous node based on the order of nodes in the parent.
void UI_NodeSetPropertyFromRAW(uiNode_t *node, const value_t *property, const void *rawValue, int rawType)
void UI_Node_DrawOverWindow(uiNode_t *node)
void UI_Node_InitNodeDynamic(uiNode_t *node)
bool UI_Node_KeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
int UI_Node_GetCellWidth(uiNode_t *node)
void UI_Node_SizeChanged(uiNode_t *node)
void UI_NodeSetBox(uiNode_t *node, float x, float y, float w, float h)
Update the node size and height and fire callbacks.
LUA_METHOD UI_Node_GetItem(uiNode_t *node, const char *name)
This functions queries a lua based method in the internal uiNode behaviour.
void UI_Node_GetClientPosition(uiNode_t const *node, vec2_t position)
void UI_Node_FocusLost(uiNode_t *node)
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...
void UI_Node_Activate(uiNode_t *node)
void UI_NodeSetSize(uiNode_t *node, vec2_t size)
Update the node size and fire the size callback.
void UI_Node_FocusGained(uiNode_t *node)
const char * UI_Node_GetTooltip(uiNode_t *node)
uiNode_t * UI_RemoveNode(uiNode_t *const node, uiNode_t *child)
Remove a node from a parent node.
void UI_UpdateRoot(uiNode_t *node, uiNode_t *newRoot)
void UI_Node_PosChanged(uiNode_t *node)
bool UI_Node_KeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)
void UI_Node_MouseUp(uiNode_t *node, int x, int y, int button)
bool UI_Node_DndEnter(uiNode_t *node)
void UI_Node_Loading(uiNode_t *node)
bool UI_Node_IsDrawItselfChild(uiNode_t const *node)
void UI_NodeAbsoluteToRelativePos(const uiNode_t *node, int *x, int *y)
Update an absolute position to a relative one.
bool UI_Node_IsGhost(uiNode_t const *node)
bool UI_Node_IsAbstract(uiNode_t const *node)
void UI_Node_DoLayout(uiNode_t *node)
void UI_Node_MouseDown(uiNode_t *node, int x, int y, int button)
bool UI_Node_IsDrawable(uiNode_t const *node)
void UI_Node_SetTooltip(uiNode_t *node, const char *tooltip)
int UI_Node_GetCellHeight(uiNode_t *node)
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
void UI_Node_Draw(uiNode_t *node)
void UI_NodeGetPoint(const uiNode_t *node, vec2_t pos, int direction)
return a relative position of a point into a node.
void UI_Node_MouseLeave(uiNode_t *node)
uiNode_t * UI_FindNode(const uiNode_t *node, const char *name)
Recursive searches for a child node by name in the entire subtree.
void UI_Node_MouseMove(uiNode_t *node, int x, int y)
bool UI_Node_Scroll(uiNode_t *node, int deltaX, int deltaY)
void UI_Node_MouseEnter(uiNode_t *node)
void UI_Node_Loaded(uiNode_t *node)
bool UI_Node_MouseLongPress(uiNode_t *node, int x, int y, int button)
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.
bool UI_Node_IsScrollableContainer(uiNode_t const *node)
void UI_Node_CapturedMouseMove(uiNode_t *node, int x, int y)
void UI_Node_CapturedMouseLost(uiNode_t *node)
bool UI_GetNodeMethod(const uiNode_t *node, const char *name, LUA_METHOD &fcn)
Finds the lua based method on this node or its super.
bool UI_Node_DndFinished(uiNode_t *node, bool isDroped)
void UI_Node_LeftClick(uiNode_t *node, int x, int y)
bool UI_Node_IsWindow(uiNode_t const *node)
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
void UI_NodeSetPos(uiNode_t *node, vec2_t pos)
Update the node size and fire the pos callback.
void UI_Node_WindowActivate(uiNode_t *node)
const char * UI_Node_GetText(uiNode_t *node)
void UI_UnHideNode(uiNode_t *node)
Unhides a given node.
bool UI_Node_DndDrop(uiNode_t *node, int x, int y)
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
bool UI_Node_StartDragging(uiNode_t *node, int startX, int startY, int currentX, int currentY, int button)
bool UI_Node_IsOptionContainer(uiNode_t const *node)
bool UI_Node_IsDisabled(uiNode_t const *node)
intptr_t UI_Node_GetMemorySize(uiNode_t const *node)
void UI_GetNodeAbsPos(const uiNode_t *node, vec2_t pos)
Returns the absolute position of a node.
void UI_Node_SetFont(uiNode_t *node, const char *name)
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
void UI_Node_RightClick(uiNode_t *node, int x, int y)
bool UI_Node_IsBattleScape(uiNode_t const *node)
bool UI_NodeInstanceOfPointer(const uiNode_t *node, const uiBehaviour_t *behaviour)
Check the node inheritance.
void UI_Node_DndLeave(uiNode_t *node)
bool UI_Node_IsInvisible(uiNode_t const *node)
void UI_Node_InitNode(uiNode_t *node)
void UI_Node_SetDisabled(uiNode_t *node, const bool value)
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...
void UI_Node_MiddleClick(uiNode_t *node, int x, int y)
void UI_Node_SetText(uiNode_t *node, const char *text)
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
bool UI_Node_DndMove(uiNode_t *node, int x, int y)
bool UI_Node_IsFlashing(uiNode_t const *node)
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
C interface to allow to access to cpp node code.
#define UI_GET_VERTICAL_ALIGN(align)
#define UI_GET_HORIZONTAL_ALIGN(align)
memPool_t * ui_dynStringPool
bool UI_WindowNodeAddIndexedNode(uiNode_t *const node, uiNode_t *const child)
Add a node to the child index.
bool UI_WindowNodeRemoveIndexedNode(uiNode_t *const node, uiNode_t *const child)
Remove a node from the child index.
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
float UI_GetReferenceFloat(const uiNode_t *const node, const void *ref)
Returns the value of the reference variable.
const char * UI_GetReferenceString(const uiNode_t *const node, const char *ref)
#define V_CVAR_OR_LONGSTRING
uiSprite_t * UI_GetSpriteByName(const char *name)
Return an sprite by is name.
#define Vector2Equal(a, b)
#define Vector2Set(v, x, y)