gui: create a TImageList with famfamfam/silk resources

This commit is contained in:
mappu 2024-06-08 14:24:35 +12:00
parent 00a96bfe84
commit 8b1e7064e7
10 changed files with 54 additions and 0 deletions

BIN
assets/database.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 390 B

BIN
assets/database_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 658 B

BIN
assets/database_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 659 B

BIN
assets/database_save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

BIN
assets/table.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

BIN
assets/table_add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

BIN
assets/table_delete.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 660 B

BIN
assets/table_save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 723 B

50
images.go Normal file
View File

@ -0,0 +1,50 @@
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
}

View File

@ -14,6 +14,8 @@ import (
type TMainForm struct {
*vcl.TForm
ImageList *vcl.TImageList
Menu *vcl.TMainMenu
Buckets *vcl.TTreeView
Tabs *vcl.TPageControl
@ -35,6 +37,8 @@ func (f *TMainForm) OnFormCreate(sender vcl.IObject) {
const MY_SPACING = 6
const MY_WIDTH = 180
f.ImageList = loadImages(f)
f.SetCaption("yvbolt")
mnuFile := vcl.NewMenuItem(f)