This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/21 22:13] atom0s |
addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/22 00:10] (current) |
||
---|---|---|---|
Line 5: | Line 5: | ||
The following data is exposed in this structure, to Lua addons: | The following data is exposed in this structure, to Lua addons: | ||
- | <code cpp> | + | <sxh cpp> |
struct ImGuiSizeConstraintCallbackData | struct ImGuiSizeConstraintCallbackData | ||
{ | { | ||
Line 12: | Line 12: | ||
ImVec2 DesiredSize; // The desired contraint to apply to the resizing of the window. (Based on the mouse position.) | ImVec2 DesiredSize; // The desired contraint to apply to the resizing of the window. (Based on the mouse position.) | ||
}; | }; | ||
- | </code> | + | </sxh> |
You should edit the DesiredSize field to constrain the window to your liking. This value takes an ImVec2 of two floats, for example: | You should edit the DesiredSize field to constrain the window to your liking. This value takes an ImVec2 of two floats, for example: | ||
- | <code lua> | + | <sxh lua> |
DesiredSize = ImVec(200, 200); | DesiredSize = ImVec(200, 200); | ||
- | </code> | + | </sxh> |
------ | ------ | ||
Line 25: | Line 25: | ||
The following example would apply a sizing constraint to keep the window in a square shape. (Similar to aspect ratio resizing.) | The following example would apply a sizing constraint to keep the window in a square shape. (Similar to aspect ratio resizing.) | ||
- | <code lua> | + | <sxh lua> |
function SquareResizeConstraint(data) | function SquareResizeConstraint(data) | ||
data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y)); | data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y)); | ||
Line 31: | Line 31: | ||
imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint'); | imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint'); | ||
- | </code> | + | </sxh> |