Skip to content

Commit

Permalink
tweak: prevent dynamic volume icon from shifting horizontally
Browse files Browse the repository at this point in the history
ref #699
  • Loading branch information
tomasklaen committed Oct 15, 2023
1 parent 06cef7c commit e068752
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions scripts/uosc/elements/Volume.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,18 @@ function Volume:render()
cursor.on_primary_down = function() mp.commandv('cycle', 'mute') end
end
local ass = assdraw.ass_new()
local icon_name = 'volume_up'
if state.mute then icon_name = 'volume_off'
elseif state.volume <= 0 then icon_name = 'volume_mute'
elseif state.volume <= 60 then icon_name = 'volume_down'
end
local width_half = (mute_rect.bx - mute_rect.ax) / 2
local height_half = (mute_rect.by - mute_rect.ay) / 2
local icon_size = math.min(width_half, height_half) * 1.5
ass:icon(mute_rect.ax + width_half, mute_rect.ay + height_half, icon_size, icon_name,
local icon_name, horizontal_shift = 'volume_up', 0
if state.mute then
icon_name = 'volume_off'
elseif state.volume <= 0 then
icon_name, horizontal_shift = 'volume_mute', height_half * 0.25
elseif state.volume <= 60 then
icon_name, horizontal_shift = 'volume_down', height_half * 0.125
end
ass:icon(mute_rect.ax + width_half - horizontal_shift, mute_rect.ay + height_half, icon_size, icon_name,
{border = options.text_border * state.scale, opacity = visibility, align = 5}
)
return ass
Expand Down

0 comments on commit e068752

Please sign in to comment.