Fixed non-cannonized rectangles being drawn
This commit is contained in:
parent
77ccde9e9b
commit
8ed1352fd4
@ -77,6 +77,7 @@ type pen struct {
|
||||
}
|
||||
|
||||
func (this *pen) Rectangle (bounds image.Rectangle) {
|
||||
bounds = bounds.Canon()
|
||||
if this.weight == 0 {
|
||||
if this.fill.A > 0 {
|
||||
this.fillRectangle(this.fill, bounds)
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/x
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
git.tebibyte.media/tomo/tomo v0.26.0
|
||||
git.tebibyte.media/tomo/tomo v0.26.1
|
||||
git.tebibyte.media/tomo/typeset v0.5.2
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1
|
||||
github.com/jezek/xgb v1.1.0
|
||||
|
4
go.sum
4
go.sum
@ -1,6 +1,6 @@
|
||||
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q=
|
||||
git.tebibyte.media/tomo/tomo v0.26.0 h1:JjOb3ZEsGfpkNBe2nVAfZYw/VrDDPqODH/ANZiG4czU=
|
||||
git.tebibyte.media/tomo/tomo v0.26.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||
git.tebibyte.media/tomo/tomo v0.26.1 h1:V5ciRuixMYb79aAawgquFEfJ1icyEmMKBKFPWwi94NE=
|
||||
git.tebibyte.media/tomo/tomo v0.26.1/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps=
|
||||
git.tebibyte.media/tomo/typeset v0.5.2 h1:qHxN62/VDnrAouOuzxLmLleQNwAebshrfVYvtoOnAG4=
|
||||
git.tebibyte.media/tomo/typeset v0.5.2/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
|
||||
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=
|
||||
|
22
textbox.go
22
textbox.go
@ -13,7 +13,7 @@ import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
|
||||
type textBox struct {
|
||||
*box
|
||||
|
||||
|
||||
hOverflow, vOverflow bool
|
||||
contentBounds image.Rectangle
|
||||
scroll image.Point
|
||||
@ -29,9 +29,9 @@ type textBox struct {
|
||||
selectStart int
|
||||
dot text.Dot
|
||||
dotColor color.Color
|
||||
|
||||
|
||||
drawer typeset.Drawer
|
||||
|
||||
|
||||
on struct {
|
||||
contentBoundsChange event.FuncBroadcaster
|
||||
dotChange event.FuncBroadcaster
|
||||
@ -137,7 +137,7 @@ func (this *textBox) SetAlign (x, y tomo.Align) {
|
||||
case tomo.AlignEnd: this.drawer.SetAlign(typeset.AlignRight)
|
||||
case tomo.AlignEven: this.drawer.SetAlign(typeset.AlignJustify)
|
||||
}
|
||||
|
||||
|
||||
this.invalidateDraw()
|
||||
}
|
||||
|
||||
@ -170,7 +170,6 @@ func (this *textBox) drawDot (can canvas.Canvas) {
|
||||
pen := can.Pen()
|
||||
pen.Fill(color.Transparent)
|
||||
pen.Stroke(this.textColor)
|
||||
pen.StrokeWeight(1)
|
||||
|
||||
bounds := this.InnerBounds()
|
||||
metrics := this.face.Metrics()
|
||||
@ -180,11 +179,12 @@ func (this *textBox) drawDot (can canvas.Canvas) {
|
||||
height := this.drawer.LineHeight().Round()
|
||||
ascent := fixed.Point26_6 { Y: metrics.Descent }
|
||||
descent := fixed.Point26_6 { Y: metrics.Ascent }
|
||||
|
||||
|
||||
switch {
|
||||
case dot.Empty():
|
||||
pen.StrokeWeight(1)
|
||||
pen.Path(roundPt(start.Add(ascent)), roundPt(start.Sub(descent)))
|
||||
|
||||
|
||||
case start.Y == end.Y:
|
||||
pen.Fill(this.dotColor)
|
||||
pen.StrokeWeight(0)
|
||||
@ -192,11 +192,11 @@ func (this *textBox) drawDot (can canvas.Canvas) {
|
||||
Min: roundPt(start.Add(ascent)),
|
||||
Max: roundPt(end.Sub(descent)),
|
||||
})
|
||||
|
||||
|
||||
default:
|
||||
pen.Fill(this.dotColor)
|
||||
pen.StrokeWeight(0)
|
||||
|
||||
|
||||
rect := image.Rectangle {
|
||||
Min: roundPt(start.Add(ascent)),
|
||||
Max: roundPt(start.Sub(descent)),
|
||||
@ -292,9 +292,9 @@ func (this *textBox) doLayout () {
|
||||
innerBounds := this.InnerBounds()
|
||||
this.drawer.SetMaxWidth(innerBounds.Dx())
|
||||
this.drawer.SetMaxHeight(innerBounds.Dy())
|
||||
|
||||
|
||||
this.contentBounds = this.normalizedLayoutBoundsSpace().Sub(this.scroll)
|
||||
|
||||
|
||||
if previousContentBounds != this.contentBounds {
|
||||
this.on.contentBoundsChange.Broadcast()
|
||||
}
|
||||
|
Reference in New Issue
Block a user