[tekui-devel] tekui: Layouter: cleaned up and optimized; Window: reimplemented...

Timm S. Mueller tmueller at neoscientists.org
Sun Apr 20 23:46:03 CEST 2008


details:   http://hg.teklib.org/tekui/rev/c91039582acb
changeset: 434:c91039582acb
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Sun Apr 20 00:58:59 2008 +0200
description:
Layouter: cleaned up and optimized; Window: reimplemented input handlers;
TextInput: added input handler for keyboard events when editing

diffs (truncated from 393 to 100 lines):

diff -r 50b4cbd0bdcb -r c91039582acb tek/class/ui/layout/default.lua
--- a/tek/class/ui/layout/default.lua	Fri Apr 18 01:13:15 2008 +0200
+++ b/tek/class/ui/layout/default.lua	Sun Apr 20 00:58:59 2008 +0200
@@ -191,10 +191,13 @@ function DefaultLayout:layout(group, r1,
 
 		local isgrid = gs1 > 1 and gs2 > 1
 
-		local c, isz, osz, m3, m4
+		local c, isz, osz, m3, m4, mm, a
 		local xywh = self.XYWH
 
 		local i1, i2, i3, i4, i5, i6 = unpack(INDICES[ori])
+		local gp = group.Padding
+		local gr = group.Rect
+		local goffs = group.MarginAndBorder[i1] + gp[i1]
 		local A = ALIGN[ori]
 
 		if i1 == 2 then
@@ -214,11 +217,10 @@ function DefaultLayout:layout(group, r1,
 		local cidx = 1
 
 		-- size on outer axis:
-		local oszmax = group.Rect[i4] - group.Rect[i2] + 1
-			- group.Padding[i2] - group.Padding[i4]
+		local oszmax = gr[i4] - gr[i2] + 1 - gp[i2] - gp[i4]
 
 		-- starting position on outer axis:
-		xywh[i6] = r2 + group.MarginAndBorder[i2] + group.Padding[i2]
+		xywh[i6] = r2 + group.MarginAndBorder[i2] + gp[i2]
 
 		-- loop outer axis:
 		for oidx = 1, gs2 do
@@ -228,7 +230,7 @@ function DefaultLayout:layout(group, r1,
 			end
 
 			-- starting position on inner axis:
-			xywh[i5] = r1 + group.MarginAndBorder[i1] + group.Padding[i1]
+			xywh[i5] = r1 + goffs
 
 			-- loop inner axis:
 			for iidx = 1, gs1 do
@@ -238,29 +240,26 @@ function DefaultLayout:layout(group, r1,
 					return
 				end
 
+				-- element minmax:
+				mm = c.MinMax
+
 				-- x0, y0 of child rectangle:
 				xywh[1] = xywh[5]
 				xywh[2] = xywh[6]
 
 				-- max per inner and outer axis:
-				m3, m4 = c.MinMax[i3], c.MinMax[i4]
+				m3, m4 = mm[i3], mm[i4]
 
 				-- inner size:
 				isz = ilist[iidx][5] -- size
-
-				local a = c[A[5]]
+				a = c[A[5]]
 				if a == "auto" then
-					m3 = c.MinMax[i1]
-				elseif a == "fill" then
-					m3 = nil
-				elseif a == "free" then
-					m3 = group.Rect[i3] - group.Rect[i1] + 1 -
-						group.Padding[i1] - group.Padding[i3]
-				end
-
-				if m3 and m3 < isz then
-					-- align if element does not fully occupy inner size:
-					local a = c[A[1]]
+					m3 = mm[i1]
+				elseif a == "free" or a == "fill" then
+					m3 = gr[i3] - gr[i1] + 1 - gp[i1] - gp[i3]
+				end
+				if m3 < isz then
+					a = c[A[1]]
 					if a == "center" then
 						xywh[i1] = xywh[i1] + floor((isz - m3) / 2)
 					elseif a == A[3] then
@@ -271,31 +270,23 @@ function DefaultLayout:layout(group, r1,
 				end
 
 				-- outer size:
-				osz = olist[oidx][5] -- size
-
-				local a = c[A[6]]
-				if a == "auto" then
-					m4 = c.MinMax[i2]
-				elseif a == "fill" then
-					m4 = nil
-				elseif a == "free" then
-					m4 = oszmax
-				end
-
-				if m4 then
-					osz = min(osz, m4)
+				a = c[A[6]]


More information about the tekui-devel mailing list