From 6a4e555ae1d3e3deee10ea63561ce7aad8b332f3 Mon Sep 17 00:00:00 2001 From: Emmanuel Lepage Vallee Date: Mon, 19 Apr 2021 01:12:16 -0700 Subject: [PATCH] slider: Fix an aliasing issue. There was a bunch of `math.floor` missing. Some slider size were blurry. --- lib/wibox/widget/slider.lua | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/wibox/widget/slider.lua b/lib/wibox/widget/slider.lua index 6c6aba2c8..b72577519 100644 --- a/lib/wibox/widget/slider.lua +++ b/lib/wibox/widget/slider.lua @@ -325,7 +325,7 @@ function slider:draw(_, cr, width, height) local handle_height, handle_width = height, self._private.handle_width or beautiful.slider_handle_width - or height/2 + or math.floor(height/2) local handle_border_width = self._private.handle_border_width or beautiful.slider_handle_border_width @@ -363,7 +363,7 @@ function slider:draw(_, cr, width, height) end else bar_height = bar_height or beautiful.slider_bar_height or height - y_offset = (height - bar_height)/2 + y_offset = math.floor((height - bar_height)/2) end @@ -380,8 +380,10 @@ function slider:draw(_, cr, width, height) bar_shape(cr, width - x_offset - right_margin, bar_height or height) if bar_active_color and type(bar_color) == "string" and type(bar_active_color) == "string" then - local bar_active_width = active_rate * (width - x_offset - right_margin) + local bar_active_width = math.floor( + active_rate * (width - x_offset - right_margin) - (handle_width - handle_border_width/2) * (active_rate - 0.5) + ) cr:set_source(color.create_pattern{ type = "linear", from = {0,0}, @@ -453,7 +455,7 @@ function slider:draw(_, cr, width, height) -- Get the widget size back to it's non-transfored value local min, _, interval = get_extremums(self) - local rel_value = ((value-min)/interval) * (width-handle_width) + local rel_value = math.floor(((value-min)/interval) * (width-handle_width)) cr:translate(x_offset + rel_value, y_offset)