Entities now give elements config and theme parameters

This commit is contained in:
Sasha Koshka 2023-04-29 14:33:56 -04:00
parent 4c9743387b
commit cd8371a3f3
2 changed files with 24 additions and 6 deletions

View File

@ -225,9 +225,8 @@ type Collapsible interface {
type Themeable interface {
tomo.Element
// SetTheme sets the element's theme to something fulfilling the
// theme.Theme interface.
SetTheme (tomo.Theme)
// HandleThemeChange is called whenever the theme is changed.
HandleThemeChange ()
}
// Configurable represents an element that can modify its behavior to fit within
@ -235,7 +234,7 @@ type Themeable interface {
type Configurable interface {
tomo.Element
// SetConfig sets the element's configuration to something fulfilling
// the config.Config interface.
SetConfig (tomo.Config)
// HandleConfigChange is called whenever configuration parameters are
// changed.
HandleConfigChange ()
}

View File

@ -99,3 +99,22 @@ type ScrollableEntity interface {
// as a result of a call to ScrollTo()), or their content size.
NotifyScrollBoundsChange ()
}
// ThemeableEntity is given to elements that support the Themeable interface.
type ThemeableEntity interface {
tomo.Entity
// Theme returns the currently active theme. When this value changes,
// the HandleThemeChange method of the element is called.
Theme () tomo.Theme
}
// ConfigurableEntity is given to elements that support the Configurable
// interface.
type ConfigurableEntity interface {
tomo.Entity
// Config returns the currently active config. When this value changes,
// the HandleThemeChange method of the element is called.
Config () tomo.Config
}