From 0afb719f8294604a58eb2f2df647fc536286a182 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Tue, 2 Nov 2021 19:29:31 -0700 Subject: [PATCH] doc: Improve the progressbar doc. Another commit in the "lets finish the widget doc" serie. --- docs/images/progressbar.svg | 323 ++++++++++++++++++ lib/wibox/widget/progressbar.lua | 85 ++++- .../widget/progressbar/background_color.lua | 35 ++ .../widget/progressbar/bar_border_color.lua | 36 ++ .../widget/progressbar/bar_border_width.lua | 36 ++ .../wibox/widget/progressbar/border_color.lua | 36 ++ .../wibox/widget/progressbar/border_width.lua | 36 ++ .../wibox/widget/progressbar/color.lua | 35 ++ .../wibox/widget/progressbar/grad1.lua | 30 ++ .../wibox/widget/progressbar/grad2.lua | 40 +++ .../wibox/widget/progressbar/margins1.lua | 35 ++ .../wibox/widget/progressbar/margins2.lua | 28 ++ .../wibox/widget/progressbar/max_value.lua | 35 ++ .../wibox/widget/progressbar/paddings1.lua | 35 ++ .../wibox/widget/progressbar/paddings2.lua | 26 ++ .../wibox/widget/progressbar/text.lua | 2 + .../wibox/widget/progressbar/ticks.lua | 36 ++ .../wibox/widget/progressbar/ticks_gap.lua | 37 ++ .../wibox/widget/progressbar/ticks_size.lua | 37 ++ .../wibox/widget/progressbar/value.lua | 34 ++ 20 files changed, 985 insertions(+), 12 deletions(-) create mode 100644 docs/images/progressbar.svg create mode 100644 tests/examples/wibox/widget/progressbar/background_color.lua create mode 100644 tests/examples/wibox/widget/progressbar/bar_border_color.lua create mode 100644 tests/examples/wibox/widget/progressbar/bar_border_width.lua create mode 100644 tests/examples/wibox/widget/progressbar/border_color.lua create mode 100644 tests/examples/wibox/widget/progressbar/border_width.lua create mode 100644 tests/examples/wibox/widget/progressbar/color.lua create mode 100644 tests/examples/wibox/widget/progressbar/grad1.lua create mode 100644 tests/examples/wibox/widget/progressbar/grad2.lua create mode 100644 tests/examples/wibox/widget/progressbar/margins1.lua create mode 100644 tests/examples/wibox/widget/progressbar/margins2.lua create mode 100644 tests/examples/wibox/widget/progressbar/max_value.lua create mode 100644 tests/examples/wibox/widget/progressbar/paddings1.lua create mode 100644 tests/examples/wibox/widget/progressbar/paddings2.lua create mode 100644 tests/examples/wibox/widget/progressbar/ticks.lua create mode 100644 tests/examples/wibox/widget/progressbar/ticks_gap.lua create mode 100644 tests/examples/wibox/widget/progressbar/ticks_size.lua create mode 100644 tests/examples/wibox/widget/progressbar/value.lua diff --git a/docs/images/progressbar.svg b/docs/images/progressbar.svg new file mode 100644 index 00000000..ade0797e --- /dev/null +++ b/docs/images/progressbar.svg @@ -0,0 +1,323 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + margins.left + paddings.right + margins.bottom + paddings.left + color + background_color + + border_color + bar_border_width + paddings.top + margins.right + border_width + margins.top + + diff --git a/lib/wibox/widget/progressbar.lua b/lib/wibox/widget/progressbar.lua index 29314cae..3100a0e0 100644 --- a/lib/wibox/widget/progressbar.lua +++ b/lib/wibox/widget/progressbar.lua @@ -1,6 +1,11 @@ --------------------------------------------------------------------------- --- A progressbar widget. -- +-- ![Components](../images/progressbar.svg) +-- +-- Common usage examples +-- ===================== +-- -- To add text on top of the progressbar, a `wibox.layout.stack` can be used: -- --@DOC_wibox_widget_progressbar_text_EXAMPLE@ @@ -13,6 +18,15 @@ -- a `wibox.container.constraint` widget or the `forced_width`/`forced_height` -- properties have to be used. -- +-- To have a gradient between 2 colors when the bar reaches a threshold, use +-- the `gears.color` gradients: +-- +--@DOC_wibox_widget_progressbar_grad1_EXAMPLE@ +-- +-- The same goes for multiple solid colors: +-- +--@DOC_wibox_widget_progressbar_grad2_EXAMPLE@ +-- --@DOC_wibox_widget_defaults_progressbar_EXAMPLE@ -- -- @author Julien Danjou <julien@danjou.info> @@ -37,14 +51,18 @@ local progressbar = { mt = {} } -- -- If the value is nil, no border will be drawn. -- +-- @DOC_wibox_widget_progressbar_border_color_EXAMPLE@ +-- -- @property border_color --- @tparam color color The border color to set. +-- @tparam gears.color color The border color to set. -- @propemits true false -- @propbeautiful -- @see gears.color --- The progressbar border width. -- +-- @DOC_wibox_widget_progressbar_border_width_EXAMPLE@ +-- -- @property border_width -- @tparam number border_width -- @propemits true false @@ -54,14 +72,18 @@ local progressbar = { mt = {} } -- -- If the value is nil, no border will be drawn. -- +-- @DOC_wibox_widget_progressbar_bar_border_color_EXAMPLE@ +-- -- @property bar_border_color --- @tparam color color The border color to set. +-- @tparam gears.color color The border color to set. -- @propemits true false -- @propbeautiful -- @see gears.color --- The progressbar inner border width. -- +-- @DOC_wibox_widget_progressbar_bar_border_width_EXAMPLE@ +-- -- @property bar_border_width -- @tparam number bar_border_width -- @propbeautiful @@ -69,16 +91,20 @@ local progressbar = { mt = {} } --- The progressbar foreground color. -- +-- @DOC_wibox_widget_progressbar_color_EXAMPLE@ +-- -- @property color --- @tparam color color The progressbar color. +-- @tparam gears.color color The progressbar color. -- @propemits true false -- @usebeautiful beautiful.progressbar_fg -- @see gears.color --- The progressbar background color. -- +-- @DOC_wibox_widget_progressbar_background_color_EXAMPLE@ +-- -- @property background_color --- @tparam color color The progressbar background color. +-- @tparam gears.color color The progressbar background color. -- @propemits true false -- @usebeautiful beautiful.progressbar_bg -- @see gears.color @@ -119,29 +145,41 @@ local progressbar = { mt = {} } -- @tparam[opt=true] boolean clip -- @propemits true false ---- The progressbar to draw ticks. Default is false. +--- The progressbar to draw ticks. +-- +-- @DOC_wibox_widget_progressbar_ticks_EXAMPLE@ -- -- @property ticks --- @tparam boolean ticks +-- @tparam[opt=false] boolean ticks -- @propemits true false --- The progressbar ticks gap. -- +-- @DOC_wibox_widget_progressbar_ticks_gap_EXAMPLE@ +-- -- @property ticks_gap --- @tparam number ticks_gap +-- @tparam[opt=1] number ticks_gap -- @propemits true false --- The progressbar ticks size. -- +-- @DOC_wibox_widget_progressbar_ticks_size_EXAMPLE@ +-- -- @property ticks_size --- @tparam number ticks_size +-- @tparam[opt=4] number ticks_size -- @propemits true false --- The maximum value the progressbar should handle. -- +-- By default, the value is 1. So the content of `value` is +-- a percentage. +-- +-- @DOC_wibox_widget_progressbar_max_value_EXAMPLE@ +-- -- @property max_value --- @tparam number max_value +-- @tparam[opt=1] number max_value -- @propemits true false +-- @see value --- The progressbar background color. -- @@ -187,10 +225,18 @@ local progressbar = { mt = {} } --- The progressbar margins. -- +-- The margins are around the progressbar. If you want to add space between the +-- bar and the border, use `paddings`. +-- +-- @DOC_wibox_widget_progressbar_margins2_EXAMPLE@ +-- -- Note that if the `clip` is disabled, this allows the background to be smaller -- than the bar. -- --- See the `clip` example. +-- It is also possible to specify a single number instead of a border for each +-- direction; +-- +-- @DOC_wibox_widget_progressbar_margins1_EXAMPLE@ -- -- @property margins -- @tparam[opt=0] (table|number|nil) margins A table for each side or a number @@ -201,13 +247,21 @@ local progressbar = { mt = {} } -- @propemits false false -- @propbeautiful -- @see clip +-- @see padding +-- @see wibox.container.margin --- The progressbar padding. -- +-- This is the space between the inner bar and the progressbar outer border. +-- -- Note that if the `clip` is disabled, this allows the bar to be taller -- than the background. -- --- See the `clip` example. +-- @DOC_wibox_widget_progressbar_paddings2_EXAMPLE@ +-- +-- The paddings can also be a single numeric value: +-- +-- @DOC_wibox_widget_progressbar_paddings1_EXAMPLE@ -- -- @property paddings -- @tparam[opt=0] (table|number|nil) padding A table for each side or a number @@ -218,6 +272,7 @@ local progressbar = { mt = {} } -- @propemits false false -- @propbeautiful -- @see clip +-- @see margins --- The progressbar margins. -- @@ -424,9 +479,15 @@ end --- Set the progressbar value. -- +-- By default, unless `max_value` is set, it is number between +-- zero and one. +-- +-- @DOC_wibox_widget_progressbar_value_EXAMPLE@ +-- -- @property value --- @tparam number value The progress bar value between 0 and 1. +-- @tparam number value The progress bar value. -- @propemits true false +-- @see max_value function progressbar:set_value(value) value = value or 0 diff --git a/tests/examples/wibox/widget/progressbar/background_color.lua b/tests/examples/wibox/widget/progressbar/background_color.lua new file mode 100644 index 00000000..a859a902 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/background_color.lua @@ -0,0 +1,35 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, color in ipairs { {nil}, {"#ff0000"}, {"#00ff00"}, {"#0000ff44"} } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + background_color = color[1], + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = color[1] and '"'..color[1]..'"' or "nil", + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/bar_border_color.lua b/tests/examples/wibox/widget/progressbar/bar_border_color.lua new file mode 100644 index 00000000..8cd5d183 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/bar_border_color.lua @@ -0,0 +1,36 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, color in ipairs { {nil}, {"#ff0000"}, {"#00ff00"}, {"#0000ff44"} } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + bar_border_width = 2, + bar_border_color = color[1], + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = color[1] and '"'..color[1]..'"' or "nil", + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/bar_border_width.lua b/tests/examples/wibox/widget/progressbar/bar_border_width.lua new file mode 100644 index 00000000..4cd31ff7 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/bar_border_width.lua @@ -0,0 +1,36 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, width in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + bar_border_width = width, + bar_border_color = "#ff0000", + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = width, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/border_color.lua b/tests/examples/wibox/widget/progressbar/border_color.lua new file mode 100644 index 00000000..8d9b22a0 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/border_color.lua @@ -0,0 +1,36 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, color in ipairs { {nil}, {"#ff0000"}, {"#00ff00"}, {"#0000ff44"} } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + border_width = 2, + border_color = color[1], + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = color[1] and '"'..color[1]..'"' or "nil", + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/border_width.lua b/tests/examples/wibox/widget/progressbar/border_width.lua new file mode 100644 index 00000000..a31ae14e --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/border_width.lua @@ -0,0 +1,36 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, width in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + border_width = width, + border_color = "#ff0000", + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = width, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/color.lua b/tests/examples/wibox/widget/progressbar/color.lua new file mode 100644 index 00000000..624f5b1b --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/color.lua @@ -0,0 +1,35 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, color in ipairs { {nil}, {"#ff0000"}, {"#00ff00"}, {"#0000ff44"} } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + color = color[1], + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = color[1] and '"'..color[1]..'"' or "nil", + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/grad1.lua b/tests/examples/wibox/widget/progressbar/grad1.lua new file mode 100644 index 00000000..06e29917 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/grad1.lua @@ -0,0 +1,30 @@ +--DOC_GEN_IMAGE --DOC_HIDE --DOC_NO_USAGE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local beautiful = require("beautiful") --DOC_HIDE + +parent:add( --DOC_HIDE + + wibox.widget { + color = { + type = "linear", + from = { 0 , 0 }, + to = { 100, 0 }, + stops = { + { 0 , "#0000ff" }, + { 0.8, "#0000ff" }, + { 1 , "#ff0000" } + } + }, + max_value = 1, + value = 1, + forced_height = 20, + forced_width = 100, + paddings = 1, + border_width = 1, + border_color = beautiful.border_color, + widget = wibox.widget.progressbar, + } + +) --DOC_HIDE +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/grad2.lua b/tests/examples/wibox/widget/progressbar/grad2.lua new file mode 100644 index 00000000..8f59e2b5 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/grad2.lua @@ -0,0 +1,40 @@ +--DOC_GEN_IMAGE --DOC_HIDE --DOC_NO_USAGE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local beautiful = require("beautiful") --DOC_HIDE + +local l = wibox.layout.fixed.vertical() --DOC_HIDE +l.spacing = 5 --DOC_HIDE + + for _, value in ipairs { 0.3, 0.5, 0.7, 1 } do + l:add( --DOC_HIDE + wibox.widget { + color = { + type = "linear", + from = { 0 , 0 }, + to = { 100, 0 }, + stops = { + { 0 , "#00ff00" }, + { 0.5, "#00ff00" }, + { 0.5, "#ffff00" }, + { 0.7, "#ffff00" }, + { 0.7, "#ffaa00" }, + { 0.8, "#ffaa00" }, + { 0.8, "#ff0000" }, + { 1 , "#ff0000" } + } + }, + max_value = 1, + value = value, + forced_height = 20, + forced_width = 100, + paddings = 1, + border_width = 1, + border_color = beautiful.border_color, + widget = wibox.widget.progressbar, + } + ) --DOC_HIDE + end + +parent:add(l) --DOC_HIDE +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/margins1.lua b/tests/examples/wibox/widget/progressbar/margins1.lua new file mode 100644 index 00000000..e6b91146 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/margins1.lua @@ -0,0 +1,35 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, margin in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + margins = margin, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = margin, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/margins2.lua b/tests/examples/wibox/widget/progressbar/margins2.lua new file mode 100644 index 00000000..7605608a --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/margins2.lua @@ -0,0 +1,28 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE +local parent = ... +local wibox = require("wibox") + +--DOC_HIDE_END +local bg = --DOC_HIDE + wibox.widget { + { + margins = { + top = 4, + bottom = 2, + right = 10, + left = 5 + }, + value = 0.33, + border_width = 2, + border_color = "#00ff00", + background = "#0000ff", + widget = wibox.widget.progressbar, + }, + forced_height = 30, --DOC_HIDE + forced_width = 75, --DOC_hIDE + bg = "#ff0000", + widget = wibox.container.background + } + +parent:add(bg) --DOC_HIDE +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/max_value.lua b/tests/examples/wibox/widget/progressbar/max_value.lua new file mode 100644 index 00000000..09777e46 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/max_value.lua @@ -0,0 +1,35 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, value in ipairs { 0, 10, 42, 999 } do + + local pb = --DOC_HIDE + wibox.widget { + value = value, + max_value = 42, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = value.."/42", + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/paddings1.lua b/tests/examples/wibox/widget/progressbar/paddings1.lua new file mode 100644 index 00000000..1395598e --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/paddings1.lua @@ -0,0 +1,35 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, padding in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + paddings = padding, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = padding, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/paddings2.lua b/tests/examples/wibox/widget/progressbar/paddings2.lua new file mode 100644 index 00000000..06a22c0e --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/paddings2.lua @@ -0,0 +1,26 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE +local parent = ... +local wibox = require("wibox") + +--DOC_HIDE_END +local bg = --DOC_HIDE + wibox.widget { + paddings = { + top = 4, + bottom = 2, + right = 10, + left = 5 + }, + value = 1, + border_width = 2, + border_color = "#00ff00", + bar_border_wisth = 2, + bar_border_color = "#ffff00", + bor_color = "#ff00ff", + background = "#0000ff", + forced_width = 75, --DOC_HIDE + forced_height = 30, --DOC_HIDE + widget = wibox.widget.progressbar, + } +parent:add(bg) --DOC_HIDE +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/text.lua b/tests/examples/wibox/widget/progressbar/text.lua index c1f6ca91..92b5c7a6 100644 --- a/tests/examples/wibox/widget/progressbar/text.lua +++ b/tests/examples/wibox/widget/progressbar/text.lua @@ -18,6 +18,8 @@ parent:add( --DOC_HIDE }, { text = "50%", + valign = "center", + align = "center", widget = wibox.widget.textbox, }, layout = wibox.layout.stack diff --git a/tests/examples/wibox/widget/progressbar/ticks.lua b/tests/examples/wibox/widget/progressbar/ticks.lua new file mode 100644 index 00000000..2f86c40b --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/ticks.lua @@ -0,0 +1,36 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, has_ticks in ipairs { true, false } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + border_width = 2, + ticks = has_ticks, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = tostring(has_ticks), + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/ticks_gap.lua b/tests/examples/wibox/widget/progressbar/ticks_gap.lua new file mode 100644 index 00000000..5af4d5d5 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/ticks_gap.lua @@ -0,0 +1,37 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, gap in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + border_width = 2, + ticks = true, + ticks_gap = gap, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = gap, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/ticks_size.lua b/tests/examples/wibox/widget/progressbar/ticks_size.lua new file mode 100644 index 00000000..60c80590 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/ticks_size.lua @@ -0,0 +1,37 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, size in ipairs { 0, 2, 4, 6 } do + + local pb = --DOC_HIDE + wibox.widget { + value = 0.33, + border_width = 2, + ticks = true, + ticks_size = size, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = size, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/widget/progressbar/value.lua b/tests/examples/wibox/widget/progressbar/value.lua new file mode 100644 index 00000000..aa9b3c15 --- /dev/null +++ b/tests/examples/wibox/widget/progressbar/value.lua @@ -0,0 +1,34 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") + +local l = wibox.layout.fixed.horizontal() +l.spacing = 5 + +--DOC_HIDE_END +for _, value in ipairs { 0, 0.2, 0.5, 1 } do + + local pb = --DOC_HIDE + wibox.widget { + value = value, + widget = wibox.widget.progressbar, + } + + --DOC_HIDE_START + l:add(wibox.widget { + pb, + { + text = value, + align = "center", + widget = wibox.widget.textbox, + }, + forced_height = 30, + forced_width = 75, + layout = wibox.layout.stack + }) + --DOC_HIDE_END +end + +parent:add(l) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80