diff --git a/tests/examples/screen/geometry.lua b/tests/examples/screen/geometry.lua index 28841792d..b7765cd18 100644 --- a/tests/examples/screen/geometry.lua +++ b/tests/examples/screen/geometry.lua @@ -23,7 +23,7 @@ end --DOC_HIDE --DOC_NEWLINE -- This will shift the workarea by 24px at the top. - awful.wibar { + local wibar = awful.wibar { position = "top", height = 24, } @@ -32,4 +32,5 @@ return { --DOC_HIDE factor = 2 , --DOC_HIDE show_boxes = false, --DOC_HIDE highlight_geometry = true , --DOC_HIDE + draw_wibar = wibar, --DOC_HIDE } --DOC_HIDE diff --git a/tests/examples/screen/padding.lua b/tests/examples/screen/padding.lua index 79b9e049a..3f8b54f67 100644 --- a/tests/examples/screen/padding.lua +++ b/tests/examples/screen/padding.lua @@ -26,7 +26,7 @@ end --DOC_HIDE bottom = 20, } - awful.wibar { --DOC_HIDE + local wibar = awful.wibar { --DOC_HIDE position = "top", --DOC_HIDE height = 24, --DOC_HIDE } --DOC_HIDE @@ -35,4 +35,5 @@ return { --DOC_HIDE factor = 2 , --DOC_HIDE show_boxes = false, --DOC_HIDE highlight_padding_area = true , --DOC_HIDE + draw_wibar = wibar, --DOC_HIDE } --DOC_HIDE diff --git a/tests/examples/screen/template.lua b/tests/examples/screen/template.lua index 761e4d6f5..af9fc2acb 100644 --- a/tests/examples/screen/template.lua +++ b/tests/examples/screen/template.lua @@ -80,6 +80,7 @@ local colors = { workarea = "#0000ff", tiling_area = "#ff0000", padding_area= "#ff0000", + wibar = "#000000", } local function draw_area(_, rect, name, offset, highlight) @@ -108,6 +109,42 @@ local function draw_bounding_area(_, rect, hole, name, offset) cr:set_operator(cairo.Operator.OVER) end +local function draw_solid_area(_, rect, name, offset, alpha) + alpha = alpha or "59" -- Defaults to 35% + local x, y = rect.x*factor+offset, rect.y*factor+offset + cr:rectangle(x, y, rect.width*factor, rect.height*factor) + + cr:save() + cr:set_source(color.create_solid_pattern(colors[name] .. alpha)) + cr:fill_preserve() + cr:restore() + + cr:set_source(color(colors[name].."44")) + cr:stroke() +end + +local function draw_wibar(_, wibar, offset) + draw_solid_area(_, wibar, 'wibar', offset) + + -- Prepare to write on the wibar area + local pctx = PangoCairo.font_map_get_default():create_context() + local playout = Pango.Layout.new(pctx) + local pdesc = Pango.FontDescription() + pdesc:set_absolute_size(11 * Pango.SCALE) + playout:set_font_description(pdesc) + + -- Write wibar on the bar area + playout.attributes, playout.text = Pango.parse_markup('Wibar', -1, 0) + local _, logical = playout:get_pixel_extents() + local dx = (wibar.width*factor - logical.width) / 2 + local dy = (wibar.height*factor - logical.height) / 2 + cr:set_source_rgb(0, 0, 0) + cr:move_to(dx, dy) + cr:show_layout(playout) + + +end + local function compute_ruler(_, rect, name) table.insert(hrulers, { label = name, x = rect.x, width = rect.width @@ -293,14 +330,14 @@ end for _=1, screen.count() do local s = screen[1] - -- The outer geometry. - compute_ruler(s, s.geometry, "geometry") + -- The padding. + compute_ruler(s, s.tiling_area, "tiling_area") -- The workarea. compute_ruler(s, s.workarea, "workarea") - -- The padding. - compute_ruler(s, s.tiling_area, "tiling_area") + -- The outer geometry. + compute_ruler(s, s.geometry, "geometry") end -- Get the final size of the image. @@ -335,6 +372,11 @@ for k=1, screen.count() do -- Draw the ruler. draw_rulers(s) + -- Draw the wibar. + if args.draw_wibar then + draw_wibar(s, args.draw_wibar, (k-1)*10) + end + -- Draw the informations. if args.display_screen_info ~= false then draw_info(s) diff --git a/tests/examples/screen/tiling_area.lua b/tests/examples/screen/tiling_area.lua index a442a7508..5b80e6128 100644 --- a/tests/examples/screen/tiling_area.lua +++ b/tests/examples/screen/tiling_area.lua @@ -18,7 +18,7 @@ screen[1].padding = { bottom = 20, } -awful.wibar { +local wibar = awful.wibar { position = "top", height = 24, } @@ -27,4 +27,5 @@ return { factor = 2 , show_boxes = false, highlight_tiling_area = true , + draw_wibar = wibar, } diff --git a/tests/examples/screen/workarea.lua b/tests/examples/screen/workarea.lua index e8823c0f5..26a2266ae 100644 --- a/tests/examples/screen/workarea.lua +++ b/tests/examples/screen/workarea.lua @@ -29,7 +29,7 @@ end --DOC_HIDE --DOC_NEWLINE -- This will shift the workarea by 24px at the top. - awful.wibar { + local wibar = awful.wibar { position = "top", height = 24, } @@ -38,4 +38,5 @@ return { --DOC_HIDE factor = 2 , --DOC_HIDE show_boxes = false, --DOC_HIDE highlight_workarea = true , --DOC_HIDE + draw_wibar = wibar, --DOC_HIDE } --DOC_HIDE