Added a theme package
This commit is contained in:
parent
e14bd81c04
commit
522ff64fd3
|
@ -0,0 +1,40 @@
|
|||
package theme
|
||||
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/event"
|
||||
|
||||
// Role describes the role of an object.
|
||||
type Role struct {
|
||||
// Package is an optional namespace field. If specified, it should be
|
||||
// the package name or module name the object is from.
|
||||
Package string
|
||||
|
||||
// Object specifies what type of object it is. For example:
|
||||
// - textInput
|
||||
// - table
|
||||
// - label
|
||||
// - dial
|
||||
Object string
|
||||
}
|
||||
|
||||
// Theme is an object that can apply a visual style to different objects.
|
||||
type Theme interface {
|
||||
// Apply applies the theme to the given object, according to the given
|
||||
// role. This may register event listeners with the given object;
|
||||
// closing the returned cookie will remove them.
|
||||
Apply (tomo.Object, Role) event.Cookie
|
||||
}
|
||||
|
||||
var current Theme
|
||||
|
||||
// SetTheme sets the theme.
|
||||
func SetTheme (theme Theme) {
|
||||
current = theme
|
||||
}
|
||||
|
||||
// Apply applies the current theme to the given object, according to the given
|
||||
// role. This may register event listeners with the given object; closing the
|
||||
// returned cookie will remove them.
|
||||
func Apply (object tomo.Object, role Role) event.Cookie {
|
||||
return current.Apply(object, role)
|
||||
}
|
Loading…
Reference in New Issue