User Tools

Site Tools


addons:functions:gui:imguisizeconstraintcallbackdata

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/21 22:13]
atom0s
addons:functions:gui:imguisizeconstraintcallbackdata [2017/04/22 00:10]
Line 1: Line 1:
-====== 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: 
- 
-<code 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.) 
-}; 
-</​code>​ 
- 
-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> 
-DesiredSize = ImVec(200, 200); 
-</​code>​ 
- 
------- 
-====== Example ====== 
- 
-The following example would apply a sizing constraint to keep the window in a square shape. (Similar to aspect ratio resizing.) 
- 
-<code 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'​);​ 
-</​code>​ 
addons/functions/gui/imguisizeconstraintcallbackdata.txt · Last modified: 2017/04/22 00:10 (external edit)