[tekui-devel] tekui: Slider: setXPosition, setYPosition are now internal funct...
Timm S. Mueller
tmueller at neoscientists.org
Fri Apr 25 00:10:43 CEST 2008
details: http://hg.teklib.org/tekui/rev/a87ef8db8896
changeset: 445:a87ef8db8896
user: Timm S. Mueller <tmueller at neoscientists.org>
date: Wed Apr 23 22:42:32 2008 +0200
description:
Slider: setXPosition, setYPosition are now internal functions
diffs (truncated from 200 to 100 lines):
diff -r d23685cfa0cd -r a87ef8db8896 tek/app/ui/dynamic.lua
--- a/tek/app/ui/dynamic.lua Wed Apr 23 20:45:37 2008 +0200
+++ b/tek/app/ui/dynamic.lua Wed Apr 23 22:42:32 2008 +0200
@@ -89,7 +89,7 @@ ui.application:new
{
ui.NOTIFY_SELF, function(self)
local e = self.Application:getElementById("1")
- self.Application:getElementById("s3"):setPosition(0x8000)
+ self.Application:getElementById("s3"):setValue("XPosition", 0x8000)
e:setValue("Weight", false)
e:setValue("Label", "unset")
end
diff -r d23685cfa0cd -r a87ef8db8896 tek/class/ui/scrollgroup.lua
--- a/tek/class/ui/scrollgroup.lua Wed Apr 23 20:45:37 2008 +0200
+++ b/tek/class/ui/scrollgroup.lua Wed Apr 23 22:42:32 2008 +0200
@@ -75,9 +75,9 @@ function ArrowButton:doSlider(direction)
function ArrowButton:doSlider(direction)
local s = self.Slider
if s.HFreedom then
- s:setXPosition(s.Position[1] + s:getClickStep(1) * direction)
+ s:setValue("XPosition", s.Position[1] + s:getClickStep(1) * direction)
elseif s.VFreedom then
- s:setYPosition(s.Position[2] + s:getClickStep(2) * direction)
+ s:setValue("YPosition", s.Position[2] + s:getClickStep(2) * direction)
end
end
@@ -383,7 +383,11 @@ function ScrollGroup:setLeft(x)
x = floor(x)
local dx = x - ca.Left
ca.Left = x
- self.HSlider:setXPosition(x * 0x10000 / ca.Width)
+ local changed
+ x, _, changed = self.HSlider:checkXPosition(x * 0x10000 / ca.Width)
+ if changed then
+ self.HSlider:setValue("XPosition", x)
+ end
if dx > 0 then
insert(self.CopyAreaList, { -dx, 0 })
elseif dx < 0 then
@@ -400,7 +404,11 @@ function ScrollGroup:setTop(y)
y = floor(y)
local dy = y - ca.Top
ca.Top = y
- self.VSlider:setYPosition(y * 0x10000 / ca.Height)
+ local changed
+ y, _, changed = self.VSlider:checkYPosition(y * 0x10000 / ca.Height)
+ if changed then
+ self.VSlider:setValue("YPosition", y)
+ end
if dy > 0 then
insert(self.CopyAreaList, { 0, -dy })
elseif dy < 0 then
diff -r d23685cfa0cd -r a87ef8db8896 tek/class/ui/slider.lua
--- a/tek/class/ui/slider.lua Wed Apr 23 20:45:37 2008 +0200
+++ b/tek/class/ui/slider.lua Wed Apr 23 22:42:32 2008 +0200
@@ -27,6 +27,9 @@ local DEF_KNOBMINH = 8
local DEF_KNOBMINH = 8
local DEF_KNOBMARGIN = { 0, 0, 0, 0 }
local NOTIFY_ONHOLD = { ui.NOTIFY_SELF, "onHold" }
+
+local NOTIFY_XPOSITION = { ui.NOTIFY_SELF, "setXPosition", ui.NOTIFY_VALUE }
+local NOTIFY_YPOSITION = { ui.NOTIFY_SELF, "setYPosition", ui.NOTIFY_VALUE }
-------------------------------------------------------------------------------
-- Class implementation:
@@ -65,9 +68,13 @@ function Slider:connectGlobal(app, windo
Gadget.connectGlobal(self, app, window)
Gadget.connectGlobal(self.Knob, app, window)
self:addNotify("Hold", true, NOTIFY_ONHOLD)
+ self:addNotify("XPosition", ui.NOTIFY_ALWAYS, NOTIFY_XPOSITION)
+ self:addNotify("YPosition", ui.NOTIFY_ALWAYS, NOTIFY_YPOSITION)
end
function Slider:disconnectGlobal()
+ self:remNotify("YPosition", ui.NOTIFY_ALWAYS, NOTIFY_YPOSITION)
+ self:remNotify("XPosition", ui.NOTIFY_ALWAYS, NOTIFY_XPOSITION)
self:remNotify("Hold", true, NOTIFY_ONHOLD)
Gadget.disconnectGlobal(self.Knob)
Gadget.disconnectGlobal(self)
@@ -265,8 +272,11 @@ function Slider:clickcontainer(xy)
newposy = self.Position[2] + cy
end
end
- if newposx or newposy then
- return self:setPosition(newposx, newposy)
+ if newposx then
+ self:setValue("XPosition", newposx)
+ end
+ if newposy then
+ self:setValue("YPosition", newposy)
end
end
@@ -291,18 +301,18 @@ end
end
function Slider:doMove(x, y)
- local newx, newy
local r = self.Rect
More information about the tekui-devel
mailing list