Skip to content

Commit 4406f37

Browse files
Ralph Kuepperclaude
andcommitted
docs(ui/layout): wrap overlay parents in ZStack for GTK4 portability
The two `widgetAddOverlay` callers in `docs/examples/ui/layout/snippets.ts` used a VStack and an ImageSymbol as the overlay parent. Macos NSView allows `addSubview` on any view, but GTK4 can only float children above siblings inside `gtk::Overlay` (which ZStack is backed by). Pre-edit the v0.5.322 GTK4 backend logged the documented "non-Overlay parent — falling back to add_child" warning at runtime; post-edit the snippet runs warning-free for the overlay patterns. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e58ff60 commit 4406f37

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

docs/examples/ui/layout/snippets.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ widgetSetHugging(stretchy, 1) // Low priority — stretch to fill
127127
// ANCHOR_END: hugging
128128

129129
// ANCHOR: overlay
130-
const container = VStack(16, [Text("Main content")])
130+
// Overlay parent must be a ZStack — macOS NSView allows `addSubview` on
131+
// any view, but GTK4 can only float children above siblings inside
132+
// `gtk::Overlay` (which is what ZStack is backed by).
133+
const container = ZStack()
134+
widgetAddChild(container, VStack(16, [Text("Main content")])) // main child
131135

132136
const badge = Text("3")
133137
setCornerRadius(badge, 10)
@@ -176,7 +180,10 @@ const searchPage = VStack(12, [searchInput, results])
176180
// ANCHOR_END: pattern-search-row
177181

178182
// ANCHOR: pattern-floating-badge
179-
const icon = ImageSymbol("bell")
183+
// Wrap the icon in a ZStack so the badge can float above it on every
184+
// platform (see `// ANCHOR: overlay` for the GTK4 vs macOS rationale).
185+
const icon = ZStack()
186+
widgetAddChild(icon, ImageSymbol("bell"))
180187
const dotBadge = Text("3")
181188
widgetAddOverlay(icon, dotBadge)
182189
widgetSetOverlayFrame(dotBadge, 20, -5, 16, 16)

0 commit comments

Comments
 (0)