diff --git a/lib/awful/widget/init.lua.in b/lib/awful/widget/init.lua.in index f68d0861..bcd53117 100644 --- a/lib/awful/widget/init.lua.in +++ b/lib/awful/widget/init.lua.in @@ -13,7 +13,6 @@ require("awful.widget.progressbar") require("awful.widget.graph") require("awful.widget.layoutbox") require("awful.widget.textclock") -require("awful.widget.layout") --- Widget module for awful module("awful.widget") diff --git a/lib/awful/widget/layout/grid.lua.in b/lib/awful/widget/layout/grid.lua.in deleted file mode 100644 index 632ee6a4..00000000 --- a/lib/awful/widget/layout/grid.lua.in +++ /dev/null @@ -1,200 +0,0 @@ -------------------------------------------------- --- @author Lukas Hrazky --- @copyright 2009 Gregor Best, Lukas Hrazky --- @release @AWESOME_VERSION@ -------------------------------------------------- - -local setmetatable = setmetatable -local require = require -local ipairs = ipairs -local pairs = pairs -local type = type -local insert = table.insert -local min = math.min -local max = math.max -local util = require("awful.util") -local clone = util.table.clone - -local margins = awful.widget.layout.margins -local layout = awful.widget.layout - -local M = {} - - --- Creates an iterator over the cell sizes from the direction string. --- It takes the bounds for the grid, the row/column sizes and a direction and returns an iterator --- over the slices of the bounds whose sizes are determined by 'widths' or 'heights'. The 'direction' --- determines which of these will be used and whether it will be in reverse or not. --- @param direction The direction in which to iterate: 'leftright', 'rightleft', 'topdown' or 'bottomup' --- @param bounds The bounds for the iterator, will be sliced according to direction --- @param widths The widths of the columns in the grid --- @param heights The heights of the rows in the grid --- @return An iterator over the slices of the bounds -local function direction_iter(direction, bounds, widths, heights) - local iter - local i = 0 - local idx, sizes - - -- preset the closure upvalues according to the direction - if direction == "leftright" or direction == "rightleft" then - idx = layout.regular_index - sizes = widths - elseif direction == "topdown" or direction == "bottomup" then - idx = layout.switched_index - sizes = heights - end - - if direction == "leftright" or direction == "topdown" then - -- the regular direction iterator - iter = function(bounds) - i = i + 1 - if not sizes[i] then return end - - local b = clone(bounds) - local width = min(sizes[i], b[idx.width]) - b[idx.width] = width - bounds[idx.x] = bounds[idx.x] + width + sizes.gap - bounds[idx.width] = bounds[idx.width] - width - return b - end - elseif direction == "rightleft" or direction == "bottomup" then - -- the reverse direction iterator - iter = function(bounds) - i = i + 1 - if not sizes[i] then return end - - local b = clone(bounds) - local width = min(sizes[i], b[idx.width]) - b[idx.x] = b[idx.x] + b[idx.width] - width + sizes.gap - b[idx.width] = width - bounds[idx.width] = bounds[idx.width] - width - return b - end - end - - return iter, bounds -end - --- Places the widgets in a grid. --- @see awful.widget.layout for a luadoc -function M.grid(bounds, widgets, screen) - local widths = {} - local heights = {} - - -- we either have a table with the widths of the cells, or its a number and there is a col_count - if type(widgets.cell_width) == "table" then - widths = widgets.cell_width - else - for i = 1, widgets.col_count do widths[i] = widgets.cell_width end - end - - -- we either have a table with the heights of the cells, or its a number and there is a row_count - if type(widgets.cell_height) == "table" then - heights = widgets.cell_height - else - for i = 1, widgets.row_count do heights[i] = widgets.cell_height end - end - - widths.gap = widgets.col_gap or 0 - heights.gap = widgets.row_gap or 0 - - -- calculate total space required for the grid - local w = - widths.gap - local h = - heights.gap - for _, v in ipairs(widths) do w = w + v + widths.gap end - for _, v in ipairs(heights) do h = h + v + heights.gap end - bounds.width = min(bounds.width, w) - bounds.height = min(bounds.height, h) - - -- the table for the geometries which will be returned - -- we clone the bounds to the 'total' attribute. bounds are used to keep the free space - -- throughout this function. at the end, 'total' is modified to represent the space taken - -- by all widgets - local geometries = {total = clone(bounds)} - - -- i counts the widgets placed in the grid - local i = 1 - - -- the iterators return the bounds for the cells of the table. first one in secondary direction - -- returns rows or columns, second one returns cell bounds in that row/column - for sb in direction_iter(widgets.secondary_dir or "topdown", bounds, widths, heights) do - for b in direction_iter(widgets.primary_dir or "leftright", sb, widths, heights) do - -- get the next widget, if there is none, we are done, some cells won't be filled - local w = widgets[i] - if not w then break end - - if type(w) == "table" or type(w) == "widget" then - local m = margins[w] - -- shrink the cell bounds by the margins - b.width = b.width - m.left - m.right - b.height = b.height - m.top - m.bottom - b.x = b.x + m.left - b.y = b.y + m.top - - if type(w) == "table" then - -- backup the width and height of the table so we can restore it - local t_width = w.width - local t_height = w.height - - -- if the 'widgets' table has height set and the table itself doesn't, we set it - if widgets.resize then - w.width = b.width - w.height = b.height - end - - -- call the layout function recursively on this table - local layout = w.layout or layout.default - local g = layout(b, w, screen) - - -- restore the table's original width and height - w.width = t_width - w.height = t_height - - -- insert all geometries from the table to our geometries - for _, w in ipairs(g) do - insert(geometries, w) - end - - elseif type(widgets[i]) == "widget" then - local g = {x = 0, y = 0, width = 0, height = 0} - - if widgets[i].visible then - -- get the geometry of the widget - g = widgets[i]:extents(screen) - - -- set the coords - g.x = b.x - g.y = b.y - - -- if we are resizing or it doesn't fit inside the bounds, set width/height - if widgets.resize or g.width > b.width then - g.width = b.width - end - if widgets.resize or g.height > b.height then - g.height = b.height - end - end - - insert(geometries, g) - end - - i = i + 1 - end - end - end - - -- set zero geometries for any leftover widgets - -- Hack: if it has been registered as a widget in a wibox, - -- it's w.len since __len meta does not work on table until Lua 5.2. - -- Otherwise it's standard #w. - local len = (widgets.len or #widgets) - for j = i, len do - insert(geometries, {x = 0, y = 0, width = 0, height = 0}) - end - - return geometries -end - -return M - --- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/lib/awful/widget/layout/horizontal.lua.in b/lib/awful/widget/layout/horizontal.lua.in deleted file mode 100644 index ab7a9ac0..00000000 --- a/lib/awful/widget/layout/horizontal.lua.in +++ /dev/null @@ -1,90 +0,0 @@ -------------------------------------------------- --- @author Gregor Best , Lukas Hrazky --- @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") - ---- Horizontal widget layouts -module("awful.widget.layout.horizontal") - --- 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: ---

