getRectangle returns x,y,w,h instead of x1,y1,x2,y2

This commit is contained in:
airstruck
2015-11-27 06:40:02 -05:00
parent 29dac8a611
commit 290f6333b7
5 changed files with 64 additions and 59 deletions

View File

@@ -35,7 +35,8 @@ return function (self)
end)
local function press (event)
local x1, y1, x2, y2 = self:getRectangle(true, true)
local x1, y1, w, h = self:getRectangle(true, true)
local x2, y2 = x1 + w, y1 + h
local halfThumb = thumb:getWidth() / 2
x1, x2 = x1 + halfThumb, x2 - halfThumb
self.value = clamp((event.x - x1) / (x2 - x1))
@@ -58,7 +59,9 @@ return function (self)
end)
self:onReshape(function (event)
local x1, y1, x2, y2 = self:getRectangle(true, true)
-- TODO: eliminate redundancy with `press`
local x1, y1, w, h = self:getRectangle(true, true)
local x2, y2 = x1 + w, y1 + h
local halfThumb = thumb:getWidth() / 2
x1, x2 = x1 + halfThumb, x2 - halfThumb
spacer.width = self.value * (x2 - x1)