Theme improvements
This commit is contained in:
parent
82657bf251
commit
a5dfdda651
@ -6,29 +6,36 @@ import "golang.org/x/image/font"
|
|||||||
import "git.tebibyte.media/tomo/tomo"
|
import "git.tebibyte.media/tomo/tomo"
|
||||||
|
|
||||||
// Attr modifies one thing about an Objects's style.
|
// Attr modifies one thing about an Objects's style.
|
||||||
type Attr interface { attr () }
|
type Attr interface { attr () int }
|
||||||
|
|
||||||
// AttrColor sets the background color of an Objects.
|
// AttrColor sets the background color of an Objects.
|
||||||
type AttrColor struct { color.Color }
|
type AttrColor struct { color.Color }
|
||||||
func (AttrColor) attr () { }
|
|
||||||
// AttrTexture sets the texture of an Objects to a named texture.
|
// AttrTexture sets the texture of an Objects to a named texture.
|
||||||
type AttrTexture string
|
type AttrTexture string
|
||||||
func (AttrTexture) attr () { }
|
|
||||||
// AttrBorder sets the border of an Objects.
|
// AttrBorder sets the border of an Objects.
|
||||||
type AttrBorder []tomo.Border
|
type AttrBorder []tomo.Border
|
||||||
func (AttrBorder) attr () { }
|
|
||||||
// AttrMinimumSize sets the minimum size of an Objects.
|
// AttrMinimumSize sets the minimum size of an Objects.
|
||||||
type AttrMinimumSize image.Point
|
type AttrMinimumSize image.Point
|
||||||
func (AttrMinimumSize) attr () { }
|
|
||||||
// AttrPadding sets the inner padding of an Objects.
|
// AttrPadding sets the inner padding of an Objects.
|
||||||
type AttrPadding tomo.Inset
|
type AttrPadding tomo.Inset
|
||||||
func (AttrPadding) attr () { }
|
|
||||||
// AttrGap sets the gap between child Objects, if the Object is a ContainerBox.
|
// AttrGap sets the gap between child Objects, if the Object is a ContainerBox.
|
||||||
type AttrGap image.Point
|
type AttrGap image.Point
|
||||||
func (AttrGap) attr () { }
|
|
||||||
// AttrTextColor sets the text color, if the Object is a TextBox.
|
// AttrTextColor sets the text color, if the Object is a TextBox.
|
||||||
type AttrTextColor struct { color.Color }
|
type AttrTextColor struct { color.Color }
|
||||||
func (AttrTextColor) attr () { }
|
// AttrDotColor sets the text selection color, if the Object is a TextBox.
|
||||||
|
type AttrDotColor struct { color.Color }
|
||||||
// AttrFace sets the font face, if the Object is a TextBox.
|
// AttrFace sets the font face, if the Object is a TextBox.
|
||||||
type AttrFace struct { font.Face }
|
type AttrFace struct { font.Face }
|
||||||
func (AttrFace) attr () { }
|
// AttrAlign sets the alignment, if the Object is a ContentBox.
|
||||||
|
type AttrAlign struct { X, Y tomo.Align }
|
||||||
|
|
||||||
|
func (AttrColor) attr () int { return 0 }
|
||||||
|
func (AttrTexture) attr () int { return 1 }
|
||||||
|
func (AttrBorder) attr () int { return 2 }
|
||||||
|
func (AttrMinimumSize) attr () int { return 3 }
|
||||||
|
func (AttrPadding) attr () int { return 4 }
|
||||||
|
func (AttrGap) attr () int { return 5 }
|
||||||
|
func (AttrTextColor) attr () int { return 6 }
|
||||||
|
func (AttrDotColor) attr () int { return 7 }
|
||||||
|
func (AttrFace) attr () int { return 8 }
|
||||||
|
func (AttrAlign) attr () int { return 9 }
|
||||||
|
|||||||
@ -10,19 +10,17 @@ import "git.tebibyte.media/tomo/tomo/input"
|
|||||||
import "git.tebibyte.media/tomo/tomo/theme"
|
import "git.tebibyte.media/tomo/tomo/theme"
|
||||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||||
|
|
||||||
|
// this is CSS's bastard child
|
||||||
|
|
||||||
// Theme allows the use of data to define a visual style.
|
// Theme allows the use of data to define a visual style.
|
||||||
type Theme struct {
|
type Theme struct {
|
||||||
// Textures maps texture names to image textures.
|
// Textures maps texture names to image textures.
|
||||||
Textures map[string] image.Image
|
Textures map[string] image.Image
|
||||||
textures map[string] canvas.TextureCloser // private texture cache
|
textures map[string] canvas.TextureCloser // private texture cache
|
||||||
missing canvas.TextureCloser // cache for "missing" texture
|
missing canvas.TextureCloser // cache for "missing" texture
|
||||||
|
|
||||||
// Default lists style attributes that apply to all objects, which are
|
|
||||||
// overridden by attributes in the Rules map.
|
|
||||||
Default Rule
|
|
||||||
|
|
||||||
// Rules determines which styles get applied to which Objects.
|
// Rules determines which styles get applied to which Objects.
|
||||||
Rules map[theme.Role] Rule
|
Rules []Rule
|
||||||
|
|
||||||
// Colors maps theme.Color values to color.RGBA values.
|
// Colors maps theme.Color values to color.RGBA values.
|
||||||
Colors map[theme.Color] color.Color
|
Colors map[theme.Color] color.Color
|
||||||