width: Maximum width of the layout. (optional)
--- height: Height of the layout. If set, all widgets are resized to this height. (optional)

--- @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 - ---- Places the widgets in a row, aligned to the right. --- It recognizes the following attributes in the encompassing table: ---

width: Maximum width of the layout. (optional)
--- height: Height of the layout. If set, all widgets are resized to this height. (optional)

--- @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 - end - return g -end - ---- Places the widgets in a row, aligned to the center. --- It recognizes the following attributes in the encompassing table: ---

width: Maximum width of the layout. (optional)
--- height: Height of the layout. If set, all widgets are resized to this height. (optional)

--- 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.x = w.x + (bounds.width - g.total.width) / 2 - end - g.total.x = 0 - g.total.width = 0 - return g -end - ---- Places the widgets in a row, making them equally wide. --- It recognizes the following attributes in the encompassing table: ---

width: Maximum width of the layout. (optional)
--- height: Height of the layout. If set, all widgets are resized to this height. (optional)
--- max_size: Maximum width of one item. If not set, widgets' widths are set so that they always --- cover all available space. (optional)
--- gap: Gap between the widgets. (optional)

--- @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 diff --git a/lib/awful/widget/layout/init.lua.in b/lib/awful/widget/layout/init.lua.in deleted file mode 100644 index fea38724..00000000 --- a/lib/awful/widget/layout/init.lua.in +++ /dev/null @@ -1,90 +0,0 @@ -------------------------------------------------- --- @author Gregor Best , Lukas Hrazky --- @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: ---

left, right, top, bottom

--- For example, if you want to put a 10 pixel free space on the left of a widget, add this: ---

--- awful.widget.layout.margins[mywidget] = { left = 10 } ---

--- @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: ---

