Apply suggestions from code review

Co-authored-by: Aire-One <Aire-One@users.noreply.github.com>
This commit is contained in:
Emmanuel Lepage Vallée 2021-07-07 00:42:31 -07:00 committed by Emmanuel Lepage Vallee
parent d5d74e44de
commit 6ad693eff0
2 changed files with 17 additions and 15 deletions

View File

@ -71,11 +71,11 @@ local align_map = {
-- --
-- Values are: -- Values are:
-- --
-- * top -- * `"top"`
-- * bottom -- * `"bottom"`
-- * left -- * `"left"`
-- * right -- * `"right"`
-- * centered -- * `"centered"`
-- --
-- @DOC_awful_wibar_align_EXAMPLE@ -- @DOC_awful_wibar_align_EXAMPLE@
-- --
@ -87,8 +87,8 @@ local align_map = {
--- Margins on each side of the wibar. --- Margins on each side of the wibar.
-- --
-- It can either be a table if `top`, `bottom`, `left`, `right` or a -- It can either be a table with `top`, `bottom`, `left` and `right`
-- single number. -- properties, or a single number that apply to all fourth sides.
-- --
-- @DOC_awful_wibar_margins_EXAMPLE@ -- @DOC_awful_wibar_margins_EXAMPLE@
-- --
@ -385,12 +385,12 @@ function awfulwibar.set_margins(w, value)
} }
end end
value = value or { value = gtable.crush({
left = 0, left = 0,
right = 0, right = 0,
top = 0, top = 0,
bottom = 0 bottom = 0
} }, value or {}, true)
w._private.margins = value w._private.margins = value

View File

@ -15,6 +15,8 @@ local args = loadfile(file_path)() or 10
args = args or {} args = args or {}
args.factor = args.factor or 10 args.factor = args.factor or 10
local SCALE_FACTOR = 0.66
local factor, img, cr = 1/args.factor local factor, img, cr = 1/args.factor
require("gears.timer").run_delayed_calls_now() require("gears.timer").run_delayed_calls_now()
@ -470,7 +472,7 @@ local function draw_struts(s)
if left > 0 then if left > 0 then
draw_hruler( draw_hruler(
s, s,
s.geometry.y*0.66, s.geometry.y*SCALE_FACTOR,
get_text_height(), get_text_height(),
{x = s.geometry.x+tr_x*2, width = left, color = colors.gaps.."66", align = true}, {x = s.geometry.x+tr_x*2, width = left, color = colors.gaps.."66", align = true},
1 1
@ -481,7 +483,7 @@ local function draw_struts(s)
draw_vruler( draw_vruler(
s, s,
get_text_height()*1.5, get_text_height()*1.5,
s.geometry.x*0.66, s.geometry.x*SCALE_FACTOR,
{y=s.geometry.y+tr_y*(1/factor), height = top, color = colors.gaps.."66", align = true}, {y=s.geometry.y+tr_y*(1/factor), height = top, color = colors.gaps.."66", align = true},
1 1
) )
@ -490,7 +492,7 @@ local function draw_struts(s)
if right > 0 then if right > 0 then
draw_hruler( draw_hruler(
s, s,
s.geometry.y*0.66, s.geometry.y*SCALE_FACTOR,
get_text_height(), get_text_height(),
{x = s.geometry.x, width = left, color = colors.gaps.."66", align = true}, {x = s.geometry.x, width = left, color = colors.gaps.."66", align = true},
1 1
@ -501,7 +503,7 @@ local function draw_struts(s)
draw_vruler( draw_vruler(
s, s,
get_text_height()*1.5, get_text_height()*1.5,
s.geometry.x*0.66, s.geometry.x*SCALE_FACTOR,
{ {
y = s.geometry.y+tr_y*(1/factor)+s.geometry.height - bottom, y = s.geometry.y+tr_y*(1/factor)+s.geometry.height - bottom,
height = bottom, height = bottom,
@ -689,7 +691,7 @@ evaluate_translation(
local sew, seh = screen._get_extents() local sew, seh = screen._get_extents()
sew, seh = sew/args.factor + (screen.count()-1)*10+2, seh/args.factor+2 sew, seh = sew/args.factor + (screen.count()-1)*10+2, seh/args.factor+2
sew, seh = sew + tr_x, seh + 0.66*tr_y sew, seh = sew + tr_x, seh + SCALE_FACTOR*tr_y
sew, seh = sew + 5*get_text_height(), seh + 5*get_text_height() sew, seh = sew + 5*get_text_height(), seh + 5*get_text_height()
@ -697,7 +699,7 @@ img = cairo.SvgSurface.create(image_path..".svg", sew, seh)
cr = cairo.Context(img) cr = cairo.Context(img)
-- Instead of adding origin offset everywhere, translate the viewport. -- Instead of adding origin offset everywhere, translate the viewport.
cr:translate(tr_x, tr_y * 0.66) cr:translate(tr_x, tr_y * SCALE_FACTOR)
-- Draw the various areas. -- Draw the various areas.
for k=1, screen.count() do for k=1, screen.count() do