User Tools

Site Tools



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:

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.)

You should edit the DesiredSize field to constrain the window to your liking. This value takes an ImVec2 of two floats, for example:

DesiredSize = ImVec(200, 200);


The following example would apply a sizing constraint to keep the window in a square shape. (Similar to aspect ratio resizing.)

function SquareResizeConstraint(data)
    data.DesiredSize = ImVec2(math.max(data.DesiredSize.x, data.DesiredSize.y), math.max(data.DesiredSize.x, data.DesiredSize.y));    

imgui.SetNextWindowSizeConstraints(0, 0, float_max, float_max, 'SquareResizeConstraint');

addons/functions/gui/imguisizeconstraintcallbackdata.txt · Last modified: 2017/04/22 00:10 (external edit)