Compare commits

...

5 Commits

@ -1,4 +1,4 @@
{
gear = "https://gitea.it/1414codeforge/gear",
moonspeak = "https://gitea.it/1414codeforge/moonspeak"
gear = "https://codeberg.org/1414codeforge/gear",
moonspeak = "https://codeberg.org/1414codeforge/moonspeak"
}

@ -45,7 +45,7 @@ function love.draw()
end
```
![Hello, World!](https://gitea.it/1414codeforge/yui-examples/raw/branch/master/pics/hello_world.png)
![Hello, World!](https://codeberg.org/1414codeforge/yui-examples/raw/branch/master/pics/hello_world.png)
## Features
@ -75,17 +75,17 @@ end
**Yui** depends on:
* [gear](https://gitea.it/1414codeforge/gear) for general algorithms.
* [moonspeak](https://gitea.it/1414codeforge/moonspeak) for its localization functionality.
* [gear](https://codeberg.org/1414codeforge/gear) for general algorithms.
* [moonspeak](https://codeberg.org/1414codeforge/moonspeak) for its localization functionality.
* ...and any of their dependencies.
You may either download each of them manually and place them inside a `lib` subdirectory, or use
[crush](https://gitea.it/1414codeforge/crush) to do the work for you.
[crush](https://codeberg.org/1414codeforge/crush) to do the work for you.
1. Clone this repository.
```sh
git clone https://gitea.it/1414codeforge/yui
git clone https://codeberg.org/1414codeforge/yui
```
2. Move to repository root directory:
@ -104,14 +104,14 @@ You should now see a `lib` subdirectory containing the necessary dependencies.
## Integrating yui in my project using crush
1. Download the latest [crush.lua](https://gitea.it/1414codeforge/crush/src/branch/master/crush.lua) file and
1. Download the latest [crush.lua](https://codeberg.org/1414codeforge/crush/src/branch/master/crush.lua) file and
place it in your project's root directory.
2. Create a `.lovedeps` text file in your project's root with the following entry:
```lua
{
yui = "https://gitea.it/1414codeforge/yui",
yui = "https://codeberg.org/1414codeforge/yui",
-- ...more dependencies, if necessary...
}
@ -149,7 +149,7 @@ The source code is also (IMHO) sufficiently
straightforward and disciplined to have a decent overview of the functionality.
Examples are available at:
[https://gitea.it/1414codeforge/yui-examples](https://gitea.it/1414codeforge/yui-examples)
<https://codeberg.org/1414codeforge/yui-examples>
## Acknowledgement

@ -14,7 +14,6 @@
local BASE = (...):gsub('layout$', '')
local Widget = require(BASE..'widget')
local core = require(BASE..'core')
local gear = require 'lib.gear'
@ -126,12 +125,21 @@ function Layout:layoutWidgets()
self.y = ry
self.w = math.max(rw, 0)
self.h = math.max(rh, 0)
-- A Layout ignores focus if empty or containing only nofocus widgets
self.nofocus = true
for _,w in ipairs(self) do
if not w.nofocus then
self.nofocus = false
break
end
end
end
-- Find layout's child containing the provided widget.
local function childof(layout, widget)
local parent = widget.parent
while parent ~= layout do
while not rawequal(parent, layout) do
widget = parent
parent = widget.parent
end
@ -173,16 +181,6 @@ function Layout:new(args)
self.padding = self.padding or 0
self.stack = {}
-- A Layout ignores focus if empty or containing only nofocus widgets
self.nofocus = true
for _,w in ipairs(self) do
if not w.nofocus then
self.nofocus = false
break
end
end
return self
end
@ -201,7 +199,7 @@ function Layout:after(widget)
widget = childof(self, widget)
for i = 1,#self do
if self[i] == widget then
if rawequal(self[i], widget) then
-- Search to the right/down
return scanforward(self, i+1)
end
@ -213,7 +211,7 @@ function Layout:before(widget)
widget = childof(self, widget)
for i = 1,#self do
if self[i] == widget then
if rawequal(self[i], widget) then
-- Search to the left/up
return scanbackwards(self, i-1)
end

@ -23,6 +23,6 @@ local Rows = setmetatable({
Rows.__index = Rows
function Rows:new(args) return setmetatable(Layout:new(args), Rows) end
function Rows:new(args) return setmetatable(Layout:new(args), self) end
return Rows

@ -82,7 +82,7 @@ function Ui:new(args)
self.x = self.x or 0
self.y = self.y or 0
self.pointerActive = true
self.timer = Timer.new()
self.timer = Timer:new()
local root = self[1]
if not isinstance(root, Widget) then

Loading…
Cancel
Save