Skip to content

Commit

Permalink
suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-heinrich committed Oct 4, 2023
1 parent 904cc02 commit 32f7811
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions scripts/uosc/elements/Menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1111,14 +1111,22 @@ function Menu:render()

local title_cut_x = content_bx
if item.hint_width > 0 then
-- controls title & hint clipping proportional to the ratio of their widths
-- both title and hint get at least 20% of the width, unless they are smaller then that
local width = content_bx - content_ax
local title_min = math.min(item.title_width, width * 0.2)
local hint_min = math.min(item.hint_width, width * 0.2)
local title_content_ratio = item.title_width / (item.title_width + item.hint_width)
title_cut_x = round(content_ax + clamp(title_min, (width - spacing) * title_content_ratio
+ (item.title_width > 0 and spacing / 2 or 0), width - hint_min))
local ratio = item.title_width / item.hint_width
if ratio <= 1 / 1.3 then
-- title is smaller
title_cut_x = math.ceil(content_ax + item.title_width)
elseif ratio >= 1.3 then
-- hint is smaller
title_cut_x = math.floor(content_bx - item.hint_width - spacing)
else
-- controls title & hint clipping proportional to the ratio of their widths
-- both title and hint get at least 20% of the width, unless they are smaller then that
local width = content_bx - content_ax
local title_min = math.min(item.title_width, width * 0.2)
local hint_min = math.min(item.hint_width, width * 0.2)
local title_ratio = item.title_width / (item.title_width + item.hint_width)
title_cut_x = round(content_ax + clamp(title_min, (width - spacing) * title_ratio, width - hint_min))
end
end

-- Hint
Expand Down

0 comments on commit 32f7811

Please # to comment.