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

91 lines
3.7 KiB
Lua

-------------------------------------------------
-- @author Gregor Best <farhaven@googlemail.com>, Lukas Hrazky <lukkash@email.cz>
-- @copyright 2009 Gregor Best, Lukas Hrazky
-- @release @AWESOME_VERSION@
-------------------------------------------------
local setmetatable = setmetatable
local require = require
local type = type
--- Widget layouts
module("awful.widget.layout")
-- the table that really contains the margins.
local margin_table = setmetatable({}, {__mode = 'k'})
-- empty margin table - used every time there is no margin for something
local empty_margin = setmetatable({}, {__index = function() return 0 end})
--- Margins of widgets and layout tables.
-- In this table you can set the margin you want the layout to use when positionning
-- your widgets or tables with widgets. The key is the widget or the table to set
-- margin for, value is either a number (setting the same margin to all four sides) or
-- a table with one or more of the following keys:
-- <p><code>left, right, top, bottom</code></p>
-- For example, if you want to put a 10 pixel free space on the left of a widget, add this:
-- <p><code>
-- awful.widget.layout.margins[mywidget] = { left = 10 }
-- </code></p>
-- @name margins
-- @class table
margins = setmetatable({}, {
__index = function(t, i)
return margin_table[i] or empty_margin
end,
__newindex = function(t, i, v)
if type(v) == "number" then
margin_table[i] = setmetatable({}, {__index = function() return v end})
elseif type(v) == "table" then
margin_table[i] = setmetatable(v, {__index = function() return 0 end})
end
end
})
-- A table used to index geometry properties. Returns the name with which it is indexed.
-- It is used in horizontal layouts, where it returns "x" when indexed by "x", etc.
regular_index = setmetatable({}, {__index = function(t, i) return i end})
-- A table used to index geometry properties. Returns the name opposite to the one
-- with which it is indexed. It is used in vertical layouts, where it returns "y"
-- when indexed by "x", etc.
switched_index = {
x = "y",
y = "x",
width = "height",
height = "width",
top = "left",
bottom = "right",
left = "top",
right = "bottom"
}
-- set the default layout function
local horizontal = require("awful.widget.layout.horizontal")
default = horizontal.leftright
require("awful.widget.layout.vertical")
--- Places the widgets in a grid.
-- It recognizes the following attributes in the encompassing table:
-- <p><code>cell_width</code>: Either a table containing column widths or
-- a number (width for all columns). In case its a number, <code>col_count</code> is mandatory.<br/>
-- <code>cell_height</code>: Either a table containing row heights or
-- a number (height for all rows). In case its a number, <code>row_count</code> is mandatory.<br/>
-- <code>col_count</code>: In case <code>cell_width</code> is a number, sets the number of columns.<br/>
-- <code>row_count</code>: In case <code>cell_height</code> is a number, sets the number of rows.<br/>
-- <code>col_gap</code>: Gap between columns in pixels. (optional)<br/>
-- <code>row_gap</code>: Gap between rows in pixels. (optional)<br/>
-- <code>resize</code>: Boolean indicating whether widgets should be resized to the size of the cell.
-- (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.
-- @name grid
-- @class function
grid = require("awful.widget.layout.grid")
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80