2009-07-02 02:10:32 +02:00
|
|
|
-------------------------------------------------
|
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
|
2009-07-02 02:10:32 +02:00
|
|
|
-- @release @AWESOME_VERSION@
|
|
|
|
-------------------------------------------------
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
local require = require
|
2009-07-02 02:10:32 +02:00
|
|
|
local ipairs = ipairs
|
2009-10-24 14:50:37 +02:00
|
|
|
local pairs = pairs
|
2009-07-02 02:10:32 +02:00
|
|
|
local util = require("awful.util")
|
2009-10-24 14:50:37 +02:00
|
|
|
local layout = require("awful.widget.layout")
|
|
|
|
local linear = require("awful.widget.layout.linear_common")
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- Vertical widget layouts
|
2009-07-02 02:10:32 +02:00
|
|
|
module("awful.widget.layout.vertical")
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
-- index used for vertical layouts
|
|
|
|
local idx = layout.switched_index
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- 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
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- 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
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
2009-10-24 14:50:37 +02:00
|
|
|
return g
|
|
|
|
end
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- 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
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
2009-10-28 11:49:08 +01:00
|
|
|
g.total.y = 0
|
|
|
|
g.total.height = 0
|
2009-10-24 14:50:37 +02:00
|
|
|
return g
|
|
|
|
end
|
2009-07-02 02:10:32 +02:00
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- 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)
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
2009-10-24 14:50:37 +02:00
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|