[tekui-devel] tekui: Cleanup in copy-refresh logic
hg-notify at neoscientists.org
hg-notify at neoscientists.org
Tue Feb 5 02:46:01 CET 2008
details: http://hg.teklib.org/tekui/rev/436b20dbbea8
changeset: 347:436b20dbbea8
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Tue Jan 29 20:21:05 2008 +0100
description:
Cleanup in copy-refresh logic
diffs (80 lines):
diff -r 14bcc7c8a51a -r 436b20dbbea8 tek/class/ui/area.lua
--- a/tek/class/ui/area.lua Tue Jan 29 03:50:58 2008 +0100
+++ b/tek/class/ui/area.lua Tue Jan 29 20:21:05 2008 +0100
@@ -175,13 +175,14 @@ function Area:layout(x0, y0, x1, y1, mar
x0 - dx, y0 - dy, x1 - dx, y1 - dy)
if s1 then
local key = ("%d:%d"):format(dx, dy)
+ -- local key = dx == 0 and dy or dx
local ca = self.Window.CopyArea
if ca[key] then
ca[key][3]:orRect(s1, s2, s3, s4)
else
ca[key] = { dx, dy, Region.new(s1, s2, s3, s4) }
end
- -- redraw background:
+ -- redraw background [TODO]:
if self.Parent then
self.Parent.Redraw = true
end
diff -r 14bcc7c8a51a -r 436b20dbbea8 tek/class/ui/window.lua
--- a/tek/class/ui/window.lua Tue Jan 29 03:50:58 2008 +0100
+++ b/tek/class/ui/window.lua Tue Jan 29 20:21:05 2008 +0100
@@ -308,6 +308,8 @@ end
function Window:update()
if self.Status == "open" then
+
+ -- handle partial relayouts:
local lg = self.LayoutGroup
while #lg > 0 do
local record = remove(lg, 1)
@@ -324,35 +326,20 @@ function Window:update()
end
end
- local d = self.Drawable
--- d:getAttrs()
-
-- handle copies:
+ local ca = self.CopyArea
local t = { }
- local ca = self.CopyArea
for key, e in pairs(ca) do
local dx, dy, region = e[1], e[2], e[3]
- local dir = ((dx < 0 and dy <= 0) or (dx <= 0 and dy > 0 and dy < -dx)
- or (dx >= 0 and dy < 0 and dx < -dy)) and -1 or 1
+ local dir = (dx == 0 and dy or dx) > 0 and 1 or -1
for _, r in region:getRects() do
local r1, r2, r3, r4 = region:getRect(r)
- local dist
- if dx == 0 then
- dist = r2
- elseif dy == 0 then
- dist = r1
--- else
--- local b = dy / dx
--- local d = r2 + r1 / b
--- local xb = d * b / (1 + b * b)
--- local yb = b * xb
--- dist = floor(xb * xb + yb * yb)
- end
- insert(t, { dist * dir, dx, dy, r1, r2, r3, r4 })
+ insert(t, { (dx == 0 and r2 or r1) * dir, dx, dy, r1, r2, r3, r4 })
end
ca[key] = nil
end
sort(t, function(a, b) return a[1] > b[1] end)
+ local d = self.Drawable
for _, r in ipairs(t) do
local t = { }
d:copyArea(r[4], r[5], r[6], r[7], r[4] + r[2], r[5] + r[3], t)
@@ -361,7 +348,7 @@ function Window:update()
end
end
- -- refres everything that is damaged:
+ -- refresh everything that is damaged:
self:refresh()
return true
end
More information about the tekui-devel
mailing list