Badar (Full moon in Arabic) is a simple and fun way to write UI, prioritizing both developer experience and readability.
Copy badar.lua to your project for basic functionality and signal.lua for signals handling.
🌙 For a functional example see: example.lua
function love.load()
local menu = component { column = true, gap = 10 }
+ label 'Hello, World!'
+ label { text = 'love2d', id = '#2' }
+ button {
text = 'Click me!',
onClick = function(self)
-- get child by id
(self.parent % '#2').text = 'awesome'
end
}
end
-
Creating a
new
component.column (boolean)
&row (boolean)
andgap (number)
are used for basic layout calculations. For inspiration see components.local newComponent = component { x = 10, y = 10, myCustomProp = true, onDrag = myCustomLogic(), -- badar connect draw signal for every "+" or "-" operation. draw = function(self) love.graphics.print('Hello!', self.x, self.y) end, }
-
component = component + child
Adds the child to its parent’s children table and register its signals.
-
component = component - child
Removes the child from its parent’s children table, and unregister its signals.
-
component % id (string)
:Returns child by id in its parent children list. Useful for modifying children within the same parent.
(parent % id).value = newValue
-
:isMouseInside()
Note
Badar uses signal.lua
by default. Feel free to use your own methods (eg. update __add
and __sub
in badar.lua).
This library is free software; you can redistribute it and/or modify it under the terms of the MIT license. See LICENSE for details.