Code compiles
This commit is contained in:
		
							parent
							
								
									e7c5b2d5b9
								
							
						
					
					
						commit
						1b489485da
					
				
							
								
								
									
										17
									
								
								icons.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								icons.go
									
									
									
									
									
								
							@ -1,18 +1,17 @@
 | 
			
		||||
package aluminum
 | 
			
		||||
 | 
			
		||||
import "os"
 | 
			
		||||
import "fs"
 | 
			
		||||
import "fmt"
 | 
			
		||||
import "io/fs"
 | 
			
		||||
import "image"
 | 
			
		||||
import "image/png"
 | 
			
		||||
import _ "image/png"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/data"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/theme"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/input"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/canvas"
 | 
			
		||||
 | 
			
		||||
type iconSet struct {
 | 
			
		||||
	fs fs.FS
 | 
			
		||||
	icons: map[theme.IconSize] map[string] canvas.Texture
 | 
			
		||||
	icons map[theme.IconSize] map[string] canvas.Texture
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *iconSet) get (size theme.IconSize, name string) canvas.Texture {
 | 
			
		||||
@ -24,11 +23,13 @@ func (this *iconSet) get (size theme.IconSize, name string) canvas.Texture {
 | 
			
		||||
		defer func () { this.icons[size][name] = texture } ()
 | 
			
		||||
 | 
			
		||||
		file, err := this.fs.Open(fmt.Sprint(size, "/", name, ".png"))
 | 
			
		||||
		if err != nil { return nil }
 | 
			
		||||
		if err != nil { return texture }
 | 
			
		||||
		defer file.Close()
 | 
			
		||||
		image, _, err := image.Decode(file)
 | 
			
		||||
		if err != nil { return nil }
 | 
			
		||||
		if err != nil { return texture }
 | 
			
		||||
		
 | 
			
		||||
		texture = tomo.NewTexture(image)
 | 
			
		||||
		return texture
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -50,6 +51,6 @@ func (this *iconSet) ApplicationIcon (id theme.ApplicationIcon, size theme.IconS
 | 
			
		||||
	if texture != nil {
 | 
			
		||||
		return texture
 | 
			
		||||
	} else {
 | 
			
		||||
		return this.get(size, fmt.Sprint("app-generic/", app.Role))
 | 
			
		||||
		return this.get(size, fmt.Sprint("app-generic/", id.Role))
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										2
									
								
								theme.go
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								theme.go
									
									
									
									
									
								
							@ -4,11 +4,9 @@ import "image"
 | 
			
		||||
import "image/color"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo"
 | 
			
		||||
import "golang.org/x/image/font/basicfont"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/data"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/theme"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/input"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/event"
 | 
			
		||||
import "git.tebibyte.media/tomo/tomo/canvas"
 | 
			
		||||
 | 
			
		||||
func hex (color uint32) (c color.RGBA) {
 | 
			
		||||
	c.A = uint8(color)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user