[tekui-devel] tekui: MenuItem alignment is now handled in PopupWindow class, w...

Timm S. Mueller tmueller at neoscientists.org
Tue Apr 22 20:02:31 CEST 2008


details:   http://hg.teklib.org/tekui/rev/4e62c68aad7e
changeset: 437:4e62c68aad7e
user:      Timm S. Mueller <tmueller at neoscientists.org>
date:      Mon Apr 21 11:04:52 2008 +0200
description:
MenuItem alignment is now handled in PopupWindow class, where it belongs;
cleanup in Window class, removed IsPopup helper

diffs (91 lines):

diff -r 65694cfc436c -r 4e62c68aad7e tek/class/ui/popitem.lua
--- a/tek/class/ui/popitem.lua	Sun Apr 20 23:48:23 2008 +0200
+++ b/tek/class/ui/popitem.lua	Mon Apr 21 11:04:52 2008 +0200
@@ -10,9 +10,10 @@ local Window = ui.Window
 local Window = ui.Window
 local Text = ui.Text
 local ipairs = ipairs
+local max = math.max
 
 module("tek.class.ui.popitem", tek.class.ui.text)
-_VERSION = "PopItem 1.22"
+_VERSION = "PopItem 1.23"
 
 -------------------------------------------------------------------------------
 --	Constants and class data:
@@ -52,7 +53,6 @@ function PopupWindow.init(self)
 	self.MaxHeight = 0
 	self.Children = self.Children or false
 	self.BeginPopupTicks = 0
-	self.IsPopup = true
 	return Window.init(self)
 end
 
@@ -85,6 +85,25 @@ function PopupWindow:passMsg(msg)
 	return Window.passMsg(self, msg)
 end
 
+function PopupWindow:setupDisplay(display)
+	if Window.setupDisplay(self, display) then
+		-- determine width of menuitems in group:
+		local maxw = 0
+		for _, e in ipairs(self.Children) do
+			if e:checkDescend(ui.MenuItem) then
+				maxw = max(maxw, e:getTextSize())
+			end
+		end
+		for _, e in ipairs(self.Children) do
+				-- align shortcut text (if present):
+			if e:checkDescend(ui.MenuItem) and e.TextRecords[2] then
+				e.TextRecords[2][5] = maxw + 20
+			end
+		end
+		return true
+	end
+end
+
 -------------------------------------------------------------------------------
 --	Class implementation:
 -------------------------------------------------------------------------------
diff -r 65694cfc436c -r 4e62c68aad7e tek/class/ui/window.lua
--- a/tek/class/ui/window.lua	Sun Apr 20 23:48:23 2008 +0200
+++ b/tek/class/ui/window.lua	Mon Apr 21 11:04:52 2008 +0200
@@ -24,7 +24,7 @@ local insert, remove, sort = table.inser
 local insert, remove, sort = table.insert, table.remove, table.sort
 
 module("tek.class.ui.window", tek.class.ui.group)
-_VERSION = "Window 1.38"
+_VERSION = "Window 1.39"
 
 -------------------------------------------------------------------------------
 --	Constants & Class data:
@@ -60,7 +60,6 @@ function Window.init(self)
 	self.HoverElement = false
 	self.InputHandlers = { }
 	self.Interval = false
-	self.IsPopup = self.IsPopup or false
 	self.LayoutGroup = { }
 	if self.BorderStyle then
 		self.Margin = self.Margin or DEF_MARGIN
@@ -100,21 +99,6 @@ function Window:setupDisplay(display)
 		self:addInputHandler(self, Window.handleInput)
 		-- notification handlers:
 		self:addNotify("Status", "hide", NOTIFY_HIDE)
-		if self.IsPopup then
-			-- determine width of all siblings in group:
-			local maxw = 0
-			for _, e in ipairs(self.Children) do
-				if e:checkDescend(ui.Text) then
-					local w = e:getTextSize()
-					maxw = max(maxw, w)
-				end
-			end
-			for _, e in ipairs(self.Children) do
-				if e:checkDescend(ui.Text) and e.TextRecords[2] then
-					e.TextRecords[2][5] = maxw + 20
-				end
-			end
-		end
 		return true
 	end
 end


More information about the tekui-devel mailing list