From 6efe40efc20e756956144a7a6524dfc6ef898138 Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Thu, 19 Sep 2024 21:10:02 -0400 Subject: [PATCH] Sort methods of TypeSetter alphabetically --- typesetter.go | 62 +++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/typesetter.go b/typesetter.go index 86fa0eb..fff5be4 100644 --- a/typesetter.go +++ b/typesetter.go @@ -132,12 +132,9 @@ func (this *TypeSetter) Em () fixed.Int26_6 { return width } -// MinimumSize returns the minimum width and height needed to display text. If -// wrapping is enabled, this method will return { X: Em(), Y: 0 }. -func (this *TypeSetter) MinimumSize () fixed.Point26_6 { - if this.wrap { return fixed.Point26_6{ X: this.Em(), Y: 0 } } - this.needFlow() - return this.minimumSize +// Face returns the font face as set by SetFace. +func (this *TypeSetter) Face () font.Face { + return this.face } // LayoutBounds returns the semantic bounding box of the text. The origin point @@ -155,6 +152,14 @@ func (this *TypeSetter) LayoutBoundsSpace () fixed.Rectangle26_6 { return this.layoutBoundsSpace } +// MinimumSize returns the minimum width and height needed to display text. If +// wrapping is enabled, this method will return { X: Em(), Y: 0 }. +func (this *TypeSetter) MinimumSize () fixed.Point26_6 { + if this.wrap { return fixed.Point26_6{ X: this.Em(), Y: 0 } } + this.needFlow() + return this.minimumSize +} + // PositionAt returns the position of the rune at the specified index. func (this *TypeSetter) PositionAt (index int) fixed.Point26_6 { idx := 0 @@ -170,11 +175,19 @@ func (this *TypeSetter) PositionAt (index int) fixed.Point26_6 { return position } -// SetText sets the text of the TypeSetter. -func (this *TypeSetter) SetText (text string) { - if this.text == text { return } - this.text = text - this.invalidate(validationLevelTokens) +// SetAlign sets the horizontal and vertical alignment of the text. +func (this *TypeSetter) SetAlign (x, y Align) { + if this.xAlign == x && this.yAlign == y { return } + this.xAlign = x + this.yAlign = y + this.invalidate(validationLevelFlow) +} + +// SetFace sets the font face the text will be laid out according to. +func (this *TypeSetter) SetFace (face font.Face) { + if this.face == face { return } + this.face = face + this.invalidate(validationLevelMeasurement) } // SetSize sets the width and height of the TypeSetter. @@ -184,6 +197,13 @@ func (this *TypeSetter) SetSize (size fixed.Point26_6) { this.invalidate(validationLevelFlow) } +// SetText sets the text of the TypeSetter. +func (this *TypeSetter) SetText (text string) { + if this.text == text { return } + this.text = text + this.invalidate(validationLevelTokens) +} + // SetWrap sets whether the text will wrap to the width specified by SetSize. func (this *TypeSetter) SetWrap (wrap bool) { if this.wrap == wrap { return } @@ -191,26 +211,6 @@ func (this *TypeSetter) SetWrap (wrap bool) { this.invalidate(validationLevelFlow) } -// SetAlign sets the horizontal and vertical alignment of the text. -func (this *TypeSetter) SetAlign (x, y Align) { - if this.xAlign == x && this.yAlign == y { return } - this.xAlign = x - this.yAlign = y - this.invalidate(validationLevelFlow) -} - -// Face returns the font face as set by SetFace. -func (this *TypeSetter) Face () font.Face { - return this.face -} - -// SetFace sets the font face the text will be laid out according to. -func (this *TypeSetter) SetFace (face font.Face) { - if this.face == face { return } - this.face = face - this.invalidate(validationLevelMeasurement) -} - func (this *TypeSetter) needTokens () { if this.valid(validationLevelTokens) { return } this.runes, this.tokens = parseString(this.text)