Fixed non-cannonized rectangles being drawn

This commit is contained in:
Sasha Koshka 2023-08-24 17:15:34 -04:00
parent 77ccde9e9b
commit 8ed1352fd4
4 changed files with 15 additions and 14 deletions

View File

@ -77,6 +77,7 @@ type pen struct {
} }
func (this *pen) Rectangle (bounds image.Rectangle) { func (this *pen) Rectangle (bounds image.Rectangle) {
bounds = bounds.Canon()
if this.weight == 0 { if this.weight == 0 {
if this.fill.A > 0 { if this.fill.A > 0 {
this.fillRectangle(this.fill, bounds) this.fillRectangle(this.fill, bounds)

2
go.mod
View File

@ -3,7 +3,7 @@ module git.tebibyte.media/tomo/x
go 1.20 go 1.20
require ( 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/typeset v0.5.2
git.tebibyte.media/tomo/xgbkb v1.0.1 git.tebibyte.media/tomo/xgbkb v1.0.1
github.com/jezek/xgb v1.1.0 github.com/jezek/xgb v1.1.0

4
go.sum
View File

@ -1,6 +1,6 @@
git.tebibyte.media/sashakoshka/xgbkb v1.0.0/go.mod h1:pNcE6TRO93vHd6q42SdwLSTTj25L0Yzggz7yLe0JV6Q= 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.1 h1:V5ciRuixMYb79aAawgquFEfJ1icyEmMKBKFPWwi94NE=
git.tebibyte.media/tomo/tomo v0.26.0/go.mod h1:C9EzepS9wjkTJjnZaPBh22YvVPyA4hbBAJVU20Rdmps= 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 h1:qHxN62/VDnrAouOuzxLmLleQNwAebshrfVYvtoOnAG4=
git.tebibyte.media/tomo/typeset v0.5.2/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g= git.tebibyte.media/tomo/typeset v0.5.2/go.mod h1:PwDpSdBF3l/EzoIsa2ME7QffVVajnTHZN6l3MHEGe1g=
git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE= git.tebibyte.media/tomo/xgbkb v1.0.1 h1:b3HDUopjdQp1MZrb5Vpil4bOtk3NnNXtfQW27Blw2kE=

View File

@ -13,7 +13,7 @@ import "git.tebibyte.media/tomo/tomo/canvas"
type textBox struct { type textBox struct {
*box *box
hOverflow, vOverflow bool hOverflow, vOverflow bool
contentBounds image.Rectangle contentBounds image.Rectangle
scroll image.Point scroll image.Point
@ -29,9 +29,9 @@ type textBox struct {
selectStart int selectStart int
dot text.Dot dot text.Dot
dotColor color.Color dotColor color.Color
drawer typeset.Drawer drawer typeset.Drawer
on struct { on struct {
contentBoundsChange event.FuncBroadcaster contentBoundsChange event.FuncBroadcaster
dotChange 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.AlignEnd: this.drawer.SetAlign(typeset.AlignRight)
case tomo.AlignEven: this.drawer.SetAlign(typeset.AlignJustify) case tomo.AlignEven: this.drawer.SetAlign(typeset.AlignJustify)
} }
this.invalidateDraw() this.invalidateDraw()
} }
@ -170,7 +170,6 @@ func (this *textBox) drawDot (can canvas.Canvas) {
pen := can.Pen() pen := can.Pen()
pen.Fill(color.Transparent) pen.Fill(color.Transparent)
pen.Stroke(this.textColor) pen.Stroke(this.textColor)
pen.StrokeWeight(1)
bounds := this.InnerBounds() bounds := this.InnerBounds()
metrics := this.face.Metrics() metrics := this.face.Metrics()
@ -180,11 +179,12 @@ func (this *textBox) drawDot (can canvas.Canvas) {
height := this.drawer.LineHeight().Round() height := this.drawer.LineHeight().Round()
ascent := fixed.Point26_6 { Y: metrics.Descent } ascent := fixed.Point26_6 { Y: metrics.Descent }
descent := fixed.Point26_6 { Y: metrics.Ascent } descent := fixed.Point26_6 { Y: metrics.Ascent }
switch { switch {
case dot.Empty(): case dot.Empty():
pen.StrokeWeight(1)
pen.Path(roundPt(start.Add(ascent)), roundPt(start.Sub(descent))) pen.Path(roundPt(start.Add(ascent)), roundPt(start.Sub(descent)))
case start.Y == end.Y: case start.Y == end.Y:
pen.Fill(this.dotColor) pen.Fill(this.dotColor)
pen.StrokeWeight(0) pen.StrokeWeight(0)
@ -192,11 +192,11 @@ func (this *textBox) drawDot (can canvas.Canvas) {
Min: roundPt(start.Add(ascent)), Min: roundPt(start.Add(ascent)),
Max: roundPt(end.Sub(descent)), Max: roundPt(end.Sub(descent)),
}) })
default: default:
pen.Fill(this.dotColor) pen.Fill(this.dotColor)
pen.StrokeWeight(0) pen.StrokeWeight(0)
rect := image.Rectangle { rect := image.Rectangle {
Min: roundPt(start.Add(ascent)), Min: roundPt(start.Add(ascent)),
Max: roundPt(start.Sub(descent)), Max: roundPt(start.Sub(descent)),
@ -292,9 +292,9 @@ func (this *textBox) doLayout () {
innerBounds := this.InnerBounds() innerBounds := this.InnerBounds()
this.drawer.SetMaxWidth(innerBounds.Dx()) this.drawer.SetMaxWidth(innerBounds.Dx())
this.drawer.SetMaxHeight(innerBounds.Dy()) this.drawer.SetMaxHeight(innerBounds.Dy())
this.contentBounds = this.normalizedLayoutBoundsSpace().Sub(this.scroll) this.contentBounds = this.normalizedLayoutBoundsSpace().Sub(this.scroll)
if previousContentBounds != this.contentBounds { if previousContentBounds != this.contentBounds {
this.on.contentBoundsChange.Broadcast() this.on.contentBoundsChange.Broadcast()
} }