Skip to content
Snippets Groups Projects
Commit bbc387cf authored by dg's avatar dg
Browse files

fix

git-svn-id: http://svn.net-core.org/repos/t-engine4@2839 51575b47-30f0-44d4-a5cc-537603b46e54
parent dda717b1
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,7 @@
require "engine.class"
local Base = require "engine.ui.Base"
local Focusable = require "engine.ui.Focusable"
local Slider = require "engine.ui.Slider"
--- A generic UI list
module(..., package.seeall, class.inherit(Base, Focusable))
......@@ -49,15 +50,7 @@ function _M:generate()
-- Draw the scrollbar
if self.scrollbar then
local sb, sb_w, sb_h = self:getImage("ui/scrollbar.png")
local ssb, ssb_w, ssb_h = self:getImage("ui/scrollbar-sel.png")
self.scrollbar = { bar = {}, sel = {} }
self.scrollbar.sel.w, self.scrollbar.sel.h, self.scrollbar.sel.tex, self.scrollbar.sel.texw, self.scrollbar.sel.texh = ssb_w, ssb_h, ssb:glTexture()
local s = core.display.newSurface(sb_w, self.h - fh)
s:erase(200,0,0)
for i = 0, self.h - fh do s:merge(sb, 0, i) end
self.scrollbar.bar.w, self.scrollbar.bar.h, self.scrollbar.bar.tex, self.scrollbar.bar.texw, self.scrollbar.bar.texh = ssb_w, self.h - fh, s:glTexture()
self.scrollbar = Slider.new{size=self.h - fh, max=1}
end
-- Add UI controls
......@@ -148,9 +141,8 @@ function _M:display(x, y)
end
if self.focused and self.scrollbar then
local pos = self.scroll * (self.h - self.fh) / (self.max - self.max_display + 1)
self.scrollbar.bar.tex:toScreenFull(bx + self.w - self.scrollbar.bar.w, by + self.fh, self.scrollbar.bar.w, self.scrollbar.bar.h, self.scrollbar.bar.texw, self.scrollbar.bar.texh)
self.scrollbar.sel.tex:toScreenFull(bx + self.w - self.scrollbar.sel.w, by + self.fh + pos, self.scrollbar.sel.w, self.scrollbar.sel.h, self.scrollbar.sel.texw, self.scrollbar.sel.texh)
self.scrollbar.pos = self.scroll
self.scrollbar.pos = self.max - self.max_display + 1
self.scrollbar:display(bx + self.w - self.scrollbar.w, by)
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment