Differences From
Artifact [787cef01b1]:
1 1 local l = sorcery.lib
2 2 local dui = sorcery.data.ui
3 3
4 4 return {
5 + form = function()
6 + return {
7 + src = "";
8 + width = 8;
9 + pad = 0;
10 + curs = {x = 0, y = 0, maxh = 0};
11 + nl = function(self, h)
12 + h = h or 0
13 + self.curs.x = 0
14 + self.curs.y = math.max(h, self.curs.y + self.curs.maxh)
15 + self.curs.maxh = 0
16 + end;
17 + atttach = function(self, elt, x, y, w, h, ...)
18 + local content = ''
19 + if self.width - self.curs.x < w then self:nl() end
20 + for _, v in pairs{...} do
21 + content = content .. ';' .. minetest.formspec_escape(tostring(v))
22 + end
23 + self.src = self.src .. string.format('%s[%f,%f;%f,%f%s]', elt, x,y, w,h, content)
24 + if h > self.curs.maxh then self.curs.maxh = h end
25 + end;
26 + add = function(self, elt, w, h, ...)
27 + local ax, ay = self.curs.x, self.curs.y
28 + self:attach(elt, ax,ay, w,h, ...)
29 + self.curs.x = self.curs.x + w + self.pad
30 + if self.curs.x > self.width then self:nl() end
31 + return ax, ay
32 + end;
33 + render = function()
34 + return string.format("size[%f,%f]%s", self.width, self.curs.y + self.pad + self.curs.maxh, self.src)
35 + end;
36 + }
37 + end;
38 +
5 39 tooltip = function(a)
6 40 local color = a.color and a.color:readable()
7 41 if color == nil then color = l.color(136,158,177) end
8 42 local str = a.title
9 43 if a.desc then
10 44 str = str .. '\n' .. color:fmt(minetest.wrap_text(a.desc,60))
11 45 end