rightclick for changing image and disable dblClick edit by default

This commit is contained in:
lordwelch 2016-03-21 08:49:06 -07:00
parent ba3ed7375b
commit d37a260236
2 changed files with 50 additions and 19 deletions

37
main.go
View File

@ -16,6 +16,8 @@ import (
"gopkg.in/gographics/imagick.v2/imagick" "gopkg.in/gographics/imagick.v2/imagick"
) )
type Bool bool
type cell struct { type cell struct {
text string text string
img *imagick.MagickWand img *imagick.MagickWand
@ -37,11 +39,12 @@ var (
err error err error
monitors []*glfw.Monitor monitors []*glfw.Monitor
projMonitor *glfw.Monitor projMonitor *glfw.Monitor
tex1 uint32 tex1 *uint32
texDel = false texDel, quickEdit Bool = false, false
) )
func main() { func main() {
selSlide = 0
if err = qml.Run(run); err != nil { if err = qml.Run(run); err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err) fmt.Fprintf(os.Stderr, "error: %v\n", err)
@ -95,7 +98,7 @@ func setupScene() {
gl.ClearColor(0, 0, 0, 0) gl.ClearColor(0, 0, 0, 0)
if texDel { if texDel {
gl.DeleteTextures(1, &tex1) gl.DeleteTextures(1, tex1)
} }
tex1 = newTexture(*slides[selSlide].getImage(x0, y0)) tex1 = newTexture(*slides[selSlide].getImage(x0, y0))
@ -133,7 +136,7 @@ func drawSlide() {
} }
func newTexture(rgba image.RGBA) uint32 { func newTexture(rgba image.RGBA) *uint32 {
var texture1 uint32 var texture1 uint32
gl.Enable(gl.TEXTURE_2D) gl.Enable(gl.TEXTURE_2D)
gl.GenTextures(1, &texture1) gl.GenTextures(1, &texture1)
@ -149,7 +152,7 @@ func newTexture(rgba image.RGBA) uint32 {
gl.UNSIGNED_BYTE, gl.UNSIGNED_BYTE,
gl.Ptr(rgba.Pix)) gl.Ptr(rgba.Pix))
return texture1 return &texture1
} }
@ -251,6 +254,10 @@ func setSignals() {
}) })
window.ObjectByName("mnuEdit").On("triggered", func() {
(&quickEdit).Toggle()
})
textEdit.ObjectByName("textEdit1").On("focusChanged", func(focus bool) { textEdit.ObjectByName("textEdit1").On("focusChanged", func(focus bool) {
var ( var (
str string str string
@ -290,9 +297,16 @@ func (cl cell) getImage(x, y int) (img *image.RGBA) {
} }
func (cl *cell) setSignal() { func (cl *cell) setSignal() {
cl.qmlcell.ObjectByName("cellMouse").On("clicked", func() { cl.qmlcell.ObjectByName("cellMouse").On("clicked", func(musEvent qml.Object) {
btn := musEvent.Property("button")
if btn == 2 {
//cl.qmlcell.ObjectByName("cellMouse").Call("rightClicked")
} else {
selSlide = cl.qmlcell.Int("index")
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true) cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
cl.img.FlipImage()
setupScene() setupScene()
}
}) })
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) { cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
@ -320,7 +334,7 @@ func (cl *cell) setSignal() {
}) })
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() { cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
if quickEdit {
textEdit.Set("cell", cl.index) textEdit.Set("cell", cl.index)
textEdit.Set("x", cl.qmlcell.Int("x")) textEdit.Set("x", cl.qmlcell.Int("x"))
textEdit.Set("y", cl.qmlcell.Int("y")) textEdit.Set("y", cl.qmlcell.Int("y"))
@ -332,6 +346,7 @@ func (cl *cell) setSignal() {
textEdit.Set("enabled", true) textEdit.Set("enabled", true)
textEdit.ObjectByName("textEdit1").Set("text", cl.text) textEdit.ObjectByName("textEdit1").Set("text", cl.text)
}
}) })
} }
@ -377,6 +392,14 @@ func (sl *slide) remove(i int) {
*sl, (*sl)[len((*sl))-1] = append((*sl)[:i], (*sl)[i+1:]...), nil *sl, (*sl)[len((*sl))-1] = append((*sl)[:i], (*sl)[i+1:]...), nil
} }
func (bl *Bool) Toggle() {
if *bl == false {
*bl = true
} else {
*bl = false
}
}
func (cl cell) String() string { func (cl cell) String() string {
return fmt.Sprintf("Index: %d \nText: %s\n", cl.index, cl.text) return fmt.Sprintf("Index: %d \nText: %s\n", cl.index, cl.text)
} }

View File

@ -51,6 +51,14 @@ ApplicationWindow {
shortcut: StandardKey.Quit shortcut: StandardKey.Quit
} }
} }
Menu {
title: "&Edit"
MenuItem {
text: "quick edit"
objectName: "mnuEdit"
}
}
Menu { Menu {
title: "&Help" title: "&Help"
MenuItem { MenuItem {