doc: Modernize the widget doc.

This hass the following tags:

 * @interface
 * @tparam
 * @propbeautiful
 * @propemits
 * @renamedin

Beside tags, it adds some comments, fix formatting and add
new lines and dots where they belong.

Also add some signals to standardize everything.
This commit is contained in:
Emmanuel Lepage Vallee 2019-11-29 00:33:44 -05:00
parent 095e50b687
commit be14666b4a
10 changed files with 379 additions and 80 deletions

View File

@ -20,41 +20,50 @@ local gtable = require( "gears.table" )
local checkbox = {} local checkbox = {}
--- The outer (unchecked area) border width. --- The outer (unchecked area) border width.
--
-- @beautiful beautiful.checkbox_border_width -- @beautiful beautiful.checkbox_border_width
-- @param number -- @param number
--- The outer (unchecked area) background color, pattern or gradient. --- The outer (unchecked area) background color, pattern or gradient.
--
-- @beautiful beautiful.checkbox_bg -- @beautiful beautiful.checkbox_bg
-- @param color -- @param color
--- The outer (unchecked area) border color. --- The outer (unchecked area) border color.
--
-- @beautiful beautiful.checkbox_border_color -- @beautiful beautiful.checkbox_border_color
-- @param color -- @param color
--- The checked part border color. --- The checked part border color.
--
-- @beautiful beautiful.checkbox_check_border_color -- @beautiful beautiful.checkbox_check_border_color
-- @param color -- @param color
--- The checked part border width. --- The checked part border width.
--
-- @beautiful beautiful.checkbox_check_border_width -- @beautiful beautiful.checkbox_check_border_width
-- @param number -- @param number
--- The checked part filling color. --- The checked part filling color.
--
-- @beautiful beautiful.checkbox_check_color -- @beautiful beautiful.checkbox_check_color
-- @param number -- @param number
--- The outer (unchecked area) shape. --- The outer (unchecked area) shape.
--
-- @beautiful beautiful.checkbox_shape -- @beautiful beautiful.checkbox_shape
-- @tparam gears.shape shape -- @tparam gears.shape|function shape
-- @see gears.shape -- @see gears.shape
--- The checked part shape. --- The checked part shape.
--
-- If none is set, then the `shape` property will be used. -- If none is set, then the `shape` property will be used.
-- @beautiful beautiful.checkbox_check_shape -- @beautiful beautiful.checkbox_check_shape
-- @tparam gears.shape shape -- @tparam gears.shape|function shape
-- @see gears.shape -- @see gears.shape
--- The padding between the outline and the progressbar. --- The padding between the outline and the progressbar.
--
-- @beautiful beautiful.checkbox_paddings -- @beautiful beautiful.checkbox_paddings
-- @tparam[opt=0] table|number paddings A number or a table -- @tparam[opt=0] table|number paddings A number or a table
-- @tparam[opt=0] number paddings.top -- @tparam[opt=0] number paddings.top
@ -63,6 +72,7 @@ local checkbox = {}
-- @tparam[opt=0] number paddings.right -- @tparam[opt=0] number paddings.right
--- The checkbox color. --- The checkbox color.
--
-- This will be used for the unchecked part border color and the checked part -- This will be used for the unchecked part border color and the checked part
-- filling color. Note that `check_color` and `border_color` have priority -- filling color. Note that `check_color` and `border_color` have priority
-- over this property. -- over this property.
@ -70,57 +80,87 @@ local checkbox = {}
-- @param color -- @param color
--- The outer (unchecked area) border width. --- The outer (unchecked area) border width.
--
-- @property border_width -- @property border_width
-- @param number -- @tparam number border_width
-- @propbeautiful
-- @propemits true false
--- The outer (unchecked area) background color, pattern or gradient. --- The outer (unchecked area) background color, pattern or gradient.
--
--@DOC_wibox_widget_checkbox_bg_EXAMPLE@ --@DOC_wibox_widget_checkbox_bg_EXAMPLE@
-- @property bg -- @property bg
-- @param color -- @tparam color bg
-- @propbeautiful
-- @propemits true false
--- The outer (unchecked area) border color. --- The outer (unchecked area) border color.
--
-- @property border_color -- @property border_color
-- @param color -- @tparam color border_color
-- @propbeautiful
-- @propemits true false
--- The checked part border color. --- The checked part border color.
--
-- @property check_border_color -- @property check_border_color
-- @param color -- @tparam color check_border_color
-- @propbeautiful
-- @propemits true false
--- The checked part border width. --- The checked part border width.
--
-- @property check_border_width -- @property check_border_width
-- @param number -- @tparam number check_border_width
-- @propbeautiful
-- @propemits true false
--- The checked part filling color. --- The checked part filling color.
--
-- @property check_color -- @property check_color
-- @param color -- @tparam color check_color
-- @propbeautiful
-- @propemits true false
--- The outer (unchecked area) shape. --- The outer (unchecked area) shape.
--
--@DOC_wibox_widget_checkbox_shape_EXAMPLE@ --@DOC_wibox_widget_checkbox_shape_EXAMPLE@
-- @property shape -- @property shape
-- @tparam gears.shape shape -- @tparam gears.shape shape
-- @propbeautiful
-- @propemits true false
-- @see gears.shape -- @see gears.shape
--- The checked part shape. --- The checked part shape.
--
-- If none is set, then the `shape` property will be used. -- If none is set, then the `shape` property will be used.
--@DOC_wibox_widget_checkbox_check_shape_EXAMPLE@ --@DOC_wibox_widget_checkbox_check_shape_EXAMPLE@
-- @property check_shape -- @property check_shape
-- @tparam gears.shape shape -- @tparam gears.shape shape
-- @propbeautiful
-- @propemits true false
-- @see gears.shape -- @see gears.shape
--- The padding between the outline and the progressbar. --- The padding between the outline and the progressbar.
--
-- @property paddings -- @property paddings
-- @tparam[opt=0] table|number paddings A number or a table -- @tparam[opt=0] table|number paddings A number or a table
-- @tparam[opt=0] number paddings.top -- @tparam[opt=0] number paddings.top
-- @tparam[opt=0] number paddings.bottom -- @tparam[opt=0] number paddings.bottom
-- @tparam[opt=0] number paddings.left -- @tparam[opt=0] number paddings.left
-- @tparam[opt=0] number paddings.right -- @tparam[opt=0] number paddings.right
-- @propbeautiful
-- @propemits false false
--- The checkbox color. --- The checkbox color.
--
-- This will be used for the unchecked part border color and the checked part -- This will be used for the unchecked part border color and the checked part
-- filling color. Note that `check_color` and `border_color` have priority -- filling color. Note that `check_color` and `border_color` have priority
-- over this property. -- over this property.
-- @property color -- @property color
-- @param color -- @tparam color color
-- @propbeautiful
-- @propemits true false
local function outline_workarea(self, width, height) local function outline_workarea(self, width, height)
local offset = (self._private.border_width or local offset = (self._private.border_width or
@ -220,7 +260,7 @@ for _, prop in ipairs {"border_width", "bg", "border_color", "check_border_color
"checked", "color" } do "checked", "color" } do
checkbox["set_"..prop] = function(self, value) checkbox["set_"..prop] = function(self, value)
self._private[prop] = value self._private[prop] = value
self:emit_signal("property::"..prop) self:emit_signal("property::"..prop, value)
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
end end
checkbox["get_"..prop] = function(self) checkbox["get_"..prop] = function(self)

View File

@ -28,41 +28,53 @@ local beautiful = require("beautiful")
local graph = { mt = {} } local graph = { mt = {} }
--- Set the graph border color. --- Set the graph border color.
--
-- If the value is nil, no border will be drawn. -- If the value is nil, no border will be drawn.
-- --
-- @property border_color -- @property border_color
-- @tparam gears.color border_color The border color to set. -- @tparam gears.color border_color The border color to set.
-- @propbeautiful
-- @propemits true false
-- @see gears.color -- @see gears.color
--- Set the graph foreground color. --- Set the graph foreground color.
-- --
-- @property color -- @property color
-- @tparam color color The graph color. -- @tparam color color The graph color.
-- @usebeautiful beautiful.graph_fg
-- @propemits true false
-- @see gears.color -- @see gears.color
--- Set the graph background color. --- Set the graph background color.
-- --
-- @property background_color -- @property background_color
-- @tparam gears.color background_color The graph background color. -- @tparam gears.color background_color The graph background color.
-- @usebeautiful beautiful.graph_bg
-- @propemits true false
-- @see gears.color -- @see gears.color
--- Set the maximum value the graph should handle. --- Set the maximum value the graph should handle.
--
-- If "scale" is also set, the graph never scales up below this value, but it -- If "scale" is also set, the graph never scales up below this value, but it
-- automatically scales down to make all data fit. -- automatically scales down to make all data fit.
-- --
-- @property max_value -- @property max_value
-- @param number -- @tparam number max_value
-- @propemits true false
--- The minimum value. --- The minimum value.
--
-- Note that the min_value is not supported when used along with the stack -- Note that the min_value is not supported when used along with the stack
-- property. -- property.
-- @property min_value -- @property min_value
-- @param number -- @tparam number min_value
-- @propemits true false
--- Set the graph to automatically scale its values. Default is false. --- Set the graph to automatically scale its values. Default is false.
-- --
-- @property scale -- @property scale
-- @param boolean -- @tparam boolean scale
-- @propemits true false
--- Set the width or the individual steps. --- Set the width or the individual steps.
-- --
@ -71,39 +83,47 @@ local graph = { mt = {} }
--@DOC_wibox_widget_graph_step_EXAMPLE@ --@DOC_wibox_widget_graph_step_EXAMPLE@
-- --
-- @property step_width -- @property step_width
-- @param[opt=1] number -- @tparam[opt=1] number step_width
-- @propemits true false
--- Set the spacing between the steps. --- Set the spacing between the steps.
-- --
-- Note that it isn't supported when used along with stacked graphs. -- Note that it isn't supported when used along with stacked graphs.
-- --
-- @property step_spacing -- @property step_spacing
-- @param[opt=0] number -- @tparam[opt=0] number step_spacing
-- @propemits true false
--- The step shape. --- The step shape.
--
-- @property step_shape -- @property step_shape
-- @param[opt=rectangle] shape -- @tparam[opt=rectangle] gears.shape|function step_shape
-- @propemits true false
-- @see gears.shape -- @see gears.shape
--- Set the graph to draw stacks. Default is false. --- Set the graph to draw stacks. Default is false.
-- --
-- @property stack -- @property stack
-- @param boolean -- @tparam boolean stack
-- @propemits true false
--- Set the graph stacking colors. Order matters. --- Set the graph stacking colors. Order matters.
-- --
-- @property stack_colors -- @property stack_colors
-- @param stack_colors A table with stacking colors. -- @tparam table stack_colors A table with stacking colors.
--- The graph background color. --- The graph background color.
--
-- @beautiful beautiful.graph_bg -- @beautiful beautiful.graph_bg
-- @param color -- @param color
--- The graph foreground color. --- The graph foreground color.
--
-- @beautiful beautiful.graph_fg -- @beautiful beautiful.graph_fg
-- @param color -- @param color
--- The graph border color. --- The graph border color.
--
-- @beautiful beautiful.graph_border_color -- @beautiful beautiful.graph_border_color
-- @param color -- @param color
@ -235,8 +255,8 @@ end
--- Add a value to the graph --- Add a value to the graph
-- --
-- @method add_value -- @method add_value
-- @param value The value to be added to the graph -- @tparam number value The value to be added to the graph
-- @param group The stack color group index. -- @tparam[opt] number group The stack color group index.
function graph:add_value(value, group) function graph:add_value(value, group)
value = value or 0 value = value or 0
local values = self._private.values local values = self._private.values
@ -269,6 +289,7 @@ function graph:add_value(value, group)
end end
--- Clear the graph. --- Clear the graph.
--
-- @method clear -- @method clear
function graph:clear() function graph:clear()
self._private.values = {} self._private.values = {}
@ -277,25 +298,31 @@ function graph:clear()
end end
--- Set the graph height. --- Set the graph height.
--
-- @property height -- @property height
-- @param number The height to set. -- @tparam number height The height to set.
-- @propemits true false
function graph:set_height(height) function graph:set_height(height)
if height >= 5 then if height >= 5 then
self._private.height = height self._private.height = height
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::height", height)
end end
return self return self
end end
--- Set the graph width. --- Set the graph width.
--
-- @property width -- @property width
-- @param number The width to set. -- @param number width The width to set.
-- @propemits true false
function graph:set_width(width) function graph:set_width(width)
if width >= 5 then if width >= 5 then
self._private.width = width self._private.width = width
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::width", width)
end end
return self return self
end end
@ -307,6 +334,7 @@ for _, prop in ipairs(properties) do
if _graph._private[prop] ~= value then if _graph._private[prop] ~= value then
_graph._private[prop] = value _graph._private[prop] = value
_graph:emit_signal("widget::redraw_needed") _graph:emit_signal("widget::redraw_needed")
_graph:emit_signal("property::"..prop, value)
end end
return _graph return _graph
end end
@ -319,9 +347,10 @@ for _, prop in ipairs(properties) do
end end
--- Create a graph widget. --- Create a graph widget.
-- @param args Standard widget() arguments. You should add width and height --
-- @tparam table args Standard widget() arguments. You should add width and height
-- key to set graph geometry. -- key to set graph geometry.
-- @return A new graph widget. -- @treturn wibox.widget.graph A new graph widget.
-- @constructorfct wibox.widget.graph -- @constructorfct wibox.widget.graph
function graph.new(args) function graph.new(args)
args = args or {} args = args or {}

View File

@ -153,6 +153,7 @@ end
-- --
-- @property image -- @property image
-- @tparam image image The image to render. -- @tparam image image The image to render.
-- @propemits false false
-- @see set_image -- @see set_image
--- Set the `imagebox` image. --- Set the `imagebox` image.
@ -201,6 +202,7 @@ function imagebox:set_image(image)
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::image")
return true return true
end end
@ -210,6 +212,7 @@ end
-- --
-- @property clip_shape -- @property clip_shape
-- @tparam function|gears.shape clip_shape A `gears.shape` compatible shape function. -- @tparam function|gears.shape clip_shape A `gears.shape` compatible shape function.
-- @propemits true false
-- @see gears.shape -- @see gears.shape
-- @see set_clip_shape -- @see set_clip_shape
@ -227,11 +230,13 @@ function imagebox:set_clip_shape(clip_shape, ...)
self._private.clip_shape = clip_shape self._private.clip_shape = clip_shape
self._private.clip_args = {...} self._private.clip_args = {...}
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("property::clip_shape", clip_shape)
end end
--- Should the image be resized to fit into the available space? --- Should the image be resized to fit into the available space?
-- @DOC_wibox_widget_imagebox_resize_EXAMPLE@ -- @DOC_wibox_widget_imagebox_resize_EXAMPLE@
-- @property resize -- @property resize
-- @propemits true false
-- @tparam boolean resize -- @tparam boolean resize
--- Should the image be resized to fit into the available space? --- Should the image be resized to fit into the available space?
@ -242,6 +247,7 @@ function imagebox:set_resize(allowed)
self._private.resize_forbidden = not allowed self._private.resize_forbidden = not allowed
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::resize", allowed)
end end
--- Returns a new `wibox.widget.imagebox` instance. --- Returns a new `wibox.widget.imagebox` instance.

View File

@ -137,49 +137,68 @@ local function fit(_, _, width, height)
end end
--- The pie chart data list. --- The pie chart data list.
--
-- @property data_list -- @property data_list
-- @tparam table data_list Sorted table where each entry has a label as its -- @tparam table data_list Sorted table where each entry has a label as its
-- first value and a number as its second value. -- first value and a number as its second value.
-- @propemits false false
--- The pie chart data. --- The pie chart data.
--
-- @property data -- @property data
-- @tparam table data Labels as keys and number as value. -- @tparam table data Labels as keys and number as value.
-- @propemits false false
--- The border color. --- The border color.
--
-- If none is set, it will use current foreground (text) color. -- If none is set, it will use current foreground (text) color.
--
--@DOC_wibox_widget_piechart_border_color_EXAMPLE@ --@DOC_wibox_widget_piechart_border_color_EXAMPLE@
-- @property border_color -- @property border_color
-- @param color -- @tparam color border_color
-- @propemits true false
-- @propbeautiful
-- @see gears.color -- @see gears.color
--- The pie elements border width. --- The pie elements border width.
--
--@DOC_wibox_widget_piechart_border_width_EXAMPLE@ --@DOC_wibox_widget_piechart_border_width_EXAMPLE@
-- @property border_width -- @property border_width
-- @tparam[opt=1] number border_width -- @tparam[opt=1] number border_width
-- @propemits true false
-- @propbeautiful
--- The pie chart colors. --- The pie chart colors.
--
-- If no color is set, only the border will be drawn. If less colors than -- If no color is set, only the border will be drawn. If less colors than
-- required are set, colors will be re-used in order. -- required are set, colors will be re-used in order.
--
-- @property colors -- @property colors
-- @tparam table colors A table of colors, one for each elements -- @tparam table colors A table of colors, one for each elements.
-- @propemits true false
-- @propbeautiful
-- @see gears.color -- @see gears.color
--- The border color. --- The border color.
--
-- If none is set, it will use current foreground (text) color. -- If none is set, it will use current foreground (text) color.
-- @beautiful beautiful.piechart_border_color -- @beautiful beautiful.piechart_border_color
-- @param color -- @param color
-- @see gears.color -- @see gears.color
--- If the pie chart has labels. --- If the pie chart has labels.
--
--@DOC_wibox_widget_piechart_label_EXAMPLE@ --@DOC_wibox_widget_piechart_label_EXAMPLE@
-- @property display_labels -- @property display_labels
-- @param[opt=true] boolean -- @param[opt=true] boolean
--- The pie elements border width. --- The pie elements border width.
--
-- @beautiful beautiful.piechart_border_width -- @beautiful beautiful.piechart_border_width
-- @tparam[opt=1] number border_width -- @tparam[opt=1] number border_width
--- The pie chart colors. --- The pie chart colors.
--
-- If no color is set, only the border will be drawn. If less colors than -- If no color is set, only the border will be drawn. If less colors than
-- required are set, colors will be re-used in order. -- required are set, colors will be re-used in order.
-- @beautiful beautiful.piechart_colors -- @beautiful beautiful.piechart_colors
@ -194,6 +213,8 @@ for _, prop in ipairs {"data_list", "border_color", "border_width", "colors",
self:emit_signal("property::"..prop) self:emit_signal("property::"..prop)
if prop == "data_list" then if prop == "data_list" then
self:emit_signal("property::data") self:emit_signal("property::data")
else
self:emit_signal("property::"..prop, value)
end end
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
end end
@ -219,6 +240,7 @@ function piechart:get_data()
end end
--- Create a new piechart. --- Create a new piechart.
--
-- @constructorfct wibox.widget.piechart -- @constructorfct wibox.widget.piechart
-- @tparam table data_list The data. -- @tparam table data_list The data.

View File

@ -33,37 +33,53 @@ local gtable = require("gears.table")
local progressbar = { mt = {} } local progressbar = { mt = {} }
--- The progressbar border color. --- The progressbar border color.
--
-- If the value is nil, no border will be drawn. -- If the value is nil, no border will be drawn.
-- --
-- @property border_color -- @property border_color
-- @tparam gears.color color The border color to set. -- @tparam color color The border color to set.
-- @propemits true false
-- @propbeautiful
-- @see gears.color -- @see gears.color
--- The progressbar border width. --- The progressbar border width.
--
-- @property border_width -- @property border_width
-- @param number -- @tparam number border_width
-- @propemits true false
-- @propbeautiful
--- The progressbar inner border color. --- The progressbar inner border color.
--
-- If the value is nil, no border will be drawn. -- If the value is nil, no border will be drawn.
-- --
-- @property bar_border_color -- @property bar_border_color
-- @tparam gears.color color The border color to set. -- @tparam color color The border color to set.
-- @propemits true false
-- @propbeautiful
-- @see gears.color -- @see gears.color
--- The progressbar inner border width. --- The progressbar inner border width.
--
-- @property bar_border_width -- @property bar_border_width
-- @param number -- @tparam number bar_border_width
-- @propbeautiful
-- @propemits true false
--- The progressbar foreground color. --- The progressbar foreground color.
-- --
-- @property color -- @property color
-- @tparam gears.color color The progressbar color. -- @tparam color color The progressbar color.
-- @propemits true false
-- @usebeautiful beautiful.progressbar_fg
-- @see gears.color -- @see gears.color
--- The progressbar background color. --- The progressbar background color.
-- --
-- @property background_color -- @property background_color
-- @tparam gears.color color The progressbar background color. -- @tparam color color The progressbar background color.
-- @propemits true false
-- @usebeautiful beautiful.progressbar_bg
-- @see gears.color -- @see gears.color
--- The progressbar inner shape. --- The progressbar inner shape.
@ -72,6 +88,8 @@ local progressbar = { mt = {} }
-- --
-- @property bar_shape -- @property bar_shape
-- @tparam[opt=gears.shape.rectangle] gears.shape shape -- @tparam[opt=gears.shape.rectangle] gears.shape shape
-- @propemits true false
-- @propbeautiful
-- @see gears.shape -- @see gears.shape
--- The progressbar shape. --- The progressbar shape.
@ -80,12 +98,17 @@ local progressbar = { mt = {} }
-- --
-- @property shape -- @property shape
-- @tparam[opt=gears.shape.rectangle] gears.shape shape -- @tparam[opt=gears.shape.rectangle] gears.shape shape
-- @propemits true false
-- @propbeautiful
-- @see gears.shape -- @see gears.shape
--- Set the progressbar to draw vertically. --- Set the progressbar to draw vertically.
--
-- This doesn't do anything anymore, use a `wibox.container.rotate` widget. -- This doesn't do anything anymore, use a `wibox.container.rotate` widget.
--
-- @deprecated set_vertical -- @deprecated set_vertical
-- @tparam boolean vertical -- @tparam boolean vertical
-- @deprecatedin 4.0
--- Force the inner part (the bar) to fit in the background shape. --- Force the inner part (the bar) to fit in the background shape.
-- --
@ -93,90 +116,110 @@ local progressbar = { mt = {} }
-- --
-- @property clip -- @property clip
-- @tparam[opt=true] boolean clip -- @tparam[opt=true] boolean clip
-- @propemits true false
--- The progressbar to draw ticks. Default is false. --- The progressbar to draw ticks. Default is false.
-- --
-- @property ticks -- @property ticks
-- @param boolean -- @tparam boolean ticks
-- @propemits true false
--- The progressbar ticks gap. --- The progressbar ticks gap.
-- --
-- @property ticks_gap -- @property ticks_gap
-- @param number -- @tparam number ticks_gap
-- @propemits true false
--- The progressbar ticks size. --- The progressbar ticks size.
-- --
-- @property ticks_size -- @property ticks_size
-- @param number -- @tparam number ticks_size
-- @propemits true false
--- The maximum value the progressbar should handle. --- The maximum value the progressbar should handle.
-- --
-- @property max_value -- @property max_value
-- @param number -- @tparam number max_value
-- @propemits true false
--- The progressbar background color. --- The progressbar background color.
--
-- @beautiful beautiful.progressbar_bg -- @beautiful beautiful.progressbar_bg
-- @param color -- @param color
--- The progressbar foreground color. --- The progressbar foreground color.
--
-- @beautiful beautiful.progressbar_fg -- @beautiful beautiful.progressbar_fg
-- @param color -- @param color
--- The progressbar shape. --- The progressbar shape.
--
-- @beautiful beautiful.progressbar_shape -- @beautiful beautiful.progressbar_shape
-- @tparam gears.shape shape -- @tparam gears.shape shape
-- @see gears.shape -- @see gears.shape
--- The progressbar border color. --- The progressbar border color.
--
-- @beautiful beautiful.progressbar_border_color -- @beautiful beautiful.progressbar_border_color
-- @param color -- @param color
--- The progressbar outer border width. --- The progressbar outer border width.
--
-- @beautiful beautiful.progressbar_border_width -- @beautiful beautiful.progressbar_border_width
-- @param number -- @param number
--- The progressbar inner shape. --- The progressbar inner shape.
--
-- @beautiful beautiful.progressbar_bar_shape -- @beautiful beautiful.progressbar_bar_shape
-- @tparam gears.shape shape -- @tparam gears.shape shape
-- @see gears.shape -- @see gears.shape
--- The progressbar bar border width. --- The progressbar bar border width.
--
-- @beautiful beautiful.progressbar_bar_border_width -- @beautiful beautiful.progressbar_bar_border_width
-- @param number -- @param number
--- The progressbar bar border color. --- The progressbar bar border color.
--
-- @beautiful beautiful.progressbar_bar_border_color -- @beautiful beautiful.progressbar_bar_border_color
-- @param color -- @param color
--- The progressbar margins. --- The progressbar margins.
--
-- Note that if the `clip` is disabled, this allows the background to be smaller -- Note that if the `clip` is disabled, this allows the background to be smaller
-- than the bar. -- than the bar.
-- --
-- See the `clip` example. -- See the `clip` example.
-- --
-- @property margins
-- @tparam[opt=0] (table|number|nil) margins A table for each side or a number -- @tparam[opt=0] (table|number|nil) margins A table for each side or a number
-- @tparam[opt=0] number margins.top -- @tparam[opt=0] number margins.top
-- @tparam[opt=0] number margins.bottom -- @tparam[opt=0] number margins.bottom
-- @tparam[opt=0] number margins.left -- @tparam[opt=0] number margins.left
-- @tparam[opt=0] number margins.right -- @tparam[opt=0] number margins.right
-- @property margins -- @propemits false false
-- @propbeautiful
-- @see clip -- @see clip
--- The progressbar padding. --- The progressbar padding.
--
-- Note that if the `clip` is disabled, this allows the bar to be taller -- Note that if the `clip` is disabled, this allows the bar to be taller
-- than the background. -- than the background.
-- --
-- See the `clip` example. -- See the `clip` example.
-- --
-- @property paddings
-- @tparam[opt=0] (table|number|nil) padding A table for each side or a number -- @tparam[opt=0] (table|number|nil) padding A table for each side or a number
-- @tparam[opt=0] number padding.top -- @tparam[opt=0] number padding.top
-- @tparam[opt=0] number padding.bottom -- @tparam[opt=0] number padding.bottom
-- @tparam[opt=0] number padding.left -- @tparam[opt=0] number padding.left
-- @tparam[opt=0] number padding.right -- @tparam[opt=0] number padding.right
-- @property paddings -- @propemits false false
-- @propbeautiful
-- @see clip -- @see clip
--- The progressbar margins. --- The progressbar margins.
--
-- Note that if the `clip` is disabled, this allows the background to be smaller -- Note that if the `clip` is disabled, this allows the background to be smaller
-- than the bar. -- than the bar.
-- @tparam[opt=0] (table|number|nil) margins A table for each side or a number -- @tparam[opt=0] (table|number|nil) margins A table for each side or a number
@ -188,6 +231,7 @@ local progressbar = { mt = {} }
-- @see clip -- @see clip
--- The progressbar padding. --- The progressbar padding.
--
-- Note that if the `clip` is disabled, this allows the bar to be taller -- Note that if the `clip` is disabled, this allows the bar to be taller
-- than the background. -- than the background.
-- @tparam[opt=0] (table|number|nil) padding A table for each side or a number -- @tparam[opt=0] (table|number|nil) padding A table for each side or a number
@ -378,8 +422,10 @@ function progressbar:fit(_, width, height)
end end
--- Set the progressbar value. --- Set the progressbar value.
--
-- @property value -- @property value
-- @param number The progress bar value between 0 and 1. -- @tparam number value The progress bar value between 0 and 1.
-- @propemits true false
function progressbar:set_value(value) function progressbar:set_value(value)
value = value or 0 value = value or 0
@ -398,20 +444,26 @@ function progressbar:set_max_value(max_value)
end end
--- Set the progressbar height. --- Set the progressbar height.
--
-- This method is deprecated. Use a `wibox.container.constraint` widget or -- This method is deprecated. Use a `wibox.container.constraint` widget or
-- `forced_height`. -- `forced_height`.
-- @param height The height to set. --
-- @tparam number height The height to set.
-- @deprecated set_height -- @deprecated set_height
-- @renamedin 4.0
function progressbar:set_height(height) function progressbar:set_height(height)
gdebug.deprecate("Use a `wibox.container.constraint` widget or `forced_height`", {deprecated_in=4}) gdebug.deprecate("Use a `wibox.container.constraint` widget or `forced_height`", {deprecated_in=4})
self:set_forced_height(height) self:set_forced_height(height)
end end
--- Set the progressbar width. --- Set the progressbar width.
--
-- This method is deprecated. Use a `wibox.container.constraint` widget or -- This method is deprecated. Use a `wibox.container.constraint` widget or
-- `forced_width`. -- `forced_width`.
-- @param width The width to set. --
-- @tparam number width The width to set.
-- @deprecated set_width -- @deprecated set_width
-- @renamedin 4.0
function progressbar:set_width(width) function progressbar:set_width(width)
gdebug.deprecate("Use a `wibox.container.constraint` widget or `forced_width`", {deprecated_in=4}) gdebug.deprecate("Use a `wibox.container.constraint` widget or `forced_width`", {deprecated_in=4})
self:set_forced_width(width) self:set_forced_width(width)
@ -423,9 +475,15 @@ for _, prop in ipairs(properties) do
progressbar["set_" .. prop] = function(pbar, value) progressbar["set_" .. prop] = function(pbar, value)
pbar._private[prop] = value pbar._private[prop] = value
pbar:emit_signal("widget::redraw_needed") pbar:emit_signal("widget::redraw_needed")
pbar:emit_signal("property::"..prop, value)
return pbar return pbar
end end
end end
if not progressbar["get_"..prop] then
progressbar["set_" .. prop] = function(pbar)
return pbar._private[prop]
end
end
end end
function progressbar:set_vertical(value) --luacheck: no unused_args function progressbar:set_vertical(value) --luacheck: no unused_args
@ -434,9 +492,12 @@ end
--- Create a progressbar widget. --- Create a progressbar widget.
-- @param args Standard widget() arguments. You should add width and height --
-- key to set progressbar geometry. -- @tparam table args Standard widget() arguments. You should add width and
-- @return A progressbar widget. -- height constructor parameters to set progressbar geometry.
-- @tparam number args.width The width.
-- @tparam number args.height The height.
-- @treturn wibox.widget.progressbar A progressbar widget.
-- @constructorfct wibox.widget.progressbar -- @constructorfct wibox.widget.progressbar
function progressbar.new(args) function progressbar.new(args)
args = args or {} args = args or {}

View File

@ -42,14 +42,17 @@ local separator = {}
--@DOC_wibox_widget_separator_orientation_EXAMPLE@ --@DOC_wibox_widget_separator_orientation_EXAMPLE@
-- --
-- @property orientation -- @property orientation
-- @param string -- @tparam string orientation
-- @propemits true false
--- The separator's thickness. --- The separator's thickness.
-- --
-- This is used by the default line separator, but ignored when a shape is used. -- This is used by the default line separator, but ignored when a shape is used.
-- --
-- @property thickness -- @property thickness
-- @param number -- @tparam number thickness
-- @propbeautiful
-- @propemits true false
--- The separator's shape. --- The separator's shape.
-- --
@ -57,15 +60,22 @@ local separator = {}
-- --
-- @property shape -- @property shape
-- @tparam function shape A valid shape function -- @tparam function shape A valid shape function
-- @propbeautiful
-- @propemits true false
-- @see gears.shape -- @see gears.shape
--- The relative percentage covered by the bar. --- The relative percentage covered by the bar.
--
-- @property span_ratio -- @property span_ratio
-- @tparam[opt=1] number A number between 0 and 1. -- @tparam[opt=1] number A number between 0 and 1.
-- @propbeautiful
-- @propemits true false
--- The separator's color. --- The separator's color.
-- @property color -- @property color
-- @param string -- @tparam color color
-- @propbeautiful
-- @propemits true false
-- @see gears.color -- @see gears.color
--- The separator's border color. --- The separator's border color.
@ -73,12 +83,16 @@ local separator = {}
--@DOC_wibox_widget_separator_border_color_EXAMPLE@ --@DOC_wibox_widget_separator_border_color_EXAMPLE@
-- --
-- @property border_color -- @property border_color
-- @param string -- @tparam color border_color
-- @propbeautiful
-- @propemits true false
-- @see gears.color -- @see gears.color
--- The separator's border width. --- The separator's border width.
-- @property border_width -- @property border_width
-- @param number -- @tparam number border_width
-- @propbeautiful
-- @propemits true false
--- The separator thickness. --- The separator thickness.
-- @beautiful beautiful.separator_thickness -- @beautiful beautiful.separator_thickness
@ -177,7 +191,7 @@ for _, prop in ipairs {"orientation", "color", "thickness", "span_ratio",
"border_width", "border_color", "shape" } do "border_width", "border_color", "shape" } do
separator["set_"..prop] = function(self, value) separator["set_"..prop] = function(self, value)
self._private[prop] = value self._private[prop] = value
self:emit_signal("property::"..prop) self:emit_signal("property::"..prop, value)
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
end end
separator["get_"..prop] = function(self) separator["get_"..prop] = function(self)

View File

@ -30,6 +30,8 @@ local slider = {mt={}}
-- --
-- @property handle_shape -- @property handle_shape
-- @tparam[opt=gears shape rectangle] gears.shape shape -- @tparam[opt=gears shape rectangle] gears.shape shape
-- @propemits true false
-- @propbeautiful
-- @see gears.shape -- @see gears.shape
--- The slider handle color. --- The slider handle color.
@ -37,7 +39,9 @@ local slider = {mt={}}
--@DOC_wibox_widget_slider_handle_color_EXAMPLE@ --@DOC_wibox_widget_slider_handle_color_EXAMPLE@
-- --
-- @property handle_color -- @property handle_color
-- @param color -- @propbeautiful
-- @tparam color handle_color
-- @propemits true false
--- The slider handle margins. --- The slider handle margins.
-- --
@ -49,24 +53,32 @@ local slider = {mt={}}
-- @tparam[opt=0] number margins.right -- @tparam[opt=0] number margins.right
-- @tparam[opt=0] number margins.top -- @tparam[opt=0] number margins.top
-- @tparam[opt=0] number margins.bottom -- @tparam[opt=0] number margins.bottom
-- @propemits true false
-- @propbeautiful
--- The slider handle width. --- The slider handle width.
-- --
--@DOC_wibox_widget_slider_handle_width_EXAMPLE@ --@DOC_wibox_widget_slider_handle_width_EXAMPLE@
-- --
-- @property handle_width -- @property handle_width
-- @param number -- @tparam number handle_width
-- @propemits true false
-- @propbeautiful
--- The handle border_color. --- The handle border_color.
-- --
--@DOC_wibox_widget_slider_handle_border_EXAMPLE@ --@DOC_wibox_widget_slider_handle_border_EXAMPLE@
-- --
-- @property handle_border_color -- @property handle_border_color
-- @param color -- @tparam color handle_border_color
-- @propemits true false
-- @propbeautiful
--- The handle border width. --- The handle border width.
-- @property handle_border_width -- @property handle_border_width
-- @param[opt=0] number -- @tparam[opt=0] number handle_border_width
-- @propemits true false
-- @propbeautiful
--- The bar (background) shape. --- The bar (background) shape.
-- --
@ -74,6 +86,8 @@ local slider = {mt={}}
-- --
-- @property bar_shape -- @property bar_shape
-- @tparam[opt=gears shape rectangle] gears.shape shape -- @tparam[opt=gears shape rectangle] gears.shape shape
-- @propemits true false
-- @propbeautiful
-- @see gears.shape -- @see gears.shape
--- The bar (background) height. --- The bar (background) height.
@ -81,14 +95,18 @@ local slider = {mt={}}
--@DOC_wibox_widget_slider_bar_height_EXAMPLE@ --@DOC_wibox_widget_slider_bar_height_EXAMPLE@
-- --
-- @property bar_height -- @property bar_height
-- @param number -- @tparam number bar_height
-- @propbeautiful
-- @propemits true false
--- The bar (background) color. --- The bar (background) color.
-- --
--@DOC_wibox_widget_slider_bar_color_EXAMPLE@ --@DOC_wibox_widget_slider_bar_color_EXAMPLE@
-- --
-- @property bar_color -- @property bar_color
-- @param color -- @tparam color bar_color
-- @propbeautiful
-- @propemits true false
--- The bar (active) color. --- The bar (active) color.
-- --
@ -96,7 +114,9 @@ local slider = {mt={}}
-- --
-- Only works when both `bar_active_color` and `bar_color` are passed as hex color string -- Only works when both `bar_active_color` and `bar_color` are passed as hex color string
-- @property bar_active_color -- @property bar_active_color
-- @param color -- @tparam color bar_active_color
-- @propbeautiful
-- @propemits true false
--- The bar (background) margins. --- The bar (background) margins.
-- --
@ -108,17 +128,22 @@ local slider = {mt={}}
-- @tparam[opt=0] number margins.right -- @tparam[opt=0] number margins.right
-- @tparam[opt=0] number margins.top -- @tparam[opt=0] number margins.top
-- @tparam[opt=0] number margins.bottom -- @tparam[opt=0] number margins.bottom
-- @propbeautiful
-- @propemits true false
--- The bar (background) border width. --- The bar (background) border width.
-- @property bar_border_width -- @property bar_border_width
-- @param[opt=0] numbergb -- @tparam[opt=0] number bar_border_width
-- @propemits true false
--- The bar (background) border_color. --- The bar (background) border_color.
-- --
--@DOC_wibox_widget_slider_bar_border_EXAMPLE@ --@DOC_wibox_widget_slider_bar_border_EXAMPLE@
-- --
-- @property bar_border_color -- @property bar_border_color
-- @param color -- @tparam color bar_border_color
-- @propbeautiful
-- @propemits true false
--- The slider value. --- The slider value.
-- --
@ -127,54 +152,70 @@ local slider = {mt={}}
--@DOC_wibox_widget_slider_value_EXAMPLE@ --@DOC_wibox_widget_slider_value_EXAMPLE@
-- --
-- @property value -- @property value
-- @param[opt=0] number -- @tparam[opt=0] number value
-- @propemits true false
--- The slider minimum value. --- The slider minimum value.
--
-- @property minimum -- @property minimum
-- @param[opt=0] number -- @tparam[opt=0] number minimum
-- @propemits true false
--- The slider maximum value. --- The slider maximum value.
--
-- @property maximum -- @property maximum
-- @param[opt=100] number -- @tparam[opt=100] number maximum
-- @propemits true false
--- The bar (background) border width. --- The bar (background) border width.
--
-- @beautiful beautiful.slider_bar_border_width -- @beautiful beautiful.slider_bar_border_width
-- @param number -- @param number
--- The bar (background) border color. --- The bar (background) border color.
--
-- @beautiful beautiful.slider_bar_border_color -- @beautiful beautiful.slider_bar_border_color
-- @param color -- @param color
--- The handle border_color. --- The handle border_color.
--
-- @beautiful beautiful.slider_handle_border_color -- @beautiful beautiful.slider_handle_border_color
-- @param color -- @param color
--- The handle border width. --- The handle border width.
--
-- @beautiful beautiful.slider_handle_border_width -- @beautiful beautiful.slider_handle_border_width
-- @param number -- @param number
--- The handle . --- The handle width.
--
-- @beautiful beautiful.slider_handle_width -- @beautiful beautiful.slider_handle_width
-- @param number -- @param number
--- The handle color.
--
-- @beautiful beautiful.slider_handle_color -- @beautiful beautiful.slider_handle_color
-- @param color -- @param color
--- The handle shape. --- The handle shape.
--
-- @beautiful beautiful.slider_handle_shape -- @beautiful beautiful.slider_handle_shape
-- @tparam[opt=gears shape rectangle] gears.shape shape -- @tparam[opt=gears shape rectangle] gears.shape shape
-- @see gears.shape -- @see gears.shape
--- The bar (background) shape. --- The bar (background) shape.
--
-- @beautiful beautiful.slider_bar_shape -- @beautiful beautiful.slider_bar_shape
-- @tparam[opt=gears shape rectangle] gears.shape shape -- @tparam[opt=gears shape rectangle] gears.shape shape
-- @see gears.shape -- @see gears.shape
--- The bar (background) height. --- The bar (background) height.
--
-- @beautiful beautiful.slider_bar_height -- @beautiful beautiful.slider_bar_height
-- @param number -- @param number
--- The bar (background) margins. --- The bar (background) margins.
--
-- @beautiful beautiful.slider_bar_margins -- @beautiful beautiful.slider_bar_margins
-- @tparam[opt={}] table margins -- @tparam[opt={}] table margins
-- @tparam[opt=0] number margins.left -- @tparam[opt=0] number margins.left
@ -183,6 +224,7 @@ local slider = {mt={}}
-- @tparam[opt=0] number margins.bottom -- @tparam[opt=0] number margins.bottom
--- The slider handle margins. --- The slider handle margins.
--
-- @beautiful beautiful.slider_handle_margins -- @beautiful beautiful.slider_handle_margins
-- @tparam[opt={}] table margins -- @tparam[opt={}] table margins
-- @tparam[opt=0] number margins.left -- @tparam[opt=0] number margins.left
@ -191,10 +233,12 @@ local slider = {mt={}}
-- @tparam[opt=0] number margins.bottom -- @tparam[opt=0] number margins.bottom
--- The bar (background) color. --- The bar (background) color.
--
-- @beautiful beautiful.slider_bar_color -- @beautiful beautiful.slider_bar_color
-- @param color -- @param color
--- The bar (active) color. --- The bar (active) color.
--
-- Only works when both `beautiful.slider_bar_color` and `beautiful.slider_bar_active_color` are hex color strings -- Only works when both `beautiful.slider_bar_color` and `beautiful.slider_bar_active_color` are hex color strings
-- @beautiful beautiful.slider_bar_active_color -- @beautiful beautiful.slider_bar_active_color
-- @param color -- @param color
@ -231,7 +275,7 @@ for prop in pairs(properties) do
self._private[prop] = value self._private[prop] = value
if changed then if changed then
self:emit_signal("property::"..prop) self:emit_signal("property::"..prop, value)
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
end end
end end
@ -253,7 +297,7 @@ function slider:set_value(value)
self._private.value = value self._private.value = value
if changed then if changed then
self:emit_signal( "property::value" ) self:emit_signal( "property::value", value)
self:emit_signal( "widget::redraw_needed" ) self:emit_signal( "widget::redraw_needed" )
end end
end end

View File

@ -25,10 +25,12 @@ local reverse = false
local display_on_screen = "primary" local display_on_screen = "primary"
--- The systray background color. --- The systray background color.
--
-- @beautiful beautiful.bg_systray -- @beautiful beautiful.bg_systray
-- @param string The color (string like "#ff0000" only) -- @param string The color (string like "#ff0000" only)
--- The systray icon spacing. --- The systray icon spacing.
--
-- @beautiful beautiful.systray_icon_spacing -- @beautiful beautiful.systray_icon_spacing
-- @tparam[opt=0] integer The icon spacing -- @tparam[opt=0] integer The icon spacing
@ -114,56 +116,72 @@ local function get_args(self, ...)
end end
--- Set the size of a single icon. --- Set the size of a single icon.
--
-- If this is set to nil, then the size is picked dynamically based on the -- If this is set to nil, then the size is picked dynamically based on the
-- available space. Otherwise, any single icon has a size of `size`x`size`. -- available space. Otherwise, any single icon has a size of `size`x`size`.
--
-- @property base_size -- @property base_size
-- @tparam integer|nil size The base size -- @tparam integer|nil size The base size
-- @propemits true false
function systray:set_base_size(size) function systray:set_base_size(size)
base_size = get_args(self, size) base_size = get_args(self, size)
if instance then if instance then
instance:emit_signal("widget::layout_changed") instance:emit_signal("widget::layout_changed")
instance:emit_signal("property::base_size", size)
end end
end end
--- Decide between horizontal or vertical display. --- Decide between horizontal or vertical display.
--
-- @property horizontal -- @property horizontal
-- @tparam boolean horiz Use horizontal mode? -- @tparam boolean horiz Use horizontal mode?
-- @propemits true false
function systray:set_horizontal(horiz) function systray:set_horizontal(horiz)
horizontal = get_args(self, horiz) horizontal = get_args(self, horiz)
if instance then if instance then
instance:emit_signal("widget::layout_changed") instance:emit_signal("widget::layout_changed")
instance:emit_signal("property::horizontal", horiz)
end end
end end
--- Should the systray icons be displayed in reverse order? --- Should the systray icons be displayed in reverse order?
--
-- @property reverse -- @property reverse
-- @tparam boolean rev Display in reverse order. -- @tparam boolean rev Display in reverse order.
-- @propemits true false
function systray:set_reverse(rev) function systray:set_reverse(rev)
reverse = get_args(self, rev) reverse = get_args(self, rev)
if instance then if instance then
instance:emit_signal("widget::redraw_needed") instance:emit_signal("widget::redraw_needed")
instance:emit_signal("property::reverse", rev)
end end
end end
--- Set the screen that the systray should be displayed on. --- Set the screen that the systray should be displayed on.
--
-- This can either be a screen, in which case the systray will be displayed on -- This can either be a screen, in which case the systray will be displayed on
-- exactly that screen, or the string `"primary"`, in which case it will be -- exactly that screen, or the string `"primary"`, in which case it will be
-- visible on the primary screen. The default value is "primary". -- visible on the primary screen. The default value is "primary".
--
-- @property screen -- @property screen
-- @tparam screen|"primary" s The screen to display on. -- @tparam screen|"primary" s The screen to display on.
-- @propemits true false
function systray:set_screen(s) function systray:set_screen(s)
display_on_screen = get_args(self, s) display_on_screen = get_args(self, s)
if instance then if instance then
instance:emit_signal("widget::layout_changed") instance:emit_signal("widget::layout_changed")
instance:emit_signal("property::screen", s)
end end
end end
--- Create the systray widget. --- Create the systray widget.
--
-- Note that this widget can only exist once. -- Note that this widget can only exist once.
--
-- @tparam boolean revers Show in the opposite direction -- @tparam boolean revers Show in the opposite direction
-- @treturn table The new `systray` widget -- @treturn table The new `systray` widget
-- @constructorfct wibox.widget.systray -- @constructorfct wibox.widget.systray

View File

@ -19,6 +19,7 @@ local setmetatable = setmetatable
local textbox = { mt = {} } local textbox = { mt = {} }
--- The textbox font. --- The textbox font.
--
-- @beautiful beautiful.font -- @beautiful beautiful.font
-- @param string -- @param string
@ -69,8 +70,10 @@ function textbox:fit(context, width, height)
end end
--- Get the preferred size of a textbox. --- Get the preferred size of a textbox.
--
-- This returns the size that the textbox would use if infinite space were -- This returns the size that the textbox would use if infinite space were
-- available. -- available.
--
-- @method get_preferred_size -- @method get_preferred_size
-- @tparam integer|screen s The screen on which the textbox will be displayed. -- @tparam integer|screen s The screen on which the textbox will be displayed.
-- @treturn number The preferred width. -- @treturn number The preferred width.
@ -88,8 +91,10 @@ function textbox:get_preferred_size(s)
end end
--- Get the preferred height of a textbox at a given width. --- Get the preferred height of a textbox at a given width.
--
-- This returns the height that the textbox would use when it is limited to the -- This returns the height that the textbox would use when it is limited to the
-- given width. -- given width.
--
-- @method get_height_for_width -- @method get_height_for_width
-- @tparam number width The available width. -- @tparam number width The available width.
-- @tparam integer|screen s The screen on which the textbox will be displayed. -- @tparam integer|screen s The screen on which the textbox will be displayed.
@ -106,8 +111,10 @@ function textbox:get_height_for_width(width, s)
end end
--- Get the preferred size of a textbox. --- Get the preferred size of a textbox.
--
-- This returns the size that the textbox would use if infinite space were -- This returns the size that the textbox would use if infinite space were
-- available. -- available.
--
-- @method get_preferred_size_at_dpi -- @method get_preferred_size_at_dpi
-- @tparam number dpi The DPI value to render at. -- @tparam number dpi The DPI value to render at.
-- @treturn number The preferred width. -- @treturn number The preferred width.
@ -121,8 +128,10 @@ function textbox:get_preferred_size_at_dpi(dpi)
end end
--- Get the preferred height of a textbox at a given width. --- Get the preferred height of a textbox at a given width.
--
-- This returns the height that the textbox would use when it is limited to the -- This returns the height that the textbox would use when it is limited to the
-- given width. -- given width.
--
-- @method get_height_for_width_at_dpi -- @method get_height_for_width_at_dpi
-- @tparam number width The available width. -- @tparam number width The available width.
-- @tparam number dpi The DPI value to render at. -- @tparam number dpi The DPI value to render at.
@ -136,8 +145,9 @@ function textbox:get_height_for_width_at_dpi(width, dpi)
return h return h
end end
--- Set the text of the textbox (with --- Set the text of the textbox.(with
-- [Pango markup](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html)). -- [Pango markup](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html)).
--
-- @tparam string text The text to set. This can contain pango markup (e.g. -- @tparam string text The text to set. This can contain pango markup (e.g.
-- `<b>bold</b>`). You can use `gears.string.escape` to escape -- `<b>bold</b>`). You can use `gears.string.escape` to escape
-- parts of it. -- parts of it.
@ -161,15 +171,18 @@ function textbox:set_markup_silently(text)
self._private.layout.attributes = attr self._private.layout.attributes = attr
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::markup", text)
return true return true
end end
--- Set the text of the textbox (with --- Set the text of the textbox (with
-- [Pango markup](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html)). -- [Pango markup](https://developer.gnome.org/pango/stable/PangoMarkupFormat.html)).
--
-- @property markup -- @property markup
-- @tparam string text The text to set. This can contain pango markup (e.g. -- @tparam string text The text to set. This can contain pango markup (e.g.
-- `<b>bold</b>`). You can use `gears.string.escape` to escape -- `<b>bold</b>`). You can use `gears.string.escape` to escape
-- parts of it. -- parts of it.
-- @propemits true false
-- @see text -- @see text
function textbox:set_markup(text) function textbox:set_markup(text)
@ -183,9 +196,12 @@ function textbox:get_markup()
return self._private.markup return self._private.markup
end end
--- Set a textbox' text. --- Set a textbox text.
--
-- @property text -- @property text
-- @param text The text to display. Pango markup is ignored and shown as-is. -- @tparam string text The text to display. Pango markup is ignored and shown
-- as-is.
-- @propemits true false
-- @see markup -- @see markup
function textbox:set_text(text) function textbox:set_text(text)
@ -197,15 +213,25 @@ function textbox:set_text(text)
self._private.layout.attributes = nil self._private.layout.attributes = nil
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::text", text)
end end
function textbox:get_text() function textbox:get_text()
return self._private.layout.text return self._private.layout.text
end end
--- Set a textbox' ellipsize mode. --- Set a textbox ellipsize mode.
--
-- Valid values are:
--
-- * **start**
-- * **middle**
-- * **end**
--
-- @property ellipsize -- @property ellipsize
-- @param mode Where should long lines be shortened? "start", "middle" or "end" -- @tparam string mode Where should long lines be shortened? "start", "middle"
-- or "end".
-- @propemits true false
function textbox:set_ellipsize(mode) function textbox:set_ellipsize(mode)
local allowed = { none = "NONE", start = "START", middle = "MIDDLE", ["end"] = "END" } local allowed = { none = "NONE", start = "START", middle = "MIDDLE", ["end"] = "END" }
@ -216,12 +242,21 @@ function textbox:set_ellipsize(mode)
self._private.layout:set_ellipsize(allowed[mode]) self._private.layout:set_ellipsize(allowed[mode])
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::ellipsize", mode)
end end
end end
--- Set a textbox' wrap mode. --- Set a textbox wrap mode.
--
-- Valid values are:
--
-- * **word**
-- * **char**
-- * **word_char**
--
-- @property wrap -- @property wrap
-- @param mode Where to wrap? After "word", "char" or "word_char" -- @tparam string mode Where to wrap? After "word", "char" or "word_char".
-- @propemits true false
function textbox:set_wrap(mode) function textbox:set_wrap(mode)
local allowed = { word = "WORD", char = "CHAR", word_char = "WORD_CHAR" } local allowed = { word = "WORD", char = "CHAR", word_char = "WORD_CHAR" }
@ -232,12 +267,22 @@ function textbox:set_wrap(mode)
self._private.layout:set_wrap(allowed[mode]) self._private.layout:set_wrap(allowed[mode])
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::wrap", mode)
end end
end end
--- The textbox' vertical alignment --- The textbox' vertical alignment.
--
-- Valid values are:
--
-- * **top**
-- * **center**
-- * **bottom**
--
-- @property valign -- @property valign
-- @param mode Where should the textbox be drawn? "top", "center" or "bottom" -- @tparam string mode Where should the textbox be drawn? "top", "center" or
-- "bottom".
-- @propemits true false
function textbox:set_valign(mode) function textbox:set_valign(mode)
local allowed = { top = true, center = true, bottom = true } local allowed = { top = true, center = true, bottom = true }
@ -248,12 +293,22 @@ function textbox:set_valign(mode)
self._private.valign = mode self._private.valign = mode
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::valign", mode)
end end
end end
--- Set a textbox' horizontal alignment. --- Set a textbox horizontal alignment.
--
-- Valid values are:
--
-- * **left**
-- * **center**
-- * **right**
--
-- @property align -- @property align
-- @param mode Where should the textbox be drawn? "left", "center" or "right" -- @tparam string mode Where should the textbox be drawn? "left", "center" or
-- "right".
-- @propemits true false
function textbox:set_align(mode) function textbox:set_align(mode)
local allowed = { left = "LEFT", center = "CENTER", right = "RIGHT" } local allowed = { left = "LEFT", center = "CENTER", right = "RIGHT" }
@ -264,20 +319,26 @@ function textbox:set_align(mode)
self._private.layout:set_alignment(allowed[mode]) self._private.layout:set_alignment(allowed[mode])
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::align", mode)
end end
end end
--- Set a textbox' font --- Set a textbox font.
--
-- @property font -- @property font
-- @param font The font description as string -- @tparam string font The font description as string.
-- @propemits true false
-- @propbeautiful
function textbox:set_font(font) function textbox:set_font(font)
self._private.layout:set_font_description(beautiful.get_font(font)) self._private.layout:set_font_description(beautiful.get_font(font))
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
self:emit_signal("widget::layout_changed") self:emit_signal("widget::layout_changed")
self:emit_signal("property::font", font)
end end
--- Create a new textbox. --- Create a new textbox.
--
-- @tparam[opt=""] string text The textbox content -- @tparam[opt=""] string text The textbox content
-- @tparam[opt=false] boolean ignore_markup Ignore the pango/HTML markup -- @tparam[opt=false] boolean ignore_markup Ignore the pango/HTML markup
-- @treturn table A new textbox widget -- @treturn table A new textbox widget

View File

@ -29,6 +29,7 @@ if source_date_epoch and os.getenv("SOURCE_DIRECTORY") then
end end
--- Set the clock's format. --- Set the clock's format.
--
-- For information about the format specifiers, see -- For information about the format specifiers, see
-- [the GLib docs](https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format). -- [the GLib docs](https://developer.gnome.org/glib/stable/glib-GDateTime.html#g-date-time-format).
-- @property format -- @property format
@ -43,7 +44,8 @@ function textclock:get_format()
return self._private.format return self._private.format
end end
--- Set the clock's timezone --- Set the clock's timezone.
--
-- e.g. "Z" for UTC, "±hh:mm" or "Europe/Amsterdam". See -- e.g. "Z" for UTC, "±hh:mm" or "Europe/Amsterdam". See
-- [GTimeZone](https://developer.gnome.org/glib/stable/glib-GTimeZone.html#g-time-zone-new). -- [GTimeZone](https://developer.gnome.org/glib/stable/glib-GTimeZone.html#g-time-zone-new).
-- @property timezone -- @property timezone
@ -59,7 +61,8 @@ function textclock:get_timezone()
return self._private.tzid return self._private.tzid
end end
--- Set the clock's refresh rate --- Set the clock's refresh rate.
--
-- @property refresh -- @property refresh
-- @tparam number refresh How often the clock is updated, in seconds -- @tparam number refresh How often the clock is updated, in seconds
@ -73,6 +76,7 @@ function textclock:get_refresh()
end end
--- Force a textclock to update now. --- Force a textclock to update now.
--
-- @method force_update -- @method force_update
function textclock:force_update() function textclock:force_update()
self._timer:emit_signal("timeout") self._timer:emit_signal("timeout")