|
|
|
|
@@ -9,14 +9,14 @@ import "golang.org/x/image/font"
|
|
|
|
|
import "golang.org/x/image/font/basicfont"
|
|
|
|
|
import "tomo"
|
|
|
|
|
import "tomo/data"
|
|
|
|
|
import "tomo/artist"
|
|
|
|
|
import "tomo/artist/artutil"
|
|
|
|
|
import "tomo/artist/patterns"
|
|
|
|
|
import "art"
|
|
|
|
|
import "art/artutil"
|
|
|
|
|
import "art/patterns"
|
|
|
|
|
|
|
|
|
|
//go:embed assets/wintergreen.png
|
|
|
|
|
var defaultAtlasBytes []byte
|
|
|
|
|
var defaultAtlas artist.Canvas
|
|
|
|
|
var defaultTextures [17][9]artist.Pattern
|
|
|
|
|
var defaultAtlas art.Canvas
|
|
|
|
|
var defaultTextures [17][9]art.Pattern
|
|
|
|
|
//go:embed assets/wintergreen-icons-small.png
|
|
|
|
|
var defaultIconsSmallAtlasBytes []byte
|
|
|
|
|
var defaultIconsSmall [640]binaryIcon
|
|
|
|
|
@@ -24,15 +24,15 @@ var defaultIconsSmall [640]binaryIcon
|
|
|
|
|
var defaultIconsLargeAtlasBytes []byte
|
|
|
|
|
var defaultIconsLarge [640]binaryIcon
|
|
|
|
|
|
|
|
|
|
func atlasCell (col, row int, border artist.Inset) {
|
|
|
|
|
func atlasCell (col, row int, border art.Inset) {
|
|
|
|
|
bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16))
|
|
|
|
|
defaultTextures[col][row] = patterns.Border {
|
|
|
|
|
Canvas: artist.Cut(defaultAtlas, bounds),
|
|
|
|
|
Canvas: art.Cut(defaultAtlas, bounds),
|
|
|
|
|
Inset: border,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func atlasCol (col int, border artist.Inset) {
|
|
|
|
|
func atlasCol (col int, border art.Inset) {
|
|
|
|
|
for index, _ := range defaultTextures[col] {
|
|
|
|
|
atlasCell(col, index, border)
|
|
|
|
|
}
|
|
|
|
|
@@ -43,7 +43,7 @@ type binaryIcon struct {
|
|
|
|
|
stride int
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (icon binaryIcon) Draw (destination artist.Canvas, color color.RGBA, at image.Point) {
|
|
|
|
|
func (icon binaryIcon) Draw (destination art.Canvas, color color.RGBA, at image.Point) {
|
|
|
|
|
bounds := icon.Bounds().Add(at).Intersect(destination.Bounds())
|
|
|
|
|
point := image.Point { }
|
|
|
|
|
data, stride := destination.Buffer()
|
|
|
|
|
@@ -85,43 +85,43 @@ func binaryIconFrom (source image.Image, clip image.Rectangle) (icon binaryIcon)
|
|
|
|
|
|
|
|
|
|
func init () {
|
|
|
|
|
defaultAtlasImage, _, _ := image.Decode(bytes.NewReader(defaultAtlasBytes))
|
|
|
|
|
defaultAtlas = artist.FromImage(defaultAtlasImage)
|
|
|
|
|
defaultAtlas = art.FromImage(defaultAtlasImage)
|
|
|
|
|
|
|
|
|
|
// PatternDead
|
|
|
|
|
atlasCol(0, artist.Inset { })
|
|
|
|
|
atlasCol(0, art.Inset { })
|
|
|
|
|
// PatternRaised
|
|
|
|
|
atlasCol(1, artist.Inset { 6, 6, 6, 6 })
|
|
|
|
|
atlasCol(1, art.Inset { 6, 6, 6, 6 })
|
|
|
|
|
// PatternSunken
|
|
|
|
|
atlasCol(2, artist.Inset { 4, 4, 4, 4 })
|
|
|
|
|
atlasCol(2, art.Inset { 4, 4, 4, 4 })
|
|
|
|
|
// PatternPinboard
|
|
|
|
|
atlasCol(3, artist.Inset { 2, 2, 2, 2 })
|
|
|
|
|
atlasCol(3, art.Inset { 2, 2, 2, 2 })
|
|
|
|
|
// PatternButton
|
|
|
|
|
atlasCol(4, artist.Inset { 6, 6, 6, 6 })
|
|
|
|
|
atlasCol(4, art.Inset { 6, 6, 6, 6 })
|
|
|
|
|
// PatternInput
|
|
|
|
|
atlasCol(5, artist.Inset { 4, 4, 4, 4 })
|
|
|
|
|
atlasCol(5, art.Inset { 4, 4, 4, 4 })
|
|
|
|
|
// PatternGutter
|
|
|
|
|
atlasCol(6, artist.Inset { 7, 7, 7, 7 })
|
|
|
|
|
atlasCol(6, art.Inset { 7, 7, 7, 7 })
|
|
|
|
|
// PatternHandle
|
|
|
|
|
atlasCol(7, artist.Inset { 3, 3, 3, 3 })
|
|
|
|
|
atlasCol(7, art.Inset { 3, 3, 3, 3 })
|
|
|
|
|
// PatternLine
|
|
|
|
|
atlasCol(8, artist.Inset { 1, 1, 1, 1 })
|
|
|
|
|
atlasCol(8, art.Inset { 1, 1, 1, 1 })
|
|
|
|
|
// PatternMercury
|
|
|
|
|
atlasCol(13, artist.Inset { 2, 2, 2, 2 })
|
|
|
|
|
atlasCol(13, art.Inset { 2, 2, 2, 2 })
|
|
|
|
|
// PatternTableHead:
|
|
|
|
|
atlasCol(14, artist.Inset { 4, 4, 4, 4 })
|
|
|
|
|
atlasCol(14, art.Inset { 4, 4, 4, 4 })
|
|
|
|
|
// PatternTableCell:
|
|
|
|
|
atlasCol(15, artist.Inset { 4, 4, 4, 4 })
|
|
|
|
|
atlasCol(15, art.Inset { 4, 4, 4, 4 })
|
|
|
|
|
// PatternLamp:
|
|
|
|
|
atlasCol(16, artist.Inset { 4, 3, 4, 3 })
|
|
|
|
|
atlasCol(16, art.Inset { 4, 3, 4, 3 })
|
|
|
|
|
|
|
|
|
|
// PatternButton: basic.checkbox
|
|
|
|
|
atlasCol(9, artist.Inset { 3, 3, 3, 3 })
|
|
|
|
|
atlasCol(9, art.Inset { 3, 3, 3, 3 })
|
|
|
|
|
// PatternRaised: basic.listEntry
|
|
|
|
|
atlasCol(10, artist.Inset { 3, 3, 3, 3 })
|
|
|
|
|
atlasCol(10, art.Inset { 3, 3, 3, 3 })
|
|
|
|
|
// PatternRaised: fun.flatKey
|
|
|
|
|
atlasCol(11, artist.Inset { 3, 3, 5, 3 })
|
|
|
|
|
atlasCol(11, art.Inset { 3, 3, 5, 3 })
|
|
|
|
|
// PatternRaised: fun.sharpKey
|
|
|
|
|
atlasCol(12, artist.Inset { 3, 3, 4, 3 })
|
|
|
|
|
atlasCol(12, art.Inset { 3, 3, 4, 3 })
|
|
|
|
|
|
|
|
|
|
// set up small icons
|
|
|
|
|
defaultIconsSmallAtlasImage, _, _ := image.Decode (
|
|
|
|
|
@@ -164,7 +164,7 @@ func (Theme) FontFace (style tomo.FontStyle, size tomo.FontSize, c tomo.Case) fo
|
|
|
|
|
return basicfont.Face7x13
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) artist.Icon {
|
|
|
|
|
func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) art.Icon {
|
|
|
|
|
if size == tomo.IconSizeLarge {
|
|
|
|
|
if id < 0 || int(id) >= len(defaultIconsLarge) {
|
|
|
|
|
return nil
|
|
|
|
|
@@ -180,12 +180,12 @@ func (Theme) Icon (id tomo.Icon, size tomo.IconSize, c tomo.Case) artist.Icon {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Theme) MimeIcon (data.Mime, tomo.IconSize, tomo.Case) artist.Icon {
|
|
|
|
|
func (Theme) MimeIcon (data.Mime, tomo.IconSize, tomo.Case) art.Icon {
|
|
|
|
|
// TODO
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Theme) Pattern (id tomo.Pattern, state tomo.State, c tomo.Case) artist.Pattern {
|
|
|
|
|
func (Theme) Pattern (id tomo.Pattern, state tomo.State, c tomo.Case) art.Pattern {
|
|
|
|
|
offset := 0; switch {
|
|
|
|
|
case state.Disabled: offset = 1
|
|
|
|
|
case state.Pressed && state.On: offset = 4
|
|
|
|
|
@@ -254,31 +254,31 @@ func (Theme) Color (id tomo.Color, state tomo.State, c tomo.Case) color.RGBA {
|
|
|
|
|
} [id])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (Theme) Padding (id tomo.Pattern, c tomo.Case) artist.Inset {
|
|
|
|
|
func (Theme) Padding (id tomo.Pattern, c tomo.Case) art.Inset {
|
|
|
|
|
switch id {
|
|
|
|
|
case tomo.PatternSunken:
|
|
|
|
|
if c.Match("tomo", "progressBar", "") {
|
|
|
|
|
return artist.I(2, 1, 1, 2)
|
|
|
|
|
return art.I(2, 1, 1, 2)
|
|
|
|
|
} else if c.Match("tomo", "list", "") {
|
|
|
|
|
return artist.I(2)
|
|
|
|
|
return art.I(2)
|
|
|
|
|
} else if c.Match("tomo", "flowList", "") {
|
|
|
|
|
return artist.I(2)
|
|
|
|
|
return art.I(2)
|
|
|
|
|
} else {
|
|
|
|
|
return artist.I(8)
|
|
|
|
|
return art.I(8)
|
|
|
|
|
}
|
|
|
|
|
case tomo.PatternPinboard:
|
|
|
|
|
if c.Match("tomo", "piano", "") {
|
|
|
|
|
return artist.I(2)
|
|
|
|
|
return art.I(2)
|
|
|
|
|
} else {
|
|
|
|
|
return artist.I(8)
|
|
|
|
|
return art.I(8)
|
|
|
|
|
}
|
|
|
|
|
case tomo.PatternTableCell: return artist.I(5)
|
|
|
|
|
case tomo.PatternTableHead: return artist.I(5)
|
|
|
|
|
case tomo.PatternGutter: return artist.I(0)
|
|
|
|
|
case tomo.PatternLine: return artist.I(1)
|
|
|
|
|
case tomo.PatternMercury: return artist.I(5)
|
|
|
|
|
case tomo.PatternLamp: return artist.I(5, 5, 5, 6)
|
|
|
|
|
default: return artist.I(8)
|
|
|
|
|
case tomo.PatternTableCell: return art.I(5)
|
|
|
|
|
case tomo.PatternTableHead: return art.I(5)
|
|
|
|
|
case tomo.PatternGutter: return art.I(0)
|
|
|
|
|
case tomo.PatternLine: return art.I(1)
|
|
|
|
|
case tomo.PatternMercury: return art.I(5)
|
|
|
|
|
case tomo.PatternLamp: return art.I(5, 5, 5, 6)
|
|
|
|
|
default: return art.I(8)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|