besnoi / lovely-imgui Goto Github PK
View Code? Open in Web Editor NEWModern Immediate-Mode library for LÖVE :hearts:
Modern Immediate-Mode library for LÖVE :hearts:
First off, let me say I absolutely love what this library is trying to do and would very much like to see it finished.
In playing around with it, it seems the checkbox widget doesn't actually update the toggle variable when clicked. Investigating seems that the issue is that the if statement on line 44 of CheckBox.lua never is satisfied because the id is updated before it evaluates lastActiveItem.
I was able to get it to work by swapping out the if statement for the same one used in Button.lua
if uiState.hotItem==id and uiState.activeItem==id then
First, this library looks awesome. Great work!
A common issue I have with love GUI libs is no gamepad support. I'm making a game that only uses gamepad/keys, but things like button could work if I could say "this is the current menu selection" or "the user has navigated to this button using the joypad".
I looked at the code and tried to figure it out, from an external-to-imgui perspective. This example is meant to use up/down keys and space to select:
imgui = require 'imgui'
local uiState = require "imgui.Core.UIState"
-- this tracks the current key choice
local currentItem = 1
-- NOTE: I'm new to imgui so there is probably a better way...
function love.draw()
uiState.hotItem = currentItem
imgui.layout.setFlex(true)
imgui.layout.setColumns(2)
if imgui.button('A') then
imgui.label('You are clicking on the A button!!')
else
imgui.label('')
end
if imgui.button('B') then
imgui.label('You are clicking on the B button!!')
else
imgui.label('')
end
if imgui.button('C') then
imgui.label('You are clicking on the C button!!')
else
imgui.label('')
end
imgui.draw()
end
function love.keypressed(key)
if key == 'space' then
uiState.activeItem=currentItem
end
if key == 'up' then
currentItem = currentItem - 1
end
if key == 'down' then
currentItem = currentItem + 1
end
if currentItem > imgui['_genID'] then
currentItem = 1
end
if currentItem < 1 then
currentItem = imgui['_genID']
end
end
function love.keyreleased(key)
if key == 'space' then
uiState.activeItem=nil
end
end
It seems to be tracking the current-selection ok, but I can't quite figure out how to say "this was chosen".
Do you have a suggestion of a better way to do it? Is there interest in making this more internal (I am using _genID
which seems hacky, but I bet widgets could even track this on their own.)
Here is a ready-made demo, just rename to demo.love:
demo.zip
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.