From f2b77653557a34db95d266648c96cd508970b450 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Sun, 9 Oct 2016 01:33:08 -0400 Subject: [PATCH] tests: Test the `manual` layout. --- .../examples/wibox/layout/defaults/manual.lua | 24 ++++++++++ tests/examples/wibox/layout/manual/add_at.lua | 48 +++++++++++++++++++ .../wibox/layout/manual/move_widget.lua | 18 +++++++ 3 files changed, 90 insertions(+) create mode 100644 tests/examples/wibox/layout/defaults/manual.lua create mode 100644 tests/examples/wibox/layout/manual/add_at.lua create mode 100644 tests/examples/wibox/layout/manual/move_widget.lua diff --git a/tests/examples/wibox/layout/defaults/manual.lua b/tests/examples/wibox/layout/defaults/manual.lua new file mode 100644 index 000000000..9f72920ce --- /dev/null +++ b/tests/examples/wibox/layout/defaults/manual.lua @@ -0,0 +1,24 @@ +local generic_widget = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE + +local w1, w2 = generic_widget(), generic_widget() +w1.point = {x=75,y=5} +w1.text = "first" +w1.forced_width = 50 + +w2.text = "second" +w2.point = function(geo, args) + -- Bottom right + return { + x = args.parent.width-geo.width, + y = args.parent.height-geo.height + } +end + +return --DOC_HIDE +wibox.layout { + w1, + w2, + generic_widget("third"), + layout = wibox.layout.manual +} diff --git a/tests/examples/wibox/layout/manual/add_at.lua b/tests/examples/wibox/layout/manual/add_at.lua new file mode 100644 index 000000000..ba5dbcb34 --- /dev/null +++ b/tests/examples/wibox/layout/manual/add_at.lua @@ -0,0 +1,48 @@ +local generic_widget = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local awful = {placement = require("awful.placement")} --DOC_HIDE + +local l = wibox.layout { + layout = wibox.layout.manual +} +-- +-- Option 1: Set the point directly in the widget +local w1 = generic_widget() +w1.point = {x=75, y=5} +w1.text = "first" +w1.forced_width = 50 +l:add(w1) + +-- +-- Option 2: Set the point directly in the widget as a function + +local w2 = generic_widget() +w2.text = "second" +w2.point = function(geo, args) + return { + x = args.parent.width - geo.width, + y = 0 + } +end +l:add(w2) + +-- +-- Option 3: Set the point directly in the widget as an `awful.placement` +-- function. + +local w3 = generic_widget() +w3.text = "third" +w3.point = awful.placement.bottom_right +l:add(w3) + +-- +-- Option 4: Use `:add_at` instead of using the `.point` property. This works +-- with all 3 ways to define the point. +-- function. + +local w4 = generic_widget() +w4.text = "fourth" +l:add_at(w4, awful.placement.centered + awful.placement.maximize_horizontally) + +return l, 200, 100 --DOC_HIDE + diff --git a/tests/examples/wibox/layout/manual/move_widget.lua b/tests/examples/wibox/layout/manual/move_widget.lua new file mode 100644 index 000000000..7f329aca3 --- /dev/null +++ b/tests/examples/wibox/layout/manual/move_widget.lua @@ -0,0 +1,18 @@ +local generic_widget = ... --DOC_HIDE +local wibox = require("wibox") --DOC_HIDE +local awful = {placement = require("awful.placement")} --DOC_HIDE + +local l = wibox.layout { + layout = wibox.layout.manual +} +-- +local w1 = generic_widget() +w1.point = {x=75, y=5} +w1.text = "first" +w1.forced_width = 50 +l:add(w1) + +l:move_widget(w1, awful.placement.bottom_right) + +return l, 100, 50 --DOC_HIDE +