ImGui.Core:setNextWindowSizeConstraints

From GiderosMobile
Revision as of 12:14, 27 August 2024 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui<br/> === Description === Sets the desired constrained sizes of the next window in the windows list...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2020.9
Class: ImGui

Description

Sets the desired constrained sizes of the next window in the windows list.

ImGui:setNextWindowSizeConstraints(min_w,min_h,max_w,max_h [,resize_callback,user_data])

Parameters

min_w: (number) the next window desired minimum width
min_h: (number) the next window desired minimum height
max_w: (number) the next window desired maximum width
max_h: (number) the next window desired maximum height
resize_callback: (function) a function to call with first argument being resize_callback optional
user_data: (any) any user data to pass to the resize_callback function optional

Examples

A fixed window size

function onEnterFrame(e)
	self.imgui:newFrame(e.deltaTime)
	local ischanged = false
	-- myWindow1
	self.imgui:setNextWindowPos(8, 8)
	self.imgui:setNextWindowSizeConstraints(64*6, 64*2, 64*6, 64*2) -- fixed window size
	self.imgui:beginWindow("myWindow1") -- no close button
		-- add your widgets here
	self.imgui:endWindow()
	-- myWindow2
	-- ...
	self.imgui:endFrame()
	self.imgui:render()
end

Resize window by 32 increment

require "ImGui"

local function stepSize(callback_data, step)
	local w, h = callback_data:getDesiredSize()
	w = (w // step) * step
	h = (h // step) * step
	return w, h
end

local ui = ImGui.new()
stage:addChild(ui)

stage:addEventListener("enterFrame", function(e)
	ui:newFrame(e.deltaTime)
	-- window size step is 32 (last argument, that is passed to the callback as second argument)
	ui:setNextWindowSizeConstraints(200, 200, 400, 400, stepSize, 32)
	if (ui:beginWindow("My window")) then
		ui:textWrapped("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
	end
	ui:endWindow()
	ui:showDemoWindow()
	ui:render()
	ui:endFrame()
end)




Dear ImGui