diff --git a/README.md b/README.md index 3aa34e3..9a4ab8e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # etk - Ebitengine Tool Kit -[![GoDoc](https://code.rocket9labs.com/tslocum/godoc-static/raw/branch/master/badge.svg)](https://docs.rocket9labs.com/code.rocket9labs.com/tslocum/etk) +[![GoDoc](https://code.rocket9labs.com/tslocum/godoc-static/raw/branch/main/badge.svg)](https://docs.rocket9labs.com/code.rocket9labs.com/tslocum/etk) [![Donate via LiberaPay](https://img.shields.io/liberapay/receives/rocket9labs.com.svg?logo=liberapay)](https://liberapay.com/rocket9labs.com) [Ebitengine](https://github.com/hajimehoshi/ebiten) tool kit for creating graphical user interfaces diff --git a/messeji/textfield.go b/messeji/textfield.go index 4dc20f4..0dbdaa5 100644 --- a/messeji/textfield.go +++ b/messeji/textfield.go @@ -951,6 +951,7 @@ func (f *TextField) drawContent() (overflow bool) { lastVisible = len(f.bufferWrapped) - 1 } } + numVisible := lastVisible - firstVisible // Calculate buffer size (width for single-line fields or height for multi-line fields). if f.singleLine { w, _ := text.Measure(f.bufferWrapped[firstVisible], f.face, float64(f.lineHeight)) @@ -1003,9 +1004,9 @@ func (f *TextField) drawContent() (overflow bool) { // Align vertically. totalHeight := f.lineOffset + lineHeight*(lines) if f.vertical == AlignCenter && totalHeight <= h { - lineY = fieldHeight/2 - totalHeight/2 + f.lineOffset + (lineHeight * (i)) + lineY = fieldHeight/2 - totalHeight/2 + f.lineOffset + (lineHeight * (i)) - 2 } else if f.vertical == AlignEnd && totalHeight <= h { - lineY = (fieldHeight - lineHeight*i) - f.padding + lineY = fieldHeight - lineHeight*(numVisible+1-i) - f.padding } // Draw line.