Merge style.go and unit.go
This commit is contained in:
parent
a01e5f8716
commit
b264e11ea6
47
style.go
47
style.go
@ -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)
|
|
||||||
}
|
|
45
unit.go
45
unit.go
@ -1,5 +1,6 @@
|
|||||||
package tomo
|
package tomo
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
import "image"
|
import "image"
|
||||||
import "image/color"
|
import "image/color"
|
||||||
|
|
||||||
@ -123,3 +124,47 @@ type Face struct {
|
|||||||
// altering their design.
|
// altering their design.
|
||||||
Slant float64
|
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)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user