This repository has been archived on 2023-08-08. You can view files and clone it, but cannot push or open issues or pull requests.
tomo-old/theme/theme.go

131 lines
3.8 KiB
Go
Raw Normal View History

2023-01-08 23:03:19 -07:00
package theme
import "image"
import "image/color"
import "golang.org/x/image/font"
import "git.tebibyte.media/sashakoshka/tomo/artist"
import "git.tebibyte.media/sashakoshka/tomo/defaultfont"
// none of these colors are final! TODO: generate these values from a theme
// file at startup.
func hex (color uint32) (c color.RGBA) {
c.A = uint8(color)
c.B = uint8(color >> 8)
c.G = uint8(color >> 16)
c.R = uint8(color >> 24)
return
}
var accentPattern = artist.NewUniform(hex(0x408090FF))
var backgroundPattern = artist.NewUniform(color.Gray16 { 0xAAAA })
var foregroundPattern = artist.NewUniform(color.Gray16 { 0x0000 })
var weakForegroundPattern = artist.NewUniform(color.Gray16 { 0x4444 })
var strokePattern = artist.NewUniform(color.Gray16 { 0x0000 })
2023-01-20 17:24:21 -07:00
var sunkenPattern = artist.NewMultiBordered (
artist.Stroke { Weight: 1, Pattern: strokePattern },
artist.Stroke {
Weight: 1,
2023-01-20 21:00:26 -07:00
Pattern: artist.Beveled {
artist.NewUniform(hex(0x3b534eFF)),
artist.NewUniform(hex(0x97a09cFF)),
},
},
2023-01-21 19:24:02 -07:00
// artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) },
artist.Stroke { Pattern: artist.Striped {
First: artist.Stroke {
Weight: 2,
Pattern: artist.NewUniform(hex(0x97a09cFF)),
},
Second: artist.Stroke {
Weight: 1,
Pattern: artist.NewUniform(hex(0x6e8079FF)),
},
}})
2023-01-21 18:58:25 -07:00
var raisedPattern = artist.NewMultiBordered (
artist.Stroke { Weight: 1, Pattern: strokePattern },
artist.Stroke {
Weight: 1,
Pattern: artist.Beveled {
artist.NewUniform(hex(0xDBDBDBFF)),
artist.NewUniform(hex(0x383C3AFF)),
2023-01-21 18:58:25 -07:00
},
},
artist.Stroke { Pattern: artist.NewUniform(hex(0xAAAAAAFF)) })
var selectedRaisedPattern = artist.NewMultiBordered (
artist.Stroke { Weight: 1, Pattern: strokePattern },
artist.Stroke {
Weight: 1,
Pattern: artist.Beveled {
artist.NewUniform(hex(0xDBDBDBFF)),
artist.NewUniform(hex(0x383C3AFF)),
2023-01-21 18:58:25 -07:00
},
},
artist.Stroke { Weight: 1, Pattern: accentPattern },
artist.Stroke { Pattern: artist.NewUniform(hex(0xAAAAAAFF)) })
2023-01-20 17:24:21 -07:00
var deadPattern = artist.NewMultiBordered (
artist.Stroke { Weight: 1, Pattern: strokePattern },
artist.Stroke { Pattern: artist.NewUniform(hex(0x97a09cFF)) })
2023-01-19 16:29:57 -07:00
func AccentPattern () (artist.Pattern) { return accentPattern }
func BackgroundPattern () (artist.Pattern) { return backgroundPattern }
2023-01-21 18:58:25 -07:00
func SunkenPattern () (artist.Pattern) { return sunkenPattern }
func RaisedPattern (selected bool) (artist.Pattern) {
if selected {
return selectedRaisedPattern
} else {
return raisedPattern
}
}
2023-01-19 16:29:57 -07:00
func DeadPattern () (artist.Pattern) { return deadPattern }
func ForegroundPattern (enabled bool) (artist.Pattern) {
if enabled {
return foregroundPattern
2023-01-08 23:03:19 -07:00
} else {
return weakForegroundPattern
2023-01-08 23:03:19 -07:00
}
}
// TODO: load fonts from an actual source instead of using defaultfont
2023-01-08 23:03:19 -07:00
// FontFaceRegular returns the font face to be used for normal text.
func FontFaceRegular () font.Face {
return defaultfont.FaceRegular
}
// FontFaceBold returns the font face to be used for bolded text.
func FontFaceBold () font.Face {
return defaultfont.FaceBold
}
// FontFaceItalic returns the font face to be used for italicized text.
func FontFaceItalic () font.Face {
return defaultfont.FaceItalic
}
// FontFaceBoldItalic returns the font face to be used for text that is both
// bolded and italicized.
func FontFaceBoldItalic () font.Face {
return defaultfont.FaceBoldItalic
}
// Padding returns how spaced out things should be on the screen. Generally,
// text should be offset from its container on all sides by this amount.
func Padding () int {
return 8
}
2023-01-21 19:24:02 -07:00
func ScrollBarWidth () int {
return Padding() * 2
}
2023-01-08 23:03:19 -07:00
// SinkOffsetVector specifies a vector for things such as text to move by when a
// "sinking in" effect is desired, such as a button label during a button press.
func SinkOffsetVector () image.Point {
return image.Point { 1, 1 }
}