Added a case specifier to the theme API

This will allow themes to pull off some cool dirty tricks without
screwing anything up
This commit is contained in:
Sasha Koshka 2023-01-30 01:30:13 -05:00
parent 2c55824920
commit 174beba79f
12 changed files with 147 additions and 31 deletions

View File

@ -6,6 +6,8 @@ import "git.tebibyte.media/sashakoshka/tomo/theme"
import "git.tebibyte.media/sashakoshka/tomo/artist" import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/elements/core" import "git.tebibyte.media/sashakoshka/tomo/elements/core"
var buttonCase = theme.C("basic", "button")
// Button is a clickable button. // Button is a clickable button.
type Button struct { type Button struct {
*core.Core *core.Core
@ -114,7 +116,7 @@ func (element *Button) SetText (text string) {
element.text = text element.text = text
element.drawer.SetText([]rune(text)) element.drawer.SetText([]rune(text))
textBounds := element.drawer.LayoutBounds() textBounds := element.drawer.LayoutBounds()
_, inset := theme.ButtonPattern(theme.PatternState { }) _, inset := theme.ButtonPattern(theme.PatternState { Case: buttonCase })
minimumSize := inset.Inverse().Apply(textBounds).Inset(-theme.Padding()) minimumSize := inset.Inverse().Apply(textBounds).Inset(-theme.Padding())
element.core.SetMinimumSize(minimumSize.Dx(), minimumSize.Dy()) element.core.SetMinimumSize(minimumSize.Dx(), minimumSize.Dy())
if element.core.HasImage () { if element.core.HasImage () {