Address review comments

This commit is contained in:
Ousmane Traore 2017-04-30 18:43:05 -04:00
parent 8ae8551fda
commit ac4239754f
1 changed files with 13 additions and 14 deletions

View File

@ -1,11 +1,10 @@
package pixelgl
import (
"image"
"image/color"
"runtime"
"image"
"github.com/faiface/glhf"
"github.com/faiface/mainthread"
"github.com/faiface/pixel"
@ -22,15 +21,17 @@ type WindowConfig struct {
// Title at the top of the Window.
Title string
// Icons specifies the icon images used by the window. This is usually displayed
// Icon specifies the icon images available to be used by the window. This is usually displayed
// in the top bar of the window or in the task bar of the desktop environment.
//
// If passed one image, it will use that image, if passed an array of images
// those of or closest to the sizes desired by the system are selected.
// The desired image sizes varies depending on platform and system settings. The selected
// images will be rescaled as needed. Good sizes include 16x16, 32x32 and 48x48.
// NOTE: Setting this value doesn't have an effect on OSX. You'll need to set the icon
//
// Note: Setting this value doesn't have an effect on OSX. You'll need to set the icon
// when bundling your application for release.
Icons []pixel.Picture
Icon []pixel.Picture
// Bounds specify the bounds of the Window in pixels.
Bounds pixel.Rect
@ -130,16 +131,14 @@ func NewWindow(cfg WindowConfig) (*Window, error) {
w.Update()
runtime.SetFinalizer(w, (*Window).Destroy)
if len(cfg.Icons) > 0 {
var imgs []image.Image
for _, v := range cfg.Icons {
pic := pixel.PictureDataFromPicture(v)
imgs = append(imgs, pic.Image())
}
mainthread.Call(func() {
w.window.SetIcon(imgs)
})
imgs := make([]image.Image, len(cfg.Icon))
for _, v := range cfg.Icon {
pic := pixel.PictureDataFromPicture(v)
imgs = append(imgs, pic.Image())
}
mainthread.Call(func() {
w.window.SetIcon(imgs)
})
return w, nil
}