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

Checkboxes now have the box before the text (this is reversable by adding a...

Checkboxes now have the box before the text (this is reversable by adding a check_last=true parameter when creating them)


git-svn-id: http://svn.net-core.org/repos/t-engine4@6387 51575b47-30f0-44d4-a5cc-537603b46e54
parent 06ee9951
No related branches found
No related tags found
No related merge requests found
......@@ -28,6 +28,7 @@ function _M:init(t)
self.title = assert(t.title, "no checkbox title")
self.text = t.text or ""
self.checked = t.default
self.check_first = not t.check_last
self.fct = t.fct or function() end
self.on_change = t.on_change
......@@ -68,19 +69,27 @@ function _M:select()
end
function _M:display(x, y, nb_keyframes)
if self.text_shadow then self.tex[1]:toScreenFull(x+1, y+1 + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3], 0, 0, 0, self.text_shadow) end
self.tex[1]:toScreenFull(x, y + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3])
if self.focused then
self.check.t:toScreenFull(x + self.title_w, y, self.check.w, self.check.h, self.check.tw, self.check.th)
if self.check_first then
if self.text_shadow then self.tex[1]:toScreenFull(x+1 + self.check.w, y+1 + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3], 0, 0, 0, self.text_shadow) end
self.tex[1]:toScreenFull(x + self.check.w, y + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3])
if self.focused then
self.check.t:toScreenFull(x, y, self.check.w, self.check.h, self.check.tw, self.check.th)
else
self.check.t:toScreenFull(x, y, self.check.w, self.check.h, self.check.tw, self.check.th)
end
if self.checked then
self.tick.t:toScreenFull(x, y, self.tick.w, self.tick.h, self.tick.tw, self.tick.th)
end
else
self.check.t:toScreenFull(x + self.title_w, y, self.check.w, self.check.h, self.check.tw, self.check.th)
if self.focus_decay then
-- self.check.t:toScreenFull(x + self.title_w, y, self.check.w, self.check.h, self.check.tw, self.check.th)
self.focus_decay = self.focus_decay - nb_keyframes
if self.focus_decay <= 0 then self.focus_decay = nil end
if self.text_shadow then self.tex[1]:toScreenFull(x+1, y+1 + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3], 0, 0, 0, self.text_shadow) end
self.tex[1]:toScreenFull(x, y + (self.h - self.title_h) / 2, self.title_w, self.title_h, self.tex[2], self.tex[3])
if self.focused then
self.check.t:toScreenFull(x + self.title_w, y, self.check.w, self.check.h, self.check.tw, self.check.th)
else
self.check.t:toScreenFull(x + self.title_w, y, self.check.w, self.check.h, self.check.tw, self.check.th)
end
if self.checked then
self.tick.t:toScreenFull(x + self.title_w, y, self.tick.w, self.tick.h, self.tick.tw, self.tick.th)
end
end
if self.checked then
self.tick.t:toScreenFull(x + self.title_w, y, self.tick.w, self.tick.h, self.tick.tw, self.tick.th)
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