Difference between revisions of "Dear ImGui"

From GiderosMobile
(added example)
(getting ready)
Line 9: Line 9:
  
  
'''This is brand new in Gideros Studio so it may take some time to document it thoroughly.'''
+
'''This is a brand new plugin in Gideros Studio so it may take some time to document it thoroughly.'''
  
In the meantime, the '''author's GitHub''' is the best place to start using Dear ImGui in Gideros Studio.
+
In the meantime, the '''author's GitHub''' is the best place to get info regarding Dear ImGui Gideros functions.
 
  https://github.com/MultiPain/Gideros_ImGui
 
  https://github.com/MultiPain/Gideros_ImGui
  
Line 18: Line 18:
 
</source>
 
</source>
  
=== Examples ===
+
== DEAR IMGUI TEXT ==
'''The basics of Dear ImGui'''
 
 
<source lang="lua">
 
<source lang="lua">
 
require "ImGui"
 
require "ImGui"
Line 25: Line 24:
 
-- a Dear ImGui instance
 
-- a Dear ImGui instance
 
local imgui = ImGui.new()
 
local imgui = ImGui.new()
 +
stage:addChild(imgui)
  
 
-- we scale the font up
 
-- we scale the font up
Line 33: Line 33:
 
--imgui:setDarkStyle()
 
--imgui:setDarkStyle()
 
imgui:setClassicStyle()
 
imgui:setClassicStyle()
 
-- we add imgui to the stage
 
stage:addChild(imgui)
 
  
 
-- we create 2 variables to hold our main window status
 
-- we create 2 variables to hold our main window status

Revision as of 07:18, 30 August 2020

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2020.9

Description

This is an implementation of the Dear ImGui library.

See full original documentation here: https://pthom.github.io/imgui_manual_online/manual/imgui_manual.html


This is a brand new plugin in Gideros Studio so it may take some time to document it thoroughly.

In the meantime, the author's GitHub is the best place to get info regarding Dear ImGui Gideros functions.

https://github.com/MultiPain/Gideros_ImGui
require 'ImGui'

DEAR IMGUI TEXT

require "ImGui"

-- a Dear ImGui instance
local imgui = ImGui.new()
stage:addChild(imgui)

-- we scale the font up
imgui:ioSetFontGlobalScale(2)

-- we choose a style (default = Dark)
--imgui:setLightStyle()
--imgui:setDarkStyle()
imgui:setClassicStyle()

-- we create 2 variables to hold our main window status
local mainWindowOpen, mainWindowDrawn

-- Dear ImGui runs on the game loop
function enterFrame(e)
	-- 1 we start ImGui
	imgui:newFrame(e)

	-- 2 we build our GUI
	mainWindowOpen, mainWindowDrawn =
		imgui:beginWindow(
			"Hello ImGui v"..ImGui._VERSION, -- main window title
			true -- main window is expanded
		)
	if (mainWindowDrawn) then -- the variable is false when main window is collapsed
		imgui:text("Hello Dear ImGui!") -- we add a text element to our GUI
	end
	imgui:endWindow()

	-- 3 we render our window
	imgui:endFrame()
	imgui:render()
end

-- this wouldn't work without listeners
stage:addEventListener("mouseDown", function(e) imgui:onMouseDown(e) end)
stage:addEventListener("mouseUp", function(e) imgui:onMouseUp(e) end)
stage:addEventListener("mouseHover", function(e) imgui:onMouseHover(e) end)
stage:addEventListener("mouseMove", function(e) imgui:onMouseMove(e) end)
stage:addEventListener("mouseWheel", function(e) imgui:onMouseWheel(e) end)
stage:addEventListener("keyDown", function(e) imgui:onKeyDown(e) end)
stage:addEventListener("keyUp", function(e) imgui:onKeyUp(e) end)
stage:addEventListener("keyChar", function(e) imgui:onKeyChar(e) end)
stage:addEventListener("enterFrame", enterFrame)

Methods

Events

Constants