let GLFW restart

add mouse area to qmlimg
This commit is contained in:
lordwelch 2016-04-12 10:22:14 -07:00
parent bba9f04902
commit d06d77000c
4 changed files with 35 additions and 7 deletions

View File

@ -109,7 +109,7 @@ func checkMon() {
monHeight = monitors[1].GetVideoMode().Height
win, err = glfw.CreateWindow(monWidth, monHeight, "Cube", nil, nil)
win.SetPos(monitors[1].GetPos())
fmt.Printf("Width: %d Height: %d \n",monWidth, monHeight)
fmt.Printf("Width: %d Height: %d \n", monWidth, monHeight)
if err != nil {
panic(err)
}

View File

@ -6,8 +6,8 @@ import (
"os"
"path/filepath"
"github.com/kardianos/osext"
"github.com/go-gl/glfw/v3.1/glfw"
"github.com/kardianos/osext"
"github.com/lordwelch/qml"
"gopkg.in/gographics/imagick.v2/imagick"
)
@ -109,7 +109,6 @@ func (sl *slide) add( /*cl *cell*/ ) {
//keep the pointer/dereference (i'm not sure which it is)
//problems occur otherwise
*sl = append(*sl, &cl)
cl.setSignal()
//seperate image object in QML
cl.qmlimg = qimg.Create(nil)
@ -117,6 +116,7 @@ func (sl *slide) add( /*cl *cell*/ ) {
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d"+`;`+"0", cl.index))
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
cl.qmlimg.Set("index", cl.index)
cl.setSignal()
}

22
qml.go
View File

@ -43,6 +43,23 @@ func (cl *cell) setSignal() {
cl.clearcache()
})
cl.qmlimg.ObjectByName("cellMouse").On("clicked", func(musEvent qml.Object) {
btn := musEvent.Property("button")
//right click
if btn == 2 {
//context menu
window.ObjectByName("mnuCtx").Call("popup")
rhtClkCell = cl.index
} else {
//left click
//select and update image preview for cell
selCell = cl.qmlcell.Int("index")
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
setupScene()
}
//update image preview
cl.clearcache()
})
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
if focus {
cl.qmlcell.ObjectByName("cellMouse").Call("selected")
@ -107,7 +124,10 @@ func setSignals() {
})
window.ObjectByName("mnuDisplay").On("triggered", func() {
qml.RunMain(glInit)
win.SetShouldClose(false)
window.Set("cls", false)
win.Show()
qml.ResetGLFW()
})
window.ObjectByName("mnuEdit").On("triggered", func() {

View File

@ -12,4 +12,12 @@ Image {
anchors.right: parent.right
anchors.left: parent.left
//cache: false
MouseArea {
id: cellMouse
hoverEnabled: true
enabled: true
objectName: "cellMouse"
anchors.fill: parent
acceptedButtons: Qt.AllButtons
}
}