diff --git a/style.go b/style.go deleted file mode 100644 index 0539f7b..0000000 --- a/style.go +++ /dev/null @@ -1,47 +0,0 @@ -package tomo - -import "fmt" - -// 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 - // This should correspond directly to the type name of the object. - Object string -} - -// String satisfies the fmt.Stringer interface. It follows the format of: -// Package.Object -func (r Role) String () string { - return fmt.Sprintf("%s.%s", r.Package, r.Object) -} - -// R is shorthand for creating a role structure. -func R (pack, object string) Role { - return Role { Package: pack, Object: object } -} - -// Color represents a color ID. -type Color int; const ( - ColorBackground Color = iota - ColorForeground - ColorRaised - ColorSunken - ColorAccent -) - -// RGBA satisfies the color.Color interface. The result of this method may be -// rendered invalid if the visual style changes, so it is often necessary to -// subscribe to the StyleChange event in order to get new RGBA values when this -// happens. -func (id Color) RGBA () (r, g, b, a uint32) { - assertBackend() - return backend.ColorRGBA(id) -} diff --git a/unit.go b/unit.go index cd14bea..abb6e9c 100644 --- a/unit.go +++ b/unit.go @@ -1,5 +1,6 @@ package tomo +import "fmt" import "image" import "image/color" @@ -123,3 +124,47 @@ type Face struct { // altering their design. Slant float64 } + +// 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 + // This should correspond directly to the type name of the object. + Object string +} + +// String satisfies the fmt.Stringer interface. It follows the format of: +// Package.Object +func (r Role) String () string { + return fmt.Sprintf("%s.%s", r.Package, r.Object) +} + +// R is shorthand for creating a role structure. +func R (pack, object string) Role { + return Role { Package: pack, Object: object } +} + +// Color represents a color ID. +type Color int; const ( + ColorBackground Color = iota + ColorForeground + ColorRaised + ColorSunken + ColorAccent +) + +// RGBA satisfies the color.Color interface. The result of this method may be +// rendered invalid if the visual style changes, so it is often necessary to +// subscribe to the StyleChange event in order to get new RGBA values when this +// happens. +func (id Color) RGBA () (r, g, b, a uint32) { + assertBackend() + return backend.ColorRGBA(id) +}