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

View File

@ -99,3 +99,22 @@ type ScrollableEntity interface {
// as a result of a call to ScrollTo()), or their content size. // as a result of a call to ScrollTo()), or their content size.
NotifyScrollBoundsChange () 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
}