Stop some redundant rendering in the piano

This commit is contained in:
Sasha Koshka 2023-02-14 17:05:13 -05:00
parent 09f782953e
commit d59b7d812d
2 changed files with 14 additions and 4 deletions

View File

@ -460,7 +460,6 @@ func (element *List) draw () {
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)

View File

@ -5,6 +5,7 @@ import "git.tebibyte.media/sashakoshka/tomo/input"
import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/config"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/shatter"
import "git.tebibyte.media/sashakoshka/tomo/elements/core"
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
@ -28,6 +29,7 @@ type Piano struct {
flatKeys []pianoKey
sharpKeys []pianoKey
contentBounds image.Rectangle
pressed *pianoKey
keynavPressed map[music.Note] bool
@ -271,6 +273,11 @@ func (element *Piano) recalculate () {
}
note ++
}
element.contentBounds = image.Rectangle {
bounds.Min,
image.Pt(dot.X, bounds.Max.Y),
}
}
func (element *Piano) draw () {
@ -278,9 +285,6 @@ func (element *Piano) draw () {
Focused: element.Focused(),
Disabled: !element.Enabled(),
}
pattern := element.theme.Pattern(theme.PatternPinboard, state)
// inset := element.theme.Inset(theme.PatternSunken)
artist.FillRectangle(element.core, pattern, element.Bounds())
for _, key := range element.flatKeys {
_, keynavPressed := element.keynavPressed[key.Note]
@ -298,6 +302,13 @@ func (element *Piano) draw () {
(*element.pressed).Note == key.Note || keynavPressed,
state)
}
pattern := element.theme.Pattern(theme.PatternPinboard, state)
tiles := shatter.Shatter(element.Bounds(), element.contentBounds)
for _, tile := range tiles {
artist.FillRectangleClip (
element.core, pattern, element.Bounds(), tile)
}
}
func (element *Piano) drawFlat (