yvbolt/images.go

51 lines
1.0 KiB
Go
Raw Normal View History

package main
import (
"embed"
"github.com/ying32/govcl/vcl"
)
//go:embed assets/*
var assetsFs embed.FS
const (
imgDatabase = 0
imgDatabaseAdd = 1
imgDatabaseDelete = 2
imgDatabaseSave = 3
imgTable = 4
imgTableAdd = 5
imgTableDelete = 6
imgTableSave = 7
)
func loadImages(owner vcl.IComponent) *vcl.TImageList {
mustLoad := func(n string) *vcl.TBitmap {
imgData, err := assetsFs.ReadFile(n)
if err != nil {
panic(err)
}
png := vcl.NewPngImage()
png.LoadFromBytes(imgData)
ret := vcl.NewBitmap()
ret.Assign(png)
return ret
}
ilist := vcl.NewImageList(owner)
ilist.Add(mustLoad("assets/database.png"), nil)
ilist.Add(mustLoad("assets/database_add.png"), nil)
ilist.Add(mustLoad("assets/database_delete.png"), nil)
ilist.Add(mustLoad("assets/database_save.png"), nil)
ilist.Add(mustLoad("assets/table.png"), nil)
ilist.Add(mustLoad("assets/table_add.png"), nil)
ilist.Add(mustLoad("assets/table_delete.png"), nil)
ilist.Add(mustLoad("assets/table_save.png"), nil)
return ilist
}