A lightweight Love2d GUI library with the purpose of creating easy and fast interfaces for quick debugging, ultra-customizable menus and more.
GlideUI is currently W.I.P (Work In Progress), so expect bugs and missing features. I am working hard on making it fully stable, but for now, do not expect perfect behavior from the library.
- If you encounter any bug or have suggestions, you can open an issue.
- If you want to contribute, please see CONTRIBUTING.md.
Glide's elements are not button
, slider
, etc. They are objects with various useful events, methods, style options, and basic parameters. This makes it so you can build your GUI elements step by step, but without being too tedious, allowing for incredible customization.
Frames in Glide act as element containers. You can align (more easily) or attach (more precisely) an element to a frame, and then move the frame with Frame:Drag()
or by manually changing frame.x
and frame.y
. Frames also have mouse grabbing (with Frame:GrabMouse(true)
).
GlideUI allows for infinite customization of elements and frames. You can lighten or darken your elements with methods, or restore their color completely. Set and adjust properties as needed. Set and align the text inside elements, or align elements inside frames. The possibilites are infinite!
Glide's elements have easy-to-use events, such as OnPress(button: number, func: function)
, OnHover(func: function)
, OnUnhover(func: function)
, OnHold(button: number, func: function)
, and more.
This will produce a GUI with a button in the middle of a draggable frame.
function love.load()
glide = require("lib.glide")
--make a new element
--parameters: x, y, width, height, color
BUTTON = glide.New(200, 300, 125, 25, {0.25, 0.25, 0.75})
BUTTON:SetText("Press me!") --set the button's text
--make a new frame
--parameters: x, y, width, height, color
FRAME = glide.NewFrame(100, 200, 200, 200, {0.5, 0.5, 0.5})
end
function love.update(dt) -- called every frame
glide.Update() --IMPORTANT: call this before any other glide call
--use the button's OnPress event
BUTTON:OnPress(1, function()
BUTTON:SetText("Pressed!")
end)
--make the button be in the middle of the frame
BUTTON:AlignToFrameX(FRAME, "center")
BUTTON:AlignToFrameY(FRAME, "center")
--make the frame draggable
FRAME:Drag()
end
function love.draw()
--draw both button and frame
--draw first the frame to not make it draw over the button
FRAME:Draw()
BUTTON:Draw()
end
There are three methods to download the library:
Pros/Cons
- Easy to use.
- Doesn't require a git repository.
- Has to be manually updated.
- Harder to manage long-term.
git clone https://github.com/Nykenik24/GlideUI.git path/to/glide
git submodule add https://github.com/Nykenik24/GlideUI.git path/to/glide
- Go to the repository main page.
- At the bottom-right, go to the latest release.
- Download the
.zip
file attached. - Put it in your project.
- Extract it.
Pros/Cons
- Releases are usually stable and rarely have bugs.
- You don't have the latest features.
local glide = require("path.to.glide")
Now you can use GlideUI!
Make a better frame dragging system.- Make all the functionality you need.
- Make it as stable as possible.
To run the demo, run the main.lua
file with love
.
Button with hover
function love.load()
local glide = require("glide")
BUTTON = glide.New(200, 300, 125, 25, {1, 0, 0})
end
function love.update()
glide.Update()
BUTTON:OnHover(function()
BUTTON:Darken(0.25)
end)
BUTTON:OnUnhover(function()
BUTTON:RestoreColor()
end)
end
function love.draw()
BUTTON:Draw()
end