Fix problem with treeview keeping the editor busy

Fix a problem introduced when fixing the dirty pixel problem, commit
cb08c5c. The node, when determining the layout was rounding the size
of the fixed-size view. In turns this latter was calling move_towards
to the default_size it wanted. If default_size was non-integer the
value vas never archieved because it was rounded during layout and
move_towars was keeping the editor busy by setting the
core.need_redraw flag.
This commit is contained in:
Francesco Abbate 2021-10-14 09:13:06 +02:00
parent bed103b7a6
commit 1794765f07
2 changed files with 7 additions and 1 deletions

View File

@ -412,7 +412,7 @@ end
-- axis are swapped; this function lets us use the same code for both -- axis are swapped; this function lets us use the same code for both
local function calc_split_sizes(self, x, y, x1, x2, y1, y2) local function calc_split_sizes(self, x, y, x1, x2, y1, y2)
local ds = ((x1 and x1 < 1) or (x2 and x2 < 1)) and 0 or style.divider_size local ds = ((x1 and x1 < 1) or (x2 and x2 < 1)) and 0 or style.divider_size
local n = math.floor(x1 and x1 + ds or (x2 and self.size[x] - x2 or self.size[x] * self.divider)) local n = x1 and x1 + ds or (x2 and self.size[x] - x2 or math.floor(self.size[x] * self.divider))
self.a.position[x] = self.position[x] self.a.position[x] = self.position[x]
self.a.position[y] = self.position[y] self.a.position[y] = self.position[y]
self.a.size[x] = n - ds self.a.size[x] = n - ds
@ -675,6 +675,10 @@ end
function Node:resize(axis, value) function Node:resize(axis, value)
-- the application works fine with non-integer values but to have pixel-perfect
-- placements of view elements, like the scrollbar, we round the value to be
-- an integer.
value = math.floor(value)
if self.type == 'leaf' then if self.type == 'leaf' then
-- If it is not locked we don't accept the -- If it is not locked we don't accept the
-- resize operation here because for proportional panes the resize is -- resize operation here because for proportional panes the resize is

View File

@ -238,6 +238,8 @@ function TreeView:update()
if self.init_size then if self.init_size then
self.size.x = dest self.size.x = dest
self.init_size = false self.init_size = false
else
self:move_towards(self.size, "x", dest)
end end
local duration = system.get_time() - self.tooltip.begin local duration = system.get_time() - self.tooltip.begin