2022-08-15 23:41:17 +02:00
|
|
|
Yui - A Declarative UI library for LÖVE
|
|
|
|
=======================================
|
|
|
|
|
2022-08-17 13:35:30 +02:00
|
|
|
**Yui** - Yet another User Interface, is a library to create menu-like GUIs
|
2022-08-17 17:27:11 +02:00
|
|
|
for the [LÖVE](https://love2d.org) engine.
|
2022-08-15 23:41:17 +02:00
|
|
|
|
|
|
|
## Why is that?
|
|
|
|
|
|
|
|
Because I'm spending so much time tweaking and customizing existing libraries,
|
|
|
|
I might as well make my own.
|
|
|
|
|
2022-08-17 17:04:25 +02:00
|
|
|
## Hello, World!
|
|
|
|
|
|
|
|
```lua
|
|
|
|
local yui = require 'lib.yui'
|
|
|
|
|
|
|
|
function love.load()
|
|
|
|
local w, h = 300, 80
|
|
|
|
local x = math.floor((love.graphics.getWidth() - w) / 2)
|
|
|
|
local y = math.floor((love.graphics.getHeight() - h) / 2)
|
|
|
|
|
|
|
|
ui = yui.Ui.new {
|
|
|
|
x = x, y = y,
|
|
|
|
|
|
|
|
yui.Rows {
|
|
|
|
yui.Label {
|
|
|
|
w = w, h = h / 2,
|
|
|
|
text = "Hello, World!"
|
|
|
|
},
|
|
|
|
yui.Button {
|
|
|
|
text = "Close",
|
|
|
|
|
|
|
|
onHit = function() love.event.quit() end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
function love.update(dt)
|
|
|
|
ui:update(dt)
|
|
|
|
end
|
|
|
|
|
|
|
|
function love.draw()
|
|
|
|
ui:draw()
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
2022-11-06 17:44:57 +01:00
|
|
|
![Hello, World!](https://gitea.it/1414codeforge/yui-examples/raw/branch/master/pics/hello_world.png)
|
2022-08-17 17:04:25 +02:00
|
|
|
|
2022-08-17 13:35:30 +02:00
|
|
|
## Features
|
|
|
|
|
|
|
|
**Yui** fills the following gaps:
|
|
|
|
|
|
|
|
* Immediate mode UIs tend to clutter LÖVE `update()` code a lot, using a declarative approach - that is:
|
|
|
|
describing how the UI should look upfront, and then letting the UI code `update()` and `draw()` itself accordingly,
|
|
|
|
makes for a cleaner code.
|
|
|
|
* Adapt to different sources of input easily (keyboard, mouse, touch, gamepad).
|
|
|
|
* Out of the box internationalization.
|
|
|
|
* Out of the box keyboard navigation across widgets.
|
|
|
|
* Simple layouts (place widget in columns or rows, or possibly build rows made of several columns - grids).
|
|
|
|
* Custom widgets support.
|
|
|
|
* Custom theme support.
|
|
|
|
* Custom input sources support.
|
|
|
|
* Sufficiently compact, straightforward and hackable code.
|
|
|
|
|
|
|
|
**Yui** does have some downsides:
|
|
|
|
|
|
|
|
* The declarative approach makes UIs harder to change drastically from frame to frame.
|
|
|
|
* **Yui** tries to ameliorate this, allowing widgets property tweening, it's still less powerful
|
|
|
|
compared to an all out immediate UI approach.
|
|
|
|
* Features come with a price, **Yui**'s code tries to be small and simple, but there are definitely smaller
|
|
|
|
(and less featureful) frameworks out there.
|
|
|
|
|
2022-08-15 23:41:17 +02:00
|
|
|
## Dependencies
|
|
|
|
|
|
|
|
**Yui** depends on:
|
|
|
|
|
2022-11-06 17:44:57 +01:00
|
|
|
* [gear](https://gitea.it/1414codeforge/gear) for general algorithms.
|
|
|
|
* [moonspeak](https://gitea.it/1414codeforge/moonspeak) for its localization functionality.
|
2022-08-17 13:35:30 +02:00
|
|
|
* ...and any of their dependencies.
|
|
|
|
|
|
|
|
You may either download each of them manually and place them inside a `lib` subdirectory, or use
|
2022-11-06 17:44:57 +01:00
|
|
|
[crush](https://gitea.it/1414codeforge/crush) to do the work for you.
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
1. Clone this repository.
|
|
|
|
|
|
|
|
```sh
|
2022-11-06 17:44:57 +01:00
|
|
|
git clone https://gitea.it/1414codeforge/yui
|
2022-08-17 13:35:30 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
2. Move to repository root directory:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cd yui
|
|
|
|
```
|
|
|
|
|
|
|
|
3. Resolve dependencies using **crush**.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
lua crush.lua
|
|
|
|
```
|
|
|
|
|
|
|
|
You should now see a `lib` subdirectory containing the necessary dependencies.
|
|
|
|
|
|
|
|
## Integrating yui in my project using crush
|
|
|
|
|
2022-11-06 17:44:57 +01:00
|
|
|
1. Download the latest [crush.lua](https://gitea.it/1414codeforge/crush/src/branch/master/crush.lua) file and
|
2022-08-17 13:35:30 +02:00
|
|
|
place it in your project's root directory.
|
|
|
|
|
2022-08-17 15:52:18 +02:00
|
|
|
2. Create a `.lovedeps` text file in your project's root with the following entry:
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
```lua
|
|
|
|
{
|
2022-11-06 17:44:57 +01:00
|
|
|
yui = "https://gitea.it/1414codeforge/yui",
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
-- ...more dependencies, if necessary...
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2022-08-17 15:52:18 +02:00
|
|
|
3. **Yui** can now be downloaded directly by `crush` to the project's `lib` directory:
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
```sh
|
|
|
|
lua crush.lua
|
|
|
|
```
|
|
|
|
|
2022-08-17 15:52:18 +02:00
|
|
|
4. Now `yui` can be `require()`d in your code, like this:
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
```lua
|
|
|
|
local yui = require 'lib.yui'
|
|
|
|
```
|
|
|
|
|
2022-08-17 15:52:18 +02:00
|
|
|
5. Any project depending on yours will now fetch `yui`
|
|
|
|
automatically when using `crush`, following the above procedure.
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
## Documentation
|
|
|
|
|
|
|
|
...Ouch.
|
|
|
|
|
2022-08-24 22:16:17 +02:00
|
|
|
Documentation is underway, however the source code is (IMHO) sufficiently
|
2022-08-17 15:52:18 +02:00
|
|
|
straightforward and disciplined to have a decent overview of the functionality.
|
2022-08-15 23:41:17 +02:00
|
|
|
|
2022-08-24 22:16:17 +02:00
|
|
|
Examples are available at:
|
2022-11-06 17:44:57 +01:00
|
|
|
[https://gitea.it/1414codeforge/yui-examples](https://gitea.it/1414codeforge/yui-examples)
|
2022-08-24 22:16:17 +02:00
|
|
|
|
2022-08-15 23:41:17 +02:00
|
|
|
## Acknowledgement
|
|
|
|
|
|
|
|
Portions of this library's widget rendering code are taken from the
|
|
|
|
Simple User Interface Toolkit (**SUIT**) for LÖVE by Matthias Richter.
|
|
|
|
|
|
|
|
SUIT's source code is available at: [vrld/SUIT](https://github.com/vrld/SUIT).
|
|
|
|
SUIT is licensed under the [MIT license](https://github.com/vrld/suit/blob/master/license.txt).
|
|
|
|
|
2022-08-17 17:28:06 +02:00
|
|
|
Widgets offered by **yui** and basic theme are also mostly taken from SUIT.
|
2022-08-15 23:41:17 +02:00
|
|
|
|
|
|
|
See [ACKNOWLEDGEMENT](README.ACKNOWLEDGEMENT) for full SUIT license
|
|
|
|
information and copyright notice.
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
## Similar projects
|
|
|
|
|
|
|
|
* [SUIT](https://github.com/vrld/SUIT) an excellent, simple and flexible framework for immediate UIs.
|
2022-08-24 17:28:48 +02:00
|
|
|
* [Gspöt](https://notabug.org/pgimeno/Gspot) a stateful GUI lib for LÖVE, has similar aims, but different approach.
|
2022-08-17 13:35:30 +02:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
|
|
|
Zlib, see [LICENSE](LICENSE) for details.
|