--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local cairo = require("lgi").cairo
-- luacheck: push no max string line length
local svg_image_path = [[
]]
--luacheck: pop
-- There is no path there, but that's just for the doc.
local handle = wibox.widget.imagebox._load_rsvg_handle(svg_image_path)
local png_image_path = cairo.ImageSurface(cairo.Format.ARGB32, 48, 48)
local cr = cairo.Context(png_image_path)
handle:render_cairo(cr)
local l = wibox.layout {
forced_width = 440,
spacing = 5,
forced_num_cols = 2,
homogeneous = false,
expand = false,
layout = wibox.layout.grid.vertical
}
l:add_widget_at(wibox.widget {
markup = "SVG image (34x34 pt):",
widget = wibox.widget.textbox,
},1,1)
l:add_widget_at(wibox.widget {
markup = "PNG image (48x48 px):",
widget = wibox.widget.textbox,
},1,2)
l:add_widget_at(wibox.widget {
image = svg_image_path,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 1, 1, 1)
l:add_widget_at(wibox.widget {
image = png_image_path,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 2, 1, 1)
--DOC_HIDE_END
for k, borders in ipairs {0, 10, 30, 64} do
--DOC_HIDE_START
local r = 1 + k*2
l:add_widget_at(wibox.widget {
markup = "borders = ".. borders .."",
widget = wibox.widget.textbox,
}, r, 1, 1, 2)
--DOC_HIDE_END
for idx, image in ipairs {svg_image_path, png_image_path} do
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
fill = false,
borders = borders,
border_image = image,
forced_width = 200, --DOC_HIDE
forced_height = 100,
widget = wibox.container.border
}
l:add_widget_at(w, r+1, idx, 1, 1)
end
end
--DOC_HIDE_START
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80