This commit is contained in:
sxyazi
2024-07-12 21:36:17 +08:00
parent c8b3e3979d
commit 3783ea0feb
8 changed files with 33 additions and 36 deletions

View File

@@ -1,36 +1,37 @@
local function setup()
Manager.render = function(self, area)
local c = self:layout(area)
local old_build = Tab.build
Tab.build = function(self, ...)
local bar = function(c, x, y)
if x <= 0 or x == area.w - 1 then
return {}
if x <= 0 or x == self._area.w - 1 then
return ui.Bar(ui.Rect.default, ui.Bar.TOP)
end
return ui.Bar(
ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, area.w - x, 1), h = math.min(1, area.h) },
ui.Rect { x = x, y = math.max(0, y), w = ya.clamp(0, self._area.w - x, 1), h = math.min(1, self._area.h) },
ui.Bar.TOP
):symbol(c)
end
local c = self._chunks
self._chunks = {
c[1]:padding(ui.Padding.y(1)),
c[2]:padding(c[1].w > 0 and ui.Padding.y(1) or ui.Padding(1, 0, 1, 1)),
c[3]:padding(ui.Padding.y(1)),
}
local style = THEME.manager.border_style
return ya.flat {
-- Borders
ui.Border(area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style),
ui.Bar(c[1]:padding(ui.Padding.y(1)), ui.Bar.RIGHT):style(style),
ui.Bar(c[3]:padding(ui.Padding.y(1)), ui.Bar.LEFT):style(style),
self._base = ya.list_merge(self._base or {}, {
ui.Border(self._area, ui.Border.ALL):type(ui.Border.ROUNDED):style(style),
ui.Bar(self._chunks[1], ui.Bar.RIGHT):style(style),
ui.Bar(self._chunks[3], ui.Bar.LEFT):style(style),
bar("", c[1].right - 1, c[1].y),
bar("", c[1].right - 1, c[1].bottom - 1),
bar("", c[2].right, c[2].y),
bar("", c[2].right, c[2].bottom - 1),
})
-- Parent
Parent:render(c[1]:padding(ui.Padding.xy(1))),
-- Current
Current:render(c[2]:padding(c[1].w > 0 and ui.Padding.y(1) or ui.Padding(1, 0, 1, 1))),
-- Preview
Preview:render(c[3]:padding(ui.Padding.xy(1))),
}
old_build(self, ...)
end
end