[tekui-devel] tekui: Improved Slider; added dynamic layout to FloatText
hg-notify at neoscientists.org
hg-notify at neoscientists.org
Tue Feb 5 02:46:02 CET 2008
details: http://hg.teklib.org/tekui/rev/526c98a52048
changeset: 354:526c98a52048
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Mon Feb 04 04:51:19 2008 +0100
description:
Improved Slider; added dynamic layout to FloatText
diffs (truncated from 257 to 100 lines):
diff -r bf837437c2dc -r 526c98a52048 tek/app/ui/floattext.lua
--- a/tek/app/ui/floattext.lua Sun Feb 03 22:28:41 2008 +0100
+++ b/tek/app/ui/floattext.lua Mon Feb 04 04:51:19 2008 +0100
@@ -9,7 +9,9 @@ ui.Application:new {
Children = {
ui.Window:new {
Children = {
- ui.FloatText:new { }
+ ui.FloatText:new {
+ FloatText = [[ Hello. My Handle is The Cuisinart Blade, (I have since changed it) most people called me C.B., just as another nickname. I got into computers because I always had a knack for Games, Programs, Etc... I loved the feel of the keyboard as I typed, espically around Midnight, when School was only 7 hours away. That Dickhead in your 1st hour waiting to pick on you at the stroke of the clock. What little that he knew. I Loved the feeling of flying through the 'Net, talking to the other Hackers like me, always trying to impress one another. They came in all fashions of Handles: The Ax Murderer, Psycho, The Hacker Kid, Phobia, Etc...the list is nearly endless. And each with an utterly unique personality, so far advanced from the Morons we all remember at high school. I loved talking to these "Wanderers of the Wunderland" so much, I would call all over the united states just to do that. I remember back in 1988, 9600 was almost as uncommon as the newest modems of today. I loved to suck down that Jolt, turn on the overhead light in the basement, and hack until morning. Then goto school to have that enormus football jock try to scare me into submission. I will admit that, yes, he did scare me. But what a fool he was, thinking that pure brawn was power. Knowledge IS power. I never did good in High School. Knowledge is not there, it was in the 'Net! THAT was where I was a King. That was where I was a God. ANYONE who has truely roamed the 'Net or been in that type of world could tell you that, (Right, King Blotto?) hands down. I loved running home, or taking the bus, right into my basement! Homework? Bah! What a waste of time it was, compared to the thrill of Hacking? Homework was little more than review. I sat down and got onto my Computer and began to type. I called a rather large BBS in which, Hackers frequented. Nowadays they are considered "Wandering" Boards. They appear to wander because they change phone numbers all the time. Anyway, I called up my favorite Pirate BBS and went onto Multi- nodal chat to talk to the others about their exploits. Some of them had told me of their abilities to smash entire phone networks, others had told me of their A-Typical grade changes, (Yawn) But most of all I loved to brag. The unwritten rule in being a hacker, you're nothing unless you have something to brag about. At the time, I didn't, so I decided to get a name in the computer Hacking Club and do just that: Hack. At first I wondered where I should go, what I should do. I had no idea where to begin. I had been all over the world in the 'Net, and nothing to show for it, other than just knowing of everyone, or everything. I needed more. That is the answer to everything in the mind of a Hacker, the NEED to know. I decided to try something small. That night, my friend, (who I will call Dr.Antristo) and I, called up another Pirate BBS and Downloaded the number of a rather prominent business, (at the time) and decided to call. Our biggest fear was being traced, so we got togther and built what is nowadays almost routine, (from what I hear) a BOX. I made the call and found myself looking into a Menu System, that asked for a NAME, and Security ID. I had no idea about any security ID, or anyone who worked there, so I decided to Hang up and try in a day or 2, AFTER I did some "Checking Up" on their Company. ]],
+ }
}
}
}
diff -r bf837437c2dc -r 526c98a52048 tek/class/ui/floattext.lua
--- a/tek/class/ui/floattext.lua Sun Feb 03 22:28:41 2008 +0100
+++ b/tek/class/ui/floattext.lua Mon Feb 04 04:51:19 2008 +0100
@@ -7,6 +7,7 @@
local ui = require "tek.lib.ui"
local db = require "tek.lib.debug"
+db.level = 4
local Area = ui.Area
local ScrollGroup = ui.ScrollGroup
@@ -14,9 +15,14 @@ local Canvas = ui.Canvas
local unpack = unpack
local overlap = ui.Region.overlapCoords
+local insert = table.insert
+local remove = table.remove
+local concat = table.concat
+local min = math.min
+local ipairs = ipairs
module("tek.class.ui.floattext", tek.class.ui.scrollgroup)
-_VERSION = "FloatText 0.1"
+_VERSION = "FloatText 0.2"
local FloatText = _M
-------------------------------------------------------------------------------
@@ -75,6 +81,7 @@ function TextArea:draw(bgpen)
local dr = self.DamageRegion
if dr then
+ local pens = d.Pens
for _, r in dr:getRects() do
local r1, r2, r3, r4 = dr:getRect(r)
d:fillRect(r1, r2, r3, r4, bgpen)
@@ -83,7 +90,7 @@ function TextArea:draw(bgpen)
local a1, a2, a3, a4 = overlap(r1, r2, r3, r4, t[1], t[2], t[3], t[4])
if a1 then
d:pushClipRect(a1, a2, a3, a4)
- d:drawText(t[1], t[2], t.Text, d.Pens[ui.PEN_SHINE])
+ d:drawText(t[1], t[2], t.Text, pens[ui.PEN_BUTTONTEXT])
d:popClipRect()
end
end
@@ -93,25 +100,53 @@ function TextArea:draw(bgpen)
end
-function TextArea:layout(r1, r2, r3, r4, markdamage)
- Area.layout(self, r1, r2, r3, r4, markdamage)
+function TextArea:layoutText(x, y, width, text)
+ text = text or { }
+ local line = { }
+ local linestring
+ local fh = self.FHeight
+ local tw
- local x = self.Rect[1]
- local y = self.Rect[2]
- for i = 1, #self.Text do
- local t = self.Text[i]
- local w, h = ui.Display:textSize(self.Font, t.Text)
- t[1] = x
- t[2] = y
- t[3] = x + w - 1
- t[4] = y + h - 1
- y = y + self.FHeight
+ for word in self.FloatText:gmatch("[^%s]+") do
+ insert(line, word)
+ local newstring = concat(line, " ")
+ tw = ui.Display:textSize(self.Font, newstring)
+ if tw >= width then
+ if linestring then
+ insert(text, { x, y, x + tw - 1, y + fh - 1, Text = linestring })
+ y = y + fh
+ end
+ if tw > width then
+ line = { word }
+ linestring = word
+ else
+ line = { }
+ linestring = nil
+ end
+ else
+ linestring = newstring
+ end
More information about the tekui-devel
mailing list