Use FillRectangleClip in List and Container

This commit is contained in:
Sasha Koshka 2023-02-14 16:53:28 -05:00
parent fa42cf1f5f
commit 09f782953e
4 changed files with 43 additions and 28 deletions

View File

@ -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

View File

@ -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

View File

@ -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)
}
}

View File

@ -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