-
Notifications
You must be signed in to change notification settings - Fork 601
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: Add more
wibox.container.background
examples.
- Loading branch information
Showing
6 changed files
with
319 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
tests/examples/wibox/container/background/border_color.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
54 changes: 54 additions & 0 deletions
54
tests/examples/wibox/container/background/border_strategy.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "<b>border_strategy = \"".. strategy .."\"</b>", | ||
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 |
34 changes: 34 additions & 0 deletions
34
tests/examples/wibox/container/background/border_width.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
82 changes: 82 additions & 0 deletions
82
tests/examples/wibox/container/background/stretch_horizontally.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "<b>stretch_horizontally = \"".. (stretch and "true" or "false") .."\"</b>", | ||
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 |
83 changes: 83 additions & 0 deletions
83
tests/examples/wibox/container/background/stretch_vertically.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 = "<b>stretch_vertically = \"".. (stretch and "true" or "false") .."\"</b>", | ||
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 |