Difference between revisions of "ImGui.Core:colorPicker3"

From GiderosMobile
(Created page with "__NOTOC__ '''Available since:''' Gideros 2020.9<br/> '''Class:''' ImGui<br/> === Description === Displays an RGB color picker widget. <source lang="lua"> (number), (bool)...")
 
m (Text replacement - "</source>" to "</syntaxhighlight>")
 
(4 intermediate revisions by 2 users not shown)
Line 5: Line 5:
 
=== Description ===
 
=== Description ===
 
Displays an RGB color picker widget.
 
Displays an RGB color picker widget.
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
(number), (bool) = ImGui:colorPicker3(label, color, [ImGuiColorEditFlags=0])
 
(number), (bool) = ImGui:colorPicker3(label, color, [ImGuiColorEditFlags=0])
</source>
+
</syntaxhighlight>
  
 
=== Parameters ===
 
=== Parameters ===
 
'''label''': (string) the label<br/>
 
'''label''': (string) the label<br/>
'''color''': (number) the current color<br/>
+
'''color''': (number) the current color, ''should be the same as number''<br/>
 
'''ImGuiColorEditFlags''': (number) one of ImGui color edit flags<br/>
 
'''ImGuiColorEditFlags''': (number) one of ImGui color edit flags<br/>
  
Line 19: Line 19:
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
 
require "ImGui"
 
require "ImGui"
  
Line 30: Line 30:
 
function onEnterFrame(e)
 
function onEnterFrame(e)
 
-- 1 we start ImGui
 
-- 1 we start ImGui
imgui:newFrame(e)
+
imgui:newFrame(e.deltaTime)
 
-- 2 we add some child windows and build our GUI
 
-- 2 we add some child windows and build our GUI
window01 = imgui:beginWindow("Window 01") -- no close button (X)
+
-- window01 = imgui:beginWindow("Window 01") -- no close button (X)
 
if window01 then -- the variable is false when window is collapsed
 
if window01 then -- the variable is false when window is collapsed
 
imgui:text("Hello Dear ImGui!")
 
imgui:text("Hello Dear ImGui!")
Line 45: Line 45:
  
 
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
 
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)
</source>
+
</syntaxhighlight>
  
 
{{ImGui}}
 
{{ImGui}}

Latest revision as of 15:29, 13 July 2023

Available since: Gideros 2020.9
Class: ImGui

Description

Displays an RGB color picker widget.

(number), (bool) = ImGui:colorPicker3(label, color, [ImGuiColorEditFlags=0])

Parameters

label: (string) the label
color: (number) the current color, should be the same as number
ImGuiColorEditFlags: (number) one of ImGui color edit flags

Return values

Returns (number) the current color
Returns (bool) whether the current color has changed

Example

require "ImGui"

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

local window01 = true
local hexcolor = 0x00ff00

function onEnterFrame(e)
	-- 1 we start ImGui
	imgui:newFrame(e.deltaTime)
	-- 2 we add some child windows and build our GUI
--	window01 = imgui:beginWindow("Window 01") -- no close button (X)
	if window01 then -- the variable is false when window is collapsed
		imgui:text("Hello Dear ImGui!")
		local isChanged = false
		hexcolor, isChanged = imgui:colorPicker3("label", hexcolor, 0)
		if isChanged then print(hexcolor) end
	end
	-- 3 we end the frame and render to screen
	imgui:endFrame()
	imgui:render()
end

stage:addEventListener(Event.ENTER_FRAME, onEnterFrame)