Icons and styles use xyz.holanet.Nasin config
This commit is contained in:
@@ -6,9 +6,10 @@ import _ "embed"
|
||||
import _ "image/png"
|
||||
import "git.tebibyte.media/tomo/tomo"
|
||||
import "git.tebibyte.media/tomo/tomo/data"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/util"
|
||||
import "git.tebibyte.media/tomo/tomo/event"
|
||||
import "git.tebibyte.media/tomo/tomo/canvas"
|
||||
import "git.tebibyte.media/tomo/backend/style"
|
||||
import "git.tebibyte.media/tomo/nasin/internal/util"
|
||||
|
||||
//go:embed assets/icons-small.png
|
||||
var atlasSmallBytes []byte
|
||||
@@ -35,7 +36,7 @@ const (
|
||||
iconXOfficeSpreadsheet = tomo.Icon("x-office-spreadsheet")
|
||||
)
|
||||
|
||||
func generateSource (data []byte, width int) map[tomo.Icon] canvas.Texture {
|
||||
func generateSource (data []byte, width int) (canvas.TextureCloser, map[tomo.Icon] canvas.Texture) {
|
||||
atlasImage, _, err := image.Decode(bytes.NewReader(data))
|
||||
if err != nil { panic(err) }
|
||||
atlasTexture := tomo.NewTexture(atlasImage)
|
||||
@@ -448,23 +449,26 @@ func generateSource (data []byte, width int) map[tomo.Icon] canvas.Texture {
|
||||
col(tomo.IconWeatherSnow)
|
||||
col(tomo.IconWeatherStorm)
|
||||
|
||||
return source
|
||||
return atlasTexture, source
|
||||
}
|
||||
|
||||
type iconSet struct {
|
||||
atlasSmall canvas.TextureCloser
|
||||
atlasLarge canvas.TextureCloser
|
||||
texturesSmall map[tomo.Icon] canvas.Texture
|
||||
texturesLarge map[tomo.Icon] canvas.Texture
|
||||
}
|
||||
|
||||
// New creates a new fallback icon set.
|
||||
func New () style.IconSet {
|
||||
return new(iconSet)
|
||||
func New () (style.IconSet, event.Cookie) {
|
||||
iconSet := new(iconSet)
|
||||
return iconSet, iconSet
|
||||
}
|
||||
|
||||
func (this *iconSet) ensure () {
|
||||
if this.texturesSmall != nil { return }
|
||||
this.texturesSmall = generateSource(atlasSmallBytes, 16)
|
||||
this.texturesLarge = generateSource(atlasLargeBytes, 32)
|
||||
this.atlasSmall, this.texturesSmall = generateSource(atlasSmallBytes, 16)
|
||||
this.atlasLarge, this.texturesLarge = generateSource(atlasLargeBytes, 32)
|
||||
}
|
||||
|
||||
func (this *iconSet) selectSource (size tomo.IconSize) map[tomo.Icon] canvas.Texture {
|
||||
@@ -500,3 +504,12 @@ func (this *iconSet) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Textur
|
||||
return source[tomo.Icon(iconApplicationXGeneric)]
|
||||
}
|
||||
}
|
||||
|
||||
func (this *iconSet) Close () {
|
||||
if this.atlasSmall != nil {
|
||||
this.atlasSmall.Close()
|
||||
}
|
||||
if this.atlasLarge != nil {
|
||||
this.atlasLarge.Close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user