2010-10-06 12:42:56 +02:00
|
|
|
---------------------------------------------------------------------------
|
2021-07-13 20:18:31 +02:00
|
|
|
-- The `align` layout has three slots for child widgets. On its main axis, it
|
|
|
|
-- will use as much space as is available to it and distribute that to its child
|
|
|
|
-- widgets by stretching or shrinking them based on the chosen @{expand}
|
|
|
|
-- strategy.
|
|
|
|
-- On its secondary axis, the biggest child widget determines the size of the
|
|
|
|
-- layout, but smaller widgets will not be stretched to match it.
|
|
|
|
--
|
|
|
|
-- In its default configuration, the layout will give the first and third
|
|
|
|
-- widgets only the minimum space they ask for and it aligns them to the outer
|
|
|
|
-- edges. The remaining space between them is made available to the widget in
|
|
|
|
-- slot two.
|
|
|
|
--
|
|
|
|
-- This layout is most commonly used to split content into left/top, center and
|
|
|
|
-- right/bottom sections. As such, it is usually seen as the root layout in
|
|
|
|
-- @{awful.wibar}.
|
|
|
|
--
|
|
|
|
-- You may also fill just one or two of the widget slots, the @{expand} algorithm
|
|
|
|
-- will adjust accordingly.
|
2016-05-25 21:02:54 +02:00
|
|
|
--
|
|
|
|
--@DOC_wibox_layout_defaults_align_EXAMPLE@
|
2021-07-13 20:18:31 +02:00
|
|
|
--
|
2010-10-06 12:42:56 +02:00
|
|
|
-- @author Uli Schlachter
|
|
|
|
-- @copyright 2010 Uli Schlachter
|
2019-06-06 08:19:03 +02:00
|
|
|
-- @layoutmod wibox.layout.align
|
2021-03-27 20:05:10 +01:00
|
|
|
-- @supermodule wibox.widget.base
|
2010-10-06 12:42:56 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
local table = table
|
|
|
|
local pairs = pairs
|
|
|
|
local type = type
|
2014-01-02 09:09:08 +01:00
|
|
|
local floor = math.floor
|
2017-03-26 21:20:18 +02:00
|
|
|
local gtable = require("gears.table")
|
2015-06-14 15:57:33 +02:00
|
|
|
local base = require("wibox.widget.base")
|
2010-10-06 12:42:56 +02:00
|
|
|
|
2012-06-12 15:29:52 +02:00
|
|
|
local align = {}
|
2010-10-06 12:42:56 +02:00
|
|
|
|
2016-05-23 09:02:11 +02:00
|
|
|
-- Calculate the layout of an align layout.
|
2015-08-08 13:18:54 +02:00
|
|
|
-- @param context The context in which we are drawn.
|
2013-01-05 16:12:47 +01:00
|
|
|
-- @param width The available width.
|
|
|
|
-- @param height The available height.
|
2015-06-14 16:03:29 +02:00
|
|
|
function align:layout(context, width, height)
|
|
|
|
local result = {}
|
|
|
|
|
2014-01-04 20:10:01 +01:00
|
|
|
-- Draw will have to deal with all three align modes and should work in a
|
|
|
|
-- way that makes sense if one or two of the widgets are missing (if they
|
|
|
|
-- are all missing, it won't draw anything.) It should also handle the case
|
|
|
|
-- where the fit something that isn't set to expand (for instance the
|
|
|
|
-- outside widgets when the expand mode is "inside" or any of the widgets
|
|
|
|
-- when the expand mode is "none" wants to take up more space than is
|
|
|
|
-- allowed.
|
2010-10-06 12:42:56 +02:00
|
|
|
local size_first = 0
|
2014-01-04 20:10:01 +01:00
|
|
|
-- start with all the space given by the parent, subtract as we go along
|
2016-05-27 01:41:58 +02:00
|
|
|
local size_remains = self._private.dir == "y" and height or width
|
2015-08-13 15:42:39 +02:00
|
|
|
-- This is only set & used if expand ~= "inside" and we have second width.
|
|
|
|
-- It contains the size allocated to the second widget.
|
|
|
|
local size_second
|
2014-01-02 09:09:08 +01:00
|
|
|
|
2014-01-04 20:10:01 +01:00
|
|
|
-- we will prioritize the middle widget unless the expand mode is "inside"
|
|
|
|
-- if it is, we prioritize the first widget by not doing this block also,
|
|
|
|
-- if the second widget doesn't exist, we will prioritise the first one
|
|
|
|
-- instead
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand ~= "inside" and self._private.second then
|
|
|
|
local w, h = base.fit_widget(self, context, self._private.second, width, height)
|
|
|
|
size_second = self._private.dir == "y" and h or w
|
2014-01-04 20:10:01 +01:00
|
|
|
-- if all the space is taken, skip the rest, and draw just the middle
|
|
|
|
-- widget
|
2014-01-02 09:09:08 +01:00
|
|
|
if size_second >= size_remains then
|
2016-05-27 01:41:58 +02:00
|
|
|
return { base.place_widget_at(self._private.second, 0, 0, width, height) }
|
2014-01-02 09:09:08 +01:00
|
|
|
else
|
2014-01-04 20:10:01 +01:00
|
|
|
-- the middle widget is sized first, the outside widgets are given
|
|
|
|
-- the remaining space if available we will draw later
|
2014-01-02 09:09:08 +01:00
|
|
|
size_remains = floor((size_remains - size_second) / 2)
|
|
|
|
end
|
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.first then
|
2012-06-16 21:12:26 +02:00
|
|
|
local w, h, _ = width, height, nil
|
2014-01-04 20:10:01 +01:00
|
|
|
-- we use the fit function for the "inside" and "none" modes, but
|
|
|
|
-- ignore it for the "outside" mode, which will force it to expand
|
|
|
|
-- into the remaining space
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand ~= "outside" then
|
|
|
|
if self._private.dir == "y" then
|
|
|
|
_, h = base.fit_widget(self, context, self._private.first, width, size_remains)
|
2014-01-02 09:09:08 +01:00
|
|
|
size_first = h
|
2014-01-04 20:10:01 +01:00
|
|
|
-- for "inside", the third widget will get a chance to use the
|
|
|
|
-- remaining space, then the middle widget. For "none" we give
|
|
|
|
-- the third widget the remaining space if there was no second
|
|
|
|
-- widget to take up any space (as the first if block is skipped
|
|
|
|
-- if this is the case)
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand == "inside" or not self._private.second then
|
2014-01-02 09:09:08 +01:00
|
|
|
size_remains = size_remains - h
|
|
|
|
end
|
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
w, _ = base.fit_widget(self, context, self._private.first, size_remains, height)
|
2014-01-02 09:09:08 +01:00
|
|
|
size_first = w
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand == "inside" or not self._private.second then
|
2014-01-02 09:09:08 +01:00
|
|
|
size_remains = size_remains - w
|
|
|
|
end
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.dir == "y" then
|
2014-01-02 09:09:08 +01:00
|
|
|
h = size_remains
|
|
|
|
else
|
|
|
|
w = size_remains
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
table.insert(result, base.place_widget_at(self._private.first, 0, 0, w, h))
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2014-01-04 20:10:01 +01:00
|
|
|
-- size_remains will be <= 0 if first used all the space
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.third and size_remains > 0 then
|
2014-01-02 09:09:08 +01:00
|
|
|
local w, h, _ = width, height, nil
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand ~= "outside" then
|
|
|
|
if self._private.dir == "y" then
|
|
|
|
_, h = base.fit_widget(self, context, self._private.third, width, size_remains)
|
2014-01-04 20:10:01 +01:00
|
|
|
-- give the middle widget the rest of the space for "inside" mode
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand == "inside" then
|
2014-01-02 09:09:08 +01:00
|
|
|
size_remains = size_remains - h
|
|
|
|
end
|
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
w, _ = base.fit_widget(self, context, self._private.third, size_remains, height)
|
|
|
|
if self._private.expand == "inside" then
|
2014-01-02 09:09:08 +01:00
|
|
|
size_remains = size_remains - w
|
|
|
|
end
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.dir == "y" then
|
2014-01-02 09:09:08 +01:00
|
|
|
h = size_remains
|
|
|
|
else
|
|
|
|
w = size_remains
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2014-01-02 09:09:08 +01:00
|
|
|
local x, y = width - w, height - h
|
2016-05-27 01:41:58 +02:00
|
|
|
table.insert(result, base.place_widget_at(self._private.third, x, y, w, h))
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2014-01-04 20:10:01 +01:00
|
|
|
-- here we either draw the second widget in the space set aside for it
|
|
|
|
-- in the beginning, or in the remaining space, if it is "inside"
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.second and size_remains > 0 then
|
2014-01-02 09:09:08 +01:00
|
|
|
local x, y, w, h = 0, 0, width, height
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.expand == "inside" then
|
|
|
|
if self._private.dir == "y" then
|
2014-01-02 09:09:08 +01:00
|
|
|
h = size_remains
|
|
|
|
x, y = 0, size_first
|
|
|
|
else
|
|
|
|
w = size_remains
|
|
|
|
x, y = size_first, 0
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
else
|
2016-02-07 14:13:43 +01:00
|
|
|
local _
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.dir == "y" then
|
|
|
|
_, h = base.fit_widget(self, context, self._private.second, width, size_second)
|
2014-01-02 09:09:08 +01:00
|
|
|
y = floor( (height - h)/2 )
|
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
w, _ = base.fit_widget(self, context, self._private.second, size_second, height)
|
2014-01-02 09:09:08 +01:00
|
|
|
x = floor( (width -w)/2 )
|
|
|
|
end
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
table.insert(result, base.place_widget_at(self._private.second, x, y, w, h))
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2015-06-14 16:03:29 +02:00
|
|
|
return result
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- The widget in slot one.
|
|
|
|
--
|
|
|
|
-- This is the widget that is at the left/top.
|
|
|
|
--
|
2016-05-27 01:41:58 +02:00
|
|
|
-- @property first
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] widget|nil first
|
|
|
|
-- @propertytype nil This spot will be empty. Depending on how large the second
|
|
|
|
-- widget is an and the value of `expand`, it might mean it will leave an empty
|
|
|
|
-- area.
|
2019-11-29 07:22:50 +01:00
|
|
|
-- @propemits true false
|
2016-05-27 01:41:58 +02:00
|
|
|
|
2012-11-18 20:44:03 +01:00
|
|
|
function align:set_first(widget)
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.first == widget then
|
2015-06-21 14:53:16 +02:00
|
|
|
return
|
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
self._private.first = widget
|
2015-06-14 16:03:29 +02:00
|
|
|
self:emit_signal("widget::layout_changed")
|
2019-11-29 07:22:50 +01:00
|
|
|
self:emit_signal("property::first", widget)
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- The widget in slot two.
|
|
|
|
--
|
|
|
|
-- This is the centered one.
|
|
|
|
--
|
2016-05-27 01:41:58 +02:00
|
|
|
-- @property second
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] widget|nil second
|
|
|
|
-- @propertytype nil When this property is `nil`, then there will be an empty
|
|
|
|
-- area.
|
2019-11-29 07:22:50 +01:00
|
|
|
-- @propemits true false
|
2016-05-27 01:41:58 +02:00
|
|
|
|
2012-11-18 20:44:03 +01:00
|
|
|
function align:set_second(widget)
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.second == widget then
|
2015-06-21 14:53:16 +02:00
|
|
|
return
|
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
self._private.second = widget
|
2015-06-14 16:03:29 +02:00
|
|
|
self:emit_signal("widget::layout_changed")
|
2019-11-29 07:22:50 +01:00
|
|
|
self:emit_signal("property::second", widget)
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- The widget in slot three.
|
|
|
|
--
|
|
|
|
-- This is the widget that is at the right/bottom.
|
|
|
|
--
|
2016-05-27 01:41:58 +02:00
|
|
|
-- @property third
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @tparam[opt=nil] widget|nil third
|
|
|
|
-- @propertytype nil This spot will be empty. Depending on how large the second
|
|
|
|
-- widget is an and the value of `expand`, it might mean it will leave an empty
|
|
|
|
-- area.
|
2019-11-29 07:22:50 +01:00
|
|
|
-- @propemits true false
|
2016-05-27 01:41:58 +02:00
|
|
|
|
2012-11-18 20:44:03 +01:00
|
|
|
function align:set_third(widget)
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.third == widget then
|
2015-06-21 14:53:16 +02:00
|
|
|
return
|
|
|
|
end
|
2016-05-27 01:41:58 +02:00
|
|
|
self._private.third = widget
|
2015-06-14 16:03:29 +02:00
|
|
|
self:emit_signal("widget::layout_changed")
|
2019-11-29 07:22:50 +01:00
|
|
|
self:emit_signal("property::third", widget)
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
for _, prop in ipairs {"first", "second", "third", "expand" } do
|
|
|
|
align["get_"..prop] = function(self)
|
|
|
|
return self._private[prop]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-16 07:13:07 +01:00
|
|
|
function align:get_children()
|
2017-03-26 21:20:18 +02:00
|
|
|
return gtable.from_sparse {self._private.first, self._private.second, self._private.third}
|
2016-01-16 07:13:07 +01:00
|
|
|
end
|
|
|
|
|
2016-02-04 07:11:10 +01:00
|
|
|
function align:set_children(children)
|
2016-02-27 13:55:34 +01:00
|
|
|
self:set_first(children[1])
|
|
|
|
self:set_second(children[2])
|
|
|
|
self:set_third(children[3])
|
2016-02-04 07:11:10 +01:00
|
|
|
end
|
|
|
|
|
2016-05-23 09:02:11 +02:00
|
|
|
-- Fit the align layout into the given space. The align layout will
|
2014-01-04 16:10:37 +01:00
|
|
|
-- ask for the sum of the sizes of its sub-widgets in its direction
|
|
|
|
-- and the largest sized sub widget in the other direction.
|
2015-08-08 13:43:35 +02:00
|
|
|
-- @param context The context in which we are fit.
|
2013-01-05 16:12:49 +01:00
|
|
|
-- @param orig_width The available width.
|
|
|
|
-- @param orig_height The available height.
|
2015-08-08 13:43:35 +02:00
|
|
|
function align:fit(context, orig_width, orig_height)
|
2014-01-04 16:10:37 +01:00
|
|
|
local used_in_dir = 0
|
|
|
|
local used_in_other = 0
|
2013-01-05 16:12:49 +01:00
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
for _, v in pairs{self._private.first, self._private.second, self._private.third} do
|
2015-09-17 15:01:50 +02:00
|
|
|
local w, h = base.fit_widget(self, context, v, orig_width, orig_height)
|
2013-01-05 16:12:49 +01:00
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
local max = self._private.dir == "y" and w or h
|
2014-01-04 16:10:37 +01:00
|
|
|
if max > used_in_other then
|
|
|
|
used_in_other = max
|
2013-01-05 16:12:49 +01:00
|
|
|
end
|
2014-01-04 16:10:37 +01:00
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
used_in_dir = used_in_dir + (self._private.dir == "y" and h or w)
|
2013-01-05 16:12:49 +01:00
|
|
|
end
|
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
if self._private.dir == "y" then
|
2014-01-04 16:10:37 +01:00
|
|
|
return used_in_other, used_in_dir
|
2013-01-05 16:12:49 +01:00
|
|
|
end
|
2014-01-04 16:10:37 +01:00
|
|
|
return used_in_dir, used_in_other
|
2013-01-05 16:12:49 +01:00
|
|
|
end
|
2015-06-14 16:03:29 +02:00
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- Set the expand mode, which determines how child widgets expand to take up
|
2015-10-14 00:21:29 +02:00
|
|
|
-- unused space.
|
|
|
|
--
|
2022-08-22 08:02:26 +02:00
|
|
|
-- Attempting to set any other value than one of those three will fall back to
|
|
|
|
-- `"inside"`.
|
2015-10-14 00:21:29 +02:00
|
|
|
--
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @property expand
|
|
|
|
-- @tparam[opt="inside"] string expand How to use unused space.
|
|
|
|
-- @propertyvalue "inside" The widgets in slot one and three are set to their minimal
|
2021-07-13 20:18:31 +02:00
|
|
|
-- required size. The widget in slot two is then given the remaining space.
|
|
|
|
-- This is the default behaviour.
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @propertyvalue "outside" The widget in slot two is set to its minimal required size and
|
2021-07-13 20:18:31 +02:00
|
|
|
-- placed in the center of the space available to the layout. The other
|
|
|
|
-- widgets are then given the remaining space on either side.
|
|
|
|
-- If the center widget requires all available space, the outer widgets are
|
|
|
|
-- not drawn at all.
|
2022-08-22 08:02:26 +02:00
|
|
|
-- @propertyvalue "none" All widgets are given their minimal required size or the
|
2021-07-13 20:18:31 +02:00
|
|
|
-- remaining space, whichever is smaller. The center widget gets priority.
|
2016-05-27 01:41:58 +02:00
|
|
|
|
2014-01-02 09:09:08 +01:00
|
|
|
function align:set_expand(mode)
|
|
|
|
if mode == "none" or mode == "outside" then
|
2016-05-27 01:41:58 +02:00
|
|
|
self._private.expand = mode
|
2014-01-02 09:09:08 +01:00
|
|
|
else
|
2016-05-27 01:41:58 +02:00
|
|
|
self._private.expand = "inside"
|
2014-01-02 09:09:08 +01:00
|
|
|
end
|
2015-06-14 16:03:29 +02:00
|
|
|
self:emit_signal("widget::layout_changed")
|
2019-11-29 07:22:50 +01:00
|
|
|
self:emit_signal("property::expand", mode)
|
2014-01-02 09:09:08 +01:00
|
|
|
end
|
2013-01-05 16:12:49 +01:00
|
|
|
|
2012-11-18 20:44:03 +01:00
|
|
|
function align:reset()
|
2016-02-07 14:13:43 +01:00
|
|
|
for _, v in pairs({ "first", "second", "third" }) do
|
2012-11-18 20:44:03 +01:00
|
|
|
self[v] = nil
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
2015-06-14 16:03:29 +02:00
|
|
|
self:emit_signal("widget::layout_changed")
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
|
2015-09-28 21:00:49 +02:00
|
|
|
local function get_layout(dir, first, second, third)
|
2016-05-27 01:41:58 +02:00
|
|
|
local ret = base.make_widget(nil, nil, {enable_properties = true})
|
|
|
|
ret._private.dir = dir
|
2010-10-06 12:42:56 +02:00
|
|
|
|
2012-06-12 15:29:52 +02:00
|
|
|
for k, v in pairs(align) do
|
2010-10-06 12:42:56 +02:00
|
|
|
if type(v) == "function" then
|
2016-05-27 01:41:58 +02:00
|
|
|
rawset(ret, k, v)
|
2010-10-06 12:42:56 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-01-02 09:09:08 +01:00
|
|
|
ret:set_expand("inside")
|
2015-09-28 21:00:49 +02:00
|
|
|
ret:set_first(first)
|
|
|
|
ret:set_second(second)
|
|
|
|
ret:set_third(third)
|
2014-01-02 09:09:08 +01:00
|
|
|
|
2016-02-04 07:11:10 +01:00
|
|
|
-- An align layout allow set_children to have empty entries
|
|
|
|
ret.allow_empty_widget = true
|
|
|
|
|
2010-10-06 12:42:56 +02:00
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- Returns a new horizontal align layout.
|
|
|
|
--
|
|
|
|
-- The three widget slots are aligned left, center and right.
|
|
|
|
--
|
|
|
|
-- Additionally, this creates the aliases `set_left`, `set_middle` and
|
|
|
|
-- `set_right` to assign @{first}, @{second} and @{third} respectively.
|
2019-06-07 20:59:34 +02:00
|
|
|
-- @constructorfct wibox.layout.align.horizontal
|
2021-07-13 20:18:31 +02:00
|
|
|
-- @tparam[opt] widget left Widget to be put in slot one.
|
|
|
|
-- @tparam[opt] widget middle Widget to be put in slot two.
|
|
|
|
-- @tparam[opt] widget right Widget to be put in slot three.
|
2015-09-28 21:00:49 +02:00
|
|
|
function align.horizontal(left, middle, right)
|
|
|
|
local ret = get_layout("x", left, middle, right)
|
2010-10-06 12:42:56 +02:00
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
rawset(ret, "set_left" , ret.set_first )
|
|
|
|
rawset(ret, "set_middle", ret.set_second )
|
|
|
|
rawset(ret, "set_right" , ret.set_third )
|
2010-10-06 12:42:56 +02:00
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2021-07-13 20:18:31 +02:00
|
|
|
--- Returns a new vertical align layout.
|
|
|
|
--
|
|
|
|
-- The three widget slots are aligned top, center and bottom.
|
|
|
|
--
|
|
|
|
-- Additionally, this creates the aliases `set_top`, `set_middle` and
|
|
|
|
-- `set_bottom` to assign @{first}, @{second} and @{third} respectively.
|
2019-06-07 20:59:34 +02:00
|
|
|
-- @constructorfct wibox.layout.align.vertical
|
2021-07-13 20:18:31 +02:00
|
|
|
-- @tparam[opt] widget top Widget to be put in slot one.
|
|
|
|
-- @tparam[opt] widget middle Widget to be put in slot two.
|
|
|
|
-- @tparam[opt] widget bottom Widget to be put in slot three.
|
2015-09-28 21:00:49 +02:00
|
|
|
function align.vertical(top, middle, bottom)
|
|
|
|
local ret = get_layout("y", top, middle, bottom)
|
2010-10-06 12:42:56 +02:00
|
|
|
|
2016-05-27 01:41:58 +02:00
|
|
|
rawset(ret, "set_top" , ret.set_first )
|
|
|
|
rawset(ret, "set_middle", ret.set_second )
|
|
|
|
rawset(ret, "set_bottom", ret.set_third )
|
2010-10-06 12:42:56 +02:00
|
|
|
|
|
|
|
return ret
|
|
|
|
end
|
|
|
|
|
2017-10-21 01:54:36 +02:00
|
|
|
--@DOC_fixed_COMMON@
|
|
|
|
|
2012-06-12 15:29:52 +02:00
|
|
|
return align
|
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|