Remedy #10
This commit is contained in:
parent
d587e39506
commit
ca4d3e62c4
11
backend.go
11
backend.go
@ -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
|
||||
|
2
icon.go
2
icon.go
@ -419,5 +419,7 @@ var icons Icons
|
||||
|
||||
// SetIcons sets the icon set.
|
||||
func SetIcons (icns Icons) {
|
||||
assertBackend()
|
||||
icons = icns
|
||||
backend.SetIcons(icns)
|
||||
}
|
||||
|
@ -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.
|
||||
|
10
theme.go
10
theme.go
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user