feat: implement special spinner icon for menus

Allows menus to use `spinner` as an item icon, which will display a rotating spinner. Along with a no-op command on an item and `keep_open=true`, this can be used to display placeholder menus/items that are still loading.

Extracts spinner from `BufferingIndicator` into `ass:spinner()` utility.
This commit is contained in:
tomasklaen
2022-10-28 22:22:21 +02:00
parent 59ac8af48f
commit d8fad3306a
4 changed files with 33 additions and 16 deletions

View File

@@ -507,7 +507,7 @@ function Menu:on_global_mbtn_left_up()
if math.abs(distance) > 50 then
self.current.fling = {
y = self.current.scroll_y, distance = distance, time = self.drag_data[#self.drag_data].time,
easing = ease_out_quart, duration = 0.5, update_cursor = true
easing = ease_out_quart, duration = 0.5, update_cursor = true,
}
end
end
@@ -669,10 +669,15 @@ function Menu:render()
-- Icon
if item.icon then
ass:icon(content_bx - (icon_size / 2), item_center_y, icon_size * 1.5, item.icon, {
color = font_color, opacity = text_opacity, clip = item_clip,
shadow = 1, shadow_color = shadow_color,
})
local x, y = content_bx - (icon_size / 2), item_center_y
if item.icon == 'spinner' then
ass:spinner(x, y, icon_size * 1.5, {color = font_color, opacity = text_opacity * 0.8})
else
ass:icon(x, y, icon_size * 1.5, item.icon, {
color = font_color, opacity = text_opacity, clip = item_clip,
shadow = 1, shadow_color = shadow_color,
})
end
content_bx = content_bx - icon_size - spacing
end