Difference between revisions of "ImGui.Core:beginWindow"

From GiderosMobile
(→‎Example: deltaTime)
m (Text replacement - "<source" to "<syntaxhighlight")
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Pushes a window to the stack and starts appending to it.
 
Pushes a window to the stack and starts appending to it.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(bool) (bool) = ImGui:beginWindow(name,open,flags)
 
(bool) (bool) = ImGui:beginWindow(name,open,flags)
 
</source>
 
</source>
Line 21: Line 21:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "ImGui"
 
require "ImGui"
  

Revision as of 15:28, 13 July 2023

Available since: Gideros 2020.9
Class: ImGui

Description

Pushes a window to the stack and starts appending to it. <syntaxhighlight lang="lua"> (bool) (bool) = ImGui:beginWindow(name,open,flags) </source>

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 Constants - Window Flags

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

<syntaxhighlight lang="lua"> 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) </source>