From dfdd721303ac30353493585fb51dcaeb4291fc6f Mon Sep 17 00:00:00 2001 From: Sasha Koshka Date: Sat, 29 Apr 2023 14:33:56 -0400 Subject: [PATCH] Entities now give elements config and theme parameters --- ability/element.go | 11 +++++------ ability/entity.go | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/ability/element.go b/ability/element.go index 416bde9..467de1b 100644 --- a/ability/element.go +++ b/ability/element.go @@ -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 () } diff --git a/ability/entity.go b/ability/entity.go index 4f351dd..3de8af3 100644 --- a/ability/entity.go +++ b/ability/entity.go @@ -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 +}