mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-01 07:35:40 +00:00
widget{,/material}: surface line height manipulation
This commit surfaces fields to manipulate the line height of all label and editor types. It's unfortunate how this spreads through the API, but I don't see a good way to eliminate that right now. Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
This commit is contained in:
@@ -44,6 +44,12 @@ type textSource interface {
|
||||
// be scrolled, and for configuring and drawing text selection boxes.
|
||||
type textView struct {
|
||||
Alignment text.Alignment
|
||||
// LineHeight controls the distance between the baselines of lines of text.
|
||||
// If zero, a sensible default will be used.
|
||||
LineHeight unit.Sp
|
||||
// LineHeightScale applies a scaling factor to the LineHeight. If zero, a
|
||||
// sensible default will be used.
|
||||
LineHeightScale float32
|
||||
// SingleLine forces the text to stay on a single line.
|
||||
// SingleLine also sets the scrolling direction to
|
||||
// horizontal.
|
||||
@@ -273,6 +279,14 @@ func (e *textView) Update(gtx layout.Context, lt *text.Shaper, font font.Font, s
|
||||
e.params.WrapPolicy = e.WrapPolicy
|
||||
e.invalidate()
|
||||
}
|
||||
if lh := fixed.I(gtx.Sp(e.LineHeight)); lh != e.params.LineHeight {
|
||||
e.params.LineHeight = lh
|
||||
e.invalidate()
|
||||
}
|
||||
if e.LineHeightScale != e.params.LineHeightScale {
|
||||
e.params.LineHeightScale = e.LineHeightScale
|
||||
e.invalidate()
|
||||
}
|
||||
|
||||
e.makeValid()
|
||||
if eventHandling != nil {
|
||||
|
||||
Reference in New Issue
Block a user