From 3830e9de352b70561448444e32e677830b23dcda Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 16 Nov 2019 19:51:50 +0100 Subject: [PATCH 1/3] Invert rulers insertion order. Rulers insertion order impact the result of the bubble sort algorithm. By inverting the order, we can make the output image looking more natural. Awesome's screen properties can be seen like this: * The screen has a geometry (its size) ; * Inside there is the workarea ; * Inside there is the tiling_area. It seems better to draw rulers in this order. --- tests/examples/screen/template.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/examples/screen/template.lua b/tests/examples/screen/template.lua index 761e4d6f..950042e9 100644 --- a/tests/examples/screen/template.lua +++ b/tests/examples/screen/template.lua @@ -293,14 +293,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. From 92f698bbaefbebe6f8b0e09234bab5a18c3b3c18 Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 16 Nov 2019 20:01:00 +0100 Subject: [PATCH 2/3] Add an option to draw the wibar on screen images. Add a new option to the screen image template: `draw_wibar`. This option draw the wibar on the generated image. --- tests/examples/screen/template.lua | 42 ++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/examples/screen/template.lua b/tests/examples/screen/template.lua index 950042e9..af9fc2ac 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 @@ -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) From 3791daaeaf544b49d5e552b9377f4d53aa3b5c5f Mon Sep 17 00:00:00 2001 From: Aire-One Date: Sat, 16 Nov 2019 20:08:36 +0100 Subject: [PATCH 3/3] Add wibar drawing to screen properties images. --- tests/examples/screen/geometry.lua | 3 ++- tests/examples/screen/padding.lua | 3 ++- tests/examples/screen/tiling_area.lua | 3 ++- tests/examples/screen/workarea.lua | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/examples/screen/geometry.lua b/tests/examples/screen/geometry.lua index 28841792..b7765cd1 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 79b9e049..3f8b54f6 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/tiling_area.lua b/tests/examples/screen/tiling_area.lua index a442a750..5b80e612 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 e8823c0f..26a2266a 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