This commit is contained in:
Sasha Koshka 2024-06-07 18:57:16 -04:00
parent d587e39506
commit ca4d3e62c4
4 changed files with 17 additions and 8 deletions

View File

@ -33,6 +33,17 @@ type Backend interface {
// must reject any canvas that was not made by it.
NewCanvas (image.Rectangle) canvas.CanvasCloser
// SetStyle sets the style that will be used on objects. The backend is
// in charge of applying the style to objects. When this method is
// called, it must propagate a StyleChange event to all boxes it is
// keeping track of.
SetStyle (Style)
// SetIcons sets the icon set that icons will be pulled from. When this
// method is called, it must propagate an IconChange event to all boxes
// it is keeping track of.
SetIcons (Icons)
// Run runs the event loop until Stop() is called, or the backend
// experiences a fatal error.
Run () error

View File

@ -419,5 +419,7 @@ var icons Icons
// SetIcons sets the icon set.
func SetIcons (icns Icons) {
assertBackend()
icons = icns
backend.SetIcons(icns)
}

View File

@ -124,6 +124,8 @@ type Box interface {
OnScroll (func (deltaX, deltaY float64)) event.Cookie
OnKeyDown (func (key input.Key, numberPad bool)) event.Cookie
OnKeyUp (func (key input.Key, numberPad bool)) event.Cookie
OnStyleChange (func ()) event.Cookie
OnIconsChange (func ()) event.Cookie
}
// CanvasBox is a box that can be drawn to.

View File

@ -77,13 +77,7 @@ var style Style
// SetStyle sets the style.
func SetStyle (sty Style) {
assertBackend()
style = sty
}
// Apply applies the current style to the given object, according its role. This
// may register event listeners with the given object; closing the returned
// cookie will remove them.
func Apply (object Object) event.Cookie {
if style == nil { return event.NoCookie { } }
return style.Apply(object)
backend.SetStyle(sty)
}