Contents
TwDefineStruct (function)
DescriptionThis function creates a new TwType corresponding to a C/C++ structure. Thus it could be used with TwAddVar* functions to control variable of type struct. ParametersnameSpecify a name for the struct type (must be unique). structMembersAn array of elements of type TwStructMember containing the descriptions of the structure members. nbMembersNumber of elements of the structMembers array. structSizeSize of the C/C++ structure (in bytes). summaryCallback
An optional callback function that will be called to display a summary of the structure content. If The callback function should be declared like this: void TW_CALL SummaryCallback(char *summaryString, size_t summaryMaxLength, const void *value, void *summaryClientData); { const MyStruct *s = *(const MyStruct *)value; s->PrintToString(summaryString, summaryMaxLength); // for instance. // summaryString is a pre-allocated C string (zero-ended) to be filled. // Its maximum length is summaryMaxLength. } summaryClientData
For your convenience, this is a supplementary pointer that will be passed to the Return values
Example// A user defined structure typedef struct { int X; float F; void *P; int Y; } MyStruct; MyStruct elem; // an element of type MyStruct that we want to add to a tweak bar // Description of the structure (note that you are not required to describe all members, and that members can be reordered) TwStructMember myStructMembers[] = { { "x", TW_TYPE_INT32, offsetof(MyStruct, X), "min=0 max=9" }, { "y", TW_TYPE_INT32, offsetof(MyStruct, Y), "" }, { "f", TW_TYPE_FLOAT, offsetof(MyStruct, F), "step=0.1" } }; TwType myStructType; // ... // Define myStructType myStructType = TwDefineStruct("MyStructType", myStructMembers, 3, sizeof(MyStruct), NULL, NULL); // Add elem to bar TwAddVarRW(bar, "Elem", myStructType, &elem, NULL); See also |