cell_width: Either a table containing column widths or --- a number (width for all columns). In case its a number, col_count is mandatory.
--- cell_height: Either a table containing row heights or --- a number (height for all rows). In case its a number, row_count is mandatory.
--- col_count: In case cell_width is a number, sets the number of columns.
--- row_count: In case cell_height is a number, sets the number of rows.
--- col_gap: Gap between columns in pixels. (optional)
--- row_gap: Gap between rows in pixels. (optional)
--- resize: Boolean indicating whether widgets should be resized to the size of the cell. --- (optional)

--- @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").grid - --- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/lib/awful/widget/layout/linear_common.lua.in b/lib/awful/widget/layout/linear_common.lua.in deleted file mode 100644 index 278449df..00000000 --- a/lib/awful/widget/layout/linear_common.lua.in +++ /dev/null @@ -1,286 +0,0 @@ -------------------------------------------------- --- @author Gregor Best , Lukas Hrazky --- @copyright 2009 Gregor Best, Lukas Hrazky --- @release @AWESOME_VERSION@ -------------------------------------------------- - -local setmetatable = setmetatable -local require = require -local ipairs = ipairs -local type = type -local insert = table.insert -local min = math.min -local max = math.max -local floor = math.floor -local util = require("awful.util") -local clone = util.table.clone - -local margins = awful.widget.layout.margins -local layout = awful.widget.layout - -local linear_common = {} - --- Calculates geometries for fixed layouts. --- This generic function is used for all layouts exept flex. --- It is written for horizontal layouts, but by using a special index 'idx' to access --- all the geometry attributes, it is used for vertical layouts too. In that case, 'idx' --- returns 'y' for 'x', 'width' for 'height', etc. --- @param idx An index table that defines whether horzintal or vertical arrangement will be --- calculated. See regular_index and switched_index tables. --- @param bounds The geometry of the bounds for the layout. --- @param widgets The table of the widgets to layout, can be nested. --- @param screen The screen of the wibox. --- @return A table of geometries of all the widgets. -function linear_common.fixed(idx, bounds, widgets, screen) - -- set bounds width and height to what is preset in the widgets table (if there is something) - -- we don't need to use idx here since we're treating both directions the same way - if widgets.width and widgets.width < bounds.width then - bounds.width = widgets.width - end - if widgets.height and widgets.height < bounds.height then - bounds.height = widgets.height - end - - -- the table for the geometries which will be returned - -- we clone the bounds to the 'total' attribute. bounds are used to keep the free space - -- throughout this function. at the end, 'total' is modified to represent the space taken - -- by all widgets - local geometries = {total = clone(bounds)} - -- the height of the heighest widget, will be the height of the total space taken - local maxh = 0 - - for _, v in ipairs(widgets) do - if type(v) == "table" or type(v) == "widget" then - local m = margins[v] - -- we can shrink the bounds by the horizontal margins right now, they affect our free - -- space directly (vertical don't, they are different for every item in 'widgets') - bounds[idx.width] = bounds[idx.width] - m[idx.left] - m[idx.right] - bounds[idx.x] = bounds[idx.x] + m[idx.left] - - if type(v) == "table" then - -- create new bounds for the table and shrink it by the vertical margins - local t_bounds = clone(bounds) - t_bounds[idx.height] = t_bounds[idx.height] - m[idx.top] - m[idx.bottom] - t_bounds[idx.y] = t_bounds[idx.y] + m[idx.top] - - -- backup the width and height of the table so we can restore it - local t_width = v.width - local t_height = v.height - - -- if the 'widgets' table has height set and the table itself doesn't, we set it - v[idx.height] = v[idx.height] or widgets[idx.height] - - -- call the layout function recursively on this table - local layout = v.layout or layout.default - local g = layout(t_bounds, v, screen) - - -- restore the table's original width and height - v.width = t_width - v.height = t_height - - -- subtract the space taken by the table from our bounds - bounds[idx.width] = bounds[idx.width] - g.total[idx.width] - -- we only move the 'x' coord if the taken space is on the left side of our bounds - if g.total[idx.x] == bounds[idx.x] then - bounds[idx.x] = bounds[idx.x] + g.total[idx.width] + m[idx.right] - end - - -- update the maximum height with this new table - maxh = max(maxh, g.total[idx.height] + m[idx.top] + m[idx.bottom]) - - -- insert all geometries from the table to our geometries - for _, w in ipairs(g) do - insert(geometries, w) - end - - elseif type(v) == "widget" then - local g = {x = 0, y = 0, width = 0, height = 0} - - if v.visible then - -- get the geometry of the widget - g = v:extents(screen) - - -- resize to fit the height available if requested - if v.resize and g.width > 0 and g.height > 0 then - local ratio = g[idx.width] / g[idx.height] - g[idx.width] = floor(bounds[idx.height] * ratio) - g[idx.height] = bounds[idx.height] - end - - -- set the coords, apply the top margin - g[idx.y] = bounds[idx.y] + m[idx.top] - g[idx.x] = bounds[idx.x] - - -- limit the width of the widget to what's available - g[idx.width] = min(g[idx.width], bounds[idx.width]) - - -- if the 'widgets' table has height set, we set it to the widget - g[idx.height] = widgets[idx.height] and - (widgets[idx.height] - m[idx.top] - m[idx.bottom]) or g[idx.height] - - -- limit the height of the widget to what's available - g[idx.height] = min(g[idx.height], bounds[idx.height] - m[idx.top] - m[idx.bottom]) - - -- subtract the space taken by the widget from our bounds - bounds[idx.width] = bounds[idx.width] - g[idx.width] - -- move bounds right by the widget's width - bounds[idx.x] = bounds[idx.x] + g[idx.width] + m[idx.right] - - -- update the maximum height with height of this widget - maxh = max(maxh, g[idx.height] + m[idx.top] + m[idx.bottom]) - end - - insert(geometries, g) - end - end - end - - -- calculate the total space taken by the widgets - geometries.total[idx.width] = geometries.total[idx.width] - bounds[idx.width] - geometries.total[idx.height] = widgets[idx.height] or maxh - -- if the bounds are on the left of what was empty in the beginning of this function, - -- we move the total to the right. this, however, most probably happened cos of rightleft layout - -- inside 'widgets', and only if there was nothing aligned to the left - if geometries.total[idx.x] == bounds[idx.x] then - geometries.total[idx.x] = geometries.total[idx.x] + bounds[idx.width] - end - - return geometries -end - - --- Calculates geometries for flex layouts. --- This generic function is used for all flex layouts. --- It is written for horizontal layouts, but by using special index 'idx' to access --- all the geometry attributes, it is used for vertical layouts too. In that case, 'idx' --- returns 'y' for 'x', 'width' for 'height', etc. --- @param idx An index table that defines whether horzintal or vertical arrangement will be --- calculated. See regular_index and switched_index tables. --- @param bounds The geometry of the bounds for the layout. --- @param widgets The table of the widgets to layout, can be nested. --- @param screen The screen of the wibox. --- @return A table of geometries of all the widgets. -function linear_common.flex(idx, bounds, widgets, screen) - -- set bounds width and height to what is preset in the widgets table (if there is something) - -- we don't need to use idx here since we're treating both directions the same way - if widgets.width and widgets.width < bounds.width then - bounds.width = widgets.width - end - if widgets.height and widgets.height < bounds.height then - bounds.height = widgets.height - end - - -- the table for the geometries which will be returned - -- we clone the bounds to the 'total' attribute. bounds are used to keep the free space - -- throughout this function. at the end, 'total' is modified to represent the space taken - -- by all widgets - local geometries = {total = clone(bounds)} - -- the height of the heighest widget, will be the height of the total space taken - local maxh = 0 - -- the number of widgets/tables in 'widgets' argument - local n = 0 - -- get the gap or set to 0 - local gap = widgets.gap or 0 - - -- count the widgets/tables - for _, v in ipairs(widgets) do - if type(v) == "table" or (type(v) == "widget" and v.visible) then - n = n + 1 - end - end - - -- calculate the width. these vars keep the floating numbers, while bounds keep the - -- rounded ones and are set from these on each iteration to ensure proper rounding - local width = (n > 0) and ((widgets[idx.width] or bounds[idx.width]) - gap * (n - 1)) / n or 0 - local x = bounds[idx.x] - - -- if max_size is set and it is lower than the calculated width, use it - width = (widgets.max_size and widgets.max_size < width) and widgets.max_size or width - - for _, v in ipairs(widgets) do - -- someone give me freaking continue - if type(v) == "widget" and not v.visible then - insert(geometries, {x = 0, y = 0, width = 0, height = 0}) - elseif type(v) == "widget" or type(v) == "table" then - -- do the floating magic, calculate real_width which will be set to the geometries - x = x + width - local real_width = floor(x - bounds[idx.x] + 0.5) - - local m = margins[v] - - if type(v) == "table" then - -- create new bounds for the table and shrink it by the margins - local t_bounds = {} - t_bounds[idx.x] = bounds[idx.x] + m[idx.left] - t_bounds[idx.y] = bounds[idx.y] + m[idx.top] - t_bounds[idx.width] = real_width - m[idx.left] - m[idx.right] - t_bounds[idx.height] = bounds[idx.height] - m[idx.top] - m[idx.bottom] - - -- backup the width and height of the table so we can restore it - local t_width = v.width - local t_height = v.height - - -- set the table's width so it can flex what's inside it - v[idx.width] = real_width - - -- if the 'widgets' table has height set and the table itself doesn't, we set it - v[idx.height] = v[idx.height] or widgets[idx.height] - - -- call the layout function recursively on this table - local layout = v.layout or layout.default - local g = layout(t_bounds, v, screen) - - -- restore the table's original width and height - v.width = t_width - v.height = t_height - - -- update the maximum height with this new table - maxh = max(maxh, g.total[idx.height] + m[idx.top] + m[idx.bottom]) - - for _, v in ipairs(g) do - insert(geometries, v) - end - elseif type(v) == "widget" then - local g = v:extents(screen) - - -- resize to fit the width available if requested - if v.resize and g.width > 0 and g.height > 0 then - local ratio = g[idx.height] / g[idx.width] - g[idx.height] = real_width * ratio - end - - -- set the widget geometry - g[idx.x] = bounds[idx.x] + m[idx.left] - g[idx.width] = real_width - m[idx.left] - m[idx.right] - g[idx.y] = bounds[idx.y] + m[idx.top] - - -- if the 'widgets' table has height set, we set it to the widget - g[idx.height] = widgets[idx.height] and - (widgets[idx.height] - m[idx.top] - m[idx.bottom]) or g[idx.height] - - -- limit the height of the widget to what's available - g[idx.height] = min(g[idx.height], bounds[idx.height] - m[idx.top] - m[idx.bottom]) - - -- update the maximum height with height of this widget - maxh = max(maxh, g[idx.height] + m[idx.top] + m[idx.bottom]) - - insert(geometries, g) - end - - -- update the bounds (move it to the right by the widget's width) - bounds[idx.width] = bounds[idx.width] - real_width - gap - x = x + gap - bounds[idx.x] = floor(x + 0.5) - end - end - - -- we have total already from the cloned bounds, just set the height to what we got - geometries.total[idx.width] = geometries.total[idx.width] - bounds[idx.width] - geometries.total[idx.height] = widgets[idx.height] or maxh - - return geometries -end - -return linear_common - --- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/lib/awful/widget/layout/vertical.lua.in b/lib/awful/widget/layout/vertical.lua.in deleted file mode 100644 index c7061476..00000000 --- a/lib/awful/widget/layout/vertical.lua.in +++ /dev/null @@ -1,93 +0,0 @@ -------------------------------------------------- --- @author Gregor Best , Lukas Hrazky --- @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: ---

width: Maximum width of the layout. If set, all widgets are resized to this width. --- (optional)
--- height: Height of the layout. (optional)

--- @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: ---

width: Maximum width of the layout. If set, all widgets are resized to this width. --- (optional)
--- height: Height of the layout. (optional)

--- @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: ---

width: Maximum width of the layout. If set, all widgets are resized to this width. --- (optional)
--- height: Height of the layout. (optional)

--- 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: ---

width: Maximum width of the layout. If set, all widgets are resized to this width. --- (optional)
--- height: Height of the layout. (optional)
--- max_size: Maximum height of one item. If not set, widgets' heights are set so that they always --- cover all available space. (optional)
--- gap: Gap between the widgets. (optional)

--- @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 diff --git a/lib/awful/widget/prompt.lua.in b/lib/awful/widget/prompt.lua.in index a77ade12..9570bbd2 100644 --- a/lib/awful/widget/prompt.lua.in +++ b/lib/awful/widget/prompt.lua.in @@ -9,7 +9,6 @@ local setmetatable = setmetatable local completion = require("awful.completion") local util = require("awful.util") local prompt = require("awful.prompt") -local layout = require("awful.widget.layout") local widget_base = require("wibox.widget.base") local textbox = require("wibox.widget.textbox") local type = type