Adding first pass at tableView to layout
This commit is contained in:
parent
1a26ec4d24
commit
82193a41ca
1 changed files with 30 additions and 0 deletions
|
|
@ -55,4 +55,34 @@ align = hAlign vAlign w h child \
|
|||
h = h
|
||||
};
|
||||
|
||||
tableView = list \ w h \
|
||||
firstRow = unwrapOr "{}" (nth 0 list);
|
||||
|
||||
columnNames = keys firstRow;
|
||||
|
||||
colW = w / (len columnNames);
|
||||
rowH = 24;
|
||||
|
||||
rowFromRecord = r \
|
||||
(row { w = w, h = rowH }
|
||||
(map (cn \
|
||||
cellValue = display (unwrapOr "" (getField cn r));
|
||||
Fixed 100 (cw ch \ (sizedText cellValue).ui)
|
||||
) columnNames)
|
||||
).ui;
|
||||
|
||||
headerRow = (row { w = w, h = rowH }
|
||||
(map (cn \
|
||||
Fixed colW (cw ch \ (sizedText cn).ui)
|
||||
) columnNames)
|
||||
).ui;
|
||||
|
||||
bodyRows = map (r \ Fixed rowH (cw cch \ rowFromRecord r)) list;
|
||||
|
||||
(col { w = 500, h = 500 } [
|
||||
Fixed rowH (cw ch \ headerRow),
|
||||
...bodyRows
|
||||
]).ui;
|
||||
|
||||
|
||||
@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue