[tekui-devel] tekui: UI, Visual: Added MSG_USER input type; X11 Display: Added...

Timm S. Mueller tmueller at schulze-mueller.de
Sat Mar 14 20:12:51 CET 2009


details:   http://hg.teklib.org/tekui/rev/5f8a445a9c80
changeset: 53:5f8a445a9c80
user:      Timm S. Mueller <tmueller at schulze-mueller.de>
date:      Sat Mar 14 20:10:25 2009 +0100
description:
UI, Visual: Added MSG_USER input type; X11 Display: Added a reader which
repackages lines coming from stdin to user messages, and sends them to the
application; config: Added ENABLE_STDIO option; Application, Visual/Lua
getMsg(): now returns unpacked userdata in msg[-1]; Application: Message
processing optimized and streamlined, added addInputHandler() and
remInputHandler() for reacting on MSG_USER input messages; demo.css renamed to
industrial.css; added gendata.lua, 'meter' example and support class;
Visual/Lua: sleep() argument now specifies microseconds, no longer seconds

diffs (truncated from 1265 to 100 lines):

diff -r ff0ac2a3ad5d -r 5f8a445a9c80 bin/gendata.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/gendata.lua	Sat Mar 14 20:10:25 2009 +0100
@@ -0,0 +1,39 @@
+#!/usr/bin/env lua
+
+local visual = require "tek.lib.visual"
+
+local PI = math.pi
+local PI2 = PI*2
+local SIN = math.sin
+
+local s1 = 0
+local s2 = 0
+local x1 = 0
+local x2 = 0
+
+while true do
+
+	local n = 256
+
+	x1 = s1
+	x2 = s2
+
+	for cx = 0, n-1 do
+		local y = ((x1 % 2) - 1 + SIN(x2) * 0.5) / 4 + 0.5
+		y = y * 0x10000
+		io.stdout:write(("%d "):format(y))
+		x1 = x1 + 0.08
+		x2 = x2 + 0.33
+	end
+	io.stdout:write("\n")
+
+	s1 = s1 + 0.047
+	s2 = s2 + 0.33
+	if s2 > PI2 then
+		s2 = s2 - PI2
+	end
+
+	-- wait given number of microseconds:
+	visual.sleep(30)
+
+end
diff -r ff0ac2a3ad5d -r 5f8a445a9c80 bin/meter.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/meter.lua	Sat Mar 14 20:10:25 2009 +0100
@@ -0,0 +1,27 @@
+#!/usr/bin/env lua
+
+ui = require "tek.ui"
+
+print "This example visualizes sets of 256 16bit numbers, coming in via stdin."
+print "The X11 driver supports the conversion of stdin into input messages of"
+print "the required MSG_USER type. Invoke this example as follows:"
+print "# bin/gendata.lua | bin/meter.lua"
+
+ui.Application:new
+{
+	ThemeName = "industrial",
+	Children =
+	{
+		ui.Window:new
+		{
+			Title = "stdin Meter",
+			Orientation = "vertical",
+			Children =
+			{
+				ui.Text:new { Text = "stdin Meter" },
+				ui.Meter:new { }
+			}
+		}
+	}
+
+}:run()
diff -r ff0ac2a3ad5d -r 5f8a445a9c80 bin/tek/ui/class/meter.lua
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bin/tek/ui/class/meter.lua	Sat Mar 14 20:10:25 2009 +0100
@@ -0,0 +1,81 @@
+
+--
+--	tek.ui.class.meter
+--	Written by Timm S. Mueller <tmueller at schulze-mueller.de>
+--	See copyright notice in COPYRIGHT
+--
+--	This class paints sets of 256 16bit numbers coming in as MSG_USER,
+--	for which it registeres an input handler with the application.
+--
+
+local ui = require "tek.ui"
+local Frame = ui.Frame
+
+local floor = math.floor
+local max = math.max
+local min = math.min
+local pi = math.pi
+local sin = math.sin
+local tonumber = tonumber
+
+module("tek.ui.class.meter", tek.ui.class.frame)
+_VERSION = "Meter 1.0"


More information about the tekui-devel mailing list