itd/cmd/itgui/titledText.go

36 lines
689 B
Go
Raw Permalink Normal View History

2022-05-05 21:00:49 +00:00
package main
import "fyne.io/fyne/v2/widget"
type titledText struct {
*widget.RichText
}
func newTitledText(title, text string) titledText {
titleStyle := widget.RichTextStyleHeading
titleStyle.TextStyle.Bold = false
return titledText{
widget.NewRichText(
&widget.TextSegment{
Style: widget.RichTextStyleParagraph,
Text: title,
},
&widget.TextSegment{
Style: titleStyle,
Text: text,
},
&widget.SeparatorSegment{},
),
}
}
func (t titledText) SetTitle(s string) {
t.RichText.Segments[0].(*widget.TextSegment).Text = s
t.Refresh()
}
func (t titledText) SetBody(s string) {
t.RichText.Segments[1].(*widget.TextSegment).Text = s
t.Refresh()
}