Defold Learn logo


Gui

Defold GUI system

Namespace: dmGui
Include: #include <dmsdk/gui/gui.h>
TYPES
HContext A handle to a gui context
HNode A handle to a gui node
HScene A handle to a gui scene
HScript A handle to a gui script
HTextureSource A handle to a texture source, which can be a point...
ENUMS
AdjustMode
AdjustReference
CustomPropertyType
NodeTextureType This enum denotes what kind of texture type the m_...
Playback
Property
Result
Result
STRUCTS
struct CustomProperty Custom GUI node property value
FUNCTIONS
void DeleteNode (dmGui::HScene scene, dmGui::HNode node) Defer delete a node
dmGui::HNode GetFirstChildNode (dmGui::HScene scene, dmGui::HNode node) Get first child node
dmGui::HNode GetNextNode (dmGui::HScene scene, dmGui::HNode node) Get next sibling
uint32_t GetNodeCustomData (dmGui::HScene scene, HNode node) get node custom type
void* GetNodeCustomData (dmGui::HScene scene, HNode node) get node custom data
dmGui::Result GetNodeCustomProperty (dmGui::HScene scene, dmGui::HNode node, dmhash_t key, dmGui::CustomProperty* prop) Get a custom property from a GUI node
dmhash_t GetNodeId (dmGui::HScene scene, dmGui::HNode node) Get the id of a node.
bool GetNodeIsBone (dmGui::HScene scene, dmGui::HNode node) Query if the node is a bone
dmGui::HNode GetNodeParent (dmGui::HScene scene, dmGui::HNode node) Get the parent of a gui node
dmVMath::Vector4 GetNodeProperty (dmGui::HScene scene, dmGui::HNode node, dmGui::Property property) Get property value
dmhash_t GetNodeTextureId (dmGui::HScene scene, HNode node) get node texture
void* GetResource (dmGui::HScene scene, dmhash_t resource_id, dmhash_t suffix_with_dot) Gets a resource by its resource alias.
void INVALID_HANDLE () Invalid node handle
void LuaPushNode (lua_State* L, dmGui::HScene scene, HNode node) Pushes a dmGui::HNode to the stack
dmGui::HNode NewNode (dmGui::HScene scene, dmVMath::Point3 position, dmVMath::Vector3 size, dmGui::NodeType node_type, uint32_t custom_type)
void SetNodeAdjustMode (dmGui::HScene scene, dmGui::HNode node, AdjustMode adjust_mode) Set adjust mode
dmGui::Result SetNodeCustomProperty (dmGui::HScene scene, dmGui::HNode node, dmhash_t key, const dmGui::CustomProperty* prop) Set a custom property on a GUI node
void SetNodeId (dmGui::HScene scene, dmGui::HNode node, dmhash_t id) Set the id of a node.
void SetNodeIsBone (dmGui::HScene scene, dmGui::HNode node, bool is_bone) Set the bone state of the node
dmGui::Result SetNodeParent (dmGui::HScene scene, dmGui::HNode node, dmGui::HNode parent, bool keep_scene_transform) Set the parent of a gui node
void SetNodeProperty (dmGui::HScene scene, dmGui::HNode node, dmGui::Property property, dmVMath::Vector4 value) Set property value
void SetNodeTexture (dmGui::HScene scene, HNode node, dmhash_t texture_id) set node texture
void SetNodeTexture (dmGui::HScene scene, HNode node, NodeTextureType type, void* texture) set node texture

Functions

DeleteNode

void DeleteNode(dmGui::HScene scene, dmGui::HNode node)

Defer delete a node

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the node to delete

GetFirstChildNode

dmGui::HNode GetFirstChildNode(dmGui::HScene scene, dmGui::HNode node)

Get first child node

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node Gets the first child node. If 0, gets the first top level node.

RETURNS

dmGui::HNode The first child node

GetNextNode

dmGui::HNode GetNextNode(dmGui::HScene scene, dmGui::HNode node)

Get next sibling

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the current sibling

RETURNS

dmGui::HNode the next sibling, or INVALID_HANDLE if no more siblings

GetNodeCustomData

uint32_t GetNodeCustomData(dmGui::HScene scene, HNode node)

get node custom type

PARAMETERS

dmGui::HScene scene the gui scene
HNode node the gui node

RETURNS

uint32_t the custom type. Or 0 if it is no custom type

GetNodeCustomData

void* GetNodeCustomData(dmGui::HScene scene, HNode node)

get node custom data

PARAMETERS

dmGui::HScene scene the gui scene
HNode node the gui node

RETURNS

