Large icons in the default set!

This commit is contained in:
Sasha Koshka 2023-03-10 18:53:27 -05:00
parent 5d4a26a877
commit 9cc9e78504
5 changed files with 33 additions and 7 deletions

View File

@ -49,7 +49,7 @@ func NewDialog (
case DialogKindError: iconId = theme.IconError
}
messageContainer.Adopt(basicElements.NewIcon(iconId, theme.IconSizeSmall), false)
messageContainer.Adopt(basicElements.NewIcon(iconId, theme.IconSizeLarge), false)
messageContainer.Adopt(basicElements.NewLabel(message, false), true)
container.Adopt(messageContainer, true)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -19,6 +19,9 @@ var defaultTextures [14][9]artist.Pattern
//go:embed assets/wintergreen-icons-small.png
var defaultIconsSmallAtlasBytes []byte
var defaultIconsSmall [640]binaryIcon
//go:embed assets/wintergreen-icons-large.png
var defaultIconsLargeAtlasBytes []byte
var defaultIconsLarge [640]binaryIcon
func atlasCell (col, row int, border artist.Inset) {
bounds := image.Rect(0, 0, 16, 16).Add(image.Pt(col, row).Mul(16))
@ -116,14 +119,34 @@ func init () {
// set up small icons
defaultIconsSmallAtlasImage, _, _ := image.Decode (
bytes.NewReader(defaultIconsSmallAtlasBytes))
bounds := defaultIconsSmallAtlasImage.Bounds()
point := image.Point { }
iconIndex := 0
for point.Y = bounds.Min.Y; point.Y < bounds.Max.Y; point.Y += 16 {
for point.X = bounds.Min.X; point.X < bounds.Max.X; point.X += 16 {
for point.Y = 0; point.Y < 20; point.Y ++ {
for point.X = 0; point.X < 32; point.X ++ {
defaultIconsSmall[iconIndex] = binaryIconFrom (
defaultIconsSmallAtlasImage,
image.Rect(0, 0, 16, 16).Add(point))
image.Rect(0, 0, 16, 16).Add(point.Mul(16)))
iconIndex ++
}}
// set up large icons
defaultIconsLargeAtlasImage, _, _ := image.Decode (
bytes.NewReader(defaultIconsLargeAtlasBytes))
point = image.Point { }
iconIndex = 0
for point.Y = 0; point.Y < 8; point.Y ++ {
for point.X = 0; point.X < 32; point.X ++ {
defaultIconsLarge[iconIndex] = binaryIconFrom (
defaultIconsLargeAtlasImage,
image.Rect(0, 0, 32, 32).Add(point.Mul(32)))
iconIndex ++
}}
iconIndex = 384
for point.Y = 8; point.Y < 12; point.Y ++ {
for point.X = 0; point.X < 32; point.X ++ {
defaultIconsLarge[iconIndex] = binaryIconFrom (
defaultIconsLargeAtlasImage,
image.Rect(0, 0, 32, 32).Add(point.Mul(32)))
iconIndex ++
}}
}
@ -148,8 +171,11 @@ func (Default) FontFace (style FontStyle, size FontSize, c Case) font.Face {
// Icon returns an icon from the default set corresponding to the given name.
func (Default) Icon (id Icon, size IconSize, c Case) artist.Icon {
if size == IconSizeLarge {
// TODO
return nil
if id < 0 || int(id) >= len(defaultIconsLarge) {
return nil
} else {
return defaultIconsLarge[id]
}
} else {
if id < 0 || int(id) >= len(defaultIconsSmall) {
return nil

Binary file not shown.