addceck for imgprovider

This commit is contained in:
lordwelch 2016-03-11 09:56:45 -08:00
parent 5f12adaa92
commit f4450e7e3d
2 changed files with 18 additions and 10 deletions

View File

@ -2,7 +2,6 @@
package main
import (
"fmt"
"image"
"strconv"
)
@ -11,11 +10,15 @@ import (
Image {
source: "image://images/`*/
var imgready = false
func imgProvider(id string, width, height int) image.Image {
var i int
fmt.Println("id: ", id)
i, _ = strconv.Atoi(id)
fmt.Println("haha: ", i)
if imgready {
i, _ := strconv.Atoi(id)
return slides[i].getImage(width, height)
} else {
var img1 image.Image = image.NewRGBA(image.Rect(0, 0, 340, 480))
return img1
}
}

11
main.go
View File

@ -55,7 +55,7 @@ func main() {
func run() error {
var mainQml qml.Object
imagick.Initialize()
defer imagick.Terminate()
mw1 = imagick.NewMagickWand()
err = mw1.ReadImage("logo:")
@ -89,6 +89,7 @@ func run() error {
textEdit = window.ObjectByName("textEdit")
slides.addCell()
setSignals()
imgready = true
window.Show()
qml.RunMain(glInit)
@ -112,6 +113,7 @@ func setupScene() {
gl.Ortho(-1, 1, -1, 1, 1.0, 10.0)
gl.MatrixMode(gl.MODELVIEW)
gl.LoadIdentity()
}
func drawSlide() {
@ -156,6 +158,7 @@ func newTexture(rgba image.RGBA) uint32 {
gl.Ptr(rgba.Pix))
return texture1
}
func checkMon() {
@ -198,6 +201,7 @@ func monitorInfo() {
fmt.Printf("monitor name: %s\n", mon.GetName())
i, t := mon.GetPos()
fmt.Printf("position X: %d Y: %d\n", i, t)
}
}
@ -222,14 +226,15 @@ func glInit() {
drawSlide()
win.SwapBuffers()
return 0
} else {
win.Hide()
win.Destroy()
return 1
}
}
}
}
}
func setSignals() {
window.ObjectByName("btnAdd").On("clicked", func() {