2009-10-24 14:50:37 +02:00
|
|
|
-------------------------------------------------
|
|
|
|
-- @author Gregor Best <farhaven@googlemail.com>, Lukas Hrazky <lukkash@email.cz>
|
|
|
|
-- @copyright 2009 Gregor Best, Lukas Hrazky
|
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
-------------------------------------------------
|
|
|
|
|
2009-08-24 18:23:32 +02:00
|
|
|
local setmetatable = setmetatable
|
|
|
|
local require = require
|
2009-10-24 14:50:37 +02:00
|
|
|
local type = type
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- Widget layouts
|
2009-07-02 02:10:32 +02:00
|
|
|
module("awful.widget.layout")
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
-- 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>
|
2009-08-24 18:23:32 +02:00
|
|
|
-- awful.widget.layout.margins[mywidget] = { left = 10 }
|
2009-10-24 14:50:37 +02:00
|
|
|
-- </code></p>
|
2009-08-24 18:23:32 +02:00
|
|
|
-- @name margins
|
|
|
|
-- @class table
|
2009-10-24 14:50:37 +02:00
|
|
|
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
|
2009-08-24 18:23:32 +02:00
|
|
|
|
|
|
|
require("awful.widget.layout.vertical")
|
2009-10-24 14:50:37 +02:00
|
|
|
|
|
|
|
--- 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")
|
2009-08-24 18:23:32 +02:00
|
|
|
|
2009-07-02 02:10:32 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|