forked from joejulian/gio
ui/text: add LayoutOptions
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
+1
-1
@@ -302,7 +302,7 @@ func (e *Editor) moveCoord(pos image.Point) {
|
||||
}
|
||||
|
||||
func (e *Editor) layoutText() {
|
||||
textLayout := e.Face.Layout(e.rr.String(), e.SingleLine, e.maxWidth)
|
||||
textLayout := e.Face.Layout(e.rr.String(), LayoutOptions{SingleLine: e.SingleLine, MaxWidth: e.maxWidth})
|
||||
lines := textLayout.Lines
|
||||
dims := linesDimens(lines)
|
||||
for i := 0; i < len(lines)-1; i++ {
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ func (l *lineIterator) Next() (String, f32.Point, bool) {
|
||||
}
|
||||
|
||||
func (l Label) Layout(ops *ui.Ops, cs layout.Constraints) layout.Dimens {
|
||||
textLayout := l.Face.Layout(l.Text, false, cs.Width.Max)
|
||||
textLayout := l.Face.Layout(l.Text, LayoutOptions{MaxWidth: cs.Width.Max})
|
||||
lines := textLayout.Lines
|
||||
if max := l.MaxLines; max > 0 && len(lines) > max {
|
||||
lines = lines[:max]
|
||||
|
||||
+6
-1
@@ -33,8 +33,13 @@ type Layout struct {
|
||||
Lines []Line
|
||||
}
|
||||
|
||||
type LayoutOptions struct {
|
||||
MaxWidth int
|
||||
SingleLine bool
|
||||
}
|
||||
|
||||
type Face interface {
|
||||
Layout(str string, singleLine bool, maxWidth int) *Layout
|
||||
Layout(str string, opts LayoutOptions) *Layout
|
||||
Path(str String) ui.BlockOp
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user