~whereswaldon/gio-x

360dbefab2cf2c3146dd8fd0c612d0e8fd748c74 — Chris Waldon 8 months ago 64f221a
richtext: surface wrap policy in richtext API

This commit allows configuring the wrapping policy of a richtext.Text using the
policies defined within styledtext.WrapPolicy.

Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 5 insertions(+), 3 deletions(-)

M richtext/richtext.go
M richtext/richtext.go => richtext/richtext.go +5 -3
@@ 182,9 182,10 @@ func (ss SpanStyle) DeepCopy() SpanStyle {

// TextStyle presents rich text.
type TextStyle struct {
	State     *InteractiveText
	Styles    []SpanStyle
	Alignment text.Alignment
	State      *InteractiveText
	Styles     []SpanStyle
	Alignment  text.Alignment
	WrapPolicy styledtext.WrapPolicy
	*text.Shaper
}



@@ 218,6 219,7 @@ func (t TextStyle) Layout(gtx layout.Context) layout.Dimensions {
	t.State.resize(numInteractive)

	text := styledtext.Text(t.Shaper, styles...)
	text.WrapPolicy = t.WrapPolicy
	text.Alignment = t.Alignment
	return text.Layout(gtx, func(gtx layout.Context, i int, _ layout.Dimensions) {
		span := &t.Styles[i]