From 1fb01f36df1adb9b2e2ae0c39de3757b65a63f57 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Mon, 17 May 2021 15:11:06 +0200 Subject: [PATCH] Avoid overflowing tab rectangles when animating --- data/core/rootview.lua | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/data/core/rootview.lua b/data/core/rootview.lua index 3f300b45..17bb7c77 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -321,9 +321,12 @@ end function Node:get_tab_rect(idx) local sbw = get_scroll_button_width() - local x = self.position.x + sbw + self.tab_width * (idx - 1) - self.tab_shift + local maxw = self.size.x - 2 * sbw + local x0 = self.position.x + sbw + local x1 = x0 + common.clamp(self.tab_width * (idx - 1) - self.tab_shift, 0, maxw) + local x2 = x0 + common.clamp(self.tab_width * idx - self.tab_shift, 0, maxw) local h = style.font:get_height() + style.padding.y * 2 - return x, self.position.y, self.tab_width, h + return x1, self.position.y, x2 - x1, h end