From f30dfc20fead9ef4679df2517904b0b23445e63b Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Sat, 15 May 2021 16:26:15 +0200 Subject: [PATCH] More accurate tab width calculation Ensure the right side of the right-most tab always end up at the same position. --- data/core/rootview.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/data/core/rootview.lua b/data/core/rootview.lua index d0a1e825..7dd5b9a0 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -278,10 +278,11 @@ end function Node:get_tab_rect(idx) - local twp = math.floor((self.size.x - style.padding.x) / #self.views + 0.5) - local tw = math.min(style.tab_width, twp) + local tw = math.min(style.tab_width, (self.size.x - style.padding.x) / #self.views) + local x_left = self.position.x + tw * (idx - 1) + local x1, x2 = math.floor(x_left), math.floor(x_left + tw) local h = style.font:get_height() + style.padding.y * 2 - return self.position.x + (idx-1) * tw, self.position.y, tw, h + return x1, self.position.y, x2 - x1, h end