From 32f78113a3f38ed8d648542483fabc1b17177467 Mon Sep 17 00:00:00 2001 From: christoph-heinrich Date: Wed, 4 Oct 2023 18:55:19 +0200 Subject: [PATCH] suggestion --- scripts/uosc/elements/Menu.lua | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/scripts/uosc/elements/Menu.lua b/scripts/uosc/elements/Menu.lua index f74a942e..4a85abb7 100644 --- a/scripts/uosc/elements/Menu.lua +++ b/scripts/uosc/elements/Menu.lua @@ -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