doc: Use the theme foreground color instead of black in the templates.
This is a step toward adding a dark theme to the doc. Otherwise, the images were black on dark grey, which is impossible to read.
This commit is contained in:
parent
f6f57e7ba0
commit
197ed41c2d
|
@ -10,6 +10,7 @@ local Pango = require("lgi").Pango
|
||||||
local PangoCairo = require("lgi").PangoCairo
|
local PangoCairo = require("lgi").PangoCairo
|
||||||
local color = require("gears.color")
|
local color = require("gears.color")
|
||||||
local aclient = require("awful.client")
|
local aclient = require("awful.client")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
|
||||||
-- Let the test request a size and file format
|
-- Let the test request a size and file format
|
||||||
local args = loadfile(file_path)() or 10
|
local args = loadfile(file_path)() or 10
|
||||||
|
@ -79,11 +80,11 @@ local function stripe_pat(col, angle, line_width, spacing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local colors = {
|
local colors = {
|
||||||
geometry = "#000000",
|
geometry = beautiful.fg_normal,
|
||||||
workarea = "#0000ff",
|
workarea = "#0000ff",
|
||||||
tiling_area = "#ff0000",
|
tiling_area = "#ff0000",
|
||||||
padding_area = "#ff0000",
|
padding_area = "#ff0000",
|
||||||
wibar = "#000000",
|
wibar = beautiful.fg_normal,
|
||||||
tiling_client = "#ff0000",
|
tiling_client = "#ff0000",
|
||||||
gaps = "#9900ff",
|
gaps = "#9900ff",
|
||||||
}
|
}
|
||||||
|
@ -94,12 +95,12 @@ local function draw_area(_, rect, name, offset, highlight)
|
||||||
|
|
||||||
if highlight then
|
if highlight then
|
||||||
cr:save()
|
cr:save()
|
||||||
cr:set_source(stripe_pat(colors[name].."22", nil, 1, 3))
|
cr:set_source(stripe_pat(color.change_opacity(colors[name], 0.0863), nil, 1, 3))
|
||||||
cr:fill_preserve()
|
cr:fill_preserve()
|
||||||
cr:restore()
|
cr:restore()
|
||||||
end
|
end
|
||||||
|
|
||||||
cr:set_source(color(colors[name].."44"))
|
cr:set_source(color.change_opacity(colors[name], 0.1725))
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -115,16 +116,16 @@ local function draw_bounding_area(_, rect, hole, name, offset)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw_solid_area(_, rect, name, offset, alpha)
|
local function draw_solid_area(_, rect, name, offset, alpha)
|
||||||
alpha = alpha or "59" -- Defaults to 35%
|
alpha = alpha or 0.2314 -- Defaults to 35%
|
||||||
local x, y = rect.x*factor+offset, rect.y*factor+offset
|
local x, y = rect.x*factor+offset, rect.y*factor+offset
|
||||||
cr:rectangle(x, y, rect.width*factor, rect.height*factor)
|
cr:rectangle(x, y, rect.width*factor, rect.height*factor)
|
||||||
|
|
||||||
cr:save()
|
cr:save()
|
||||||
cr:set_source(color.create_solid_pattern(colors[name] .. alpha))
|
cr:set_source(color.change_opacity(colors[name], alpha))
|
||||||
cr:fill_preserve()
|
cr:fill_preserve()
|
||||||
cr:restore()
|
cr:restore()
|
||||||
|
|
||||||
cr:set_source(color(colors[name].."44"))
|
cr:set_source(color.change_opacity(colors[name], 0.0863))
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -141,7 +142,7 @@ local function write_on_area_middle(rect, text, offset)
|
||||||
local _, logical = playout:get_pixel_extents()
|
local _, logical = playout:get_pixel_extents()
|
||||||
local dx = (rect.x*factor+offset) + (rect.width*factor - logical.width) / 2
|
local dx = (rect.x*factor+offset) + (rect.width*factor - logical.width) / 2
|
||||||
local dy = (rect.y*factor+offset) + (rect.height*factor - logical.height) / 2
|
local dy = (rect.y*factor+offset) + (rect.height*factor - logical.height) / 2
|
||||||
cr:set_source_rgb(0, 0, 0)
|
cr:set_source(beautiful.fg_normal)
|
||||||
cr:move_to(dx, dy)
|
cr:move_to(dx, dy)
|
||||||
cr:show_layout(playout)
|
cr:show_layout(playout)
|
||||||
end
|
end
|
||||||
|
@ -265,7 +266,7 @@ end
|
||||||
|
|
||||||
local function draw_vruler(s, dx2, sx, ruler, layer)
|
local function draw_vruler(s, dx2, sx, ruler, layer)
|
||||||
local pad = 5+(layer-1)*dx2
|
local pad = 5+(layer-1)*dx2
|
||||||
cr:set_source(color(ruler.color or (colors[ruler.label].."66")))
|
cr:set_source(color(ruler.color or (color.change_opacity(colors[ruler.label], 0.2588))))
|
||||||
cr:move_to(sx+layer*dx2, ruler.y*factor)
|
cr:move_to(sx+layer*dx2, ruler.y*factor)
|
||||||
cr:line_to(sx+layer*dx2, ruler.y*factor+ruler.height*factor)
|
cr:line_to(sx+layer*dx2, ruler.y*factor+ruler.height*factor)
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
|
@ -291,7 +292,7 @@ end
|
||||||
|
|
||||||
local function draw_hruler(s, dx2, sy, ruler, layer)
|
local function draw_hruler(s, dx2, sy, ruler, layer)
|
||||||
local pad = 10+(layer-1)*(dx2 or 0)
|
local pad = 10+(layer-1)*(dx2 or 0)
|
||||||
cr:set_source(color(ruler.color or (colors[ruler.label].."66")))
|
cr:set_source(color(ruler.color or (color.change_opacity(colors[ruler.label], 0.2588))))
|
||||||
cr:move_to(ruler.x*factor, sy+pad)
|
cr:move_to(ruler.x*factor, sy+pad)
|
||||||
cr:line_to(ruler.x*factor+ruler.width*factor, sy+pad)
|
cr:line_to(ruler.x*factor+ruler.width*factor, sy+pad)
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
|
@ -426,7 +427,7 @@ local function draw_gaps(s)
|
||||||
x = offset.x+hgap[1]+tr_x,
|
x = offset.x+hgap[1]+tr_x,
|
||||||
width = math.ceil(hgap[2]-hgap[1]),
|
width = math.ceil(hgap[2]-hgap[1]),
|
||||||
label = nil,
|
label = nil,
|
||||||
color = colors.gaps.."66",
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
align = true
|
align = true
|
||||||
},
|
},
|
||||||
1
|
1
|
||||||
|
@ -442,7 +443,7 @@ local function draw_gaps(s)
|
||||||
y = offset.y+vgap[1]+tr_y,
|
y = offset.y+vgap[1]+tr_y,
|
||||||
height = math.ceil(vgap[2]-vgap[1]),
|
height = math.ceil(vgap[2]-vgap[1]),
|
||||||
label = nil,
|
label = nil,
|
||||||
color = colors.gaps.."66",
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
align = true
|
align = true
|
||||||
},
|
},
|
||||||
1
|
1
|
||||||
|
@ -475,7 +476,12 @@ local function draw_struts(s)
|
||||||
s,
|
s,
|
||||||
s.geometry.y*SCALE_FACTOR,
|
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 = color.change_opacity(colors.gaps, 0.2588),
|
||||||
|
align = true
|
||||||
|
},
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -485,7 +491,12 @@ local function draw_struts(s)
|
||||||
s,
|
s,
|
||||||
get_text_height()*1.5,
|
get_text_height()*1.5,
|
||||||
s.geometry.x*SCALE_FACTOR,
|
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 = color.change_opacity(colors.gaps, 0.2588),
|
||||||
|
align = true
|
||||||
|
},
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -495,7 +506,12 @@ local function draw_struts(s)
|
||||||
s,
|
s,
|
||||||
s.geometry.y*SCALE_FACTOR,
|
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 = color.change_opacity(colors.gaps, 0.2588),
|
||||||
|
align = true
|
||||||
|
},
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -508,7 +524,7 @@ local function draw_struts(s)
|
||||||
{
|
{
|
||||||
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,
|
||||||
color = colors.gaps.."66",
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
align = true
|
align = true
|
||||||
},
|
},
|
||||||
1
|
1
|
||||||
|
@ -528,8 +544,19 @@ local function draw_mwfact(s)
|
||||||
|
|
||||||
local w1, w2 = math.ceil(width*mwfact), math.ceil(width*(1-mwfact))
|
local w1, w2 = math.ceil(width*mwfact), math.ceil(width*(1-mwfact))
|
||||||
|
|
||||||
draw_hruler(s, offset, get_text_height(), {x=offset,width=w1,color = colors.gaps.."66", align=true}, 1)
|
draw_hruler(s, offset, get_text_height(), {
|
||||||
draw_hruler(s, offset, get_text_height(), {x=offset+w1,width=w2,color = colors.gaps.."66", align=true}, 1)
|
x = offset,
|
||||||
|
width = w1,
|
||||||
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
|
align = true
|
||||||
|
}, 1)
|
||||||
|
|
||||||
|
draw_hruler(s, offset, get_text_height(), {
|
||||||
|
x = offset+w1,
|
||||||
|
width = w2,
|
||||||
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
|
align = true
|
||||||
|
}, 1)
|
||||||
|
|
||||||
cr:translate(tr_x, tr_y)
|
cr:translate(tr_x, tr_y)
|
||||||
end
|
end
|
||||||
|
@ -560,7 +587,7 @@ local function draw_wfact(s)
|
||||||
{
|
{
|
||||||
y = math.floor(offset),
|
y = math.floor(offset),
|
||||||
height =math.ceil( (height/sum) * windowfacts[1][i]),
|
height =math.ceil( (height/sum) * windowfacts[1][i]),
|
||||||
color = colors.gaps.."66",
|
color = color.change_opacity(colors.gaps, 0.2588),
|
||||||
align = true,
|
align = true,
|
||||||
},
|
},
|
||||||
1
|
1
|
||||||
|
@ -634,7 +661,7 @@ end
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
local function draw_info(s)
|
local function draw_info(s)
|
||||||
cr:set_source_rgb(0, 0, 0)
|
cr:set_source(beautiful.fg_normal)
|
||||||
|
|
||||||
local pctx = PangoCairo.font_map_get_default():create_context()
|
local pctx = PangoCairo.font_map_get_default():create_context()
|
||||||
local playout2 = Pango.Layout.new(pctx)
|
local playout2 = Pango.Layout.new(pctx)
|
||||||
|
@ -792,7 +819,7 @@ for k=1, screen.count() do
|
||||||
height = c.height + 2*gap,
|
height = c.height + 2*gap,
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_client(s, proxy, 'gaps', (k-1)*10, nil, "11")
|
draw_client(s, proxy, 'gaps', (k-1)*10, nil, 0.0431)
|
||||||
elseif args.draw_client_snap and c.floating then
|
elseif args.draw_client_snap and c.floating then
|
||||||
local proxy = {
|
local proxy = {
|
||||||
x = c.x - sd,
|
x = c.x - sd,
|
||||||
|
@ -801,7 +828,7 @@ for k=1, screen.count() do
|
||||||
height = c.height + 2*sd,
|
height = c.height + 2*sd,
|
||||||
}
|
}
|
||||||
|
|
||||||
draw_client(s, proxy, 'gaps', (k-1)*10, nil, "11")
|
draw_client(s, proxy, 'gaps', (k-1)*10, nil, 0.0431)
|
||||||
end
|
end
|
||||||
|
|
||||||
draw_client(s, c, 'tiling_client', (k-1)*10, label)
|
draw_client(s, c, 'tiling_client', (k-1)*10, label)
|
||||||
|
|
|
@ -96,7 +96,7 @@ local function draw_lines()
|
||||||
if (not self.widget_pos) or (not self.pager_pos) then return end
|
if (not self.widget_pos) or (not self.pager_pos) then return end
|
||||||
|
|
||||||
cr:set_line_width(1)
|
cr:set_line_width(1)
|
||||||
cr:set_source_rgba(0,0,0,0.3)
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.3))
|
||||||
|
|
||||||
local count = #self.widget_pos
|
local count = #self.widget_pos
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ local function gen_vertical_line(args)
|
||||||
local w = wibox.widget.base.make_widget()
|
local w = wibox.widget.base.make_widget()
|
||||||
|
|
||||||
function w:draw(_, cr, w2, h)
|
function w:draw(_, cr, w2, h)
|
||||||
cr:set_source_rgba(0,0,0,0.5)
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.5))
|
||||||
|
|
||||||
if args.begin then
|
if args.begin then
|
||||||
cr:rectangle(w2/2-0.5, h/2, 1, h/2)
|
cr:rectangle(w2/2-0.5, h/2, 1, h/2)
|
||||||
|
@ -147,7 +147,7 @@ local function gen_vertical_line(args)
|
||||||
cr:arc(w2/2, args.center and h/2 or w2/2 ,bar_size/4, 0, 2*math.pi)
|
cr:arc(w2/2, args.center and h/2 or w2/2 ,bar_size/4, 0, 2*math.pi)
|
||||||
cr:set_source_rgb(1,1,1)
|
cr:set_source_rgb(1,1,1)
|
||||||
cr:fill_preserve()
|
cr:fill_preserve()
|
||||||
cr:set_source_rgba(0,0,0,0.5)
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.5))
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -302,7 +302,8 @@ local function fake_arrange(tag)
|
||||||
focus = focus_wrap,
|
focus = focus_wrap,
|
||||||
geometries = setmetatable({}, {__mode = "k"}),
|
geometries = setmetatable({}, {__mode = "k"}),
|
||||||
workarea = tag.screen.workarea,
|
workarea = tag.screen.workarea,
|
||||||
useless_gap = tag.gaps or 4,
|
useless_gap = tag.gaps or beautiful.useless_gap or 4,
|
||||||
|
gap_single_client= tag.gap_single_client or beautiful.gap_single_client or nil,
|
||||||
apply_size_hints = false,
|
apply_size_hints = false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,14 +356,14 @@ local function gen_fake_clients(tag, args)
|
||||||
cr:stroke()
|
cr:stroke()
|
||||||
|
|
||||||
if show_name and type(geom.c) == "table" and geom.c.name then
|
if show_name and type(geom.c) == "table" and geom.c.name then
|
||||||
cr:set_source_rgb(0, 0, 0)
|
cr:set_source(beautiful.fg_normal)
|
||||||
cr:move_to(x + 2, y + height - 2)
|
cr:move_to(x + 2, y + height - 2)
|
||||||
cr:show_text(geom.c.name)
|
cr:show_text(geom.c.name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Draw the screen outline.
|
-- Draw the screen outline.
|
||||||
cr:set_source(color("#00000044"))
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.1725))
|
||||||
cr:set_line_width(1.5)
|
cr:set_line_width(1.5)
|
||||||
cr:set_dash({10,4},1)
|
cr:set_dash({10,4},1)
|
||||||
cr:rectangle(0, 0, w, h)
|
cr:rectangle(0, 0, w, h)
|
||||||
|
@ -447,7 +448,7 @@ local function gen_label(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function draw_info(s, cr, factor)
|
local function draw_info(s, cr, factor)
|
||||||
cr:set_source_rgba(0, 0, 0, 0.4)
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.4))
|
||||||
|
|
||||||
local pctx = PangoCairo.font_map_get_default():create_context()
|
local pctx = PangoCairo.font_map_get_default():create_context()
|
||||||
local playout = Pango.Layout.new(pctx)
|
local playout = Pango.Layout.new(pctx)
|
||||||
|
@ -639,7 +640,7 @@ local function gen_screens(l, screens, args)
|
||||||
end
|
end
|
||||||
|
|
||||||
function s.widget:draw(_, cr, w, h)
|
function s.widget:draw(_, cr, w, h)
|
||||||
cr:set_source(color("#00000044"))
|
cr:set_source(color.change_opacity(beautiful.fg_normal, 0.1725))
|
||||||
cr:set_line_width(1.5)
|
cr:set_line_width(1.5)
|
||||||
cr:set_dash({10,4},1)
|
cr:set_dash({10,4},1)
|
||||||
cr:rectangle(1,1,w-2,h-2)
|
cr:rectangle(1,1,w-2,h-2)
|
||||||
|
|
|
@ -4,6 +4,8 @@ require("_common_template")(...)
|
||||||
local wibox = require( "wibox" )
|
local wibox = require( "wibox" )
|
||||||
local surface = require( "gears.surface" )
|
local surface = require( "gears.surface" )
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
|
local color = require("gears.color")
|
||||||
|
local beautiful = require("beautiful")
|
||||||
|
|
||||||
--- Create a copy of the widget frozen in time.
|
--- Create a copy of the widget frozen in time.
|
||||||
-- This is useful whe the global state is modified between the time this is
|
-- This is useful whe the global state is modified between the time this is
|
||||||
|
@ -22,6 +24,8 @@ function _memento(wdg, width, height, context, force) -- luacheck: globals _meme
|
||||||
|
|
||||||
local cr = cairo.Context(memento)
|
local cr = cairo.Context(memento)
|
||||||
|
|
||||||
|
cr:set_source(color(beautiful.fg_normal))
|
||||||
|
|
||||||
wibox.widget.draw_to_cairo_context(wdg, cr, w, h, context)
|
wibox.widget.draw_to_cairo_context(wdg, cr, w, h, context)
|
||||||
|
|
||||||
return wibox.widget {
|
return wibox.widget {
|
||||||
|
|
Loading…
Reference in New Issue