Views now take a ctx. OS can call them directly
This commit is contained in:
parent
de515f35e9
commit
b04be8ccab
2 changed files with 15 additions and 34 deletions
|
|
@ -28,7 +28,7 @@ layoutDir : Direction \ { w : Int, h : Int } \ List LayoutChild \ { ui : UI, w :
|
|||
posY = dir
|
||||
| Col \ acc.pos
|
||||
| Row \ 0;
|
||||
rendered = ui.positioned { x = posX, y = posY, child = allocated.view childW childH };
|
||||
rendered = ui.positioned { x = posX, y = posY, child = allocated.view { w = childW, h = childH } };
|
||||
acc.{ pos = acc.pos + allocated.s, children = [...acc.children, rendered] }) { pos = 0, children = [] } children;
|
||||
{
|
||||
ui = ui.stack { children = result.children },
|
||||
|
|
@ -55,34 +55,18 @@ 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;
|
||||
|
||||
tableView = list \ ctx \
|
||||
w = ctx.w;
|
||||
h = ctx.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 colW (ctx \ (sizedText cellValue).ui)) columnNames)).ui;
|
||||
headerRow = (row { w = w, h = rowH } (map (cn \ Fixed colW (ctx \ (sizedText cn).ui)) columnNames)).ui;
|
||||
bodyRows = map (r \ Fixed rowH (ctx \ rowFromRecord r)) list;
|
||||
(col { w = w, h = h } [Fixed rowH (ctx \ headerRow), ...bodyRows]).ui;
|
||||
|
||||
@
|
||||
|
|
|
|||
|
|
@ -386,10 +386,7 @@ sizedText = content \
|
|||
size = measureText { content = content };
|
||||
{ ui = renderText { content = content }, w = size.width, h = size.height };
|
||||
|
||||
# new CG layout
|
||||
# move to layout module
|
||||
|
||||
LayoutChild = Fixed Int (Int \ Int \ UI) | Flex Int (Int \ Int \ UI);
|
||||
LayoutChild = Fixed Int (Ctx \ UI) | Flex Int (Ctx \ UI);
|
||||
Alignment = Start | Center | End;
|
||||
Direction = Col | Row;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue