make glfw close first

fix other stuff....
This commit is contained in:
lordwelch 2016-02-17 14:55:29 -08:00
parent 0461807287
commit 03e816356c
4 changed files with 113 additions and 49 deletions

View File

@ -2,7 +2,6 @@
package main
import (
"fmt"
"math"
"github.com/gographics/imagick/imagick"
@ -13,7 +12,7 @@ func resizeImage(mw *imagick.MagickWand, newWidth, newHeight int, keepSpecSize,
width, height, origHeight, origWidth int
)
origHeight = int(mw.GetImageHeight())
fmt.Println("hahahahahah :-P")
//fmt.Println("hahahahahah :-P")
origWidth = int(mw.GetImageWidth())
if (origHeight != newHeight) || (origWidth != newWidth) {
@ -35,7 +34,7 @@ func resizeImage(mw *imagick.MagickWand, newWidth, newHeight int, keepSpecSize,
center = false
} else {
resmw.NewImage(uint(newWidth), uint(newHeight), imagick.NewPixelWand())
fmt.Println(resmw.GetImageHeight(), resmw.GetImageWidth())
//fmt.Println(resmw.GetImageHeight(), resmw.GetImageWidth())
if center {
err = mw.ResizeImage(uint(width), uint(height), imagick.FILTER_LANCZOS, 1)
if err != nil {

50
main.go
View File

@ -1,8 +1,6 @@
// PresentationApp project main.go
package main
import "C"
import (
"fmt"
"image"
@ -19,11 +17,11 @@ import (
type cell struct {
text string
//img image.Image
img image.RGBA
qmlcell qml.Object
index int
}
type slide []cell
type slide []*cell
var (
x, y int
@ -35,7 +33,8 @@ var (
slides slide
err error
monitors []*glfw.Monitor
mw1 *imagick.MagickWand
projMonitor *glfw.Monitor
mw1, mw2 *imagick.MagickWand
tex1 uint32
//drawSlide func()
)
@ -48,6 +47,7 @@ func main() {
}
defer glfw.Terminate()
fmt.Println("test")
}
@ -88,19 +88,19 @@ func run() error {
setSignals()
window.Show()
qml.RunMain(func() {
glInit()
})
qml.RunMain(glInit)
window.Wait()
mw1.Destroy()
//win.Destroy()
mw2.Destroy()
imagick.Terminate()
return nil
}
func setupScene() {
gl.ClearColor(0.1, 0.5, 0.9, 0.0)
mw2 := resizeImage(mw1, x, y, true, true)
mw2 = resizeImage(mw1, x, y, true, true)
tex1 = newTexture(*mw2)
@ -172,10 +172,13 @@ func checkMon() {
glfw.WindowHint(glfw.Decorated, glfw.False)
if i := len(monitors); i < 2 {
fmt.Println("You only have 1 monitor!!!!!!!!!!! :-P")
win, err = glfw.CreateWindow(600, 800, "Cube", nil, nil)
x = 800
y = 600
win, err = glfw.CreateWindow(x, y, "Cube", nil, nil)
if err != nil {
panic(err)
}
projMonitor = monitors[0]
} else {
fmt.Printf("You have %d monitors\n", i)
x = monitors[1].GetVideoMode().Width
@ -187,6 +190,7 @@ func checkMon() {
if err != nil {
panic(err)
}
projMonitor = monitors[1]
}
monitorInfo()
@ -213,7 +217,7 @@ func glInit() {
panic(err)
}
setupScene()
win.SetPos(monitors[1].GetPos())
win.SetPos(projMonitor.GetPos())
qml.Func1 = func() int {
if !win.ShouldClose() {
@ -223,7 +227,7 @@ func glInit() {
return 0
} else {
win.Hide()
win.Destroy()
return 1
}
}
@ -231,16 +235,29 @@ func glInit() {
}
func setSignals() {
window.On("closing", func() {
fmt.Println(window.Bool("cls"))
win.Hide()
//win.Destroy()
window.Set("cls", true)
})
textEdit.ObjectByName("textEdit1").On("focusChanged", func(focus bool) {
var (
str string
cel cell
cel *cell
)
if !focus {
str = textEdit.ObjectByName("textEdit1").String("text")
cel = slides[textEdit.Int("cell")]
if textEdit.Bool("txt") {
cel.qmlcell.ObjectByName("cellText").Set("text", str)
//fmt.Println("haha.....:-P")
cel.text = str
//fmt.Println("----->"+cel.text, str, textEdit.Int("cell"))
}
}
})
@ -249,6 +266,7 @@ func setSignals() {
func (cl *cell) setSignal() {
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
cellText := cl.qmlcell.ObjectByName("cellText")
textEdit.Set("cell", cl.index)
textEdit.Set("x", cellText.Int("x")+4)
textEdit.Set("y", cellText.Int("y")+4)
@ -258,6 +276,8 @@ func (cl *cell) setSignal() {
textEdit.Set("visible", true)
textEdit.ObjectByName("textEdit1").Set("focus", true)
textEdit.Set("enabled", true)
textEdit.ObjectByName("textEdit1").Set("text", cl.text)
})
}
@ -273,7 +293,7 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
cl.text = "testing 1... 2... 3..."
cl.qmlcell.ObjectByName("cellText").Set("text", cl.text)
*sl = append(*sl, cl)
*sl = append(*sl, &cl)
cl.setSignal()

View File

@ -12,7 +12,12 @@ ApplicationWindow {
minimumHeight: 500
width: 1000
height: 600
Screen.objectName: "Screen1"
property bool cls: false
//Screen.objectName: "Screen1"
onClosing: if (!cls) {
close.accepted = false
}
AboutDialog { id: aboutDialog }
Action {
@ -130,14 +135,18 @@ ApplicationWindow {
Rectangle {
id: textEdit
property int cell
x: 448
y: 151
x: 232
y: 622
objectName: "textEdit"
width: 200
height: 200
color: "#ffffff"
visible: false
Keys.onEscapePressed: {
property bool txt: true
Keys.onPressed: {
if ((event.key == Qt.Key_Return) && (event.modifiers & Qt.ControlModifier)) {
txt = true
x = -100
y = -100
visible = false
@ -145,7 +154,25 @@ ApplicationWindow {
enabled = false
opacity = 0
textEdit1.focus = false
event.accepted = true
}
if (event.key == Qt.Key_Escape) {
txt = false
x = -100
y = -100
visible = false
focus = true
enabled = false
opacity = 0
textEdit1.focus = false
event.accepted = true
}
}
TextArea {
id: textEdit1

View File

@ -6,34 +6,52 @@ Rectangle {
property int index: 0
width: 100
height: 100
color: "#00000000"
border.width: 2
anchors.right: parent.right
anchors.left: parent.left
onFocusChanged: if (focus) {
border.color = "gainsboro"
color = "blue"
}
Text {
id: cellText
enabled: true
objectName: "cellText"
height: 75
text: "hello this is text\nhaha\nhdsjfklfhaskjd"
textFormat: Text.AutoText
clip: true
font.bold: false
anchors.fill: parent
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignTop
anchors.fill: parent
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
font.pixelSize: 12
onFocusChanged: if (focus) {
parent.border.color = "gainsboro"
parent.color = "blue"
}
MouseArea {
id: cellMouse
hoverEnabled: true
enabled: true
objectName: "cellMouse"
anchors.fill: parent
onFocusChanged: if (focus) {
parent.parent.border.color = "gainsboro"
parent.parent.color = "blue"
}
onClicked: focus = true
onEntered: if (containsMouse) {
parent.parent.border.color = "skyblue"
parent.parent.color = "darkblue"
parent.color = "white"
}
onExited: {
parent.parent.border.color = "white"
parent.parent.color = "white"
parent.color = "black"
}
}
}
}