void* the custom data created per node by the gui node type extension

GetNodeCustomProperty

dmGui::Result GetNodeCustomProperty(dmGui::HScene scene, dmGui::HNode node, dmhash_t key, dmGui::CustomProperty* prop)

Get a custom property from a GUI node. String values returned in the output property are owned by the GUI scene and must not be freed by the caller.

PARAMETERS

dmGui::HScene scene scene
dmGui::HNode node node
dmhash_t key property name hash
dmGui::CustomProperty* prop output property

RETURNS

dmGui::Result RESULT_OK on success

GetNodeId

dmhash_t GetNodeId(dmGui::HScene scene, dmGui::HNode node)

Get the id of a node.

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node

RETURNS

dmhash_t the id of the node

GetNodeIsBone

bool GetNodeIsBone(dmGui::HScene scene, dmGui::HNode node)

Query if the node is a bone

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node

RETURNS

bool true if the node is a bone

GetNodeParent

dmGui::HNode GetNodeParent(dmGui::HScene scene, dmGui::HNode node)

Get the parent of a gui node

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node

RETURNS

dmGui::HNode the parent, or INVALID_HANDLE is unsuccessful

GetNodeProperty

dmVMath::Vector4 GetNodeProperty(dmGui::HScene scene, dmGui::HNode node, dmGui::Property property)

Get property value

PARAMETERS

dmGui::HScene scene scene
dmGui::HNode node node
dmGui::Property property property enum

RETURNS

dmVMath::Vector4

GetNodeTextureId

dmhash_t GetNodeTextureId(dmGui::HScene scene, HNode node)

get node texture

PARAMETERS

dmGui::HScene scene the gui scene
HNode node the gui node

RETURNS

dmhash_t the currently assigned texture

GetResource

void* GetResource(dmGui::HScene scene, dmhash_t resource_id, dmhash_t suffix_with_dot)

Gets a resource by its resource alias.

PARAMETERS

dmGui::HScene scene the gui scene
dmhash_t resource_id the resource alias
dmhash_t suffix_with_dot the hash of the suffix: hash(".spinescenec")

RETURNS

void* the resource if successful

INVALID_HANDLE

void INVALID_HANDLE()

Invalid node handle

PARAMETERS


LuaPushNode

void LuaPushNode(lua_State* L, dmGui::HScene scene, HNode node)

Pushes a dmGui::HNode to the stack

PARAMETERS

lua_State* L the Lua scene
dmGui::HScene scene the gui scene
HNode node the gui node

NewNode

dmGui::HNode NewNode(dmGui::HScene scene, dmVMath::Point3 position, dmVMath::Vector3 size, dmGui::NodeType node_type, uint32_t custom_type)

PARAMETERS

dmGui::HScene scene the gui scene
dmVMath::Point3 position the position
dmVMath::Vector3 size the size
dmGui::NodeType node_type the node type
uint32_t custom_type If node_type == dmGui::NODE_TYPE_CUSTOM, then this is used to create a custom node data for the registered custom type

RETURNS

dmGui::HNode the created node

SetNodeAdjustMode

void SetNodeAdjustMode(dmGui::HScene scene, dmGui::HNode node, AdjustMode adjust_mode)

Set adjust mode

PARAMETERS

dmGui::HScene scene scene
dmGui::HNode node node
AdjustMode adjust_mode the adjust mode

SetNodeCustomProperty

dmGui::Result SetNodeCustomProperty(dmGui::HScene scene, dmGui::HNode node, dmhash_t key, const dmGui::CustomProperty* prop)

Set a custom property on a GUI node. String values are copied, and the caller retains ownership of the input string.

PARAMETERS

dmGui::HScene scene scene
dmGui::HNode node node
dmhash_t key property name hash
const dmGui::CustomProperty* prop property value

RETURNS

dmGui::Result RESULT_OK on success

SetNodeId

void SetNodeId(dmGui::HScene scene, dmGui::HNode node, dmhash_t id)

Set the id of a node.

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node
dmhash_t id the id

SetNodeIsBone

void SetNodeIsBone(dmGui::HScene scene, dmGui::HNode node, bool is_bone)

Set the bone state of the node

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node
bool is_bone true if the node is ot be used as a bone

SetNodeParent

dmGui::Result SetNodeParent(dmGui::HScene scene, dmGui::HNode node, dmGui::HNode parent, bool keep_scene_transform)

Set the parent of a gui node

PARAMETERS

dmGui::HScene scene the gui scene
dmGui::HNode node the gui node
dmGui::HNode parent the new parent. May be null
bool keep_scene_transform true to keep the world position

