diff --git a/tests/examples/shims/beautiful.lua b/tests/examples/shims/beautiful.lua index 396ace662..dffb924ce 100644 --- a/tests/examples/shims/beautiful.lua +++ b/tests/examples/shims/beautiful.lua @@ -3,15 +3,24 @@ local Pango = lgi.Pango local cairo = lgi.cairo -- A simple Awesome logo -local function logo() +local function logo(fg, bg) local img = cairo.ImageSurface.create(cairo.Format.ARGB32, 22, 22) local cr = cairo.Context(img) -- Awesome default #555555 - cr:set_source_rgb(0.21568627451, 0.21568627451, 0.21568627451) + if bg then + cr:set_source(bg) + else + cr:set_source_rgb(0.21568627451, 0.21568627451, 0.21568627451) + end + cr:paint() - cr:set_source_rgb(1,1,1) + if fg then + cr:set_source(fg) + else + cr:set_source_rgb(1,1,1) + end cr:rectangle(0, 7, 15, 1) cr:fill() @@ -48,7 +57,8 @@ local module = { -- Fake resources handling xresources = require("beautiful.xresources"), - awesome_icon = logo() + awesome_icon = logo(), + _logo = logo, } module.graph_bg = module.bg_normal diff --git a/tests/examples/wibox/container/background/border_color.lua b/tests/examples/wibox/container/background/border_color.lua new file mode 100644 index 000000000..99a7cd184 --- /dev/null +++ b/tests/examples/wibox/container/background/border_color.lua @@ -0,0 +1,52 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") +local gears = { shape = require("gears.shape"), color = require("gears.color") } +local beautiful = require("beautiful") + +parent.spacing = 5 + +--DOC_HIDE_END + +local colors = { + beautiful.bg_normal, + "#00ff00", + gears.color { + type = "linear", + from = { 0 , 20 }, + to = { 20, 0 }, + stops = { + { 0, "#0000ff" }, + { 1, "#ff0000" } + }, + }, +} + +--DOC_NEWLINE + +for _, color in ipairs(colors) do + local w = wibox.widget { + { + { + text = " Content ", + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + margins = 10, + widget = wibox.container.margin + }, + border_color = color, + border_width = 3, + stretch_vertically = true, + stretch_horizontally = true, + shape = gears.shape.rounded_rect, + widget = wibox.container.background + } + + parent:add(w) --DOC_HIDE +end + +--DOC_HIDE_START + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/container/background/border_strategy.lua b/tests/examples/wibox/container/background/border_strategy.lua new file mode 100644 index 000000000..1952396b9 --- /dev/null +++ b/tests/examples/wibox/container/background/border_strategy.lua @@ -0,0 +1,54 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") +local gears = { shape = require("gears.shape") } +local beautiful = require("beautiful") + +local l = wibox.layout { + forced_width = 640, + spacing = 5, + forced_num_cols = 2, + homogeneous = false, + expand = false, + layout = wibox.layout.grid.vertical +} + +--DOC_HIDE_END + +for k, strategy in ipairs { "none", "inner" } do + --DOC_HIDE_START + local r = k*2 + + l:add_widget_at(wibox.widget { + markup = "border_strategy = \"".. strategy .."\"", + widget = wibox.widget.textbox, + }, r, 1, 1, 2) + --DOC_HIDE_END + + for idx, width in ipairs {0, 1, 3, 10 } do + local w = wibox.widget { + { + { + text = "border_width = "..width, + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + border_color = beautiful.bg_normal, + border_width = width, + border_strategy = strategy, + shape = gears.shape.rounded_rect, + widget = wibox.container.background + }, + widget = wibox.container.place + } + + 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 diff --git a/tests/examples/wibox/container/background/border_width.lua b/tests/examples/wibox/container/background/border_width.lua new file mode 100644 index 000000000..7fc874558 --- /dev/null +++ b/tests/examples/wibox/container/background/border_width.lua @@ -0,0 +1,34 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") +local gears = { shape = require("gears.shape") } +local beautiful = require("beautiful") + +parent.spacing = 5 + +--DOC_HIDE_END + +for _, width in ipairs {0, 1, 3, 10 } do + local w = wibox.widget { + { + { + text = " Content ", + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + margins = 10, + widget = wibox.container.margin + }, + border_color = beautiful.bg_normal, + border_width = width, + shape = gears.shape.rounded_rect, + widget = wibox.container.background + } + + parent:add(w) --DOC_HIDE +end + +--DOC_HIDE_START + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/container/background/stretch_horizontally.lua b/tests/examples/wibox/container/background/stretch_horizontally.lua new file mode 100644 index 000000000..3cad561b8 --- /dev/null +++ b/tests/examples/wibox/container/background/stretch_horizontally.lua @@ -0,0 +1,82 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") +local gears = { shape = require("gears.shape"), color = require("gears.color") } + +local l = wibox.layout { + forced_width = 640, + spacing = 5, + forced_num_cols = 2, + homogeneous = false, + expand = false, + layout = wibox.layout.grid.vertical +} + +--DOC_HIDE_END + +local gradients = { + gears.color { + type = "linear", + from = { 0 , 0 }, + to = { 100, 0 }, + stops = { + { 0 , "#0000ff" }, + { 0.8, "#0000ff" }, + { 1 , "#ff0000" } + } + }, + gears.color { + type = "radial", + from = { 30, 98, 20 }, + to = { 30, 98, 120 }, + stops = { + { 0 , "#ff0000" }, + { 0.5, "#00ff00" }, + { 1 , "#0000ff" }, + } + } +} + +--DOC_NEWLINE + +for k, stretch in ipairs { false, true } do + --DOC_HIDE_START + local r = (k-1)*5 + 1 + + l:add_widget_at(wibox.widget { + markup = "stretch_horizontally = \"".. (stretch and "true" or "false") .."\"", + widget = wibox.widget.textbox, + }, r, 1, 1, 2) + --DOC_HIDE_END + + for __, grad in ipairs(gradients) do + for idx, width in ipairs { 50, 100, 150, 200 } do + local w = wibox.widget { + { + { + text = " Width: " .. width .. " ", + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + bg = grad, + stretch_horizontally = stretch, + forced_width = width, + fg = "#ffffff", + shape = gears.shape.rounded_rect, + widget = wibox.container.background + }, + forced_width = 200, + widget = wibox.container.place + } + + l:add_widget_at(w, (k-1)*5 + idx + 1, __, 1, 1) --DOC_HIDE + end + end + --DOC_HIDE_END +end +--DOC_HIDE_START + +parent:add(l) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/tests/examples/wibox/container/background/stretch_vertically.lua b/tests/examples/wibox/container/background/stretch_vertically.lua new file mode 100644 index 000000000..35dbb13bf --- /dev/null +++ b/tests/examples/wibox/container/background/stretch_vertically.lua @@ -0,0 +1,83 @@ +--DOC_GEN_IMAGE --DOC_HIDE_START +local parent = ... +local wibox = require("wibox") +local gears = { shape = require("gears.shape"), color = require("gears.color") } + +local l = wibox.layout { + forced_width = 640, + spacing = 5, + forced_num_cols = 2, + homogeneous = false, + expand = false, + layout = wibox.layout.grid.vertical +} + +--DOC_HIDE_END + +local gradients = { + gears.color { + type = "linear", + from = { 0, 0 }, + to = { 0, 100 }, + stops = { + { 0 , "#0000ff" }, + { 0.8, "#0000ff" }, + { 1 , "#ff0000" } + } + }, + gears.color { + type = "radial", + from = { 30, 98, 20 }, + to = { 30, 98, 120 }, + stops = { + { 0 , "#ff0000" }, + { 0.5, "#00ff00" }, + { 1 , "#0000ff" }, + } + } +} + +--DOC_NEWLINE + +for k, stretch in ipairs { false, true } do + --DOC_HIDE_START + local r = (k-1) * 3 + 1 + + l:add_widget_at(wibox.widget { + markup = "stretch_vertically = \"".. (stretch and "true" or "false") .."\"", + widget = wibox.widget.textbox, + }, r, 1, 1, 2) + --DOC_HIDE_END + + + for _, gradient in ipairs(gradients) do + for idx, height in ipairs { 10, 50, 100, 150 } do + local w = wibox.widget { + { + { + text = " Height: " .. height .. " ", + valign = "center", + align = "center", + widget = wibox.widget.textbox + }, + bg = gradient, + stretch_vertically = stretch, + forced_height = height, + fg = "#ffffff", + shape = gears.shape.rounded_rect, + widget = wibox.container.background + }, + forced_height = 150, + widget = wibox.container.place + } + + l:add_widget_at(w, r + _, idx, 1, 1) --DOC_HIDE + end + end + --DOC_HIDE_END +end +--DOC_HIDE_START + +parent:add(l) + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80