awesome/lib/awful/widget/layout/vertical.lua.in

94 lines
4.3 KiB
Lua
Raw Normal View History

-------------------------------------------------
-- @author Gregor Best <farhaven@googlemail.com>, Lukas Hrazky <lukkash@email.cz>
-- @copyright 2009 Gregor Best, Lukas Hrazky
-- @release @AWESOME_VERSION@
-------------------------------------------------
local require = require
local ipairs = ipairs
local pairs = pairs
local util = require("awful.util")
local layout = require("awful.widget.layout")
local linear = require("awful.widget.layout.linear_common")
--- Vertical widget layouts
module("awful.widget.layout.vertical")
-- index used for vertical layouts
local idx = layout.switched_index
--- Places the widgets in a column, aligned to the top.
-- It recognizes the following attributes in the encompassing table:
-- <p><code>width</code>: Maximum width of the layout. If set, all widgets are resized to this width.
-- (optional)<br/>
-- <code>height</code>: Height of the layout. (optional)</p>
-- @param bounds The geometry of the bounds for the layout.
-- @param widgets The table of the widgets to layout. When layout function is placed in
-- a table, it is the table that is passed as this argument.
-- @param screen The screen of the wibox.
-- @return A table of geometries of all the widgets.
function topdown(bounds, widgets, screen)
return linear.fixed(idx, bounds, widgets, screen)
end
--- Places the widgets in a column, aligned to the bottom.
-- It recognizes the following attributes in the encompassing table:
-- <p><code>width</code>: Maximum width of the layout. If set, all widgets are resized to this width.
-- (optional)<br/>
-- <code>height</code>: Height of the layout. (optional)</p>
-- @param bounds The geometry of the bounds for the layout.
-- @param widgets The table of the widgets to layout. When layout function is placed in
-- a table, it is the table that is passed as this argument.
-- @param screen The screen of the wibox.
-- @return A table of geometries of all the widgets.
function bottomup(bounds, widgets, screen)
local g = linear.fixed(idx, util.table.clone(bounds), widgets, screen)
for _, w in pairs(g) do
w.y = w.y + bounds.height - g.total.height
end
return g
end
--- Places the widgets in a column, aligned to the center.
-- It recognizes the following attributes in the encompassing table:
-- <p><code>width</code>: Maximum width of the layout. If set, all widgets are resized to this width.
-- (optional)<br/>
-- <code>height</code>: Height of the layout. (optional)</p>
-- The widgets will be placed in the center of the free space that is left after all widgets
-- preceding the table with this layout were placed. The area covered by widgets with this layout
-- is not subtracted from the total free area (so the widgets "cover no space"). Therefore, if you
-- put anything after a table with center layout, the widgets may overlap.
-- @param bounds The geometry of the bounds for the layout.
-- @param widgets The table of the widgets to layout. When layout function is placed in
-- a table, it is the table that is passed as this argument.
-- @param screen The screen of the wibox.
-- @return A table of geometries of all the widgets.
function center(bounds, widgets, screen)
local g = linear.fixed(idx, util.table.clone(bounds), widgets, screen)
for _, w in ipairs(g) do
w.y = w.y + (bounds.height - g.total.height) / 2
end
g.total.y = 0
g.total.height = 0
return g
end
--- Places the widgets in a column, making them equally high.
-- It recognizes the following attributes in the encompassing table:
-- <p><code>width</code>: Maximum width of the layout. If set, all widgets are resized to this width.
-- (optional)<br/>
-- <code>height</code>: Height of the layout. (optional)<br/>
-- <code>max_size</code>: Maximum height of one item. If not set, widgets' heights are set so that they always
-- cover all available space. (optional)<br/>
-- <code>gap</code>: Gap between the widgets. (optional)</p>
-- @param bounds The geometry of the bounds for the layout.
-- @param widgets The table of the widgets to layout. When layout function is placed in
-- a table, it is the table that is passed as this argument.
-- @param screen The screen of the wibox.
-- @return A table of geometries of all the widgets.
function flex(bounds, widgets, screen)
return linear.flex(idx, bounds, widgets, screen)
end
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80