2009-07-12 20:27:41 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 12:44:21 +02:00
|
|
|
--- Dwindle and spiral layouts
|
|
|
|
--
|
2009-07-12 20:27:41 +02:00
|
|
|
-- @author Uli Schlachter <psychon@znc.in>
|
|
|
|
-- @copyright 2009 Uli Schlachter
|
|
|
|
-- @copyright 2008 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
2014-05-20 12:44:21 +02:00
|
|
|
--
|
|
|
|
-- @module awful.layout.suit.spiral
|
2009-07-12 20:27:41 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local ipairs = ipairs
|
2014-01-18 16:12:30 +01:00
|
|
|
local math = math
|
2009-07-12 20:27:41 +02:00
|
|
|
|
2016-08-14 07:34:43 +02:00
|
|
|
--- The spiral layout layoutbox icon.
|
|
|
|
-- @beautiful beautiful.layout_spiral
|
|
|
|
-- @param surface
|
|
|
|
-- @see gears.surface
|
|
|
|
|
|
|
|
--- The dwindle layout layoutbox icon.
|
|
|
|
-- @beautiful beautiful.layout_dwindle
|
|
|
|
-- @param surface
|
|
|
|
-- @see gears.surface
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
local spiral = {}
|
2009-07-12 20:27:41 +02:00
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
local function do_spiral(p, _spiral)
|
2009-07-12 20:27:41 +02:00
|
|
|
local wa = p.workarea
|
|
|
|
local cls = p.clients
|
|
|
|
local n = #cls
|
2014-01-18 16:12:30 +01:00
|
|
|
local old_width, old_height = wa.width, 2 * wa.height
|
2009-07-12 20:27:41 +02:00
|
|
|
|
|
|
|
for k, c in ipairs(cls) do
|
2014-01-18 16:12:30 +01:00
|
|
|
if k % 2 == 0 then
|
|
|
|
wa.width, old_width = math.ceil(old_width / 2), wa.width
|
|
|
|
if k ~= n then
|
|
|
|
wa.height, old_height = math.floor(wa.height / 2), wa.height
|
|
|
|
end
|
|
|
|
else
|
|
|
|
wa.height, old_height = math.ceil(old_height / 2), wa.height
|
|
|
|
if k ~= n then
|
|
|
|
wa.width, old_width = math.floor(wa.width / 2), wa.width
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
2009-08-19 20:37:22 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
if k % 4 == 0 and _spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.x = wa.x - wa.width
|
2014-01-18 16:12:30 +01:00
|
|
|
elseif k % 2 == 0 then
|
|
|
|
wa.x = wa.x + old_width
|
|
|
|
elseif k % 4 == 3 and k < n and _spiral then
|
|
|
|
wa.x = wa.x + math.ceil(old_width / 2)
|
2009-08-19 20:37:22 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
if k % 4 == 1 and k ~= 1 and _spiral then
|
2009-08-19 20:37:25 +02:00
|
|
|
wa.y = wa.y - wa.height
|
2014-01-18 16:12:30 +01:00
|
|
|
elseif k % 2 == 1 and k ~= 1 then
|
|
|
|
wa.y = wa.y + old_height
|
|
|
|
elseif k % 4 == 0 and k < n and _spiral then
|
|
|
|
wa.y = wa.y + math.ceil(old_height / 2)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
2009-08-19 20:37:23 +02:00
|
|
|
|
2010-05-28 19:43:46 +02:00
|
|
|
local g = {
|
|
|
|
x = wa.x,
|
|
|
|
y = wa.y,
|
2015-02-15 17:25:11 +01:00
|
|
|
width = wa.width,
|
|
|
|
height = wa.height
|
2010-05-28 19:43:46 +02:00
|
|
|
}
|
2015-02-15 17:25:11 +01:00
|
|
|
p.geometries[c] = g
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Dwindle layout
|
2012-06-14 02:45:17 +02:00
|
|
|
spiral.dwindle = {}
|
|
|
|
spiral.dwindle.name = "dwindle"
|
|
|
|
function spiral.dwindle.arrange(p)
|
|
|
|
return do_spiral(p, false)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Spiral layout
|
2012-06-14 02:45:17 +02:00
|
|
|
spiral.name = "spiral"
|
|
|
|
function spiral.arrange(p)
|
|
|
|
return do_spiral(p, true)
|
2009-07-12 20:27:41 +02:00
|
|
|
end
|
|
|
|
|
2012-06-14 02:45:17 +02:00
|
|
|
return spiral
|
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|