summaryrefslogtreecommitdiff
path: root/example/layouts/grid.lua
diff options
context:
space:
mode:
Diffstat (limited to 'example/layouts/grid.lua')
-rw-r--r--example/layouts/grid.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/example/layouts/grid.lua b/example/layouts/grid.lua
new file mode 100644
index 00000000..10a0cab1
--- /dev/null
+++ b/example/layouts/grid.lua
@@ -0,0 +1,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,
+})