doc: Upgrade the widget layout documentation.
This commit is contained in:
parent
be14666b4a
commit
f21e0ba9dd
|
@ -1,42 +1,65 @@
|
||||||
--- Set a widget at a specific index, replace the current one.
|
--- Set a widget at a specific index, replace the current one.
|
||||||
-- **Signal:** widget::replaced The argument is the new widget and the old one
|
--
|
||||||
-- and the index.
|
|
||||||
-- @tparam number index A widget or a widget index
|
-- @tparam number index A widget or a widget index
|
||||||
-- @param widget2 The widget to take the place of the first one
|
-- @tparam widget widget2 The widget to take the place of the first one
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method set
|
-- @method set
|
||||||
|
-- @emits widget::replaced
|
||||||
|
-- @emitstparam widget::replaced widget self The layout.
|
||||||
|
-- @emitstparam widget::replaced widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::replaced widget previous The previous widget.
|
||||||
|
-- @emitstparam widget::replaced number index The replaced index.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Replace the first instance of `widget` in the layout with `widget2`.
|
--- Replace the first instance of `widget` in the layout with `widget2`.
|
||||||
|
--
|
||||||
-- **Signal:** widget::replaced The argument is the new widget and the old one
|
-- **Signal:** widget::replaced The argument is the new widget and the old one
|
||||||
-- and the index.
|
-- and the index.
|
||||||
-- @param widget The widget to replace
|
-- @tparam widget widget The widget to replace
|
||||||
-- @param widget2 The widget to replace `widget` with
|
-- @tparam widget widget2 The widget to replace `widget` with
|
||||||
-- @tparam[opt=false] boolean recursive Dig in all compatible layouts to find the widget.
|
-- @tparam[opt=false] boolean recursive Dig in all compatible layouts to find the widget.
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method replace_widget
|
-- @method replace_widget
|
||||||
|
-- @emits widget::replaced
|
||||||
|
-- @emitstparam widget::replaced widget self The layout.
|
||||||
|
-- @emitstparam widget::replaced widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::replaced widget previous The previous widget.
|
||||||
|
-- @emitstparam widget::replaced number index The replaced index.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Swap 2 widgets in a layout.
|
--- Swap 2 widgets in a layout.
|
||||||
-- **Signal:** widget::swapped The arguments are both widgets and both (new) indexes.
|
--
|
||||||
-- @tparam number index1 The first widget index
|
-- @tparam number index1 The first widget index
|
||||||
-- @tparam number index2 The second widget index
|
-- @tparam number index2 The second widget index
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method swap
|
-- @method swap
|
||||||
|
-- @emits widget::swapped
|
||||||
|
-- @emitstparam widget::swapped widget self The layout.
|
||||||
|
-- @emitstparam widget::swapped widget widget1 index The first widget.
|
||||||
|
-- @emitstparam widget::swapped widget widget2 index The second widget.
|
||||||
|
-- @emitstparam widget::swapped number index1 The first index.
|
||||||
|
-- @emitstparam widget::swapped number index1 The second index.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Swap 2 widgets in a layout.
|
--- Swap 2 widgets in a layout.
|
||||||
-- If widget1 is present multiple time, only the first instance is swapped
|
-- If widget1 is present multiple time, only the first instance is swapped
|
||||||
-- **Signal:** widget::swapped The arguments are both widgets and both (new) indexes.
|
-- **Signal:** widget::swapped The arguments are both widgets and both (new) indexes.
|
||||||
-- if the layouts not the same, then only `widget::replaced` will be emitted.
|
-- if the layouts not the same, then only `widget::replaced` will be emitted.
|
||||||
-- @param widget1 The first widget
|
-- @tparam widget widget1 The first widget
|
||||||
-- @param widget2 The second widget
|
-- @tparam widget widget2 The second widget
|
||||||
-- @tparam[opt=false] boolean recursive Dig in all compatible layouts to find the widget.
|
-- @tparam[opt=false] boolean recursive Dig in all compatible layouts to find the widget.
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method swap_widgets
|
-- @method swap_widgets
|
||||||
|
-- @emits widget::swapped
|
||||||
--- Get all direct children of this layout.
|
-- @emitstparam widget::swapped widget self The layout.
|
||||||
-- @param layout The layout you are modifying.
|
-- @emitstparam widget::swapped widget widget1 index The first widget.
|
||||||
-- @property children
|
-- @emitstparam widget::swapped widget widget2 index The second widget.
|
||||||
|
-- @emitstparam widget::swapped number index1 The first index.
|
||||||
|
-- @emitstparam widget::swapped number index1 The second index.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Reset a ratio layout. This removes all widgets from the layout.
|
--- Reset a ratio layout. This removes all widgets from the layout.
|
||||||
-- **Signal:** widget::reset
|
|
||||||
-- @param layout The layout you are modifying.
|
|
||||||
-- @method reset
|
-- @method reset
|
||||||
|
-- @emits widget::reset
|
||||||
|
-- @emitstparam widget::reset widget self The layout.
|
||||||
|
-- @interface layout
|
||||||
|
|
|
@ -142,7 +142,8 @@ end
|
||||||
--- Set the layout's first widget.
|
--- Set the layout's first widget.
|
||||||
-- This is the widget that is at the left/top
|
-- This is the widget that is at the left/top
|
||||||
-- @property first
|
-- @property first
|
||||||
-- @param widget
|
-- @tparam widget first
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function align:set_first(widget)
|
function align:set_first(widget)
|
||||||
if self._private.first == widget then
|
if self._private.first == widget then
|
||||||
|
@ -150,11 +151,13 @@ function align:set_first(widget)
|
||||||
end
|
end
|
||||||
self._private.first = widget
|
self._private.first = widget
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::first", widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the layout's second widget. This is the centered one.
|
--- Set the layout's second widget. This is the centered one.
|
||||||
-- @property second
|
-- @property second
|
||||||
-- @param widget
|
-- @tparam widget second
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function align:set_second(widget)
|
function align:set_second(widget)
|
||||||
if self._private.second == widget then
|
if self._private.second == widget then
|
||||||
|
@ -162,12 +165,14 @@ function align:set_second(widget)
|
||||||
end
|
end
|
||||||
self._private.second = widget
|
self._private.second = widget
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::second", widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the layout's third widget.
|
--- Set the layout's third widget.
|
||||||
-- This is the widget that is at the right/bottom
|
-- This is the widget that is at the right/bottom
|
||||||
-- @property third
|
-- @property third
|
||||||
-- @param widget
|
-- @tparam widget third
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function align:set_third(widget)
|
function align:set_third(widget)
|
||||||
if self._private.third == widget then
|
if self._private.third == widget then
|
||||||
|
@ -175,6 +180,7 @@ function align:set_third(widget)
|
||||||
end
|
end
|
||||||
self._private.third = widget
|
self._private.third = widget
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::third", widget)
|
||||||
end
|
end
|
||||||
|
|
||||||
for _, prop in ipairs {"first", "second", "third", "expand" } do
|
for _, prop in ipairs {"first", "second", "third", "expand" } do
|
||||||
|
@ -183,12 +189,6 @@ for _, prop in ipairs {"first", "second", "third", "expand" } do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- All direct children of this layout.
|
|
||||||
-- This can be used to replace all 3 widgets at once.
|
|
||||||
-- @treturn table a list of all widgets
|
|
||||||
-- @property children
|
|
||||||
-- @param table
|
|
||||||
|
|
||||||
function align:get_children()
|
function align:get_children()
|
||||||
return gtable.from_sparse {self._private.first, self._private.second, self._private.third}
|
return gtable.from_sparse {self._private.first, self._private.second, self._private.third}
|
||||||
end
|
end
|
||||||
|
@ -229,7 +229,7 @@ end
|
||||||
--- Set the expand mode which determines how sub widgets expand to take up
|
--- Set the expand mode which determines how sub widgets expand to take up
|
||||||
-- unused space.
|
-- unused space.
|
||||||
--
|
--
|
||||||
-- @tparam[opt=inside] string mode How to use unused space.
|
-- The following values are valid:
|
||||||
--
|
--
|
||||||
-- * "inside" - Default option. Size of outside widgets is determined using
|
-- * "inside" - Default option. Size of outside widgets is determined using
|
||||||
-- their fit function. Second, middle, or center widget expands to fill
|
-- their fit function. Second, middle, or center widget expands to fill
|
||||||
|
@ -240,7 +240,9 @@ end
|
||||||
-- * "none" - All widgets are sized using their fit function, drawn to only the
|
-- * "none" - All widgets are sized using their fit function, drawn to only the
|
||||||
-- returned space, or remaining space, whichever is smaller. Center widget
|
-- returned space, or remaining space, whichever is smaller. Center widget
|
||||||
-- gets priority.
|
-- gets priority.
|
||||||
|
--
|
||||||
-- @property expand
|
-- @property expand
|
||||||
|
-- @tparam[opt=inside] string mode How to use unused space.
|
||||||
|
|
||||||
function align:set_expand(mode)
|
function align:set_expand(mode)
|
||||||
if mode == "none" or mode == "outside" then
|
if mode == "none" or mode == "outside" then
|
||||||
|
@ -249,6 +251,7 @@ function align:set_expand(mode)
|
||||||
self._private.expand = "inside"
|
self._private.expand = "inside"
|
||||||
end
|
end
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::expand", mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function align:reset()
|
function align:reset()
|
||||||
|
|
|
@ -62,9 +62,11 @@ function fixed:layout(context, width, height)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Add some widgets to the given layout
|
--- Add some widgets to the given layout.
|
||||||
|
--
|
||||||
-- @method add
|
-- @method add
|
||||||
-- @param ... Widgets that should be added (must at least be one)
|
-- @tparam widget ... Widgets that should be added (must at least be one).
|
||||||
|
-- @interface layout
|
||||||
function fixed:add(...)
|
function fixed:add(...)
|
||||||
-- No table.pack in Lua 5.1 :-(
|
-- No table.pack in Lua 5.1 :-(
|
||||||
local args = { n=select('#', ...), ... }
|
local args = { n=select('#', ...), ... }
|
||||||
|
@ -78,10 +80,12 @@ function fixed:add(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Remove a widget from the layout
|
--- Remove a widget from the layout.
|
||||||
|
--
|
||||||
-- @method remove
|
-- @method remove
|
||||||
-- @tparam number index The widget index to remove
|
-- @tparam number index The widget index to remove
|
||||||
-- @treturn boolean index If the operation is successful
|
-- @treturn boolean index If the operation is successful
|
||||||
|
-- @interface layout
|
||||||
function fixed:remove(index)
|
function fixed:remove(index)
|
||||||
if not index or index < 1 or index > #self._private.widgets then return false end
|
if not index or index < 1 or index > #self._private.widgets then return false end
|
||||||
|
|
||||||
|
@ -92,12 +96,14 @@ function fixed:remove(index)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Remove one or more widgets from the layout
|
--- Remove one or more widgets from the layout.
|
||||||
|
--
|
||||||
-- The last parameter can be a boolean, forcing a recursive seach of the
|
-- The last parameter can be a boolean, forcing a recursive seach of the
|
||||||
-- widget(s) to remove.
|
-- widget(s) to remove.
|
||||||
-- @method remove_widgets
|
-- @method remove_widgets
|
||||||
-- @param widget ... Widgets that should be removed (must at least be one)
|
-- @tparam widget ... Widgets that should be removed (must at least be one)
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
|
-- @interface layout
|
||||||
function fixed:remove_widgets(...)
|
function fixed:remove_widgets(...)
|
||||||
local args = { ... }
|
local args = { ... }
|
||||||
|
|
||||||
|
@ -131,12 +137,13 @@ function fixed:set_children(children)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Replace the first instance of `widget` in the layout with `widget2`
|
--- Replace the first instance of `widget` in the layout with `widget2`.
|
||||||
-- @method replace_widget
|
-- @method replace_widget
|
||||||
-- @param widget The widget to replace
|
-- @tparam widget widget The widget to replace
|
||||||
-- @param widget2 The widget to replace `widget` with
|
-- @tparam widget widget2 The widget to replace `widget` with
|
||||||
-- @tparam[opt=false] boolean recursive Digg in all compatible layouts to find the widget.
|
-- @tparam[opt=false] boolean recursive Digg in all compatible layouts to find the widget.
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
|
-- @interface layout
|
||||||
function fixed:replace_widget(widget, widget2, recursive)
|
function fixed:replace_widget(widget, widget2, recursive)
|
||||||
local idx, l = self:index(widget, recursive)
|
local idx, l = self:index(widget, recursive)
|
||||||
|
|
||||||
|
@ -217,19 +224,27 @@ end
|
||||||
--@DOC_wibox_layout_fixed_spacing_widget_EXAMPLE@
|
--@DOC_wibox_layout_fixed_spacing_widget_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- @property spacing_widget
|
-- @property spacing_widget
|
||||||
-- @param widget
|
-- @tparam widget spacing_widget
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
function fixed:set_spacing_widget(wdg)
|
function fixed:set_spacing_widget(wdg)
|
||||||
self._private.spacing_widget = base.make_widget_from_value(wdg)
|
self._private.spacing_widget = base.make_widget_from_value(wdg)
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::spacing_widget", wdg)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Insert a new widget in the layout at position `index`.
|
--- Insert a new widget in the layout at position `index`.
|
||||||
-- **Signal:** widget::inserted The arguments are the widget and the index
|
--
|
||||||
-- @method insert
|
-- @method insert
|
||||||
-- @tparam number index The position
|
-- @tparam number index The position.
|
||||||
-- @param widget The widget
|
-- @tparam widget widget The widget.
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful.
|
||||||
|
-- @emits widget::inserted
|
||||||
|
-- @emitstparam widget::inserted widget self The fixed layout.
|
||||||
|
-- @emitstparam widget::inserted widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::inserted number count The widget count.
|
||||||
|
-- @interface layout
|
||||||
function fixed:insert(index, widget)
|
function fixed:insert(index, widget)
|
||||||
if not index or index < 1 or index > #self._private.widgets + 1 then return false end
|
if not index or index < 1 or index > #self._private.widgets + 1 then return false end
|
||||||
|
|
||||||
|
@ -286,18 +301,21 @@ function fixed:reset()
|
||||||
self._private.widgets = {}
|
self._private.widgets = {}
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
self:emit_signal("widget::reseted")
|
self:emit_signal("widget::reseted")
|
||||||
|
self:emit_signal("widget::reset")
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the layout's fill_space property. If this property is true, the last
|
--- Set the layout's fill_space property. If this property is true, the last
|
||||||
-- widget will get all the space that is left. If this is false, the last widget
|
-- widget will get all the space that is left. If this is false, the last widget
|
||||||
-- won't be handled specially and there can be space left unused.
|
-- won't be handled specially and there can be space left unused.
|
||||||
-- @property fill_space
|
-- @property fill_space
|
||||||
-- @param boolean
|
-- @tparam boolean fill_space
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function fixed:fill_space(val)
|
function fixed:fill_space(val)
|
||||||
if self._private.fill_space ~= val then
|
if self._private.fill_space ~= val then
|
||||||
self._private.fill_space = not not val
|
self._private.fill_space = not not val
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::fill_space", val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -346,11 +364,14 @@ end
|
||||||
--
|
--
|
||||||
-- @property spacing
|
-- @property spacing
|
||||||
-- @tparam number spacing Spacing between widgets.
|
-- @tparam number spacing Spacing between widgets.
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
function fixed:set_spacing(spacing)
|
function fixed:set_spacing(spacing)
|
||||||
if self._private.spacing ~= spacing then
|
if self._private.spacing ~= spacing then
|
||||||
self._private.spacing = spacing
|
self._private.spacing = spacing
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::spacing", spacing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -15,30 +15,40 @@ local gtable = require("gears.table")
|
||||||
|
|
||||||
local flex = {}
|
local flex = {}
|
||||||
|
|
||||||
--@DOC_fixed_COMMON@
|
--- Add some widgets to the given fixed layout.
|
||||||
|
--
|
||||||
--- Add some widgets to the given fixed layout
|
-- @tparam widget ... Widgets that should be added (must at least be one).
|
||||||
-- @param layout The layout you are modifying.
|
|
||||||
-- @tparam widget ... Widgets that should be added (must at least be one)
|
|
||||||
-- @method add
|
-- @method add
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Remove a widget from the layout
|
--- Remove a widget from the layout.
|
||||||
-- @tparam index The widget index to remove
|
--
|
||||||
-- @treturn boolean index If the operation is successful
|
-- @tparam index The widget index to remove.
|
||||||
|
-- @treturn boolean index If the operation is successful.
|
||||||
-- @method remove
|
-- @method remove
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Remove one or more widgets from the layout
|
--- Remove one or more widgets from the layout.
|
||||||
|
--
|
||||||
-- The last parameter can be a boolean, forcing a recursive seach of the
|
-- The last parameter can be a boolean, forcing a recursive seach of the
|
||||||
-- widget(s) to remove.
|
-- widget(s) to remove.
|
||||||
-- @param widget ... Widgets that should be removed (must at least be one)
|
--
|
||||||
-- @treturn boolean If the operation is successful
|
-- @tparam widget ... Widgets that should be removed (must at least be one).
|
||||||
|
-- @treturn boolean If the operation is successful.
|
||||||
-- @method remove_widgets
|
-- @method remove_widgets
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Insert a new widget in the layout at position `index`
|
--- Insert a new widget in the layout at position `index`.
|
||||||
|
--
|
||||||
-- @tparam number index The position
|
-- @tparam number index The position
|
||||||
-- @param widget The widget
|
-- @tparam widget widget The widget
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method insert
|
-- @method insert
|
||||||
|
-- @emits widget::inserted
|
||||||
|
-- @emitstparam widget::inserted widget self The fixed layout.
|
||||||
|
-- @emitstparam widget::inserted widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::inserted number count The widget count.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- The widget used to fill the spacing between the layout elements.
|
--- The widget used to fill the spacing between the layout elements.
|
||||||
--
|
--
|
||||||
|
@ -47,7 +57,9 @@ local flex = {}
|
||||||
--@DOC_wibox_layout_flex_spacing_widget_EXAMPLE@
|
--@DOC_wibox_layout_flex_spacing_widget_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- @property spacing_widget
|
-- @property spacing_widget
|
||||||
-- @param widget
|
-- @tparam widget spacing_widget
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Add spacing between each layout widgets.
|
--- Add spacing between each layout widgets.
|
||||||
--
|
--
|
||||||
|
@ -55,6 +67,7 @@ local flex = {}
|
||||||
--
|
--
|
||||||
-- @property spacing
|
-- @property spacing
|
||||||
-- @tparam number spacing Spacing between widgets.
|
-- @tparam number spacing Spacing between widgets.
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function flex:layout(_, width, height)
|
function flex:layout(_, width, height)
|
||||||
local result = {}
|
local result = {}
|
||||||
|
@ -146,14 +159,18 @@ function flex:fit(context, orig_width, orig_height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set the maximum size the widgets in this layout will take.
|
--- Set the maximum size the widgets in this layout will take.
|
||||||
|
--
|
||||||
--That is, maximum width for horizontal and maximum height for vertical.
|
--That is, maximum width for horizontal and maximum height for vertical.
|
||||||
|
--
|
||||||
-- @property max_widget_size
|
-- @property max_widget_size
|
||||||
-- @param number
|
-- @tparam number max_widget_size
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function flex:set_max_widget_size(val)
|
function flex:set_max_widget_size(val)
|
||||||
if self._private.max_widget_size ~= val then
|
if self._private.max_widget_size ~= val then
|
||||||
self._private.max_widget_size = val
|
self._private.max_widget_size = val
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::max_widget_size", val)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,22 +184,30 @@ local function get_layout(dir, widget1, ...)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a new horizontal flex layout. A flex layout shares the available space
|
--- Returns a new horizontal flex layout.
|
||||||
-- equally among all widgets. Widgets can be added via :add(widget).
|
--
|
||||||
|
-- A flex layout shares the available space.
|
||||||
|
-- equally among all widgets. Widgets can be added via `:add(widget)`.
|
||||||
|
--
|
||||||
-- @tparam widget ... Widgets that should be added to the layout.
|
-- @tparam widget ... Widgets that should be added to the layout.
|
||||||
-- @constructorfct wibox.layout.flex.horizontal
|
-- @constructorfct wibox.layout.flex.horizontal
|
||||||
function flex.horizontal(...)
|
function flex.horizontal(...)
|
||||||
return get_layout("horizontal", ...)
|
return get_layout("horizontal", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Returns a new vertical flex layout. A flex layout shares the available space
|
--- Returns a new vertical flex layout.
|
||||||
-- equally among all widgets. Widgets can be added via :add(widget).
|
--
|
||||||
|
-- A flex layout shares the available space
|
||||||
|
-- equally among all widgets. Widgets can be added via `:add(widget)`.
|
||||||
|
--
|
||||||
-- @tparam widget ... Widgets that should be added to the layout.
|
-- @tparam widget ... Widgets that should be added to the layout.
|
||||||
-- @constructorfct wibox.layout.flex.vertical
|
-- @constructorfct wibox.layout.flex.vertical
|
||||||
function flex.vertical(...)
|
function flex.vertical(...)
|
||||||
return get_layout("vertical", ...)
|
return get_layout("vertical", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@DOC_fixed_COMMON@
|
||||||
|
|
||||||
--@DOC_widget_COMMON@
|
--@DOC_widget_COMMON@
|
||||||
|
|
||||||
--@DOC_object_COMMON@
|
--@DOC_object_COMMON@
|
||||||
|
|
|
@ -959,6 +959,8 @@ function grid.mt:__call(...)
|
||||||
return new(...)
|
return new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@DOC_fixed_COMMON@
|
||||||
|
|
||||||
--@DOC_widget_COMMON@
|
--@DOC_widget_COMMON@
|
||||||
|
|
||||||
--@DOC_object_COMMON@
|
--@DOC_object_COMMON@
|
||||||
|
|
|
@ -18,21 +18,26 @@ local manual_layout = {}
|
||||||
--- Add some widgets to the given stack layout.
|
--- Add some widgets to the given stack layout.
|
||||||
--
|
--
|
||||||
-- @method add
|
-- @method add
|
||||||
-- @param layout The layout you are modifying.
|
|
||||||
-- @tparam widget ... Widgets that should be added
|
-- @tparam widget ... Widgets that should be added
|
||||||
|
|
||||||
--- Remove a widget from the layout.
|
--- Remove a widget from the layout.
|
||||||
--
|
--
|
||||||
-- @method remove
|
-- @method remove
|
||||||
-- @tparam index The widget index to remove
|
-- @tparam number index The widget index to remove
|
||||||
-- @treturn boolean index If the operation is successful
|
-- @treturn boolean index If the operation is successful
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Insert a new widget in the layout at position `index`.
|
--- Insert a new widget in the layout at position `index`.
|
||||||
--
|
--
|
||||||
-- @method insert
|
-- @method insert
|
||||||
-- @tparam number index The position
|
-- @tparam number index The position
|
||||||
-- @param widget The widget
|
-- @tparam widget widget The widget
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful.
|
||||||
|
-- @emits widget::inserted
|
||||||
|
-- @emitstparam widget::inserted widget self The fixed layout.
|
||||||
|
-- @emitstparam widget::inserted widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::inserted number count The widget count.
|
||||||
|
-- @interface layout
|
||||||
function manual_layout:insert(index, widget)
|
function manual_layout:insert(index, widget)
|
||||||
table.insert(self._private.widgets, index, widget)
|
table.insert(self._private.widgets, index, widget)
|
||||||
|
|
||||||
|
@ -41,6 +46,8 @@ function manual_layout:insert(index, widget)
|
||||||
table.insert(self._private.pos, index, widget.point)
|
table.insert(self._private.pos, index, widget.point)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:emit_signal("widget::inserted", widget, #self._private.widgets)
|
||||||
|
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -50,7 +57,7 @@ end
|
||||||
-- widget(s) to remove.
|
-- widget(s) to remove.
|
||||||
--
|
--
|
||||||
-- @method remove_widgets
|
-- @method remove_widgets
|
||||||
-- @param widget ... Widgets that should be removed (must at least be one)
|
-- @tparam widget ... Widgets that should be removed (must at least be one)
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,6 +184,7 @@ function manual_layout:add_at(widget, point)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Move a widget (by index).
|
--- Move a widget (by index).
|
||||||
|
--
|
||||||
-- @method move
|
-- @method move
|
||||||
-- @tparam number index The widget index.
|
-- @tparam number index The widget index.
|
||||||
-- @tparam table|function point A new point value.
|
-- @tparam table|function point A new point value.
|
||||||
|
@ -219,6 +227,7 @@ function manual_layout:reset()
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a manual layout.
|
--- Create a manual layout.
|
||||||
|
--
|
||||||
-- @constructorfct wibox.layout.manual
|
-- @constructorfct wibox.layout.manual
|
||||||
-- @tparam table ... Widgets to add to the layout.
|
-- @tparam table ... Widgets to add to the layout.
|
||||||
|
|
||||||
|
@ -234,6 +243,7 @@ local function new_manual(...)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@DOC_fixed_COMMON@
|
||||||
|
|
||||||
--@DOC_widget_COMMON@
|
--@DOC_widget_COMMON@
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,6 @@ local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility
|
||||||
|
|
||||||
local ratio = {}
|
local ratio = {}
|
||||||
|
|
||||||
--@DOC_fixed_COMMON@
|
|
||||||
|
|
||||||
--- The widget used to fill the spacing between the layout elements.
|
--- The widget used to fill the spacing between the layout elements.
|
||||||
--
|
--
|
||||||
-- By default, no widget is used.
|
-- By default, no widget is used.
|
||||||
|
@ -29,7 +27,9 @@ local ratio = {}
|
||||||
--@DOC_wibox_layout_ratio_spacing_widget_EXAMPLE@
|
--@DOC_wibox_layout_ratio_spacing_widget_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- @property spacing_widget
|
-- @property spacing_widget
|
||||||
-- @param widget
|
-- @tparam widget spacing_widget
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Add spacing between each layout widgets.
|
--- Add spacing between each layout widgets.
|
||||||
--
|
--
|
||||||
|
@ -37,6 +37,8 @@ local ratio = {}
|
||||||
--
|
--
|
||||||
-- @property spacing
|
-- @property spacing
|
||||||
-- @tparam number spacing Spacing between widgets.
|
-- @tparam number spacing Spacing between widgets.
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
-- Compute the sum of all ratio (ideally, it should be 1).
|
-- Compute the sum of all ratio (ideally, it should be 1).
|
||||||
local function gen_sum(self, i_s, i_e)
|
local function gen_sum(self, i_s, i_e)
|
||||||
|
@ -227,7 +229,7 @@ end
|
||||||
-- do nothing.
|
-- do nothing.
|
||||||
--
|
--
|
||||||
-- @method inc_widget_ratio
|
-- @method inc_widget_ratio
|
||||||
-- @param widget The widget to ajust
|
-- @tparam widget widget The widget to ajust
|
||||||
-- @tparam number increment An floating point value between -1 and 1 where the
|
-- @tparam number increment An floating point value between -1 and 1 where the
|
||||||
-- end result is within 0 and 1
|
-- end result is within 0 and 1
|
||||||
function ratio:inc_widget_ratio(widget, increment)
|
function ratio:inc_widget_ratio(widget, increment)
|
||||||
|
@ -336,7 +338,7 @@ end
|
||||||
--- Update all widgets to match a set of a ratio.
|
--- Update all widgets to match a set of a ratio.
|
||||||
--
|
--
|
||||||
-- @method ajust_widget_ratio
|
-- @method ajust_widget_ratio
|
||||||
-- @param widget The widget to ajust
|
-- @tparam widget widget The widget to ajust
|
||||||
-- @tparam number before The sum of the ratio before the widget
|
-- @tparam number before The sum of the ratio before the widget
|
||||||
-- @tparam number itself The ratio for "widget"
|
-- @tparam number itself The ratio for "widget"
|
||||||
-- @tparam number after The sum of the ratio after the widget
|
-- @tparam number after The sum of the ratio after the widget
|
||||||
|
@ -347,9 +349,10 @@ end
|
||||||
|
|
||||||
--- Add some widgets to the given fixed layout.
|
--- Add some widgets to the given fixed layout.
|
||||||
--
|
--
|
||||||
-- **Signal:** widget::added The argument are the widgets
|
|
||||||
-- @method add
|
-- @method add
|
||||||
-- @tparam widget ... Widgets that should be added (must at least be one)
|
-- @tparam widget ... Widgets that should be added (must at least be one)
|
||||||
|
-- @emits widget::added All new widgets are passed in the parameters.
|
||||||
|
-- @emitstparam widget::added widget self The layout.
|
||||||
function ratio:add(...)
|
function ratio:add(...)
|
||||||
-- No table.pack in Lua 5.1 :-(
|
-- No table.pack in Lua 5.1 :-(
|
||||||
local args = { n=select('#', ...), ... }
|
local args = { n=select('#', ...), ... }
|
||||||
|
@ -367,10 +370,13 @@ end
|
||||||
|
|
||||||
--- Remove a widget from the layout.
|
--- Remove a widget from the layout.
|
||||||
--
|
--
|
||||||
-- **Signal:** widget::removed The arguments are the widget and the index
|
|
||||||
-- @method remove
|
-- @method remove
|
||||||
-- @tparam number index The widget index to remove
|
-- @tparam number index The widget index to remove
|
||||||
-- @treturn boolean index If the operation is successful
|
-- @treturn boolean index If the operation is successful
|
||||||
|
-- @emits widget::removed
|
||||||
|
-- @emitstparam widget::removed widget self The fixed layout.
|
||||||
|
-- @emitstparam widget::removed widget widget index The removed widget.
|
||||||
|
-- @emitstparam widget::removed number index The removed index.
|
||||||
function ratio:remove(index)
|
function ratio:remove(index)
|
||||||
if not index or not self._private.widgets[index] then return false end
|
if not index or not self._private.widgets[index] then return false end
|
||||||
|
|
||||||
|
@ -388,11 +394,14 @@ function ratio:remove(index)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Insert a new widget in the layout at position `index`.
|
--- Insert a new widget in the layout at position `index`.
|
||||||
-- **Signal:** widget::inserted The arguments are the widget and the index
|
|
||||||
--
|
--
|
||||||
-- @method insert
|
-- @method insert
|
||||||
-- @tparam number index The position
|
-- @tparam number index The position.
|
||||||
-- @param widget The widget
|
-- @tparam widget widget The widget.
|
||||||
|
-- @emits widget::inserted
|
||||||
|
-- @emitstparam widget::inserted widget self The ratio layout.
|
||||||
|
-- @emitstparam widget::inserted widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::inserted number count The widget count.
|
||||||
function ratio:insert(index, widget)
|
function ratio:insert(index, widget)
|
||||||
if not index or index < 1 or index > #self._private.widgets + 1 then return false end
|
if not index or index < 1 or index > #self._private.widgets + 1 then return false end
|
||||||
|
|
||||||
|
@ -422,6 +431,7 @@ end
|
||||||
--
|
--
|
||||||
-- @property inner_fill_strategy
|
-- @property inner_fill_strategy
|
||||||
-- @tparam string inner_fill_strategy One of the value listed above.
|
-- @tparam string inner_fill_strategy One of the value listed above.
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function ratio:get_inner_fill_strategy()
|
function ratio:get_inner_fill_strategy()
|
||||||
return self._private.inner_fill_strategy or "default"
|
return self._private.inner_fill_strategy or "default"
|
||||||
|
@ -442,6 +452,7 @@ function ratio:set_inner_fill_strategy(strategy)
|
||||||
|
|
||||||
self._private.inner_fill_strategy = strategy
|
self._private.inner_fill_strategy = strategy
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::inner_fill_strategy", strategy)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_layout(dir, widget1, ...)
|
local function get_layout(dir, widget1, ...)
|
||||||
|
@ -472,6 +483,8 @@ function ratio.vertical(...)
|
||||||
return get_layout("vertical", ...)
|
return get_layout("vertical", ...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@DOC_fixed_COMMON@
|
||||||
|
|
||||||
--@DOC_widget_COMMON@
|
--@DOC_widget_COMMON@
|
||||||
|
|
||||||
--@DOC_object_COMMON@
|
--@DOC_object_COMMON@
|
||||||
|
|
|
@ -22,35 +22,48 @@ local gtable = require("gears.table")
|
||||||
|
|
||||||
local stack = {mt={}}
|
local stack = {mt={}}
|
||||||
|
|
||||||
--@DOC_fixed_COMMON@
|
|
||||||
|
|
||||||
--- Add some widgets to the given stack layout.
|
--- Add some widgets to the given stack layout.
|
||||||
-- @param layout The layout you are modifying.
|
--
|
||||||
-- @tparam widget ... Widgets that should be added (must at least be one)
|
-- @tparam widget ... Widgets that should be added (must at least be one)
|
||||||
-- @method add
|
-- @method add
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Remove a widget from the layout
|
--- Remove a widget from the layout.
|
||||||
|
--
|
||||||
-- @tparam index The widget index to remove
|
-- @tparam index The widget index to remove
|
||||||
-- @treturn boolean index If the operation is successful
|
-- @treturn boolean index If the operation is successful
|
||||||
-- @method remove
|
-- @method remove
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Insert a new widget in the layout at position `index`.
|
--- Insert a new widget in the layout at position `index`.
|
||||||
|
--
|
||||||
-- @tparam number index The position
|
-- @tparam number index The position
|
||||||
-- @param widget The widget
|
-- @tparam widget widget The widget
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method insert
|
-- @method insert
|
||||||
|
-- @emits widget::inserted
|
||||||
|
-- @emitstparam widget::inserted widget self The fixed layout.
|
||||||
|
-- @emitstparam widget::inserted widget widget index The inserted widget.
|
||||||
|
-- @emitstparam widget::inserted number count The widget count.
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Remove one or more widgets from the layout.
|
--- Remove one or more widgets from the layout.
|
||||||
|
--
|
||||||
-- The last parameter can be a boolean, forcing a recursive seach of the
|
-- The last parameter can be a boolean, forcing a recursive seach of the
|
||||||
-- widget(s) to remove.
|
-- widget(s) to remove.
|
||||||
-- @param widget ... Widgets that should be removed (must at least be one)
|
--
|
||||||
|
-- @tparam widget widget ... Widgets that should be removed (must at least be one)
|
||||||
-- @treturn boolean If the operation is successful
|
-- @treturn boolean If the operation is successful
|
||||||
-- @method remove_widgets
|
-- @method remove_widgets
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
--- Add spacing around the widget, similar to the margin container.
|
--- Add spacing around the widget, similar to the margin container.
|
||||||
|
--
|
||||||
--@DOC_wibox_layout_stack_spacing_EXAMPLE@
|
--@DOC_wibox_layout_stack_spacing_EXAMPLE@
|
||||||
-- @property spacing
|
-- @property spacing
|
||||||
-- @tparam number spacing Spacing between widgets.
|
-- @tparam number spacing Spacing between widgets.
|
||||||
|
-- @propemits true false
|
||||||
|
-- @interface layout
|
||||||
|
|
||||||
function stack:layout(_, width, height)
|
function stack:layout(_, width, height)
|
||||||
local result = {}
|
local result = {}
|
||||||
|
@ -83,7 +96,10 @@ function stack:fit(context, orig_width, orig_height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- If only the first stack widget is drawn.
|
--- If only the first stack widget is drawn.
|
||||||
|
--
|
||||||
-- @property top_only
|
-- @property top_only
|
||||||
|
-- @tparam boolean top_only
|
||||||
|
-- @propemits true false
|
||||||
|
|
||||||
function stack:get_top_only()
|
function stack:get_top_only()
|
||||||
return self._private.top_only
|
return self._private.top_only
|
||||||
|
@ -91,9 +107,12 @@ end
|
||||||
|
|
||||||
function stack:set_top_only(top_only)
|
function stack:set_top_only(top_only)
|
||||||
self._private.top_only = top_only
|
self._private.top_only = top_only
|
||||||
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::top_only", top_only)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Raise a widget at `index` to the top of the stack.
|
--- Raise a widget at `index` to the top of the stack.
|
||||||
|
--
|
||||||
-- @method raise
|
-- @method raise
|
||||||
-- @tparam number index the widget index to raise
|
-- @tparam number index the widget index to raise
|
||||||
function stack:raise(index)
|
function stack:raise(index)
|
||||||
|
@ -107,8 +126,9 @@ function stack:raise(index)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Raise the first instance of `widget`.
|
--- Raise the first instance of `widget`.
|
||||||
|
--
|
||||||
-- @method raise_widget
|
-- @method raise_widget
|
||||||
-- @param widget The widget to raise
|
-- @tparam widget widget The widget to raise
|
||||||
-- @tparam[opt=false] boolean recursive Also look deeper in the hierarchy to
|
-- @tparam[opt=false] boolean recursive Also look deeper in the hierarchy to
|
||||||
-- find the widget
|
-- find the widget
|
||||||
function stack:raise_widget(widget, recursive)
|
function stack:raise_widget(widget, recursive)
|
||||||
|
@ -134,7 +154,9 @@ end
|
||||||
--@DOC_wibox_layout_stack_offset_EXAMPLE@
|
--@DOC_wibox_layout_stack_offset_EXAMPLE@
|
||||||
--
|
--
|
||||||
-- @property horizontal_offset
|
-- @property horizontal_offset
|
||||||
-- @param number
|
-- @tparam number horizontal_offset
|
||||||
|
-- @propemits true false
|
||||||
|
-- @see vertial_offset
|
||||||
|
|
||||||
--- Add an vertical offset to each layers.
|
--- Add an vertical offset to each layers.
|
||||||
--
|
--
|
||||||
|
@ -142,20 +164,24 @@ end
|
||||||
-- layers offsets.
|
-- layers offsets.
|
||||||
--
|
--
|
||||||
-- @property vertial_offset
|
-- @property vertial_offset
|
||||||
-- @param number
|
-- @tparam number vertial_offset
|
||||||
|
-- @propemits true false
|
||||||
-- @see horizontal_offset
|
-- @see horizontal_offset
|
||||||
|
|
||||||
function stack:set_horizontal_offset(value)
|
function stack:set_horizontal_offset(value)
|
||||||
self._private.h_offset = value
|
self._private.h_offset = value
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::horizontal_offset")
|
||||||
|
self:emit_signal("property::top_only", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function stack:set_vertical_offset(value)
|
function stack:set_vertical_offset(value)
|
||||||
self._private.v_offset = value
|
self._private.v_offset = value
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
self:emit_signal("property::vertical_offset", value)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Create a new stack layout.
|
--- Create a new stack layout.
|
||||||
|
--
|
||||||
-- @constructorfct wibox.layout.stack
|
-- @constructorfct wibox.layout.stack
|
||||||
-- @treturn widget A new stack layout
|
-- @treturn widget A new stack layout
|
||||||
|
|
||||||
|
@ -174,6 +200,8 @@ function stack.mt:__call(_, ...)
|
||||||
return new(...)
|
return new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--@DOC_fixed_COMMON@
|
||||||
|
|
||||||
--@DOC_widget_COMMON@
|
--@DOC_widget_COMMON@
|
||||||
|
|
||||||
--@DOC_object_COMMON@
|
--@DOC_object_COMMON@
|
||||||
|
|
Loading…
Reference in New Issue