widget: create standalone textView

This commit adds a standalone state type for manipulating
and displaying text. It reads text from a minimal interface,
shapes it, tracks valid cursor positions, and provides sizing
and scrolling services to higher-level widgets. My long term
goal with these types is to export them to allow non-core widgets
to build atop them, but I've left them private for now.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
Chris Waldon
2022-12-22 15:00:56 -05:00
committed by Elias Naur
parent 5d6cc2892d
commit f99aff96ee
3 changed files with 755 additions and 13 deletions
+2 -2
View File
@@ -68,7 +68,7 @@ type Editor struct {
maxWidth, minWidth int
viewSize image.Point
valid bool
regions []region
regions []Region
dims layout.Dimensions
requestFocus bool
@@ -750,7 +750,7 @@ func (e *Editor) PaintSelection(gtx layout.Context) {
defer clip.Rect(localViewport).Push(gtx.Ops).Pop()
e.regions = e.index.locate(docViewport, e.caret.start, e.caret.end, e.regions)
for _, region := range e.regions {
area := clip.Rect(region.bounds.Sub(e.scrollOff)).Push(gtx.Ops)
area := clip.Rect(region.Bounds).Push(gtx.Ops)
paint.PaintOp{}.Add(gtx.Ops)
area.Pop()
}