ImGui.Core:beginWindow

From GiderosMobile
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Available since: Gideros 2020.9
Class: ImGui

Description

Pushes a Window to the stack and starts appending to it.

(bool) (bool) = ImGui:beginWindow(name,open,flags)

note: if open is nil (window with no X button) then only the second boolean is returned. The boolean will then return whether the window is expanded or colapsed.

Parameters

name: (string) the window title to be displayed
open: (bool) the status of the window, true=opened, false=closed, nil=no close button on window
flags: (string) any of the ImGui Window flags, see ImGui.WindowFlags

Return values

Returns: (bool) if second argument (open) is nil, returns only the second boolean below, otherwise it returns the status of the window, true=opened, false=closed
Returns: (bool) whether the window is collapsed or expanded

Example

require "ImGui"

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

local window01 = true -- the starting state of window01, true=window is visible at start up
local window02 = true -- the starting state of window02, true=window is visible at start up
local window03 = true -- the starting state of window03, true=window is visible at start up

function onEnterFrame(e)
	-- 1 we start ImGui
	imgui:newFrame(e.deltaTime)

	-- 2 we add a child window and build our GUI
	if window01 then -- is window visible (not closed)?
		local windowdrawn = false -- is window expanded or colapsed?
		window01, windowdrawn = imgui:beginWindow( -- with close button
			"Hello ImGui v"..ImGui._VERSION, -- window title
			window01 -- returns window visibility
		)
		if windowdrawn then -- the variable is false when main window is collapsed
			imgui:text("This is an ImGui text.") -- we add a text element to our GUI
			imgui:textColored("This is a colored text.", 0xff00ff, 1)
			-- ...
		end
	end

	window02 = imgui:beginWindow("Window02") -- no close button
	if window02 then -- is window expanded or colapsed?
		imgui:text("I am a text in window02")
		print(e.deltaTime) -- test
		-- ...
	end

	window03 = imgui:beginWindow(
		0, -- dummy title because we set the window with no title bar
		nil, -- no close button
		ImGui.WindowFlags_NoTitleBar -- no title bar
	)
	if window03 then -- is window expanded or colapsed?
		imgui:text("This is an ImGui text.") -- we add a text element to our GUI
		imgui:textColored("This is a colored text.", 0xff00ff, 1)
		-- ...
	end

	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)