27 #include "../ui_actions.h"
28 #include "../ui_tooltip.h"
29 #include "../ui_behaviour.h"
30 #include "../ui_components.h"
31 #include "../ui_parse.h"
32 #include "../ui_sound.h"
33 #include "../ui_lua.h"
35 #include "../../../common/hashtable.h"
36 #include "../../../common/scripts_lua.h"
42 static void UI_NodeGetProperty_f (
void)
56 if (node ==
nullptr) {
61 if (property ==
nullptr) {
62 Com_Printf(
"UI_NodeGetProperty_f: Property from path '%s' doesn't exist\n",
Cmd_Argv(1));
82 static void UI_NodeSetProperty_f (
void)
221 if (!node->
dragdrop)
return isDropped;
277 if (node->
parent !=
nullptr)
288 if (property == propertyWidth || property == propertyHeight || property == propertySize) {
290 }
else if (property == propertyInvis) {
298 Com_Printf(
"UI_AbstractNodeCallRemovaAllChild: Invalid number of parameters\n");
312 Com_Printf(
"UI_AbstractNodeCallCreateChild: Invalid number of parameters\n");
320 if (existingNode !=
nullptr) {
321 Com_Printf(
"UI_AbstractNodeCallCreateChild: Node with name '%s' already exists\n", name);
331 if (child ==
nullptr) {
332 Com_Printf(
"UI_AbstractNodeCallCreateChild: Impossible to create the node\n");
342 Com_Printf(
"UI_AbstractNodeCallDelete: Invalid number of parameters\n");
351 Com_Printf(
"UI_AbstractNodeCallDeleteTimed: Invalid number of parameters\n");
355 const int ms = atoi(msStr);
390 if (node->
onClick !=
nullptr) {
474 behaviour->
name =
"abstractnode";
608 Cmd_AddCommand(
"debug_mnsetnodeproperty", UI_NodeSetProperty_f,
"Set a node property");
609 Cmd_AddCommand(
"debug_mngetnodeproperty", UI_NodeGetProperty_f,
"Get a node property");
struct uiAction_s * onWheelDown
const char * Cmd_Argv(int arg)
Returns a given argument.
float UI_GetFloatFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a float from a node property.
void Cmd_AddCommand(const char *cmdName, xcommand_t function, const char *desc)
Add a new command to the script interface.
virtual bool onDndDrop(uiNode_t *node, int x, int y)
virtual void onWindowActivate(uiNode_t *node)
virtual void onMouseLeave(uiNode_t *node)
bool UI_NodeSetProperty(uiNode_t *node, const value_t *property, const char *value)
Set node property.
virtual bool onDndMove(uiNode_t *node, int x, int y)
void UI_ReadNodePath(const char *path, const uiNode_t *relativeNode, const uiNode_t *iterationNode, uiNode_t **resultNode, const value_t **resultProperty, value_t *luaMethod)
Read a path and return every we can use (node and property)
virtual void initNodeDynamic(uiNode_t *node)
QGL_EXTERN GLint GLenum type
void UI_Node_WindowOpened(uiNode_t *node, linkedList_t *params)
static const value_t * propertyWidth
virtual void onRightClick(uiNode_t *node, int x, int y)
uiNode_t * UI_GetNodeByPath(const char *path)
Return a node by a path name (names with dot separation) It is a simplification facade over UI_ReadNo...
void UI_Invalidate(uiNode_t *node)
Invalidate a node and all his parent to request a layout update.
virtual void onFocusGained(uiNode_t *node)
virtual void onDndLeave(uiNode_t *node)
uiNode_t * UI_GetComponent(const char *name)
Searches all components for the specified one.
struct uiAction_s * onMouseEnter
virtual void onLoaded(uiNode_t *node)
static void UI_AbstractNodeVisibilityChange(uiNode_t *node)
uiBehaviour_t * behaviour
virtual void onWindowOpened(uiNode_t *node, linkedList_t *params)
struct uiAction_s * onMouseLeave
LUA_EVENT lua_onKeyPressed
bool UI_ExecuteLuaEventScript(uiNode_t *node, LUA_EVENT event)
Executes a lua event handler.
bool UI_ExecuteLuaEventScript_DragDrop_IsDropped(uiNode_t *node, LUA_EVENT event, bool isDropped, bool &result)
Executes a lua event handler for dragdrop interaction.
#define UI_RegisterNodeProperty(BEHAVIOUR, NAME, TYPE, OBJECTTYPE, ATTRIBUTE)
Initialize a property.
void UI_PlaySound(const char *soundFile)
Plays a ui sound.
void HASH_DeleteTable(hashTable_s **t)
Deletes a hash table and sets the pointer to NULL.
void Com_Printf(const char *const fmt,...)
static void UI_AbstractNodeCallDeleteTimed(uiNode_t *node, const uiCallContext_t *context)
void UI_AppendNode(uiNode_t *const parent, uiNode_t *newNode)
add a node at the end of the node child
void UI_Node_WindowClosed(uiNode_t *node)
bool UI_ExecuteLuaEventScript_DragDrop(uiNode_t *node, LUA_EVENT event, bool &result)
Executes a lua event handler for dragdrop interaction.
virtual void onLoading(uiNode_t *node)
LUA_EVENT lua_onWheelDown
void UI_DeleteNode(uiNode_t *node)
virtual void clone(uiNode_t const *source, uiNode_t *clone)
struct uiAction_s * onClick
LUA_EVENT lua_onMouseLeave
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.
virtual void drawTooltip(const uiNode_t *node, int x, int y) const
LUA_EVENT lua_onMiddleClick
uiNode_t * UI_AllocNode(const char *name, const char *type, bool isDynamic)
Allocate a node into the UI memory.
static void UI_AbstractNodeCallCreateChild(uiNode_t *node, const uiCallContext_t *context)
LUA_EVENT lua_onRightClick
bool UI_ExecuteLuaEventScript_DxDy(uiNode_t *node, LUA_EVENT event, int dx, int dy)
Executes a lua event handler with (dx,dy) argument.
LUA_EVENT lua_onFocusGained
struct uiAction_s * onWheelUp
struct uiAction_s * onMiddleClick
LUA_EVENT lua_onDragDropDrop
void UI_DeleteAllChild(uiNode_t *node)
Remove all child from a node (only remove dynamic memory allocation nodes)
int Cmd_Argc(void)
Return the number of arguments of the current command. "command parameter" will result in a argc of 2...
SharedPtr< uiNode > UINodePtr
const char * UI_GetPath(const uiNode_t *node)
Return a path from a window to a node.
virtual bool onScroll(uiNode_t *node, int deltaX, int deltaY)
void UI_ExecuteEventActions(uiNode_t *source, const uiAction_t *firstAction)
bool UI_ExecuteLuaEventScript_XY(uiNode_t *node, LUA_EVENT event, int x, int y)
Executes a lua event handler with (x,y) argument.
LUA_EVENT lua_onKeyReleased
Atomic structure used to define most of 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 Com_RegisterConstInt(const char *name, int value)
Register mappings between script strings and enum values for values of the type V_INT.
uiNode_t * UI_CloneNode(const uiNode_t *node, uiNode_t *newWindow, bool recursive, const char *newName, bool isDynamic)
Clone a node.
Contain the context of the calling of a function.
struct uiAction_s * onRightClick
hashTable_s * nodeMethods
virtual bool onDndEnter(uiNode_t *node)
int UI_GetParamNumber(const uiCallContext_t *context)
void UI_Node_WindowActivate(uiNode_t *node)
virtual void onMiddleClick(uiNode_t *node, int x, int y)
virtual bool onKeyReleased(uiNode_t *node, unsigned int key, unsigned short unicode)
const char * UI_GetParam(const uiCallContext_t *context, int paramID)
void UI_Node_SizeChanged(uiNode_t *node)
#define V_CVAR_OR_LONGSTRING
virtual void initNode(uiNode_t *node)
LUA_EVENT lua_onDragDropEnter
virtual void onFocusLost(uiNode_t *node)
static const value_t * propertyHeight
static const value_t * propertySize
uiNode_t * UI_GetNode(const uiNode_t *node, const char *name)
Search a child node by given name.
node behaviour, how a node work
LUA_EVENT lua_onVisibleWhen
virtual void onWindowClosed(uiNode_t *node)
QGL_EXTERN GLuint GLsizei GLsizei GLint GLenum GLchar * name
struct uiAction_s * onWheel
virtual void onSizeChanged(uiNode_t *node)
Callback stub.
bool UI_ExecuteLuaEventScript_Key(uiNode_t *node, LUA_EVENT event, unsigned int key, unsigned short unicode)
Executes a lua event handler with (keycode,unicode) argument.
LUA_EVENT lua_onMouseEnter
virtual void onPropertyChanged(uiNode_t *node, const value_t *property)
LUA_EVENT lua_onDragDropMove
bool UI_ExecuteLuaEventScript_DragDrop_XY(uiNode_t *node, LUA_EVENT event, int x, int y, bool &result)
Executes a lua event handler for dragdrop interaction.
virtual void deleteNode(uiNode_t *node)
LUA_EVENT lua_onFocusLost
void UI_Node_DoLayout(uiNode_t *node)
virtual void onMouseEnter(uiNode_t *node)
void UI_RegisterAbstractNode(uiBehaviour_t *behaviour)
const char * UI_GetStringFromNodeProperty(const uiNode_t *node, const value_t *property)
Return a string from a node property.
static const value_t * propertyInvis
LUA_EVENT lua_onDragDropLeave
static void UI_AbstractNodeCallDelete(uiNode_t *node, const uiCallContext_t *context)
static void UI_AbstractNodeCallRemovaAllChild(uiNode_t *node, const uiCallContext_t *context)
virtual void onLeftClick(uiNode_t *node, int x, int y)
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)
virtual void onActivate(uiNode_t *node)
Activate the node. Can be used without the mouse (ie. a button will execute onClick) ...
const struct value_s * UI_RegisterNodeMethod(uiBehaviour_t *behaviour, const char *name, uiNodeMethod_t function)
Register a node method to a behaviour.
int CL_Milliseconds(void)
LUA_EVENT lua_onDragDropFinished
virtual bool onKeyPressed(uiNode_t *node, unsigned int key, unsigned short unicode)