Page 8 of 9

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sat Dec 31, 2016 12:22 am
by Positive07
That is because the mouse is never released, since showPauseMenu becomes false you don't update SUIT anymore, so it doesn't get a release event. Or that is what I think...

Try:

Code: Select all

local suit = require ('suit')
pauseMenu = suit.new()

function love.update(dt)
  if (showPauseMenu) then
      pauseMenu.layout:reset((love.graphics.getWidth() / 2 ) - 150,(love.graphics.getHeight() / 2 ) - 45)
      pauseMenu:Label("Pause", pauseMenu.layout:row(300,30))
          
      if (pauseMenu:Button( "Resume", pauseMenu.layout:row() ).hit) then
        showPauseMenu = false
        --resume all gameplay logics
      end
   end
end

function love.draw()
  --If you draw but pauseMenu when showPauseMenu is false you should get no UI
  love.graphics.setBackgroundColor(0, 100, 200, 0.2)
  pauseMenu:draw()
end

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sat Dec 31, 2016 1:28 pm
by Lifri
Yep, that seems to be the issue, it is working now.
I thought that the release event would be updated automatically when the mouse is hit, since it specifically does not check for the mouse to be hold down, but just hit. At least that is what I understand by the mouse being hit, a hold down is not intended.

Anyways, that means it is necessary to call the draw function every draw call of löve, even if we do not draw something? Does not sound to be the best practice.
Is there a way that I can manually update the button / the mouse event?

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Sat Dec 31, 2016 9:11 pm
by Positive07
Think about it this way, if you don't call any SUIT function then how can SUIT run any code at all? If it can't run code then how do you expect it to detect that the mouse is not down anymore?

SUIT doesn't plug itself to LÖVE callbacks, and that is a good thing. You can actually control how everything works.

SUIT checks if there is something to draw if there is then it draws it, if it doesn't it just returns, so even if you call pause:draw() every frame, if you haven't added the buttons and labels in the update nothing will be drawn and the function will return inmediately.

SUIT draw function actually is two functions in one, one is the update function which actually updates all components and the other is the draw function which draws the elements to screen. SUIT combines them in order to offer a simpler API, you call one function that does everything.

And it works cause as I said, if nothing is added in the update then nothing is drawn to screen so there is no disadvantage on calling that function even when not needed

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Mon Jan 02, 2017 8:07 pm
by Lifri
Alright, thanks for the heads up and the help.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Tue Jan 03, 2017 3:35 am
by Positive07
Lifri wrote:Alright, thanks for the heads up and the help.
No problem! I'm here to help

PS: Is weird how I have never used this library yet I have helped so many times in this thread hahaha.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Thu Jan 05, 2017 7:15 pm
by Townsie
I've been trying on this SUIT, and I really like it. I'd love a small example of a custom widget though. I'm trying to hack together a scrollview with some text, but I'm having a hard time getting a custom widget working.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Wed Mar 15, 2017 4:41 pm
by Ashura
Seems to my the Github repository is dead, anyone interessted in continueing a fork?

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Mon Mar 27, 2017 5:05 pm
by rmcode
Is there a way to reduce the garbage production of SUIT? The bigdemo produces a few hundred kb in a few frames and I'm worried this might become a bottleneck with more involved GUIs on top of the engine.
Ashura wrote: Wed Mar 15, 2017 4:41 pm Seems to my the Github repository is dead, anyone interessted in continueing a fork?
There was a commit just 11 days ago. If a library runs fine there often just isn't a need to update its repo.

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Fri Feb 02, 2018 1:45 am
by Connorses
Just want to say thanks, "Immediate Mode" is a great way to insert or remove UI elements arbitrarily and I've been using SUIT to help build my own level editor.
Untitled.png
Untitled.png (96.67 KiB) Viewed 11524 times

Re: [Lib] SUIT - Simple User Interface Toolkit

Posted: Mon Feb 17, 2020 9:49 pm
by megalukes
Hello everyone. Is it just me or the isHovered(id) function is not working properly? I've been trying to make it work but I guess there must be something wrong since I was following documentation correctly. Here's my code. Any help would be really appreciated. Thank you!

Code: Select all

io.stdout:setvbuf("no")
function love.load()
	suit = require 'suit'
    if suit.Button("Attack", 396,140, 80,25).hit then end
    if suit.Button("Skill", 396,140+25, 80,25).hit then end

end

function love.update(dt)
    if suit.Button("Attack", 396,140, 150,50).hit then end
    if suit.Button("Skill", 396,140+60, 150,50).hit then end

    print("Attack",suit:isHovered("Attack"))
    print("Skill",suit:isHovered("Skill"))
end

function love.draw()
    suit:draw()
end