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
|
|
|
--- Horizontal widget layouts
|
2009-07-02 02:10:32 +02:00
|
|
|
module("awful.widget.layout.horizontal")
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
-- index used for horizontal layouts
|
|
|
|
local idx = layout.regular_index
|
|
|
|
|
|
|
|
--- Places the widgets in a row, aligned to the left.
|
|
|
|
-- This is the default layout.
|
|
|
|
-- It recognizes the following attributes in the encompassing table:
|
|
|
|
-- <p><code>width</code>: Maximum width of the layout. (optional)<br/>
|
|
|
|
-- <code>height</code>: Height of the layout. If set, all widgets are resized to this height. (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 leftright(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 row, aligned to the right.
|
|
|
|
-- It recognizes the following attributes in the encompassing table:
|
|
|
|
-- <p><code>width</code>: Maximum width of the layout. (optional)<br/>
|
|
|
|
-- <code>height</code>: Height of the layout. If set, all widgets are resized to this height. (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 rightleft(bounds, widgets, screen)
|
|
|
|
local g = linear.fixed(idx, util.table.clone(bounds), widgets, screen)
|
|
|
|
for _, w in pairs(g) do
|
|
|
|
w.x = w.x + bounds.width - g.total.width
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
2009-10-24 14:50:37 +02:00
|
|
|
return g
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- Places the widgets in a row, aligned to the center.
|
|
|
|
-- It recognizes the following attributes in the encompassing table:
|
|
|
|
-- <p><code>width</code>: Maximum width of the layout. (optional)<br/>
|
|
|
|
-- <code>height</code>: Height of the layout. If set, all widgets are resized to this height. (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.<br/>
|
|
|
|
-- @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.x = w.x + (bounds.width - g.total.width) / 2
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
2009-10-28 11:49:08 +01:00
|
|
|
g.total.x = 0
|
|
|
|
g.total.width = 0
|
2009-10-24 14:50:37 +02:00
|
|
|
return g
|
2009-07-02 02:10:32 +02:00
|
|
|
end
|
|
|
|
|
2009-10-24 14:50:37 +02:00
|
|
|
--- Places the widgets in a row, making them equally wide.
|
|
|
|
-- It recognizes the following attributes in the encompassing table:
|
|
|
|
-- <p><code>width</code>: Maximum width of the layout. (optional)<br/>
|
|
|
|
-- <code>height</code>: Height of the layout. If set, all widgets are resized to this height. (optional)<br/>
|
|
|
|
-- <code>max_size</code>: Maximum width of one item. If not set, widgets' widths 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
|
|
|
|
|
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80
|