Skip to content

Commit

Permalink
ProgressWidget: Add a white outline to help visibility
Browse files Browse the repository at this point in the history
At least for standard progress bars. It makes it even more invisible for
the thin style ;p.
  • Loading branch information
NiLuJe committed Jun 10, 2024
1 parent e1f2acf commit 3df0b74
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 22 deletions.
27 changes: 14 additions & 13 deletions frontend/ui/widget/progresswidget.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local Widget = require("ui/widget/widget")
local Screen = require("device").screen

-- Somewhat empirically chosen threshold to switch between the two designs ;o)
local INITIAL_MARKER_HEIGHT_THRESHOLD = Screen:scaleBySize(12)
local INITIAL_MARKER_HEIGHT_THRESHOLD = Screen:scaleBySize(11)

local ProgressWidget = Widget:extend{
width = nil,
Expand Down Expand Up @@ -90,8 +90,8 @@ function ProgressWidget:renderMarkerIcon()
if self.height <= INITIAL_MARKER_HEIGHT_THRESHOLD then
self.initial_pos_icon = IconWidget:new{
icon = "position.marker.top",
width = Math.round(self.height / 2),
height = Math.round(self.height / 2),
width = Math.round(self.height / 1.5),
height = Math.round(self.height / 1.5),
alpha = true,
}
else
Expand Down Expand Up @@ -168,8 +168,9 @@ function ProgressWidget:paintTo(bb, x, y)
end

-- Main fill bar for the specified percentage.
local fill_x
if self.percentage >= 0 and self.percentage <= 1 then
local fill_x = x + self.margin_h + self.bordersize
fill_x = x + self.margin_h + self.bordersize
if self.fill_from_right or (_mirroredUI and not self.fill_from_right) then
fill_x = fill_x + (fill_width * (1 - self.percentage))
fill_x = math.floor(fill_x)
Expand All @@ -180,15 +181,6 @@ function ProgressWidget:paintTo(bb, x, y)
math.ceil(fill_width * self.percentage),
math.ceil(fill_height),
self.fillcolor)

-- Overlay the initial position marker on top of that
if self.initial_pos_marker and self.initial_percentage >= 0 then
if self.height <= INITIAL_MARKER_HEIGHT_THRESHOLD then
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 4), y - Math.round(self.height / 6))
else
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 2), y)
end
end
end

-- ...then the tick(s).
Expand All @@ -207,6 +199,15 @@ function ProgressWidget:paintTo(bb, x, y)
self.bordercolor)
end
end

-- Overlay the initial position marker on top of everything
if self.initial_pos_marker and self.initial_percentage >= 0 and fill_x then
if self.height <= INITIAL_MARKER_HEIGHT_THRESHOLD then
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 3), y - Math.round(self.height / 6))
else
self.initial_pos_icon:paintTo(bb, Math.round(fill_x + math.ceil(fill_width * self.initial_percentage) - self.height / 2), y)
end
end
end

function ProgressWidget:setPercentage(percentage)
Expand Down
14 changes: 9 additions & 5 deletions resources/icons/mdlight/position.marker.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 8 additions & 4 deletions resources/icons/mdlight/position.marker.top.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3df0b74

Please sign in to comment.