Code Monkey home page Code Monkey logo

lovely-imgui's People

Contributors

besnoi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

lovely-imgui's Issues

Checkbox Widget Doesn't toggle state

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

gamepad/keyboard support

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

Peek 2021-05-07 15-23

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.