added equalarea layout. icon not included
This commit is contained in:
parent
9d46aa37d6
commit
5bcb519e75
|
@ -11,6 +11,7 @@ bling.layout.mstab
|
|||
bling.layout.centered
|
||||
bling.layout.vertical
|
||||
bling.layout.horizontal
|
||||
bling.layout.equalarea
|
||||
```
|
||||
|
||||
### Theme Variables
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
local math = math
|
||||
local screen = screen
|
||||
local tonumber = tonumber
|
||||
local equalarea = {name = "equalarea"}
|
||||
local function divide(p,g,low,high,cls,mwfact,mcount)
|
||||
if low == high then
|
||||
p.geometries[cls[low]] = g
|
||||
else
|
||||
local masters = math.max(0,math.min(mcount,high)-low+1)
|
||||
local numblock = high-low + 1
|
||||
local slaves = numblock - masters
|
||||
local smalldiv
|
||||
if numblock > 5 and (numblock % 5) == 0 then
|
||||
smalldiv = math.floor(numblock/5)
|
||||
else
|
||||
if (numblock % 3) == 0 then
|
||||
smalldiv = math.floor(numblock/3)
|
||||
else
|
||||
smalldiv = math.floor(numblock/2)
|
||||
end
|
||||
end
|
||||
local bigdiv = numblock - smalldiv
|
||||
local smallmasters = math.min(masters,smalldiv)
|
||||
local bigmasters = masters-smallmasters
|
||||
local smallg = {}
|
||||
local bigg = {}
|
||||
smallg.x = g.x
|
||||
smallg.y = g.y
|
||||
if g.width > (g.height*1.3) then
|
||||
smallg.height = g.height
|
||||
bigg.height = g.height
|
||||
bigg.width = math.floor(g.width*(bigmasters*(mwfact-1)+bigdiv)/(slaves+mwfact*masters))
|
||||
smallg.width = g.width-bigg.width
|
||||
bigg.y = g.y
|
||||
bigg.x = g.x + smallg.width
|
||||
else
|
||||
smallg.width = g.width
|
||||
bigg.width = g.width
|
||||
bigg.height = math.floor(g.height*(bigmasters*(mwfact-1)+bigdiv)/(slaves+mwfact*masters))
|
||||
smallg.height = g.height-bigg.height
|
||||
bigg.x = g.x
|
||||
bigg.y = g.y + smallg.height
|
||||
end
|
||||
divide(p,smallg,low,high-bigdiv,cls,mwfact,mcount)
|
||||
divide(p,bigg,low+smalldiv,high,cls,mwfact,mcount)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
local function arrange(p)
|
||||
local t = p.tag or screen[p.screen].selected_tag
|
||||
local wa = p.workarea
|
||||
local cls = p.clients
|
||||
|
||||
if #cls == 0 then return end
|
||||
local mwfact = t.master_width_factor*2
|
||||
local mcount = t.master_count
|
||||
local g = {}
|
||||
g.height = wa.height
|
||||
g.width = wa.width
|
||||
g.x = wa.x
|
||||
g.y = wa.y
|
||||
divide(p,g,1,#cls,cls,mwfact,mcount)
|
||||
end
|
||||
|
||||
function equalarea.arrange(p)
|
||||
return arrange(p)
|
||||
end
|
||||
|
||||
return {layout = equalarea}
|
|
@ -12,11 +12,15 @@ beautiful.layout_horizontal = horizontal.get_icon()
|
|||
local centered = require(... .. ".centered")
|
||||
beautiful.layout_centered = centered.get_icon()
|
||||
|
||||
local equalarea = require(... .. ".equalarea")
|
||||
|
||||
beautiful.layout_centered = centered.get_icon()
|
||||
local layout = {
|
||||
mstab = mstab.layout,
|
||||
centered = centered.layout,
|
||||
vertical = vertical.layout,
|
||||
horizontal = horizontal.layout
|
||||
horizontal = horizontal.layout,
|
||||
equalarea = equalarea.layout
|
||||
}
|
||||
|
||||
return layout
|
||||
|
|
Loading…
Reference in New Issue