6 Commits

3 changed files with 16 additions and 9 deletions

View File

@@ -203,7 +203,10 @@ func (this *box) SetPadding (padding tomo.Inset) {
}
func (this *box) SetRole (role tomo.Role) {
if this.role == role { return }
this.role = role
this.lastStyleNonce = -1
this.outer.recursiveReApply()
}
func (this *box) SetDNDData (dat data.Data) {

View File

@@ -29,7 +29,10 @@ func (this *canvasBox) Invalidate () {
}
func (this *canvasBox) Draw (can canvas.Canvas) {
if can == nil { return }
this.box.Draw(can)
this.userDrawer.Draw (
can.SubCanvas(this.padding.Apply(this.innerClippingBounds)))
if this.userDrawer != nil {
this.userDrawer.Draw (
can.SubCanvas(this.padding.Apply(this.innerClippingBounds)))
}
}

View File

@@ -1,6 +1,7 @@
package xcanvas
import "sort"
import "math"
import "image"
import "github.com/jezek/xgbutil/xgraphics"
@@ -158,12 +159,12 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
area = this.image.Bounds().Intersect(area)
if area.Empty() { return }
boundaries := make([]int, len(points))
context := fillingContext {
image: this.image,
color: this.fill,
min: area.Min.X,
max: area.Max.X,
boundaries: make([]int, len(points)),
points: points,
}
@@ -181,19 +182,19 @@ func (this *pen) fillPolygon (c xgraphics.BGRA, points ...image.Point) {
(fPointY < fy && fPrevY >= fy) ||
(fPrevY < fy && fPointY >= fy)
if addboundary {
context.boundaries[boundaryCount] = int (
boundaries[boundaryCount] = int(math.Round (
fPointX +
(fy - fPointY) /
(fPrevY - fPointY) *
(fPrevX - fPointX))
(fPrevX - fPointX)))
boundaryCount ++
}
prevPoint = point
}
// sort boundary list
cutBoundaries := context.boundaries[:boundaryCount]
sort.Ints(cutBoundaries)
context.boundaries = boundaries[:boundaryCount]
sort.Ints(context.boundaries)
// fill pixels between boundary pairs
if c.A == 255 {
@@ -215,7 +216,7 @@ type fillingContext struct {
}
func (context *fillingContext) fillPolygonHotOpaque () {
for index := 0; index < len(context.boundaries); index += 2 {
for index := 0; index < len(context.boundaries) - 1; index += 2 {
left := context.boundaries[index]
right := context.boundaries[index + 1]
@@ -240,7 +241,7 @@ func (context *fillingContext) fillPolygonHotOpaque () {
}
func (context *fillingContext) fillPolygonHotTransparent () {
for index := 0; index < len(context.boundaries); index += 2 {
for index := 0; index < len(context.boundaries) - 1; index += 2 {
left := context.boundaries[index]
right := context.boundaries[index + 1]