feat: dynamic mode

This commit is contained in:
2026-04-01 08:28:44 +02:00
parent df11705875
commit 619d3ec538
16 changed files with 1184 additions and 38 deletions

View File

@@ -6,6 +6,8 @@ from uframe.ir import (
IRNode, Page, Box, Row, Col, Spacer, Pad, Rect,
Heading, Text, Label, Divider, Link, ListNode, ListItem,
Gauge, Sparkline, Status, Table,
Form, Field, Password, Radio, Checkbox, FormButton,
Let, Source, IfBlock, ForLoop, CacheControl, OnSubmit, StateDecl,
)
@@ -111,8 +113,29 @@ def layout(node: IRNode, x: int, y: int, w: int, h: int) -> int:
node.rect.h = (cursor_y - y) + node.bottom
return node.rect.h
elif isinstance(node, Form):
cursor_y = y
for child in node.children:
child_h = layout(child, x, cursor_y, w, h - (cursor_y - y))
cursor_y += child_h
node.rect.h = cursor_y - y
return node.rect.h
elif isinstance(node, (Let, Source, CacheControl, StateDecl)):
node.rect.h = 0
return 0
elif isinstance(node, (IfBlock, ForLoop, OnSubmit)):
cursor_y = y
for child in node.children:
child_h = layout(child, x, cursor_y, w, h - (cursor_y - y))
cursor_y += child_h
node.rect.h = cursor_y - y
return node.rect.h
elif isinstance(node, (Heading, Text, Label, Divider, Link, ListItem,
Gauge, Sparkline, Status, Table)):
Gauge, Sparkline, Status, Table,
Field, Password, Radio, Checkbox, FormButton)):
node.rect.h = node.pref_height
return node.pref_height