This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/21 22:12] atom0s created |
addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/22 00:10] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | todo | + | ====== ImGuiSizeConstraintCallbackData ====== |
+ | |||
+ | The ImGuiSizeConstraintCallbackData structure contains information used for window resizing callbacks. This allows users to adjust how their window(s) resize if they want to use certain constraints. | ||
+ | |||
+ | The following data is exposed in this structure, to Lua addons: | ||
+ | |||
+ | <sxh cpp> | ||
+ | struct ImGuiSizeConstraintCallbackData | ||
+ | { | ||
+ | ImVec2 Pos; // The current window position, for reference. (Read Only) | ||
+ | ImVec2 CurrentSize; // The current window size, for reference. (Read Only) | ||
+ | ImVec2 DesiredSize; // The desired contraint to apply to the resizing of the window. (Based on the mouse position.) | ||
+ | }; | ||
+ | </sxh> | ||
+ | |||
+ | You should edit the DesiredSize field to constrain the window to your liking. This value takes an ImVec2 of two floats, for example: | ||
+ | |||
+ | <sxh lua> | ||
+ | DesiredSize = ImVec(200, 200); | ||
+ | </sxh> | ||
+ | |||
+ | ------ | ||
+ | ====== Example ====== | ||
+ | |||
+ | The following example would apply a sizing constraint to keep the window in a square shape. (Similar to aspect ratio resizing.) | ||
+ | |||
+ | <sxh lua> | ||
+ | function SquareResizeConstraint(data) | ||
+ | data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y)); | ||
+ | end | ||
+ | |||
+ | imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint'); | ||
+ | </sxh> |