29
30
31
32
33
34
35
36
37
38
39
40
41
42
...
148
149
150
151
152
153
154
155
156
157
158
159
160
161
...
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
...
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
...
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
end
local created = state == nil
if not state then
state = {
page = page or 'index';
form = self.id;
}
starlit.activeUI[user.name] = state
self:cb('setupState', user, ...)
elseif page ~= nil and state.page ~= page then
state.page = page
local psetup = self.pages[state.page].setupState
if psetup then psetup(state,user, ...) end
................................................................................
widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
-- TODO alignments
state.x=state.x + state.spacing + st.w
state.h = math.max(state.h, st.h)
end
state.h = state.h + state.padding
state.w = state.x + state.padding/2
elseif def.kind == 'list' then
local slotTypes = {
plain = {hue = 200, sat = -.1, lum = 0};
element = {hue = 20, sat = -.3, lum = 0};
chip = {hue = 0, sat = -1, lum = 0};
psi = {hue = 300, sat = 0, lum = 0};
power = {hue = 50, sat = 0, lum = .2};
................................................................................
def.w, def.h,
def.idx))
local sm = 1
state.w = def.w * sm + (spac * (def.w - 1))
state.h = def.h * sm + (spac * (def.h - 1))
elseif def.kind == 'contact' then
if def.color then table.insert(lines, btnColorDef(def.id)) end
widget('image_button%s[%s,%s;%s,%s;%s;%s;%s]',
def.close and '_exit' or '',
state.x, state.y, def.w, def.h,
E(def.img), E(def.id), E(def.label or ''))
elseif def.kind == 'button' then
if def.color then table.insert(lines, btnColorDef(def.id)) end
local label = E(def.label or '')
if state.fg then label = lib.color(state.fg):fmt(label) end
widget('button%s[%s,%s;%s,%s;%s;%s]',
def.close and '_exit' or '',
state.x, state.y, def.w, def.h,
................................................................................
-- TODO paragraph formatter
widget('hypertext[%s,%s;%s,%s;%s;%s]',
state.x, state.y, def.w, def.h, E(def.id), E(def.text))
elseif def.kind == 'hbar' or def.kind == 'vbar' then -- TODO fancy image bars
local cl = lib.color(state.color)
local fg = state.fg or cl:readable(.8,1)
local wfac, hfac = 1,1
local clamp = math.min(math.max(def.fac, 0), 1)
if def.kind == 'hbar'
then wfac = wfac * clamp
else hfac = hfac * clamp
end
local x,y, w,h = state.x, state.y, def.w, def.h
widget('box[%s,%s;%s,%s;%s]',
x,y, w,h, cl:brighten(0.2):hex())
................................................................................
widget('hypertext[%s,%s;%s,%s;;%s]',
state.x, state.y, def.w, def.h,
string.format('<global halign=center valign=middle color=%s>%s', fg:hex(), E(def.text)))
end
end
if def.desc then
widget('tooltip[%s,%s;%s,%s;%s]',
state.x, state.y, def.w, def.h, E(def.desc))
end
local originX = (parent and parent.x or 0)
local originY = (parent and parent.y or 0)
local l = table.concat(lines)
-- if state.fixed and (state.w < state.x or state.h < state.y) then
-- l = string.format('scroll_container[%s,%s;%s,%s;scroll_%s;%s]%sscroll_container_end[]',
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
|
>
>
>
|
|
>
>
>
|
>
>
|
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
...
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
...
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
...
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
...
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
end
local created = state == nil
if not state then
state = {
page = page or 'index';
form = self.id;
self = self;
close = function() self:close(user) end;
}
starlit.activeUI[user.name] = state
self:cb('setupState', user, ...)
elseif page ~= nil and state.page ~= page then
state.page = page
local psetup = self.pages[state.page].setupState
if psetup then psetup(state,user, ...) end
................................................................................
widget('container[%s,%s]%scontainer_end[]', state.x, state.y, src)
-- TODO alignments
state.x=state.x + state.spacing + st.w
state.h = math.max(state.h, st.h)
end
state.h = state.h + state.padding
state.w = state.x + state.padding/2
elseif def.kind == 'pane' then
widget('scroll_container[%s,%s;%s,%s;%s;vertical]',
state.x, state.y, state.w, state.h,
def.id)
local y = 0
for _, w in ipairs(def) do
local src, st = starlit.ui.build(w, state)
widget('container[%s,%s]%scontainer_end[]', 0, y, src)
y=y + state.spacing + st.h
state.w = math.max(state.w, st.w)
end
widget('scroll_container_end[]')
if y > state.h then
widget('scrollbar[%s,%s;%s,%s;vertical;%s;]',
state.x, state.y, .5, state.h,
def.id)
end
state.w = state.w + state.padding
state.h = state.h + state.padding/2
elseif def.kind == 'list' then
local slotTypes = {
plain = {hue = 200, sat = -.1, lum = 0};
element = {hue = 20, sat = -.3, lum = 0};
chip = {hue = 0, sat = -1, lum = 0};
psi = {hue = 300, sat = 0, lum = 0};
power = {hue = 50, sat = 0, lum = .2};
................................................................................
def.w, def.h,
def.idx))
local sm = 1
state.w = def.w * sm + (spac * (def.w - 1))
state.h = def.h * sm + (spac * (def.h - 1))
elseif def.kind == 'contact' then
if def.color then table.insert(lines, btnColorDef(def.id)) end
local img = def.img
local desc
if def.item then
img = ItemStack(def.item):get_name()
desc = ItemStack(def.item):get_description()
end
widget('%simage_button%s[%s,%s;%s,%s;%s;%s;%s]',
def.item and 'item_' or '',
def.close and '_exit' or '',
state.x, state.y, def.w, def.h,
E(img), E(def.id), E(def.label or ''))
if desc and not def.desc then
widget('tooltip[%s;%s]', E(def.id), E(desc))
end
elseif def.kind == 'button' then
if def.color then table.insert(lines, btnColorDef(def.id)) end
local label = E(def.label or '')
if state.fg then label = lib.color(state.fg):fmt(label) end
widget('button%s[%s,%s;%s,%s;%s;%s]',
def.close and '_exit' or '',
state.x, state.y, def.w, def.h,
................................................................................
-- TODO paragraph formatter
widget('hypertext[%s,%s;%s,%s;%s;%s]',
state.x, state.y, def.w, def.h, E(def.id), E(def.text))
elseif def.kind == 'hbar' or def.kind == 'vbar' then -- TODO fancy image bars
local cl = lib.color(state.color)
local fg = state.fg or cl:readable(.8,1)
local wfac, hfac = 1,1
local clamp = math.min(math.max(def.fac or 0, 0), 1)
if def.kind == 'hbar'
then wfac = wfac * clamp
else hfac = hfac * clamp
end
local x,y, w,h = state.x, state.y, def.w, def.h
widget('box[%s,%s;%s,%s;%s]',
x,y, w,h, cl:brighten(0.2):hex())
................................................................................
widget('hypertext[%s,%s;%s,%s;;%s]',
state.x, state.y, def.w, def.h,
string.format('<global halign=center valign=middle color=%s>%s', fg:hex(), E(def.text)))
end
end
if def.desc then
local coord
if def.id then
coord = E(def.id)
else
coord = string.format("%s,%s;%s,%s", state.x, state.y, def.w, def.h)
end
widget('tooltip[%s;%s;#000000;#ffffff]', coord, E(def.desc))
end
local originX = (parent and parent.x or 0)
local originY = (parent and parent.y or 0)
local l = table.concat(lines)
-- if state.fixed and (state.w < state.x or state.h < state.y) then
-- l = string.format('scroll_container[%s,%s;%s,%s;scroll_%s;%s]%sscroll_container_end[]',
|