make switcher more natural in draft mode
This commit is contained in:
parent
1a9d94a9f7
commit
7e15746759
15
layout.lua
15
layout.lua
|
@ -80,11 +80,16 @@ local function find_rd(c, regions, lu)
|
|||
end
|
||||
|
||||
local function set_geometry(c, region_lu, region_rd, useless_gap, border_width)
|
||||
-- We try to negate the gap of outer layer8
|
||||
c.x = region_lu.x - useless_gap
|
||||
c.y = region_lu.y - useless_gap
|
||||
c.width = region_rd.x + region_rd.width - region_lu.x + (useless_gap - border_width) * 2
|
||||
c.height = region_rd.y + region_rd.height - region_lu.y + (useless_gap - border_width) * 2
|
||||
-- We try to negate the gap of outer layer
|
||||
if region_lu ~= nil then
|
||||
c.x = region_lu.x - useless_gap
|
||||
c.y = region_lu.y - useless_gap
|
||||
end
|
||||
|
||||
if region_rd ~= nil then
|
||||
c.width = region_rd.x + region_rd.width - c.x + useless_gap - border_width * 2
|
||||
c.height = region_rd.y + region_rd.height - c.y + useless_gap - border_width * 2
|
||||
end
|
||||
end
|
||||
|
||||
local function create(name, editor)
|
||||
|
|
14
switcher.lua
14
switcher.lua
|
@ -314,18 +314,26 @@ local function start(c)
|
|||
if regions[rd].x + regions[rd].width <= regions[lu].x or
|
||||
regions[rd].y + regions[rd].height <= regions[lu].y
|
||||
then
|
||||
rd = lu
|
||||
rd = nil
|
||||
end
|
||||
else
|
||||
rd = choice
|
||||
if regions[rd].x + regions[rd].width <= regions[lu].x or
|
||||
regions[rd].y + regions[rd].height <= regions[lu].y
|
||||
then
|
||||
lu = rd
|
||||
lu = nil
|
||||
end
|
||||
end
|
||||
|
||||
machi.layout.set_geometry(c, regions[lu], regions[rd], 0, c.border_width)
|
||||
if lu ~= nil and rd ~= nil then
|
||||
machi.layout.set_geometry(c, regions[lu], regions[rd], 0, c.border_width)
|
||||
elseif lu ~= nil then
|
||||
machi.layout.set_geometry(c, regions[lu], nil, 0, c.border_width)
|
||||
elseif rd ~= nil then
|
||||
c.x = min(c.x, regions[rd].x)
|
||||
c.y = min(c.y, regions[rd].y)
|
||||
machi.layout.set_geometry(c, nil, regions[rd], 0, c.border_width)
|
||||
end
|
||||
c.machi_lu = lu
|
||||
c.machi_rd = rd
|
||||
|
||||
|
|
Loading…
Reference in New Issue