tests: Test the border container.

This commit is contained in:
Emmanuel Lepage Vallee 2022-02-05 15:10:31 -08:00
parent dc207d5b49
commit 57b766ccf9
19 changed files with 1784 additions and 0 deletions

View File

@ -0,0 +1,59 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local beautiful = require( "beautiful" )
local gears = { color = require("gears.color")}
local red_logo = beautiful._logo(nil, gears.color("#ff0000"))
local green_logo = beautiful._logo(nil, gears.color("#00ff00"))
local blue_logo = beautiful._logo(nil, gears.color("#0000ff"))
local yellow_logo = beautiful._logo(nil, gears.color("#ffff00"))
local orange_logo = beautiful._logo(nil, gears.color("#ffbb00"))
local purple_logo = beautiful._logo(nil, gears.color("#ff00ff"))
local cyan_logo = beautiful._logo(nil, gears.color("#00ffff"))
local black_logo = beautiful._logo(nil, gears.color("#000000"))
--DOC_HIDE_END
local w1 = wibox.widget {
{
text = "Single image",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
borders = 20,
sides_fit_policy = "repeat",
border_images = blue_logo,
widget = wibox.container.border
}
--DOC_NEWLINE
local w2 = wibox.widget {
{
text = "Multiple images",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
sides_fit_policy = "repeat",
border_images = {
top_left = red_logo,
top = green_logo,
top_right = blue_logo,
right = yellow_logo,
bottom_right = orange_logo,
bottom = purple_logo,
bottom_left = cyan_logo,
left = black_logo,
},
widget = wibox.container.border
}
--DOC_HIDE_START
parent.spacing = 20
parent:add(w1)
parent:add(w2)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,73 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local beautiful = require( "beautiful" )
local function generic_widget(text, margins)
return wibox.widget {
{
{
{
id = "text",
align = "center",
valign = "center",
text = text,
widget = wibox.widget.textbox
},
margins = 10,
widget = wibox.container.margin,
},
border_width = 3,
border_color = beautiful.border_color,
bg = beautiful.bg_normal,
widget = wibox.container.background
},
margins = margins or 5,
widget = wibox.container.margin,
}
end
local l = wibox.layout {
spacing = 100,
forced_num_cols = 2,
forced_num_rows = 2,
homogeneous = true,
expand = true,
layout = wibox.layout.grid.vertical
}
--DOC_HIDE_END
for _, side in ipairs { "top", "bottom", "left", "right" } do
l:add(wibox.widget {
{
text = side .. " = true",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
border_merging = {
-- This is the equaivalent "left = true,". "side" is the loop
-- variable.
[side] = true
},
border_widgets = {
top_left = generic_widget("top_left"),
top = generic_widget("top"),
top_right = generic_widget("top_right"),
right = generic_widget("right"),
bottom_right = generic_widget("bottom_right"),
bottom = generic_widget("bottom"),
bottom_left = generic_widget("bottom_left"),
left = generic_widget("left"),
},
widget = wibox.container.border
})
end
--DOC_HIDE_START
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,55 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local beautiful = require( "beautiful" )
local function generic_widget(text, margins)
return wibox.widget {
{
{
{
id = "text",
align = "center",
valign = "center",
text = text,
widget = wibox.widget.textbox
},
margins = 10,
widget = wibox.container.margin,
},
border_width = 3,
border_color = beautiful.border_color,
bg = beautiful.bg_normal,
widget = wibox.container.background
},
margins = margins or 5,
widget = wibox.container.margin,
}
end
--DOC_HIDE_END
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
border_widgets = {
top_left = generic_widget("top_left"),
top = generic_widget("top"),
top_right = generic_widget("top_right"),
right = generic_widget("right"),
bottom_right = generic_widget("bottom_right"),
bottom = generic_widget("bottom"),
bottom_left = generic_widget("bottom_left"),
left = generic_widget("left"),
},
widget = wibox.container.border
}
--DOC_HIDE_START
parent:add(w)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,104 @@
--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 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="fill:url(#b);stroke-width:.55040765;stroke-miterlimit:4;;" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-vector-effect:none;fill:url(#c);fill-fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--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 = "<b>SVG image (34x34 pt):</b>",
widget = wibox.widget.textbox,
},1,1)
l:add_widget_at(wibox.widget {
markup = "<b>PNG image (48x48 px):</b>",
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 = "<b>borders = ".. borders .."</b>",
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

View File

@ -0,0 +1,122 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
-- luacheck: push no max string line length
local image_path1 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="fill:url(#b);stroke-width:.55040765;stroke-miterlimit:4;;" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-vector-effect:none;fill:url(#c);fill-fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
local image_path2 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="90" viewBox="0 0 23.812 23.813">
<defs>
<linearGradient id="a">
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="0" />
<stop style="stop-color:#4cc155;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="19.837" y1="28.684" x2="21.503" y2="30.629" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3.00654 0 0 3.01583 -33.75 -72.882)" />
</defs>
<g transform="translate(-16.82 -12.342)">
<ellipse style="fill:#ff7f2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="16.332" cx="28.681" style="fill:url(#b);stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0c;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="20.797" style="fill:#6f0;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#cf0;stroke-width:4.39130402;stroke-miterlimit:4;" cx="28.681" cy="24.29" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="36.655" style="fill:#0ff;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0f;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="32.165" rx="3.977" ry="3.99" />
<ellipse cy="32.165" cx="28.681" style="fill:#c8ab37;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#ff2a2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="32.165" rx="3.977" ry="3.99" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 440,
spacing = 5,
forced_num_cols = 2,
homogeneous = false,
expand = false,
layout = wibox.layout.grid.vertical
}
l:add(wibox.widget {
markup = "<b>Original image:</b>",
widget = wibox.widget.textbox,
})
l:add_widget_at(wibox.widget {
image = image_path1,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 1, 1, 1)
l:add_widget_at(wibox.widget {
image = image_path2,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 2, 1, 1)
--DOC_HIDE_END
for k, mode in ipairs {"fit", "repeat", "reflect", "pad"} do
--DOC_HIDE_START
local r = 1 + k*2
l:add_widget_at(wibox.widget {
markup = "<b>corners_fit_policy = \"".. mode .."\"</b>",
widget = wibox.widget.textbox,
}, r, 1, 1, 2)
--DOC_HIDE_END
for idx, image in ipairs { image_path1, image_path2 } do
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
fill = false,
borders = {
left = 10,
right = 50,
top = 10,
bottom = 50,
},
border_image = image,
corners_fit_policy = mode,
forced_width = 200, --DOC_HIDE
widget = wibox.container.border
}
l:add_widget_at(w, r+1, idx, 1, 1) --DOC_HIDE
end
--DOC_HIDE_END
end
--DOC_HIDE_START
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,29 @@
--DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE
local parent = ...
local wibox = require("wibox")
--DOC_HIDE_END
local w = wibox.widget {
{
text = "Center widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
after_draw_children = function(_, _, cr, width, height)
cr:set_source_rgba(1,0,0,1)
cr:set_dash({1,1},1)
cr:rectangle(1, 1, width-2, height-2)
cr:rectangle(5, 5, width-10, height-10)
cr:stroke()
end,
borders = 20,
honor_borders = false,
forced_width = 100, --DOC_HIDE
forced_height = 50, --DOC_HIDE
widget = wibox.container.border
}
parent:add(w) --DOC_HIDE
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,104 @@
--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 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="fill:url(#b);stroke-width:.55040765;stroke-miterlimit:4;;" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-vector-effect:none;fill:url(#c);fill-fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--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 = "<b>SVG image (34x34 pt):</b>",
widget = wibox.widget.textbox,
},1,1)
l:add_widget_at(wibox.widget {
markup = "<b>PNG image (48x48 px):</b>",
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, dpi in ipairs {72, 96, 220} do
--DOC_HIDE_START
local r = 1 + k*2
l:add_widget_at(wibox.widget {
markup = "<b>border_image_dpi = ".. dpi .."</b>",
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,
border_image_dpi = dpi,
borders = 10,
border_image = image,
forced_width = 200, --DOC_HIDE
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

View File

@ -0,0 +1,90 @@
--DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE
local parent = ...
local wibox = require("wibox")
local beautiful = require( "beautiful" )
-- luacheck: push no max line length
local image_path = '<?xml version="1.0"?>'..
'<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30" viewBox="0 0 7.937 7.937">'..
' <defs>'..
' <linearGradient id="a">'..
' <stop style="stop-opacity:1;stop-color:magenta;" offset="0" id="first"/>'..
' <stop offset=".5" style="stop-opacity:1;stop-color:cyan;" id="second"/>'..
' <stop style="stop-opacity:1;stop-color:yellow;" offset="1" id="third"/>'..
' </linearGradient>' ..
' <linearGradient xlink:href="#a" id="b" gradientUnits="userSpaceOnUse" x1="28.726" y1="64.923" x2="182.185" y2="201.75" gradientTransform="matrix(.04726 0 0 .053 83.075 141.528)"/>'..
' </defs>'..
' <path d="M84.732 144.627c-.372 0-.642.329-.642.679v6.58c0 .35.27.678.642.678h6.653c.372 0 .642-.328.642-.679v-6.579c0-.35-.27-.68-.642-.68zm.043.685h6.567v6.568h-6.567z" style="fill:url(#b);" transform="translate(-84.09 -144.627)"/>'..
'</svg>'
--luacheck: pop
local function generic_widget(text)
return wibox.widget {
{
{
{
id = "text",
align = "center",
valign = "center",
text = text,
widget = wibox.widget.textbox
},
margins = 10,
widget = wibox.container.margin,
},
border_width = 3,
border_color = "transparent",
bg = beautiful.bg_normal,
widget = wibox.container.background
},
opacity = 0.5,
widget = wibox.container.margin,
}
end
--DOC_HIDE_END
local w = wibox.widget {
-- This is the background border.
{
paddings = {
left = 5,
top = 3,
right = 10,
bottom = 10,
},
borders = 20,
border_image = image_path,
honor_borders = false,
widget = wibox.container.border
},
-- This border container is used top place widgets.
{
{
text = "Center widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
border_widgets = {
top_left = generic_widget(""),
top = generic_widget("top"),
top_right = generic_widget(""),
right = generic_widget("right"),
bottom_right = generic_widget(""),
bottom = generic_widget("bottom"),
bottom_left = generic_widget(""),
left = generic_widget("left"),
},
widget = wibox.container.border
},
forced_width = 200, --DOC_HIDE
forced_height = 200, --DOC_HIDE
layout = wibox.layout.stack
}
--DOC_HIDE_START
parent:add(w)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,58 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local beautiful = require( "beautiful" )
parent.spacing = 50
local function generic_widget(text, margins)
return wibox.widget {
{
{
{
id = "text",
align = "center",
valign = "center",
text = text,
widget = wibox.widget.textbox
},
margins = 10,
widget = wibox.container.margin,
},
border_width = 3,
border_color = beautiful.border_color,
bg = beautiful.bg_normal,
widget = wibox.container.background
},
margins = margins or 5,
widget = wibox.container.margin,
}
end
--DOC_HIDE_END
for _, expand in ipairs { false, true } do
local w = wibox.widget {
{
text = "expand_corners = " .. (expand and "true" or "false"),
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
border_widgets = {
top_left = generic_widget("top_left"),
top = generic_widget("top"),
top_right = generic_widget("top_right"),
right = generic_widget("right"),
bottom_right = generic_widget("bottom_right"),
bottom = generic_widget("bottom"),
bottom_left = generic_widget("bottom_left"),
left = generic_widget("left"),
},
expand_corners = expand,
widget = wibox.container.border
}
parent:add(wibox.container.place(w)) --DOC_HIDE
end
----DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,75 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
-- luacheck: push no max string line length
local image_path = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="opacity:1;fill:url(#b);fill-opacity:1;stroke:none;stroke-width:.55040765;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 240,
spacing = 5,
layout = wibox.layout.fixed.vertical
}
l:add(wibox.widget {
markup = "<b>Original image:</b>",
widget = wibox.widget.textbox,
})
l:add(wibox.widget {
image = image_path,
forced_height = 48,
forced_width = 48,
widget = wibox.widget.imagebox,
})
for _, fill in ipairs {true, false} do
--DOC_HIDE_END
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
borders = 10,
border_image = image_path,
fill = fill,
widget = wibox.container.border
}
--DOC_HIDE_START
l:add(wibox.widget {
{
markup = "<b>`fill` = "..(fill and "true" or "false").."</b>",
widget = wibox.widget.textbox,
},
w,
layout = wibox.layout.fixed.vertical,
})
end
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,117 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
-- luacheck: push no max line length
local image_path1 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="fill:url(#b);stroke-width:.55040765;stroke-miterlimit:4;;" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-vector-effect:none;fill:url(#c);fill-fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
local image_path2 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="90" viewBox="0 0 23.812 23.813">
<defs>
<linearGradient id="a">
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="0" />
<stop style="stop-color:#4cc155;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="19.837" y1="28.684" x2="21.503" y2="30.629" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3.00654 0 0 3.01583 -33.75 -72.882)" />
</defs>
<g transform="translate(-16.82 -12.342)">
<ellipse style="fill:#ff7f2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="16.332" cx="28.681" style="fill:url(#b);stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0c;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="20.797" style="fill:#6f0;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#cf0;stroke-width:4.39130402;stroke-miterlimit:4;" cx="28.681" cy="24.29" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="36.655" style="fill:#0ff;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0f;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="32.165" rx="3.977" ry="3.99" />
<ellipse cy="32.165" cx="28.681" style="fill:#c8ab37;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#ff2a2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="32.165" rx="3.977" ry="3.99" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 440,
spacing = 5,
forced_num_cols = 2,
homogeneous = false,
expand = false,
layout = wibox.layout.grid.vertical
}
l:add(wibox.widget {
markup = "<b>Original image:</b>",
widget = wibox.widget.textbox,
})
l:add_widget_at(wibox.widget {
image = image_path1,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 1, 1, 1)
l:add_widget_at(wibox.widget {
image = image_path2,
forced_height = 48,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, 2, 1, 1)
--DOC_HIDE_END
for k, mode in ipairs {"fit", "repeat", "reflect", "pad"} do
--DOC_HIDE_START
local r = 1 + k*2
l:add_widget_at(wibox.widget {
markup = "<b>filling_fit_policy = \"".. mode .."\"</b>",
widget = wibox.widget.textbox,
}, r, 1, 1, 2)
--DOC_HIDE_END
for idx, image in ipairs { image_path1, image_path2 } do
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
forced_height = 50, --DOC_HIDE
widget = wibox.widget.textbox
},
fill = true,
borders = idx == 1 and 10 or 30,
border_image = image,
filling_fit_policy = mode,
forced_width = 200, --DOC_HIDE
widget = wibox.container.border
}
l:add_widget_at(w, r+1, idx, 1, 1) --DOC_HIDE
end
--DOC_HIDE_END
end
--DOC_HIDE_START
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,121 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local color = require("gears.color")
local cairo = require("lgi").cairo
-- luacheck: push no max string line length
local image_path = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="opacity:0.25;fill:url(#b);fill-opacity:1;stroke:none;stroke-width:.55040765;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:0.25;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--luacheck: pop
local function sur_to_pat(img2)
local pat = cairo.Pattern.create_for_surface(img2)
pat:set_extend(cairo.Extend.REPEAT)
return pat
end
-- Imported for elv13/blind/pattern.lua
local function stripe_pat(col, angle, line_width, spacing)
col = color(col)
angle = angle or math.pi/4
line_width = line_width or 2
spacing = spacing or 2
local hy = line_width + 2*spacing
-- Get the necessary width and height so the line repeat itself correctly
local a, o = math.cos(angle)*hy, math.sin(angle)*hy
local w, h = math.ceil(a + (line_width - 1)), math.ceil(o + (line_width - 1))
-- Create the pattern
local img2 = cairo.SvgSurface.create(nil, w, h)
local cr2 = cairo.Context(img2)
cr2:set_antialias(cairo.ANTIALIAS_NONE)
-- Avoid artefacts caused by anti-aliasing
local offset = line_width
-- Setup
cr2:set_source(color(col))
cr2:set_line_width(line_width)
-- The central line
cr2:move_to(-offset, -offset)
cr2:line_to(w+offset, h+offset)
cr2:stroke()
-- Top right
cr2:move_to(-offset + w - spacing/2+line_width, -offset)
cr2:line_to(2*w+offset - spacing/2+line_width, h+offset)
cr2:stroke()
-- Bottom left
cr2:move_to(-offset + spacing/2-line_width, -offset + h)
cr2:line_to(w+offset + spacing/2-line_width, 2*h+offset)
cr2:stroke()
return sur_to_pat(img2)
end
local stripe_pattern = stripe_pat("#ff0000")
local l = wibox.layout {
forced_width = 240,
spacing = 5,
layout = wibox.layout.fixed.vertical
}
for _, honor in ipairs {true, false} do
--DOC_HIDE_END
local w = wibox.widget {
{
{
markup = "<b>Central widget</b>",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
bg = stripe_pattern,
widget = wibox.container.background
},
borders = 10,
border_image = image_path,
honor_borders = honor,
widget = wibox.container.border
}
--DOC_HIDE_START
l:add(wibox.widget {
{
markup = "<b>honor_borders = "..(honor and "true" or "false").."</b>",
widget = wibox.widget.textbox,
},
w,
layout = wibox.layout.fixed.vertical,
})
end
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,132 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local color = require("gears.color")
local beautiful = require( "beautiful" )
local cairo = require("lgi").cairo
-- luacheck: push no max string line length
local image_path = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="67.006" height="65.26">
<defs>
<filter height="1.408" y="-.204" width="1.408" x="-.204" id="a" style="color-interpolation-filters:sRGB">
<feGaussianBlur stdDeviation="2.079" />
</filter>
<filter height="1.158" y="-.079" width="1.158" x="-.079" id="b" style="color-interpolation-filters:sRGB">
<feGaussianBlur stdDeviation=".919" />
</filter>
<clipPath id="c" clipPathUnits="userSpaceOnUse">
<rect style="opacity:1;fill:#FF0000;fill-opacity:1;" width="12.7" height="12.7" x="56.318" y="122.526" rx="2.266" ry="2.266" />
</clipPath>
</defs>
<g transform="matrix(3.77953 0 0 3.77953 -205.339 -465.345)">
<path style="opacity:1;fill:#000;fill-opacity:1;filter:url(#a)" d="M341.607 504.254v40.498H326.25v-.09h-28.72a8.542 8.542 0 0 0 8.154 5.942h30.873a8.545 8.545 0 0 0 8.562-8.565v-30.873a8.527 8.527 0 0 0-3.512-6.912z" transform="matrix(.26458 0 0 .26458 -21.823 -7.793)" />
<rect ry="2.266" rx="2.266" y="122.526" x="56.318" height="12.7" width="12.7" style="opacity:1;fill:none;fill-opacity:1;filter:url(#b)" clip-path="url(#c)" transform="translate(-.267 1.837)" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#FF7700;fill-opacity:1;fill-rule:nonzero;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M58.384 123.88a2.617 2.617 0 0 0-2.616 2.615v8.17a2.617 2.617 0 0 0 2.616 2.615h8.168a2.619 2.619 0 0 0 2.617-2.615v-8.17a2.619 2.619 0 0 0-2.617-2.615zm0 .7h8.168c1.067 0 1.916.847 1.916 1.915v8.17a1.904 1.904 0 0 1-1.917 1.916h-8.167a1.904 1.904 0 0 1-1.916-1.916v-8.17c0-1.068.848-1.914 1.916-1.914z" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#FF0000;fill-opacity:1;fill-rule:nonzero;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M58.383 123.73a2.766 2.766 0 0 0-2.764 2.764v8.17a2.768 2.768 0 0 0 2.764 2.766h8.168a2.771 2.771 0 0 0 2.767-2.766v-8.17a2.77 2.77 0 0 0-2.767-2.764zm0 .3h8.168a2.468 2.468 0 0 1 2.469 2.464v8.17a2.47 2.47 0 0 1-2.47 2.467h-8.167a2.466 2.466 0 0 1-2.465-2.467v-8.17a2.464 2.464 0 0 1 2.465-2.465zm0 .402a2.054 2.054 0 0 0-2.065 2.062v8.17c0 1.147.918 2.066 2.065 2.066h8.168a2.06 2.06 0 0 0 2.066-2.066v-8.17c0-1.147-.92-2.062-2.066-2.062zm0 .298h8.168a1.75 1.75 0 0 1 1.767 1.764v8.17c0 .988-.78 1.768-1.767 1.768h-8.168c-.988 0-1.766-.78-1.766-1.768v-8.17c0-.988.778-1.764 1.766-1.764z" />
</g>
</svg>
]]
--luacheck: pop
local function sur_to_pat(img2)
local pat = cairo.Pattern.create_for_surface(img2)
pat:set_extend(cairo.Extend.REPEAT)
return pat
end
-- Imported for elv13/blind/pattern.lua
local function stripe_pat(col, angle, line_width, spacing)
col = color(col)
angle = angle or math.pi/4
line_width = line_width or 2
spacing = spacing or 2
local hy = line_width + 2*spacing
-- Get the necessary width and height so the line repeat itself correctly
local a, o = math.cos(angle)*hy, math.sin(angle)*hy
local w, h = math.ceil(a + (line_width - 1)), math.ceil(o + (line_width - 1))
-- Create the pattern
local img2 = cairo.SvgSurface.create(nil, w, h)
local cr2 = cairo.Context(img2)
cr2:set_antialias(cairo.ANTIALIAS_NONE)
-- Avoid artefacts caused by anti-aliasing
local offset = line_width
-- Setup
cr2:set_source(color(col))
cr2:set_line_width(line_width)
-- The central line
cr2:move_to(-offset, -offset)
cr2:line_to(w+offset, h+offset)
cr2:stroke()
-- Top right
cr2:move_to(-offset + w - spacing/2+line_width, -offset)
cr2:line_to(2*w+offset - spacing/2+line_width, h+offset)
cr2:stroke()
-- Bottom left
cr2:move_to(-offset + spacing/2-line_width, -offset + h)
cr2:line_to(w+offset + spacing/2-line_width, 2*h+offset)
cr2:stroke()
return sur_to_pat(img2)
end
local stripe_pattern = stripe_pat(beautiful.bg_normal)
local l = wibox.layout {
forced_width = 240,
spacing = 5,
layout = wibox.layout.fixed.vertical
}
for _, ontop in ipairs {true, false} do
--DOC_HIDE_END
local w = wibox.widget {
{
{
markup = "<b>Central widget</b>",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
bg = stripe_pattern,
widget = wibox.container.background
},
paddings = {
left = 5,
top = 3,
right = 10,
bottom = 10,
},
borders = 20,
border_image = image_path,
ontop = ontop,
honor_borders = false,
widget = wibox.container.border
}
--DOC_HIDE_START
l:add(wibox.widget {
{
markup = "<b>ontop = "..(ontop and "true" or "false").."</b>",
widget = wibox.widget.textbox,
},
w,
layout = wibox.layout.fixed.vertical,
})
end
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,142 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
local color = require("gears.color")
local cairo = require("lgi").cairo
-- luacheck: push no max string line length
local image_path = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="opacity:1;fill:url(#b);fill-opacity:1;stroke:none;stroke-width:.55040765;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 260,
spacing = 5,
layout = wibox.layout.fixed.vertical
}
local function sur_to_pat(img2)
local pat = cairo.Pattern.create_for_surface(img2)
pat:set_extend(cairo.Extend.REPEAT)
return pat
end
-- Imported for elv13/blind/pattern.lua
local function stripe_pat(col, angle, line_width, spacing)
col = color(col)
angle = angle or math.pi/4
line_width = line_width or 2
spacing = spacing or 2
local hy = line_width + 2*spacing
-- Get the necessary width and height so the line repeat itself correctly
local a, o = math.cos(angle)*hy, math.sin(angle)*hy
local w, h = math.ceil(a + (line_width - 1)), math.ceil(o + (line_width - 1))
-- Create the pattern
local img2 = cairo.SvgSurface.create(nil, w, h)
local cr2 = cairo.Context(img2)
cr2:set_antialias(cairo.ANTIALIAS_NONE)
-- Avoid artefacts caused by anti-aliasing
local offset = line_width
-- Setup
cr2:set_source(color(col))
cr2:set_line_width(line_width)
-- The central line
cr2:move_to(-offset, -offset)
cr2:line_to(w+offset, h+offset)
cr2:stroke()
-- Top right
cr2:move_to(-offset + w - spacing/2+line_width, -offset)
cr2:line_to(2*w+offset - spacing/2+line_width, h+offset)
cr2:stroke()
-- Bottom left
cr2:move_to(-offset + spacing/2-line_width, -offset + h)
cr2:line_to(w+offset + spacing/2-line_width, 2*h+offset)
cr2:stroke()
return sur_to_pat(img2)
end
local stripe_pattern = stripe_pat("#ff0000")
--DOC_HIDE_END
local paddings = {
0,
5,
10,
{
left = 5,
top = 5,
bottom = 10,
right = 10,
}
}
--DOC_NEWLINE
for _, padding in ipairs(paddings) do
local w = wibox.widget {
{
{
markup = "<b>Central widget</b>",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
bg = stripe_pattern,
widget = wibox.container.background
},
borders = 10,
paddings = padding,
border_image = image_path,
widget = wibox.container.border
}
--DOC_HIDE_START
if type(padding) == "table" then
padding = "{left=5, top=5, bottom=10, right=10}"
end
l:add(wibox.widget {
{
markup = "<b>paddings = "..padding.."</b>",
widget = wibox.widget.textbox,
},
w,
layout = wibox.layout.fixed.vertical,
})
--DOC_HIDE_END
end
parent:add(l) --DOC_HIDE
--DOC_HIDE vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,157 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
-- luacheck: push no max string line length
local image_path1 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="fill:url(#b);stroke-width:.55040765;stroke-miterlimit:4;;" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-vector-effect:none;fill:url(#c);fill-fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dashoffset:0;stroke-color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
local image_path2 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="90" height="90" viewBox="0 0 23.812 23.813">
<defs>
<linearGradient id="a">
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="0" />
<stop style="stop-color:#4cc155;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="19.837" y1="28.684" x2="21.503" y2="30.629" gradientUnits="userSpaceOnUse" gradientTransform="matrix(3.00654 0 0 3.01583 -33.75 -72.882)" />
</defs>
<g transform="translate(-16.82 -12.342)">
<ellipse style="fill:#ff7f2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="16.332" cx="28.681" style="fill:url(#b);stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0c;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="16.332" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="20.797" style="fill:#6f0;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#cf0;stroke-width:4.39130402;stroke-miterlimit:4;" cx="28.681" cy="24.29" rx="3.977" ry="3.99" />
<ellipse cy="24.29" cx="36.655" style="fill:#0ff;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#f0f;stroke-width:4.39130402;stroke-miterlimit:4;" cx="20.797" cy="32.165" rx="3.977" ry="3.99" />
<ellipse cy="32.165" cx="28.681" style="fill:#c8ab37;stroke-width:4.39130402;stroke-miterlimit:4;" rx="3.977" ry="3.99" />
<ellipse style="fill:#ff2a2a;stroke-width:4.39130402;stroke-miterlimit:4;" cx="36.655" cy="32.165" rx="3.977" ry="3.99" />
</g>
</svg>
]]
local image_path3 = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="67.006" height="65.26">
<defs>
<filter height="1.408" y="-.204" width="1.408" x="-.204" id="a" style="color-interpolation-filters:sRGB">
<feGaussianBlur stdDeviation="2.079" />
</filter>
<filter height="1.158" y="-.079" width="1.158" x="-.079" id="b" style="color-interpolation-filters:sRGB">
<feGaussianBlur stdDeviation=".919" />
</filter>
<clipPath id="c" clipPathUnits="userSpaceOnUse">
<rect style="opacity:1;fill:#4cc155;fill-opacity:1;" width="12.7" height="12.7" x="56.318" y="122.526" rx="2.266" ry="2.266" />
</clipPath>
</defs>
<g transform="matrix(3.77953 0 0 3.77953 -205.339 -465.345)">
<path style="opacity:1;fill:#000;fill-opacity:1;filter:url(#a)" d="M341.607 504.254v40.498H326.25v-.09h-28.72a8.542 8.542 0 0 0 8.154 5.942h30.873a8.545 8.545 0 0 0 8.562-8.565v-30.873a8.527 8.527 0 0 0-3.512-6.912z" transform="matrix(.26458 0 0 .26458 -21.823 -7.793)" />
<rect ry="2.266" rx="2.266" y="122.526" x="56.318" height="12.7" width="12.7" style="opacity:1;fill:none;fill-opacity:1;filter:url(#b)" clip-path="url(#c)" transform="translate(-.267 1.837)" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#ef00d9;fill-opacity:1;fill-rule:nonzero;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M58.384 123.88a2.617 2.617 0 0 0-2.616 2.615v8.17a2.617 2.617 0 0 0 2.616 2.615h8.168a2.619 2.619 0 0 0 2.617-2.615v-8.17a2.619 2.619 0 0 0-2.617-2.615zm0 .7h8.168c1.067 0 1.916.847 1.916 1.915v8.17a1.904 1.904 0 0 1-1.917 1.916h-8.167a1.904 1.904 0 0 1-1.916-1.916v-8.17c0-1.068.848-1.914 1.916-1.914z" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:#0c00ef;fill-opacity:1;fill-rule:nonzero;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M58.383 123.73a2.766 2.766 0 0 0-2.764 2.764v8.17a2.768 2.768 0 0 0 2.764 2.766h8.168a2.771 2.771 0 0 0 2.767-2.766v-8.17a2.77 2.77 0 0 0-2.767-2.764zm0 .3h8.168a2.468 2.468 0 0 1 2.469 2.464v8.17a2.47 2.47 0 0 1-2.47 2.467h-8.167a2.466 2.466 0 0 1-2.465-2.467v-8.17a2.464 2.464 0 0 1 2.465-2.465zm0 .402a2.054 2.054 0 0 0-2.065 2.062v8.17c0 1.147.918 2.066 2.065 2.066h8.168a2.06 2.06 0 0 0 2.066-2.066v-8.17c0-1.147-.92-2.062-2.066-2.062zm0 .298h8.168a1.75 1.75 0 0 1 1.767 1.764v8.17c0 .988-.78 1.768-1.767 1.768h-8.168c-.988 0-1.766-.78-1.766-1.768v-8.17c0-.988.778-1.764 1.766-1.764z" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 640,
spacing = 5,
forced_num_cols = 2,
homogeneous = false,
expand = false,
layout = wibox.layout.grid.vertical
}
l:add(wibox.widget {
markup = "<b>Original image:</b>",
widget = wibox.widget.textbox,
})
for idx, original in ipairs {image_path1, image_path2, image_path3 } do
l:add_widget_at(wibox.widget {
image = original,
forced_height = 64,
forced_width = 200,
halign = "center",
widget = wibox.widget.imagebox,
}, 2, idx, 1, 1)
end
--DOC_HIDE_END
local images = {
{
path = image_path1,
borders = 10,
},
{
path = image_path2,
borders = 30,
},
{
path = image_path3,
borders = {
top = 20,
left = 20,
bottom = 20,
right = 20,
},
},
}
--DOC_NEWLINE
for k, mode in ipairs {"fit", "repeat", "reflect", "pad"} do
--DOC_HIDE_START
local r = 1 + k*2
l:add_widget_at(wibox.widget {
markup = "<b>sides_fit_policy = \"".. mode .."\"</b>",
widget = wibox.widget.textbox,
}, r, 1, 1, 2)
--DOC_HIDE_END
for idx, image in ipairs(images) do
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
fill = false,
borders = image.borders,
border_image = image.path,
sides_fit_policy = mode,
forced_width = 200, --DOC_HIDE
widget = wibox.container.border
}
l:add_widget_at(w, r+1, idx, 1, 1) --DOC_HIDE
end
--DOC_HIDE_END
end
--DOC_HIDE_START
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,76 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
-- luacheck: push no max string line length
local image_path = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="opacity:1;fill:url(#b);fill-opacity:1;stroke:none;stroke-width:.55040765;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--luacheck: pop
local l = wibox.layout {
forced_width = 240,
spacing = 5,
layout = wibox.layout.fixed.vertical
}
l:add(wibox.widget {
markup = "<b>Original image:</b>",
widget = wibox.widget.textbox,
})
l:add(wibox.widget {
image = image_path,
forced_height = 48,
forced_width = 48,
widget = wibox.widget.imagebox,
})
for _, i in ipairs {true, false} do
--DOC_HIDE_END
local w = wibox.widget {
{
text = "Central widget",
valign = "center",
align = "center",
forced_height = 30,
forced_width = 30,
widget = wibox.widget.textbox
},
fill = true,
borders = 10,
border_image = image_path,
slice = i,
widget = wibox.container.border
}
--DOC_HIDE_START
l:add(wibox.widget {
{
markup = "<b>`slice` = "..(i and "true" or "false").."</b>",
widget = wibox.widget.textbox,
},
w,
layout = wibox.layout.fixed.vertical,
})
end
parent:add(l)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,51 @@
--DOC_GEN_IMAGE --DOC_HIDE_START
local parent = ...
local wibox = require("wibox")
--luacheck: push no max line length
--DOC_HIDE_END
local image_path = '<?xml version="1.0"?>'..
'<svg xmlns:xlink="http://www.w3.org/1999/xlink" width="30" height="30" viewBox="0 0 7.937 7.937">'..
' <defs>'..
' <linearGradient id="a">'..
' <stop style="stop-opacity:1" offset="0" id="first"/>'..
' <stop offset=".5" style="stop-opacity:1" id="second"/>'..
' <stop style="stop-opacity:1" offset="1" id="third"/>'..
' </linearGradient>' ..
' <linearGradient xlink:href="#a" id="b" gradientUnits="userSpaceOnUse" x1="28.726" y1="64.923" x2="182.185" y2="201.75" gradientTransform="matrix(.04726 0 0 .053 83.075 141.528)"/>'..
' </defs>'..
' <path d="M84.732 144.627c-.372 0-.642.329-.642.679v6.58c0 .35.27.678.642.678h6.653c.372 0 .642-.328.642-.679v-6.579c0-.35-.27-.68-.642-.68zm.043.685h6.567v6.568h-6.567z" style="fill:url(#b);" transform="translate(-84.09 -144.627)"/>'..
'</svg>'
--DOC_NEWLINE
local style = ""..
"#first {stop-color: magenta;}" ..
"#second {stop-color: cyan;}" ..
"#third {stop-color: yellow;}"
--DOC_NEWLINE
local w = wibox.widget {
{
text = "Center widget",
valign = "center",
align = "center",
widget = wibox.widget.textbox
},
borders = 50,
border_image_stylesheet = style,
border_image = image_path,
honor_borders = false,
forced_width = 100, --DOC_HIDE
forced_height = 100, --DOC_HIDE
widget = wibox.container.border
}
--DOC_HIDE_START
--luacheck: pop
parent:add(w)

View File

@ -0,0 +1,172 @@
--DOC_GEN_IMAGE --DOC_HIDE_START --DOC_NO_USAGE
local parent = ...
local wibox = require("wibox")
local gears = { shape = require("gears.shape")}
local beautiful = require( "beautiful" )
-- luacheck: push no max line length
local bg = [[
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="105.827" height="23.532" viewBox="0 0 28 6.226">
<defs>
<linearGradient gradientTransform="matrix(.22077 0 0 .2208 -204.378 31.642)" xlink:href="#a" id="d" x1="-264.083" y1="45.26" x2="-264.083" y2="17.29" gradientUnits="userSpaceOnUse"/>
<linearGradient id="a">
<stop style="stop-color:#777;stop-opacity:1" offset="0"/>
<stop style="stop-color:#dadada;stop-opacity:1" offset="1"/>
</linearGradient>
<linearGradient gradientTransform="matrix(.22077 0 0 .2208 -204.378 31.642)" xlink:href="#b" id="c" x1="-254.596" y1="18.068" x2="-254.596" y2="44.26" gradientUnits="userSpaceOnUse" spreadMethod="pad"/>
<linearGradient id="b">
<stop style="stop-color:#ececec;stop-opacity:1" offset="0"/>
<stop offset=".963" style="stop-color:#cbcbcb;stop-opacity:1"/>
<stop style="stop-color:#8d8d8d;stop-opacity:1" offset="1"/>
</linearGradient>
</defs>
<path d="M-250.12 35.462h23.877c1.111 0 2.006.894 2.006 2.006v3.999h-27.89v-3.999c0-1.112.895-2.006 2.006-2.006z" style="opacity:1;fill:url(#c);fill-opacity:1;stroke:none;stroke-width:.06623417;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" transform="translate(252.127 -35.351)"/>
<path style="opacity:1;fill:none;fill-opacity:1;stroke:url(#d);stroke-width:.22078058;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" d="M-249.988 35.462h23.745c1.111 0 2.006.894 2.006 2.006v3.999h-27.757v-3.999c0-1.112.895-2.006 2.006-2.006z" transform="translate(252.127 -35.351)"/>
</svg>
]]
local btn = [[
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="45.773" height="45.773" viewBox="0 0 12.111 12.111">
<defs>
<linearGradient id="a">
<stop style="stop-opacity:1" offset="0" id="bg2"/>
<stop style="stop-opacity:.88627452" offset="1" id="bg1"/>
</linearGradient>
<linearGradient xlink:href="#b" id="g" gradientUnits="userSpaceOnUse" x1="-453.433" y1="105.448" x2="-453.433" y2="95.432"/>
<linearGradient id="b">
<stop style="stop-color:#d8eaff;stop-opacity:1" offset="0"/>
<stop style="stop-color:#d8eaff;stop-opacity:0" offset="1"/>
</linearGradient>
<linearGradient id="c">
<stop offset="0" style="stop-color:#ececec;stop-opacity:1"/>
<stop offset="1" style="stop-color:#8d8d8d;stop-opacity:1"/>
</linearGradient>
<linearGradient xlink:href="#d" id="i" x1="-453.111" y1="95.539" x2="-453.111" y2="105.508" gradientUnits="userSpaceOnUse"/>
<linearGradient id="d">
<stop style="stop-color:#000;stop-opacity:1" offset="0"/>
<stop style="stop-color:#000;stop-opacity:0" offset="1"/>
</linearGradient>
<linearGradient id="e">
<stop style="stop-color:#101010;stop-opacity:.02531646" offset="0"/>
<stop offset=".788" style="stop-color:#000;stop-opacity:0"/>
<stop style="stop-color:#272727;stop-opacity:.68776369" offset=".875"/>
<stop style="stop-color:#ededed;stop-opacity:.40784314" offset="1"/>
</linearGradient>
<radialGradient xlink:href="#a" id="f" gradientUnits="userSpaceOnUse" cx="-453.052" cy="104.365" fx="-453.052" fy="104.365" r="5.292"/>
<radialGradient xlink:href="#e" id="j" gradientUnits="userSpaceOnUse" gradientTransform="matrix(1.14291 -.0086 .00853 1.13429 51.276 -28.422)" cx="-442.185" cy="110.611" fx="-442.185" fy="110.611" r="5.292"/>
<clipPath clipPathUnits="userSpaceOnUse" id="h">
<circle r="5.292" cy="100.83" cx="-453.193" style="opacity:1;fill:url(#radialGradient1250);fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/>
</clipPath>
</defs>
<g transform="translate(459.213 -94.787)">
<circle r="5.292" cy="100.83" cx="-453.193" style="opacity:1;fill:url(#f);fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"/>
<path d="M-448.374 98.657c.13 3.044-9.622 2.906-9.661.094-.017-.466 1.585-3.179 4.842-3.212 2.922 0 4.668 2.334 4.819 3.118z" style="opacity:1;fill:url(#g);fill-opacity:1;stroke:url(#linearGradient1378);stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0"/>
<circle clip-path="url(#h)" style="opacity:1;fill:none;fill-opacity:1;stroke:url(#i);stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;filter:url(#filter1216)" cx="-453.193" cy="100.83" r="5.292"/>
<circle style="opacity:1;fill:none;fill-opacity:1;stroke:url(#j);stroke-width:1.92490542;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" cx="-453.158" cy="100.842" r="5.093"/>
</g>
</svg>
]]
--luacheck: pop
local function generic_widget(text, margins)
return wibox.widget {
{
{
{
id = "text",
align = "center",
valign = "center",
text = text,
widget = wibox.widget.textbox
},
margins = 10,
widget = wibox.container.margin,
},
border_width = 3,
border_color = beautiful.border_color,
bg = beautiful.bg_normal,
widget = wibox.container.background
},
margins = margins or 5,
widget = wibox.container.margin,
}
end
--DOC_HIDE_END
local w = wibox.widget {
{
{
text = "Content",
align = "center",
valign = "center",
widget = wibox.widget.textbox
},
border_widgets = {
top = {
{
{
{
stylesheet = "#bg1 {stop-color:#ca2b2b;} #bg2 {stop-color:#f8b9b9;}",
image = btn,
widget = wibox.widget.imagebox
},
{
stylesheet = "#bg1 {stop-color:#ec9527;} #bg2 {stop-color:#ffff9c;}",
image = btn,
widget = wibox.widget.imagebox
},
{
stylesheet = "#bg1 {stop-color:#75b525;} #bg2 {stop-color:#e0fda9;}",
image = btn,
widget = wibox.widget.imagebox
},
spacing = 3,
layout = wibox.layout.fixed.horizontal
},
{
align = "center",
text = "Shameless macOS ripoff",
widget = wibox.widget.textbox
},
layout = wibox.layout.align.horizontal
},
paddings = 6,
borders = 14,
border_image = bg,
honor_borders = false,
fill = true,
forced_height = 28, --DOC_HIDE
widget = wibox.container.border
},
right = generic_widget(""),
bottom_right = generic_widget(""),
bottom = generic_widget(""),
bottom_left = generic_widget(""),
left = generic_widget(""),
},
borders = {
top = 28,
left = 22,
right = 22,
bottom = 22,
},
border_merging = {
top = true
},
forced_width = 300, --DOC_HIDE
forced_height = 100, --DOC_HIDE
widget = wibox.container.border
},
bg = "#d9d9d9",
shape = gears.shape.rounded_rect,
widget = wibox.container.background
}
--DOC_HIDE_START
parent:add(w)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80

View File

@ -0,0 +1,47 @@
--DOC_HIDE_ALL
--DOC_GEN_IMAGE
local wibox = require("wibox")
-- luacheck: push no max string line length
local data = [[
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" viewBox="0 0 12.7 12.7">
<defs>
<linearGradient id="a">
<stop style="stop-color:#ff2121;stop-opacity:1" offset="0" />
<stop style="stop-color:#2c21ff;stop-opacity:1" offset="1" />
</linearGradient>
<linearGradient xlink:href="#a" id="b" x1="37.798" y1="89.869" x2="148.167" y2="200.238" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" />
<linearGradient xlink:href="#a" id="c" gradientUnits="userSpaceOnUse" gradientTransform="translate(31.412 180.42) scale(.11008)" x1="148.167" y1="200.238" x2="37.798" y2="89.869" />
</defs>
<g transform="translate(-35.298 -190.038)">
<rect style="opacity:1;fill:url(#b);fill-opacity:1;stroke:none;stroke-width:.55040765;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" width="12.15" height="12.15" x="35.573" y="190.313" rx="2.371" ry="2.371" />
<path style="color:#000;dominant-baseline:auto;baseline-shift:baseline;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000;solid-opacity:1;vector-effect:none;fill:url(#c);fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:.55040765;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;enable-background:accumulate" d="M37.943 190.037a2.647 2.647 0 0 0-2.646 2.647v7.408a2.647 2.647 0 0 0 2.646 2.646h7.409a2.647 2.647 0 0 0 2.646-2.646v-7.408a2.647 2.647 0 0 0-2.646-2.647zm0 .55h7.409c1.165 0 2.095.931 2.095 2.097v7.408c0 1.165-.93 2.095-2.095 2.095h-7.409a2.085 2.085 0 0 1-2.095-2.095v-7.408c0-1.166.93-2.096 2.095-2.096z" />
</g>
</svg>
]]
--luacheck: pop
return {
text = "Before",
align = "center",
valign = "center",
widget = wibox.widget.textbox,
},
{
{
{
text = "After",
align = "center",
valign = "center",
widget = wibox.widget.textbox,
},
border_image = data,
slice = true,
fill = true,
borders = 10,
widget = wibox.container.border
},
margins = 5,
layout = wibox.container.margin
}