Added the BackgroundParent interface

Parents are now able to draw backgrounds for their children. This
means we can now have elements inside other elements that aren't
restricted to one background color.
This commit is contained in:
2023-04-02 22:02:55 -04:00
parent 7521808872
commit 6ede0d0770
9 changed files with 71 additions and 14 deletions
+8
View File
@@ -216,6 +216,14 @@ func (element *Container) NotifyMinimumSizeChange (child tomo.Element) {
element.core.DamageAll()
}
// DrawBackground draws a portion of the container's background pattern within
// the specified bounds. The container will not push these changes.
func (element *Container) DrawBackground (bounds image.Rectangle) {
element.core.DrawBackgroundBounds (
element.theme.Pattern(tomo.PatternBackground, tomo.State { }),
bounds)
}
// SetTheme sets the element's theme.
func (element *Container) SetTheme (new tomo.Theme) {
if new == element.theme.Theme { return }
+8
View File
@@ -213,6 +213,14 @@ func (element *DocumentContainer) NotifyMinimumSizeChange (child tomo.Element) {
element.core.DamageAll()
}
// DrawBackground draws a portion of the container's background pattern within
// the specified bounds. The container will not push these changes.
func (element *DocumentContainer) DrawBackground (bounds image.Rectangle) {
element.core.DrawBackgroundBounds (
element.theme.Pattern(tomo.PatternBackground, tomo.State { }),
bounds)
}
// NotifyFlexibleHeightChange notifies the parent that the parameters
// affecting a child's flexible height have changed. This method is
// expected to be called by flexible child element when their content
+8
View File
@@ -135,6 +135,14 @@ func (element *ScrollContainer) NotifyScrollBoundsChange (child tomo.Scrollable)
}
}
// DrawBackground draws a portion of the container's background pattern within
// the specified bounds. The container will not push these changes.
func (element *ScrollContainer) DrawBackground (bounds image.Rectangle) {
element.core.DrawBackgroundBounds (
element.theme.Pattern(tomo.PatternBackground, tomo.State { }),
bounds)
}
// SetTheme sets the element's theme.
func (element *ScrollContainer) SetTheme (new tomo.Theme) {
if new == element.theme.Theme { return }