feat: big title
This commit is contained in:
@@ -8,7 +8,9 @@ from uframe.ir import (
|
||||
Gauge, Sparkline, Status, Table,
|
||||
Form, Field, Password, Radio, Checkbox, FormButton,
|
||||
Let, Source, IfBlock, ForLoop, CacheControl, OnSubmit, StateDecl,
|
||||
BigTitle,
|
||||
)
|
||||
from uframe.fonts import FONT_HEIGHTS, get_text_width
|
||||
|
||||
|
||||
def _text_height(text: str, width: int) -> int:
|
||||
@@ -243,6 +245,22 @@ def measure(node: IRNode, available_width: int) -> None:
|
||||
node.pref_height = 1
|
||||
node.min_height = 1
|
||||
|
||||
elif isinstance(node, BigTitle):
|
||||
# Try the requested font, fall back to smaller if too wide
|
||||
tw = get_text_width(node.text, node.font)
|
||||
if tw <= available_width:
|
||||
h = FONT_HEIGHTS.get(node.font, 6)
|
||||
elif get_text_width(node.text, "pixel") <= available_width:
|
||||
h = FONT_HEIGHTS.get("pixel", 3)
|
||||
elif get_text_width(node.text, "thin") <= available_width:
|
||||
h = FONT_HEIGHTS.get("thin", 3)
|
||||
else:
|
||||
h = 1 # fallback to single styled line
|
||||
node.pref_width = available_width
|
||||
node.min_width = 1
|
||||
node.pref_height = h
|
||||
node.min_height = 1
|
||||
|
||||
elif isinstance(node, (Let, Source, CacheControl, StateDecl)):
|
||||
# Zero-height metadata nodes — no visual output
|
||||
node.pref_width = 0
|
||||
|
||||
Reference in New Issue
Block a user