mirror of
https://github.com/vidarh/rubywm.git
synced 2024-11-15 19:48:30 +01:00
34 lines
612 B
Ruby
34 lines
612 B
Ruby
|
|
def gap(geom,g)
|
|
geom = geom.dup
|
|
geom.x += g
|
|
geom.width -= g*2
|
|
geom.y += g
|
|
geom.height -= g*2
|
|
geom
|
|
end
|
|
|
|
def split_geom(geom, dir, node, gap, ratio)
|
|
geom = geom.dup
|
|
case dir
|
|
when :lr
|
|
lw = (geom.width-gap)*ratio
|
|
if node == 0
|
|
geom.width = lw
|
|
else
|
|
geom.width = (geom.width-gap)*(1.0-ratio)
|
|
geom.x += lw + gap
|
|
end
|
|
return geom
|
|
when :tb
|
|
th = (geom.height-gap)*ratio
|
|
if node == 0
|
|
geom.height = th
|
|
else
|
|
geom.height = (geom.height-gap)*(1.0-ratio)
|
|
geom.y += th + gap
|
|
end
|
|
return geom
|
|
else raise "Invalid direction"
|
|
end
|
|
end
|