[tekui-devel] tekui: markDamage() now takes 4 coordinates instead of a table; ...

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/3ac721bc4aea
changeset: 342:3ac721bc4aea
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Sun Jan 27 03:16:07 2008 +0100
description:
markDamage() now takes 4 coordinates instead of a table; Area and Frame
optimized for indexed table accesses; added Canvas.TempMsg

diffs (truncated from 424 to 100 lines):

diff -r 341f9af75049 -r 3ac721bc4aea tek/class/ui/area.lua
--- a/tek/class/ui/area.lua	Sat Jan 26 21:35:36 2008 +0100
+++ b/tek/class/ui/area.lua	Sun Jan 27 03:16:07 2008 +0100
@@ -25,10 +25,9 @@ local overlap = Region.overlapCoords
 local overlap = Region.overlapCoords
 
 local tonumber = tonumber
-local unpack = unpack
 
 module("tek.class.ui.area", tek.class.ui.element)
-_VERSION = "Area 3.1"
+_VERSION = "Area 3.2"
 local Area = _M
 
 -------------------------------------------------------------------------------
@@ -68,6 +67,7 @@ function Area:setupDisplay(display, draw
 	self.Margin = self.Margin or display.Theme.AreaMargin or DEF_MARGIN
 	self.Rect = { }
 	self.MinMax = { }
+	self.MarginAndBorder = { }
 	self.Display = display
 	self.Drawable = drawable
 	self.DamageRegion = false
@@ -95,7 +95,9 @@ end
 -------------------------------------------------------------------------------
 
 function Area:calcOffsets()
-	self.MarginAndBorder = { unpack(self.Margin) }
+	local s = self.Margin
+	local d = self.MarginAndBorder
+	d[1], d[2], d[3], d[4] = s[1], s[2], s[3], s[4]
 end
 
 -------------------------------------------------------------------------------
@@ -145,19 +147,26 @@ end
 
 function Area:layout(x0, y0, x1, y1, markdamage)
 
-	x0 = x0 + self.MarginAndBorder[1]
-	y0 = y0 + self.MarginAndBorder[2]
-	x1 = x1 - self.MarginAndBorder[3]
-	y1 = y1 - self.MarginAndBorder[4]
-
-	if self.Rect[1] ~= x0 or self.Rect[2] ~= y0 or
-		self.Rect[3] ~= x1 or self.Rect[4] ~= y1 then
+	local r = self.Rect
+	local m = self.MarginAndBorder
+
+	x0 = x0 + m[1]
+	y0 = y0 + m[2]
+	x1 = x1 - m[3]
+	y1 = y1 - m[4]
+
+	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 self.Rect[1] == x0 and self.Rect[2] == y0 then
-				self.DamageRegion:subRect(unpack(self.Rect))
+			if r[1] == x0 and r[2] == y0 then
+				self.DamageRegion:subRect(r[1], r[2], r[3], r[4])
 			end
 		end
 
@@ -165,10 +174,7 @@ function Area:layout(x0, y0, x1, y1, mar
 			self.Redraw = true
 		end
 
-		self.Rect[1] = x0
-		self.Rect[2] = y0
-		self.Rect[3] = x1
-		self.Rect[4] = y1
+		r[1], r[2], r[3], r[4] = x0, y0, x1, y1
 
 		return true
 
@@ -183,25 +189,27 @@ end
 -------------------------------------------------------------------------------
 
 function Area:punch(region)
-	region:subRect(unpack(self.Rect))
-end
-
--------------------------------------------------------------------------------
---	area:markDamage(rect): If the element overlaps with the specified
---	rectangle, marks it as dirty. Note: If rendering the element is very
---	expensive, this method can be overridden to track intra-area damages.
--------------------------------------------------------------------------------
-
-function Area:markDamage(rect)
+	local r = self.Rect
+	region:subRect(r[1], r[2], r[3], r[4])
+end
+


More information about the tekui-devel mailing list