[tekui-devel] tekui: Area:layout() and Window:refresh() now handle incremental...

hg-notify at neoscientists.org hg-notify at neoscientists.org
Tue Feb 5 02:46:00 CET 2008


details:   http://hg.teklib.org/tekui/rev/e4ab85c1fcd6
changeset: 345:e4ab85c1fcd6
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Tue Jan 29 03:28:19 2008 +0100
description:
Area:layout() and Window:refresh() now handle incremental refresh in move and
move+resize cases; Slider cleaned up and corrected: it is no longer allowed to
call layout() inside draw()

diffs (truncated from 363 to 100 lines):

diff -r c31245d1e798 -r e4ab85c1fcd6 tek/class/ui/area.lua
--- a/tek/class/ui/area.lua	Sun Jan 27 15:03:04 2008 +0100
+++ b/tek/class/ui/area.lua	Tue Jan 29 03:28:19 2008 +0100
@@ -24,10 +24,13 @@ local Region = ui.Region
 local Region = ui.Region
 local overlap = Region.overlapCoords
 
+local insert = table.insert
+local remove = table.remove
 local tonumber = tonumber
+local floor = math.floor
 
 module("tek.class.ui.area", tek.class.ui.element)
-_VERSION = "Area 3.2"
+_VERSION = "Area 4.0"
 local Area = _M
 
 -------------------------------------------------------------------------------
@@ -157,28 +160,53 @@ function Area:layout(x0, y0, x1, y1, mar
 
 	if r[1] ~= x0 or r[2] ~= y0 or r[3] ~= x1 or r[4] ~= y1 then
 
--- 		if r[1] and x1 - x0 == r[3] - r[1] and
--- 			y1 - y0 == r[4] - r[2] then
--- 			db.warn("copy would be sufficient: %s", self.Label or "")
--- 		end
-
-		if self.TrackDamage then
-			self.DamageRegion = Region.new(x0, y0, x1, y1)
-			-- avoid damages resulting from resizing the area without moving it:
-			if r[1] == x0 and r[2] == y0 then
-				self.DamageRegion:subRect(r[1], r[2], r[3], r[4])
-			end
-		end
-
-		if markdamage ~= false then
-			self.Redraw = true
+		-- shift, size:
+		local dx, dy, dw, dh
+		if r[1] then
+			dx, dy = x0 - r[1], y0 - r[2]
+			dw, dh = x1 - x0 - r[3] + r[1], y1 - y0 - r[4] + r[2]
+		end
+
+		if dx and ((dx == 0) ~= (dy == 0)) and
+			((dw == 0 and dh == 0) or self.TrackDamage) then
+			-- can refresh this element by shifting:
+
+			local s1, s2, s3, s4 = overlap(r[1], r[2], r[3], r[4],
+				x0 - dx, y0 - dy, x1 - dx, y1 - dy)
+
+			local key = ("%d:%d"):format(dx, dy)
+			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
+
+			if dw > 0 or dh > 0 then
+				-- grow + move:
+				self.DamageRegion = Region.new(x0, y0, x1, y1)
+				self.DamageRegion:subRect(r[1] + dx, r[2] + dy, r[3] + dx, r[4] + dy)
+			end
+
+		else
+			-- something changed:
+			if self.TrackDamage then
+				self.DamageRegion = Region.new(x0, y0, x1, y1)
+				-- avoid damages resulting from resizing the area without moving it:
+				if dx == 0 and dy == 0 then
+					self.DamageRegion:subRect(r[1], r[2], r[3], r[4])
+				end
+			end
+			if markdamage ~= false then
+				self.Redraw = true
+			end
 		end
 
 		r[1], r[2], r[3], r[4] = x0, y0, x1, y1
-
 		return true
 
 	else
+		-- nothing changed:
 		self.DamageRegion = false
 	end
 
diff -r c31245d1e798 -r e4ab85c1fcd6 tek/class/ui/floattext.lua
--- a/tek/class/ui/floattext.lua	Sun Jan 27 15:03:04 2008 +0100
+++ b/tek/class/ui/floattext.lua	Tue Jan 29 03:28:19 2008 +0100
@@ -128,22 +128,27 @@ function FloatText.new(class, self)
 		Object = TextArea:new {
 			FontSpec = ":32",
 			Text = {
-				{ Text = "1. Hallo" },
-				{ Text = "2. Eins" },
-				{ Text = "3. Zwei" },
-				{ Text = "4. Drei" },
-				{ Text = "5. Hallo" },


More information about the tekui-devel mailing list