Add tests for grid layout
Update tests Update tests Separate spacing and padding tests Update tests amd add imperative usage Change fixed_size to homogeneous property Update tests
This commit is contained in:
parent
9a3cdab534
commit
bf2d658380
|
@ -0,0 +1,16 @@
|
|||
local generic_widget = ... --DOC_HIDE
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
return --DOC_HIDE
|
||||
wibox.widget {
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
expand = true,
|
||||
layout = wibox.layout.grid
|
||||
}
|
||||
, nil, 60 --DOC_HIDE
|
|
@ -0,0 +1,16 @@
|
|||
local generic_widget, generic_before_after = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
local beautiful = require("beautiful") --DOC_HIDE
|
||||
|
||||
print("l:add_widget_at(new, 1, 4, 1, 1)") --DOC_HIDE
|
||||
|
||||
local w = generic_before_after(wibox.layout.grid, {
|
||||
forced_num_cols = 3,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
}, 6, "add_widget_at", {wibox.widget( --DOC_HIDE
|
||||
generic_widget("__new__",beautiful.bg_highlight) --DOC_HIDE
|
||||
), 1, 4, 1, 1 --DOC_HIDE
|
||||
}) --DOC_HIDE
|
||||
|
||||
return w, w:fit({dpi=96}, 9999, 9999) --DOC_HIDE
|
|
@ -0,0 +1,106 @@
|
|||
local generic_widget = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
local w = wibox.widget {
|
||||
{
|
||||
{
|
||||
{
|
||||
markup = "<b>expand</b> = <i>false</i>\n<b>homogeneous</b> = <i>false</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "short 1" ),
|
||||
generic_widget( "-------- long 1 --------" ),
|
||||
generic_widget( "short 2" ),
|
||||
generic_widget( "-------- long 2 --------" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
expand = false,
|
||||
homogeneous = false,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
markup = "<b>expand</b> = <i>true</i>\n<b>homogeneous</b> = <i>false</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "short 1" ),
|
||||
generic_widget( "-------- long 1 --------" ),
|
||||
generic_widget( "short 2" ),
|
||||
generic_widget( "-------- long 2 --------" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
expand = true,
|
||||
homogeneous = false,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
{
|
||||
{
|
||||
{
|
||||
markup = "<b>expand</b> = <i>false</i>\n<b>homogeneous</b> = <i>true</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "short 1" ),
|
||||
generic_widget( "-------- long 1 --------" ),
|
||||
generic_widget( "short 2" ),
|
||||
generic_widget( "-------- long 2 --------" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
expand = false,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
markup = "<b>expand</b> = <i>true</i>\n<b>homogeneous</b> = <i>true</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "short 1" ),
|
||||
generic_widget( "-------- long 1 --------" ),
|
||||
generic_widget( "short 2" ),
|
||||
generic_widget( "-------- long 2 --------" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
expand = true,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.flex.horizontal
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
}
|
||||
return w, 600, 150
|
|
@ -0,0 +1,11 @@
|
|||
local _, generic_before_after = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
print("l:extend_column(2)") --DOC_HIDE
|
||||
|
||||
local w = generic_before_after(wibox.layout.grid, {
|
||||
forced_num_cols = 3,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
}, 6, "extend_column", {2}) --DOC_HIDE
|
||||
return w, w:fit({dpi=96}, 9999, 9999) --DOC_HIDE
|
|
@ -0,0 +1,27 @@
|
|||
local generic_widget = ... --DOC_NO_USAGE --DOC_HIDE
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
local first = wibox.widget(generic_widget( "first" )) --DOC_HIDE
|
||||
local second = wibox.widget(generic_widget( "second" )) --DOC_HIDE
|
||||
local third = wibox.widget(generic_widget( "t\nh\ni\nr\nd" )) --DOC_HIDE
|
||||
local fourth = wibox.widget(generic_widget( "fourth" )) --DOC_HIDE
|
||||
local fifth = wibox.widget(generic_widget( "fifth" )) --DOC_HIDE
|
||||
local lorem = wibox.widget(generic_widget("Lorem ipsum dolor sit amet, consectetur " .. --DOC_HIDE
|
||||
"adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")) --DOC_HIDE
|
||||
|
||||
local l = wibox.widget {
|
||||
homogeneous = true,
|
||||
spacing = 5,
|
||||
min_cols_size = 10,
|
||||
min_rows_size = 10,
|
||||
layout = wibox.layout.grid,
|
||||
}
|
||||
l:add_widget_at(first , 2, 1, 1, 2)
|
||||
l:add_widget_at(second, 3, 1, 1, 2)
|
||||
l:add_widget_at(third , 2, 3, 2, 1)
|
||||
l:add_widget_at(fourth, 4, 1, 1, 1)
|
||||
l:add_widget_at(fifth , 4, 2, 1, 2)
|
||||
l:insert_row(1)
|
||||
l:add_widget_at(lorem, 1, 1, 1, 3)
|
||||
|
||||
return l, l:fit({dpi=96}, 300, 200) --DOC_HIDE
|
|
@ -0,0 +1,12 @@
|
|||
local _, generic_before_after = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
print("l:insert_column(2)") --DOC_HIDE
|
||||
|
||||
local w = generic_before_after(wibox.layout.grid, {
|
||||
forced_num_cols = 3,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
}
|
||||
, 6, "insert_column", {2}) --DOC_HIDE
|
||||
return w, w:fit({dpi=96}, 9999, 9999) --DOC_HIDE
|
|
@ -0,0 +1,49 @@
|
|||
local generic_widget = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
local beautiful = require("beautiful") --DOC_HIDE
|
||||
|
||||
local w = wibox.widget {
|
||||
{
|
||||
{
|
||||
markup = "<b>min_cols_size</b> = <i>0</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
forced_num_cols = 2,
|
||||
min_cols_size = 0,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
markup = "<b>min_cols_size</b> = <i>100</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
forced_num_cols = 2,
|
||||
min_cols_size = 100,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
return w, w:fit({dpi=96}, 9999, 9999)
|
||||
--return w, 500, 50
|
|
@ -0,0 +1,71 @@
|
|||
local generic_widget = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
local beautiful = require("beautiful") --DOC_HIDE
|
||||
|
||||
print([[l = wibox.layout {
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid
|
||||
}
|
||||
l:set_orientation("vertical") -- change to "horizontal"
|
||||
l:add(...)
|
||||
]]) --DOC_HIDE
|
||||
|
||||
return --DOC_HIDE
|
||||
wibox.widget {
|
||||
{
|
||||
{
|
||||
markup = "<b>orientation</b> = <i>'vertical'</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
generic_widget( "fifth" ),
|
||||
generic_widget( "sixth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
orientation = "vertical",
|
||||
expand = false,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
markup = "<b>orientation</b> = <i>'horizontal'</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
generic_widget( "fifth" ),
|
||||
generic_widget( "sixth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
orientation = 'horizontal',
|
||||
expand = false,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
, 300, 90 --DOC_HIDE
|
|
@ -0,0 +1,12 @@
|
|||
local _, generic_before_after = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
print("l:remove_widgets_at(1,1)") --DOC_HIDE
|
||||
|
||||
local w = generic_before_after(wibox.layout.grid, {
|
||||
forced_num_cols = 3,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
}, 6, "remove_widgets_at", {1, 1}) --DOC_HIDE
|
||||
|
||||
return w, w:fit({dpi=96}, 9999, 9999) --DOC_HIDE
|
|
@ -0,0 +1,12 @@
|
|||
local _, generic_before_after = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
|
||||
print("l:remove_column(2)") --DOC_HIDE
|
||||
|
||||
local w = generic_before_after(wibox.layout.grid, {
|
||||
forced_num_cols = 3,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
}, 6, "remove_column", {2} --DOC_HIDE
|
||||
)
|
||||
return w, w:fit({dpi=96}, 9999, 9999) --DOC_HIDE
|
|
@ -0,0 +1,56 @@
|
|||
local generic_widget = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox") --DOC_HIDE
|
||||
local beautiful = require("beautiful") --DOC_HIDE
|
||||
|
||||
local w = wibox.widget {
|
||||
{
|
||||
{
|
||||
markup = "<b>spacing</b> = <i>0</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
spacing = 0,
|
||||
padding = 0,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
{
|
||||
{
|
||||
markup = "<b>spacing</b> = <i>10</i>",
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
{
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
homogeneous = true,
|
||||
spacing = 10,
|
||||
padding = 0,
|
||||
layout = wibox.layout.grid,
|
||||
},
|
||||
margins = 1,
|
||||
color = beautiful.border_color,
|
||||
layout = wibox.container.margin,
|
||||
},
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
layout = wibox.layout.flex.horizontal
|
||||
}
|
||||
return w, w:fit({dpi=96}, 9999, 9999)
|
|
@ -0,0 +1,20 @@
|
|||
local generic_widget = ... --DOC_HIDE_ALL
|
||||
local wibox = require("wibox")
|
||||
local beautiful = require("beautiful")
|
||||
|
||||
local w = wibox.widget {
|
||||
generic_widget( "first" ),
|
||||
generic_widget( "second" ),
|
||||
generic_widget( "third" ),
|
||||
generic_widget( "fourth" ),
|
||||
forced_num_cols = 2,
|
||||
forced_num_rows = 2,
|
||||
superpose = true,
|
||||
homogeneous = true,
|
||||
layout = wibox.layout.grid,
|
||||
}
|
||||
w:add_widget_at(wibox.widget(
|
||||
generic_widget("fifth",beautiful.bg_highlight)
|
||||
), 1, 1, 1, 2)
|
||||
|
||||
return w, w:fit({dpi=96}, 9999, 9999)
|
Loading…
Reference in New Issue