diff --git a/artist/rectangle.go b/artist/rectangle.go index 25d5f8c..a3fd714 100644 --- a/artist/rectangle.go +++ b/artist/rectangle.go @@ -56,8 +56,8 @@ func FillRectangleClip ( realBounds := bounds bounds = bounds.Canon(). - Intersect(destination.Bounds()). - Intersect(mask) + Intersect(mask.Canon()). + Intersect(destination.Bounds()) if bounds.Empty() { return } updatedRegion = bounds diff --git a/elements/basic/container.go b/elements/basic/container.go index b0b3268..5fb9906 100644 --- a/elements/basic/container.go +++ b/elements/basic/container.go @@ -230,7 +230,8 @@ func (element *Container) redoAll () { theme.PatternBackground, theme.PatternState { }) for _, tile := range tiles { - artist.FillRectangle(element.core, pattern, tile) + artist.FillRectangleClip ( + element.core, pattern, element.Bounds(), tile) } // cut our canvas up and give peices to child elements diff --git a/elements/basic/list.go b/elements/basic/list.go index 580dee1..d4cbe10 100644 --- a/elements/basic/list.go +++ b/elements/basic/list.go @@ -7,6 +7,7 @@ import "git.tebibyte.media/sashakoshka/tomo/theme" import "git.tebibyte.media/sashakoshka/tomo/config" import "git.tebibyte.media/sashakoshka/tomo/canvas" import "git.tebibyte.media/sashakoshka/tomo/artist" +import "git.tebibyte.media/sashakoshka/tomo/shatter" import "git.tebibyte.media/sashakoshka/tomo/elements/core" // List is an element that contains several objects that a user can select. @@ -432,28 +433,39 @@ func (element *List) updateMinimumSize () { } func (element *List) draw () { - bounds := element.Bounds() - - inset := element.theme.Inset(theme.PatternSunken) - pattern := element.theme.Pattern (theme.PatternSunken, theme.PatternState { + bounds := element.Bounds() + inset := element.theme.Inset(theme.PatternSunken) + innerBounds := inset.Apply(bounds) + state := theme.PatternState { Disabled: !element.Enabled(), Focused: element.Focused(), - }) - artist.FillRectangle(element.core, pattern, bounds) - - bounds = inset.Apply(bounds) - dot := image.Point { - bounds.Min.X, - bounds.Min.Y - element.scroll, } - innerCanvas := canvas.Cut(element.core, bounds) + + dot := image.Point { + innerBounds.Min.X, + innerBounds.Min.Y - element.scroll, + } + innerCanvas := canvas.Cut(element.core, innerBounds) for index, entry := range element.entries { entryPosition := dot dot.Y += entry.Bounds().Dy() - if dot.Y < bounds.Min.Y { continue } - if entryPosition.Y > bounds.Max.Y { break } + if dot.Y < innerBounds.Min.Y { continue } + if entryPosition.Y > innerBounds.Max.Y { break } entry.Draw ( innerCanvas, entryPosition, element.Focused(), element.selectedEntry == index) } + + covered := image.Rect ( + 0, 0, + innerBounds.Dx(), element.contentHeight, + ).Add(innerBounds.Min).Intersect(innerBounds) + println(covered.String()) + + pattern := element.theme.Pattern(theme.PatternSunken, state) + tiles := shatter.Shatter(bounds, covered) + for _, tile := range tiles { + artist.FillRectangleClip ( + element.core, pattern, bounds, tile) + } } diff --git a/elements/testing/artist.go b/elements/testing/artist.go index b7339fc..b6d69ab 100644 --- a/elements/testing/artist.go +++ b/elements/testing/artist.go @@ -129,18 +129,20 @@ func (element *Artist) draw () { image.Rect(80, 30, 90, 45).Add(shatterPos), } tiles := shatter.Shatter(element.cellAt(4, 3), rocks...) - for index, tile := range tiles { + for _, tile := range tiles { artist.FillRectangle ( - element.core, []artist.Pattern { - uhex(0xFF0000FF), - uhex(0x00FF00FF), - uhex(0x0000FFFF), - uhex(0xFF00FFFF), - uhex(0xFFF00FFF), - uhex(0xAAAAAAFF), - uhex(0x699669FF), - uhex(0x077777FF), - } [index % 8], tile) + element.core, + artist.Bordered { + Fill: uhex(0x888888FF), + Stroke: artist.Stroke { + Pattern: artist.Beveled { + uhex(0xCCCCCCFF), + uhex(0x444444FF), + }, + Weight: 1, + }, + }, + tile) } // 0, 4 - 3, 4