Skip to content

Commit

Permalink
Merge pull request #188 from chrox/scroll_text
Browse files Browse the repository at this point in the history
add missing scrollbar widget
  • Loading branch information
houqp committed Jul 30, 2013
2 parents caf5d67 + c6f3388 commit 0024ad6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions frontend/ui/widget/scrollbar.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

VerticalScrollBar = Widget:new{
enable = true,
low = 0,
high = 1,

width = 6,
height = 50,
bordersize = 1,
bordercolor = 15,
radius = 0,
rectcolor = 15,
}

function VerticalScrollBar:getSize()
return Geom:new{
w = self.width,
h = self.height
}
end

function VerticalScrollBar:set(low, high)
self.low = low > 0 and low or 0
self.high = high < 1 and high or 1
end

function VerticalScrollBar:paintTo(bb, x, y)
if not self.enable then return end
bb:paintBorder(x, y, self.width, self.height,
self.bordersize, self.bordercolor, self.radius)
bb:paintRect(x + self.bordersize, y + self.bordersize + self.low*self.height,
self.width - 2*self.bordersize,
self.height * (self.high - self.low), self.rectcolor)
end

0 comments on commit 0024ad6

Please sign in to comment.