Add word-wrapped text display with two-finger scroll

- Renderer computes word wrap via single LayoutString pass with
  WrapHeuristically policy; glyphs drawn inline at FlagLineBreak
- Fixed line height (fontSize * 1.2), independent of glyph metrics
- Two-finger trackpad scroll via gesture.Scroll with vertical axis
- Display line feedback: renderer reports last glyph Y after each
  Draw; logic uses it to clamp scroll offset so last line stops
  at bottom of viewport with lineHeight/2 padding
- ScrollRange fix: {Min: -(1<<30), Max: 1<<30} ensures scroll
  delta is consumed (empty range consumes nothing via clampSplit)
- Line counting fix: only FlagLineBreak increments count; buffer
  flushes (32-glyph cap) draw but don't count
This commit is contained in:
gmp
2026-05-26 20:26:20 -04:00
parent ae04aabb70
commit 0246316d8f
6 changed files with 265 additions and 39 deletions
+2 -1
View File
@@ -58,7 +58,8 @@ func run(w *app.Window) error {
mu.Lock()
currentElems := elems
renderer.Draw(gtx, currentElems)
if events := renderer.CheckGestures(e.Source); len(events) > 0 {
logic.DisplayLineChan() <- int(renderer.LastLineY())
if events := renderer.CheckGestures(e.Source, gtx.Metric); len(events) > 0 {
logic.InputChan() <- events
}
e.Frame(&ops)