File Widget.h
FileList > engine > include > Widget.h
Go to the source code of this file
#include "ObjectPool.h"#include "HandleDefs.h"#include <stdbool.h>#include "DynArray.h"#include "Geometry.h"
Classes
| Type | Name |
|---|---|
| struct | CWidgetCallbacks |
| struct | CWidgetMouseCallback this isn't some "hungarian notation" shit - the name refers to widget callbacks defined as C functions! |
| struct | LuaWidgetCallback |
| struct | LuaWidgetCallbacks |
| struct | UIWidget |
| struct | WidgetDim |
| struct | WidgetMouseInfo |
| struct | WidgetPadding |
| struct | WidgetPropertyBinding |
| struct | WidgetScale |
Public Types
| Type | Name |
|---|---|
| typedef void(* | FocusedWidgetRecieveKeystrokeFn |
| typedef float(* | GetUIWidgetDimensionFn |
| typedef void(* | LayoutChildrenFn |
| typedef void(* | OnBoundPropertyChangedFn |
| typedef void(* | OnChildrenChangedFn |
| typedef void(* | OnDestroyWidgetFn |
| typedef void(* | OnWidgetInitFn |
| typedef void *(* | OutputWidgetVerticesFn |
| typedef int(* | PrintfFn |
| enum | WidgetCallbackTypes |
| typedef struct WidgetDim *(* | WidgetDimGetterFn |
| enum | WidgetDimType some are relative to their parent. In which case these should be relative to THEIR parent, fixed, or the top level window. |
| enum | WidgetDockPoint |
| typedef enum WidgetDockPoint | WidgetDockPoint |
| typedef void(* | WidgetFocusChangeCallbackFn |
| enum | WidgetHorizontalAlignment |
| typedef enum WidgetHorizontalAlignment | WidgetHorizontalAlignment |
| typedef void(* | WidgetMouseBtnCallbackFn |
| typedef void(* | WidgetMousePosCallbackFn |
| enum | WidgetPropertyBindingType |
| typedef struct Vert2DColourTextureQuad | WidgetQuad |
| typedef struct Vert2DColourTexture | WidgetVertex |
| enum | WidgetVerticalAlignment |
| typedef enum WidgetVerticalAlignment | WidgetVerticalAlignment |
Public Functions
| Type | Name |
|---|---|
| struct WidgetDim * | GetWidgetHeightDim (struct UIWidget * pWidget) |
| struct WidgetDim * | GetWidgetWidthDim (struct UIWidget * pWidget) |
| void | UI_AddChild (HWidget hParent, HWidget hChild) |
| void | UI_AddFloatPropertyBinding (struct UIWidget * pWidget, char * inBoundPropertyName, char * inBindingExpression, float * pOutData, int viewmodelTableIndex) |
| void | UI_AddIntPropertyBinding (struct UIWidget * pWidget, char * inBoundPropertyName, char * inBindingExpression, int * pOutData, int viewmodelTableIndex) |
| void | UI_AddStringPropertyBinding (struct UIWidget * pWidget, char * inBoundPropertyName, char * inBindingExpression, char ** pOutData, int viewmodelTableIndex) Add a bound string property entry to the widget and initialise a value by calling the binding getter function. |
| size_t | UI_CountWidgetChildren (HWidget pWidget) |
| size_t | UI_CountWidgetChildrenPtr (struct UIWidget * pWidget) |
| void | UI_DebugPrintCommonWidgetInfo (const struct UIWidget * inWidget, PrintfFn pPrintfFn) print a text representation of the widget tree. Falls appart if a widget fails to implement its debug print hook correctly. Shit. DON'T USE |
| void | UI_DefaultOnChildrenChanged (struct UIWidget * outWidget) |
| void | UI_DestroyWidget (HWidget widget) |
| struct WidgetPropertyBinding * | UI_FindBinding (struct UIWidget * pWidget, const char * bindingName) |
| struct UIWidget * | UI_FirstChild (HWidget hWidget) |
| void | UI_GetHitBox (GeomRect outRect, HWidget hWidget) Get the AABB of the widget, excluding padding. |
| HWidget | UI_GetScratchWiget () |
| struct UIWidget * | UI_GetWidget (HWidget hWidget) |
| void | UI_GetWidgetPadding (HWidget hWidget, float * pOutPaddingTop, float * pOutPaddingBottom, float * pOutPaddingLeft, float * pOutPaddingRight) |
| void | UI_GetWidgetSize (HWidget hWidget, float * pOutW, float * pOutH) |
| void | UI_GetWidgetTopLeft (HWidget hWidget, float * pOutLeft, float * pOutTop) get top left BEFORE padding is applied (the raw top left) |
| void | UI_Helper_OnLayoutChildren (struct UIWidget * pWidget, struct UIWidget * pParent) |
| void * | UI_Helper_OnOutputVerts (struct UIWidget * pWidget, VECTOR(WidgetVertex) pOutVerts) |
| void | UI_Init () |
| bool | UI_IsAttributeStringABindingExpression (const char * attributeValue) |
| char * | UI_MakeBindingGetterFunctionName (const char * inBindingName) USER MUST FREE RETURNED PTR append Get_ to the start of the string. |
| char * | UI_MakeBindingSetterFunctionName (const char * inBindingName) |
| HWidget | UI_NewBlankWidget () |
| float | UI_ResolveHeightDimPxls (struct UIWidget * pWidget, const struct WidgetDim * dim) |
| float | UI_ResolveWidthDimPxls (struct UIWidget * pWidget, const struct WidgetDim * dim) |
| void | UI_SendWidgetMouseEvent (struct UIWidget * pWidget, enum WidgetCallbackTypes type, struct WidgetMouseInfo * pMouseInfo) send a mouse event to the widget that will be handled either by either or both a lua function and a c function. If both the C function is called first |
| void | UI_WidgetCommonInit (struct DataNode * pInNode, struct UIWidget * outWidget) Init common attributes that all widgets can have. |
Macros
| Type | Name |
|---|---|
| define | LUA_CALLBACK_MAX_NAME_LEN 64 |
| define | MAX_NUM_BINDINGS 16 |
| define | MAX_PROPERTY_NAME_LEN 32 |
| define | NUM_BUTTONS 3 |
Public Types Documentation
typedef FocusedWidgetRecieveKeystrokeFn
typedef void(* FocusedWidgetRecieveKeystrokeFn) (struct UIWidget *pWidget, int keystroke);
typedef GetUIWidgetDimensionFn
typedef float(* GetUIWidgetDimensionFn) (struct UIWidget *pWidget, struct UIWidget *pParent);
typedef LayoutChildrenFn
typedef void(* LayoutChildrenFn) (struct UIWidget *pWidget, struct UIWidget *pParent);
typedef OnBoundPropertyChangedFn
typedef void(* OnBoundPropertyChangedFn) (struct UIWidget *pThisWidget, struct WidgetPropertyBinding *pBinding);
typedef OnChildrenChangedFn
typedef void(* OnChildrenChangedFn) (struct UIWidget *pWidget);
typedef OnDestroyWidgetFn
typedef void(* OnDestroyWidgetFn) (struct UIWidget *pWidget);
typedef OnWidgetInitFn
typedef void(* OnWidgetInitFn) (struct UIWidget *pWidget);
typedef OutputWidgetVerticesFn
typedef void *(* OutputWidgetVerticesFn) (struct UIWidget *pThisWidget, VECTOR(WidgetVertex) pOutVerts);
typedef PrintfFn
typedef int(* PrintfFn) (const char *restrict fmt,...);
enum WidgetCallbackTypes
enum WidgetCallbackTypes {
WC_OnMouseEnter,
WC_OnMouseLeave,
WC_OnMouseMove,
WC_OnMouseDown,
WC_OnMouseUp,
WC_OnGainFocus,
WC_OnLeaveFocus,
WC_NUM
};
typedef WidgetDimGetterFn
typedef struct WidgetDim *(* WidgetDimGetterFn) (struct UIWidget *pWidget);
enum WidgetDimType
some are relative to their parent. In which case these should be relative to THEIR parent, fixed, or the top level window.
enum WidgetDimType {
WD_Auto,
WD_Stretch,
WD_Pixels,
WD_StretchFraction,
WD_Percentage
};
enum WidgetDockPoint
enum WidgetDockPoint {
WDP_TopLeft,
WDP_TopMiddle,
WDP_TopRight,
WDP_MiddleRight,
WDP_BottomRight,
WDP_BottomMiddle,
WDP_BottomLeft,
WDP_MiddleLeft,
WDP_Centre
};
typedef WidgetDockPoint
typedef enum WidgetDockPoint WidgetDockPoint;
typedef WidgetFocusChangeCallbackFn
typedef void(* WidgetFocusChangeCallbackFn) (struct UIWidget *pWidget);
enum WidgetHorizontalAlignment
enum WidgetHorizontalAlignment {
WHA_Left,
WHA_Middle,
WHA_Right
};
typedef WidgetHorizontalAlignment
typedef enum WidgetHorizontalAlignment WidgetHorizontalAlignment;
typedef WidgetMouseBtnCallbackFn
typedef void(* WidgetMouseBtnCallbackFn) (struct UIWidget *pWidget, float x, float y, int btn);
typedef WidgetMousePosCallbackFn
typedef void(* WidgetMousePosCallbackFn) (struct UIWidget *pWidget, float x, float y);
enum WidgetPropertyBindingType
enum WidgetPropertyBindingType {
WBT_Int,
WBT_Float,
WBT_String,
WBT_Bool,
WBT_WidgetTree
};
typedef WidgetQuad
typedef struct Vert2DColourTextureQuad WidgetQuad;
typedef WidgetVertex
typedef struct Vert2DColourTexture WidgetVertex;
enum WidgetVerticalAlignment
enum WidgetVerticalAlignment {
WVA_Top,
WVA_Middle,
WVA_Bottom
};
typedef WidgetVerticalAlignment
typedef enum WidgetVerticalAlignment WidgetVerticalAlignment;
Public Functions Documentation
function GetWidgetHeightDim
struct WidgetDim * GetWidgetHeightDim (
struct UIWidget * pWidget
)
function GetWidgetWidthDim
struct WidgetDim * GetWidgetWidthDim (
struct UIWidget * pWidget
)
function UI_AddChild
void UI_AddChild (
HWidget hParent,
HWidget hChild
)
function UI_AddFloatPropertyBinding
void UI_AddFloatPropertyBinding (
struct UIWidget * pWidget,
char * inBoundPropertyName,
char * inBindingExpression,
float * pOutData,
int viewmodelTableIndex
)
function UI_AddIntPropertyBinding
void UI_AddIntPropertyBinding (
struct UIWidget * pWidget,
char * inBoundPropertyName,
char * inBindingExpression,
int * pOutData,
int viewmodelTableIndex
)
function UI_AddStringPropertyBinding
Add a bound string property entry to the widget and initialise a value by calling the binding getter function.
void UI_AddStringPropertyBinding (
struct UIWidget * pWidget,
char * inBoundPropertyName,
char * inBindingExpression,
char ** pOutData,
int viewmodelTableIndex
)
Parameters:
pWidgettheWidget to add the property binding. When the value changes the property of the widget will change when OnPropertyChanged is called. 2 way bindings will also be introduced for sliders, text entry fields, ectinBoundPropertyNamebound property name - as it appears in the viewmodel lua tableinBindingExpressionthe incoming binding expression, i.e. {spritename}pOutDatathe value returned from calling the lua string getter - allocates a string setting the pointer. user must deallocateviewmodelTableIndexthe index in the lua registry that contains the lua table containing the function to call
function UI_CountWidgetChildren
size_t UI_CountWidgetChildren (
HWidget pWidget
)
function UI_CountWidgetChildrenPtr
size_t UI_CountWidgetChildrenPtr (
struct UIWidget * pWidget
)
function UI_DebugPrintCommonWidgetInfo
print a text representation of the widget tree. Falls appart if a widget fails to implement its debug print hook correctly. Shit. DON'T USE
void UI_DebugPrintCommonWidgetInfo (
const struct UIWidget * inWidget,
PrintfFn pPrintfFn
)
Parameters:
inWidgetpPrintfFn
function UI_DefaultOnChildrenChanged
void UI_DefaultOnChildrenChanged (
struct UIWidget * outWidget
)
function UI_DestroyWidget
void UI_DestroyWidget (
HWidget widget
)
function UI_FindBinding
struct WidgetPropertyBinding * UI_FindBinding (
struct UIWidget * pWidget,
const char * bindingName
)
function UI_FirstChild
struct UIWidget * UI_FirstChild (
HWidget hWidget
)
function UI_GetHitBox
Get the AABB of the widget, excluding padding.
void UI_GetHitBox (
GeomRect outRect,
HWidget hWidget
)
Parameters:
outRecthWidget
function UI_GetScratchWiget
HWidget UI_GetScratchWiget ()
function UI_GetWidget
struct UIWidget * UI_GetWidget (
HWidget hWidget
)
function UI_GetWidgetPadding
void UI_GetWidgetPadding (
HWidget hWidget,
float * pOutPaddingTop,
float * pOutPaddingBottom,
float * pOutPaddingLeft,
float * pOutPaddingRight
)
function UI_GetWidgetSize
void UI_GetWidgetSize (
HWidget hWidget,
float * pOutW,
float * pOutH
)
function UI_GetWidgetTopLeft
get top left BEFORE padding is applied (the raw top left)
void UI_GetWidgetTopLeft (
HWidget hWidget,
float * pOutLeft,
float * pOutTop
)
Parameters:
hWidgetpOutLeftpOutTop
function UI_Helper_OnLayoutChildren
void UI_Helper_OnLayoutChildren (
struct UIWidget * pWidget,
struct UIWidget * pParent
)
function UI_Helper_OnOutputVerts
void * UI_Helper_OnOutputVerts (
struct UIWidget * pWidget,
VECTOR( WidgetVertex ) pOutVerts
)
function UI_Init
void UI_Init ()
function UI_IsAttributeStringABindingExpression
bool UI_IsAttributeStringABindingExpression (
const char * attributeValue
)
Parameters:
attributeValue
Returns:
is the value of an xml attribute property an absolute value (return false) or is it deferrred to a getter on the lua viewmodel (return true). Special syntax for this is to surround the name of a view model property with "{" and "}"
function UI_MakeBindingGetterFunctionName
USER MUST FREE RETURNED PTR append Get_ to the start of the string.
char * UI_MakeBindingGetterFunctionName (
const char * inBindingName
)
Parameters:
inBindingName
Returns:
function UI_MakeBindingSetterFunctionName
char * UI_MakeBindingSetterFunctionName (
const char * inBindingName
)
function UI_NewBlankWidget
HWidget UI_NewBlankWidget ()
function UI_ResolveHeightDimPxls
float UI_ResolveHeightDimPxls (
struct UIWidget * pWidget,
const struct WidgetDim * dim
)
function UI_ResolveWidthDimPxls
float UI_ResolveWidthDimPxls (
struct UIWidget * pWidget,
const struct WidgetDim * dim
)
function UI_SendWidgetMouseEvent
send a mouse event to the widget that will be handled either by either or both a lua function and a c function. If both the C function is called first
void UI_SendWidgetMouseEvent (
struct UIWidget * pWidget,
enum WidgetCallbackTypes type,
struct WidgetMouseInfo * pMouseInfo
)
Parameters:
pWidget<br>pMouseInfodata about the event
function UI_WidgetCommonInit
Init common attributes that all widgets can have.
void UI_WidgetCommonInit (
struct DataNode * pInNode,
struct UIWidget * outWidget
)
- "the base class constructor"
Parameters:
pInNodeoutWidget
Macro Definition Documentation
define LUA_CALLBACK_MAX_NAME_LEN
#define LUA_CALLBACK_MAX_NAME_LEN `64`
define MAX_NUM_BINDINGS
#define MAX_NUM_BINDINGS `16`
define MAX_PROPERTY_NAME_LEN
#define MAX_PROPERTY_NAME_LEN `32`
define NUM_BUTTONS
#define NUM_BUTTONS `3`
The documentation for this class was generated from the following file /home/runner/work/2DFarmingRPG/2DFarmingRPG/Stardew/engine/include/Widget.h