summaryrefslogtreecommitdiff
path: root/example/layouts/grid.lua
blob: 10a0cab12b9b12d862091733f4012de341d6d158 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
hl.layout.register("grid", {
    recalculate = function(ctx)
        local n = #ctx.targets
        if n == 0 then
            return
        end

        local cols = math.ceil(math.sqrt(n))

        for i, target in ipairs(ctx.targets) do
            target:place(ctx:grid_cell(i, cols))
        end
    end,
})