From bbf1c9270f8331ba270ebc5f4b86589c2db32d0e Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 12 Sep 2021 00:48:59 -0700 Subject: [PATCH] tests: Test the imagebox DPI and CSS stylesheet. --- tests/examples/wibox/widget/imagebox/dpi.lua | 48 +++++++++++++++++++ .../wibox/widget/imagebox/stylesheet.lua | 31 ++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/examples/wibox/widget/imagebox/dpi.lua create mode 100644 tests/examples/wibox/widget/imagebox/stylesheet.lua diff --git a/tests/examples/wibox/widget/imagebox/dpi.lua b/tests/examples/wibox/widget/imagebox/dpi.lua new file mode 100644 index 000000000..1a11f1f66 --- /dev/null +++ b/tests/examples/wibox/widget/imagebox/dpi.lua @@ -0,0 +1,48 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local l = wibox.layout { --DOC_HIDE + forced_width = 360, --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.flex.vertical --DOC_HIDE +} --DOC_HIDE + + + + local image = ''.. + ''.. + ''.. + 'Hello world!'.. + '' + +--DOC_NEWLINE + + for _, dpi in ipairs {100, 200, 300} do + local row = wibox.layout { --DOC_HIDE + spacing = 5, --DOC_HIDE + layout = wibox.layout.fixed.horizontal --DOC_HIDE + } --DOC_HIDE + + row:add(wibox.widget { --DOC_HIDE + markup = "dpi = "..dpi.."", --DOC_HIDE + forced_width = 80, --DOC_HIDE + widget = wibox.widget.textbox --DOC_HIDE + }) --DOC_HIDE + + local w = wibox.widget { + image = image, + dpi = dpi, + resize = false, + forced_height = 70, + forced_width = 150, + widget = wibox.widget.imagebox + } + + row:add(w) --DOC_HIDE + l:add(row) --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/imagebox/stylesheet.lua b/tests/examples/wibox/widget/imagebox/stylesheet.lua new file mode 100644 index 000000000..59a3bd3a9 --- /dev/null +++ b/tests/examples/wibox/widget/imagebox/stylesheet.lua @@ -0,0 +1,31 @@ +--DOC_GEN_IMAGE --DOC_HIDE +local parent = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + + local image = ''.. + ''.. + ''.. + ''.. + ''.. + '' + + --DOC_NEWLINE + + local stylesheet = "" .. + "rect { fill: #ffff00; } ".. + ".my_class { fill: #00ff00; } ".. + "#my_id { fill: #0000ff; }" + + --DOC_NEWLINE + + local w = wibox.widget { + forced_height = 60, --DOC_HIDE + forced_width = 190, --DOC_HIDE + stylesheet = stylesheet, + image = image, + widget = wibox.widget.imagebox + } + +parent:add(w) --DOC_HIDE + +--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80