From 885ed5f860c0eaffc07c14303a93186fed1aeb69 Mon Sep 17 00:00:00 2001 From: rxi Date: Fri, 1 May 2020 16:15:28 +0100 Subject: [PATCH] Improved handling of zero-sized locked nodes on RootView --- data/core/commandview.lua | 1 - data/core/rootview.lua | 12 +++++++----- data/core/view.lua | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/data/core/commandview.lua b/data/core/commandview.lua index f400eb8..ceb32b5 100644 --- a/data/core/commandview.lua +++ b/data/core/commandview.lua @@ -1,5 +1,4 @@ local core = require "core" -local config = require "core.config" local common = require "core.common" local style = require "core.style" local Doc = require "core.doc" diff --git a/data/core/rootview.lua b/data/core/rootview.lua index 3b59d55..4bc4cd1 100644 --- a/data/core/rootview.lua +++ b/data/core/rootview.lua @@ -241,7 +241,9 @@ function Node:get_locked_size() local x1, y1 = self.a:get_locked_size() local x2, y2 = self.b:get_locked_size() if x1 and x2 then - return x1 + x2 + style.divider_size, y1 + y2 + style.divider_size + local dsx = (x1 < 1 or x2 < 1) and 0 or style.divider_size + local dsy = (y1 < 1 or y2 < 1) and 0 or style.divider_size + return x1 + x2 + dsx, y1 + y2 + dsy end end end @@ -257,11 +259,11 @@ end -- axis are swapped; this function lets us use the same code for both local function calc_split_sizes(self, x, y, x1, x2) local n - local ds = (x1 == 0 or x2 == 0) and 0 or style.divider_size + local ds = (x1 and x1 < 1 or x2 and x2 < 1) and 0 or style.divider_size if x1 then - n = math.floor(x1 + ds) + n = x1 + ds elseif x2 then - n = math.floor(self.size[x] - x2) + n = self.size[x] - x2 else n = math.floor(self.size[x] * self.divider) end @@ -347,7 +349,7 @@ function Node:draw() self:draw_tabs() end local pos, size = self.active_view.position, self.active_view.size - core.push_clip_rect(pos.x, pos.y, size.x, size.y) + core.push_clip_rect(pos.x, pos.y, size.x + pos.x % 1, size.y + pos.y % 1) self.active_view:draw() core.pop_clip_rect() else diff --git a/data/core/view.lua b/data/core/view.lua index 36979cc..818bc82 100644 --- a/data/core/view.lua +++ b/data/core/view.lua @@ -126,7 +126,7 @@ end function View:draw_background(color) local x, y = self.position.x, self.position.y local w, h = self.size.x, self.size.y - renderer.draw_rect(x, y, math.ceil(w), math.ceil(h), color) + renderer.draw_rect(x, y, w + x % 1, h + y % 1, color) end