RETURNS

dmGui::Result dmGui::RESULT_OK is successful

SetNodeProperty

void SetNodeProperty(dmGui::HScene scene, dmGui::HNode node, dmGui::Property property, dmVMath::Vector4 value)

Set property value

PARAMETERS

dmGui::HScene scene scene
dmGui::HNode node node
dmGui::Property property property enum
dmVMath::Vector4 value

SetNodeTexture

void SetNodeTexture(dmGui::HScene scene, HNode node, dmhash_t texture_id)

set node texture

PARAMETERS

dmGui::HScene scene the gui scene
HNode node the gui node
dmhash_t texture_id the texture id

SetNodeTexture

void SetNodeTexture(dmGui::HScene scene, HNode node, NodeTextureType type, void* texture)

set node texture

PARAMETERS

dmGui::HScene scene the gui scene
HNode node the gui node
NodeTextureType type the type of texture
void* texture A pointer to a e.g. dmGameSystem::TextureSetResource*

Structs

CustomProperty

TYPE

struct CustomProperty

Custom GUI node property value. String values returned from GetNodeCustomProperty() are owned by the GUI scene and must not be freed by the caller. String values passed to SetNodeCustomProperty() are copied.

MEMBERS

dmGui::CustomPropertyType m_Type the value type


Types

HContext

void HContext()

A handle to a gui context

PARAMETERS



HNode

void HNode()

A handle to a gui node

PARAMETERS



HScene

void HScene()

A handle to a gui scene

PARAMETERS



HScript

void HScript()

A handle to a gui script

PARAMETERS



HTextureSource

void HTextureSource()

A handle to a texture source, which can be a pointer to a resource, a dmGraphics::HTexture or a dynamic texture created from a gui script.

PARAMETERS



Enums

AdjustMode

ADJUST_MODE_FIT //!< 0
ADJUST_MODE_ZOOM //!< 1
ADJUST_MODE_STRETCH //!< 2

AdjustReference

ADJUST_REFERENCE_PARENT
ADJUST_REFERENCE_DISABLED

CustomPropertyType

CUSTOM_PROPERTY_TYPE_NUMBER
CUSTOM_PROPERTY_TYPE_BOOLEAN
CUSTOM_PROPERTY_TYPE_HASH
CUSTOM_PROPERTY_TYPE_STRING
CUSTOM_PROPERTY_TYPE_VECTOR3
CUSTOM_PROPERTY_TYPE_VECTOR4
CUSTOM_PROPERTY_TYPE_QUAT

NodeTextureType

This enum denotes what kind of texture type the m_Texture pointer is referencing.

NODE_TEXTURE_TYPE_NONE
NODE_TEXTURE_TYPE_TEXTURE
NODE_TEXTURE_TYPE_TEXTURE_SET

Playback

PLAYBACK_ONCE_FORWARD
PLAYBACK_ONCE_BACKWARD
PLAYBACK_ONCE_PINGPONG
PLAYBACK_LOOP_FORWARD
PLAYBACK_LOOP_BACKWARD
PLAYBACK_LOOP_PINGPONG
PLAYBACK_NONE

Property

PROPERTY_POSITION //!< 0
PROPERTY_ROTATION //!< 1
PROPERTY_SCALE //!< 2
PROPERTY_COLOR //!< 3
PROPERTY_SIZE //!< 4
PROPERTY_OUTLINE //!< 5
PROPERTY_SHADOW //!< 6
PROPERTY_SLICE9 //!< 7
PROPERTY_PIE_PARAMS //!< 8
PROPERTY_TEXT_PARAMS //!< 9
PROPERTY_COUNT //!< 10

Result

NODE_TYPE_BOX //!< 0,
NODE_TYPE_TEXT //!< 1,
NODE_TYPE_PIE //!< 2,
NODE_TYPE_TEMPLATE //!< 3,
NODE_TYPE_PARTICLEFX //!< 5,
NODE_TYPE_CUSTOM //!< 6,
NODE_TYPE_COUNT //!< 7,

Result

RESULT_OK //!< 0
RESULT_SYNTAX_ERROR //!< -1
RESULT_SCRIPT_ERROR //!< -2
RESULT_OUT_OF_RESOURCES //!< -4
RESULT_RESOURCE_NOT_FOUND //!< -5
RESULT_TEXTURE_ALREADY_EXISTS //!< -6
RESULT_INVAL_ERROR //!< -7
RESULT_INF_RECURSION //!< -8
RESULT_DATA_ERROR //!< -9
RESULT_WRONG_TYPE //!< -10