Added rendering optimization hints to themes

This commit is contained in:
Sasha Koshka
2023-02-16 18:00:15 -05:00
parent b9cbf83a18
commit fc0a9292d9
2 changed files with 49 additions and 0 deletions

View File

@@ -209,6 +209,36 @@ func (Default) Inset (pattern Pattern, c Case) Inset {
}
}
// Hints returns rendering optimization hints for a particular pattern.
// These are optional, but following them may result in improved
// performance.
func (Default) Hints (pattern Pattern, c Case) (hints Hints) {
switch pattern {
case PatternRaised:
if c == C("basic", "listEntry") {
hints.StaticInset = Inset { 0, 1, 0, 1 }
} else {
hints.StaticInset = Inset { 3, 3, 3, 3 }
}
case PatternSunken:
if c == C("basic", "list") {
hints.StaticInset = Inset { 2, 1, 2, 1 }
} else {
hints.StaticInset = Inset { 3, 3, 3, 3 }
}
case
PatternPinboard,
PatternInput,
PatternButton,
PatternHandle:
hints.StaticInset = Inset { 3, 3, 3, 3 }
}
return
}
// Sink returns the default sink vector for the given pattern.
func (Default) Sink (pattern Pattern, c Case) image.Point {
return image.Point { 1, 1 }