mirror of
https://github.com/awesomeWM/awesome
synced 2024-11-17 07:47:41 +01:00
awful.widget.graph: Various minor fixes
For example, the rightmost pixel of a border-less graph wasn't draw and all drawing was shifted one pixel to the left. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
cafd28027f
commit
7a1acd4a98
1 changed files with 7 additions and 7 deletions
|
@ -80,7 +80,7 @@ function draw(graph, wibox, cr, width, height)
|
|||
-- Draw the background first
|
||||
cr:rectangle(border_width, border_width,
|
||||
width - (2 * border_width),
|
||||
height)
|
||||
height - (2 * border_width))
|
||||
cr:set_source(color(data[graph].background_color or "#000000aa"))
|
||||
cr:fill()
|
||||
|
||||
|
@ -99,16 +99,16 @@ function draw(graph, wibox, cr, width, height)
|
|||
|
||||
for i = 0, width - (2 * border_width) do
|
||||
local rel_i = 0
|
||||
local rel_x = border_width + i
|
||||
local rel_x = border_width + i + 0.5
|
||||
|
||||
if data[graph].stack_colors then
|
||||
for idx, col in ipairs(data[graph].stack_colors) do
|
||||
local stack_values = values[idx]
|
||||
if stack_values and i < #stack_values then
|
||||
local value = stack_values[#stack_values - i] + rel_i
|
||||
cr:move_to(rel_x, border_width - 0.5 +
|
||||
cr:move_to(rel_x, border_width +
|
||||
(height - 2 * border_width) * (1 - (rel_i / max_value)))
|
||||
cr:line_to(rel_x, border_width - 0.5 +
|
||||
cr:line_to(rel_x, border_width +
|
||||
(height - 2 * border_width) * (1 - (value / max_value)))
|
||||
cr:set_source(color(col or "#ff0000"))
|
||||
cr:stroke()
|
||||
|
@ -133,9 +133,9 @@ function draw(graph, wibox, cr, width, height)
|
|||
local value = values[#values - i]
|
||||
if value >= 0 then
|
||||
value = value / max_value
|
||||
cr:move_to(border_width + i - 0.5, border_width - 0.5 +
|
||||
cr:move_to(border_width + i + 0.5, border_width +
|
||||
(height - 2 * border_width) * (1 - value))
|
||||
cr:line_to(border_width + i - 0.5, border_width +
|
||||
cr:line_to(border_width + i + 0.5, border_width +
|
||||
(height - 2 * border_width))
|
||||
end
|
||||
end
|
||||
|
@ -184,7 +184,7 @@ local function add_value(graph, value, group)
|
|||
table.insert(values, value)
|
||||
|
||||
local border_width = 0
|
||||
if data[graph].border then border_width = 2 end
|
||||
if data[graph].border_color then border_width = 2 end
|
||||
|
||||
-- Ensure we never have more data than we can draw
|
||||
while #values > data[graph].width - border_width do
|
||||
|
|
Loading…
Reference in a new issue