[Lib] SUIT - Simple User Interface Toolkit

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Lifri
Prole
Posts: 3
Joined: Fri Dec 30, 2016 10:50 pm
Location: Germany
Contact:

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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?
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Lifri
Prole
Posts: 3
Joined: Fri Dec 30, 2016 10:50 pm
Location: Germany
Contact:

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Lifri »

Alright, thanks for the heads up and the help.
User avatar
Positive07
Party member
Posts: 1014
Joined: Sun Aug 12, 2012 4:34 pm
Location: Argentina

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
for i, person in ipairs(everybody) do
[tab]if not person.obey then person:setObey(true) end
end
love.system.openURL(github.com/pablomayobre)
Townsie
Prole
Posts: 5
Joined: Thu Jan 05, 2017 7:13 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
Ashura
Prole
Posts: 1
Joined: Wed Mar 15, 2017 4:40 pm

Re: [Lib] SUIT - Simple User Interface Toolkit

Post by Ashura »

Seems to my the Github repository is dead, anyone interessted in continueing a fork?
User avatar
rmcode
Party member
Posts: 454
Joined: Tue Jul 15, 2014 12:04 pm
Location: Germany
Contact:

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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.
Connorses
Citizen
Posts: 63
Joined: Fri Sep 06, 2013 7:02 am

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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 11528 times
User avatar
megalukes
Citizen
Posts: 94
Joined: Fri Jun 27, 2014 11:29 pm
Location: Brazil

Re: [Lib] SUIT - Simple User Interface Toolkit

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests