diff --git a/magickwand.go b/magickwand.go index 762def5..90dc36b 100644 --- a/magickwand.go +++ b/magickwand.go @@ -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 { diff --git a/main.go b/main.go index 4e6e438..8b3c083 100644 --- a/main.go +++ b/main.go @@ -1,8 +1,6 @@ // PresentationApp project main.go package main -import "C" - import ( "fmt" "image" @@ -18,25 +16,26 @@ import ( ) type cell struct { - text string - //img image.Image + text string + img image.RGBA qmlcell qml.Object index int } -type slide []cell +type slide []*cell var ( - x, y int - path string - textEdit qml.Object - cellQml qml.Object - window *qml.Window - win *glfw.Window - slides slide - err error - monitors []*glfw.Monitor - mw1 *imagick.MagickWand - tex1 uint32 + x, y int + path string + textEdit qml.Object + cellQml qml.Object + window *qml.Window + win *glfw.Window + slides slide + err error + monitors []*glfw.Monitor + 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")] - cel.qmlcell.ObjectByName("cellText").Set("text", str) + 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() diff --git a/main.qml b/main.qml index 8fdb7d4..4300bd9 100644 --- a/main.qml +++ b/main.qml @@ -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,23 +135,45 @@ 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: { - x = -100 - y = -100 - visible = false - focus = true - enabled = false - opacity = 0 - textEdit1.focus = false + property bool txt: true + Keys.onPressed: { + if ((event.key == Qt.Key_Return) && (event.modifiers & Qt.ControlModifier)) { + txt = true + + x = -100 + y = -100 + visible = false + focus = true + 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 objectName: "textEdit1" diff --git a/qml/cell.qml b/qml/cell.qml index 9d8ed61..bbf0c5d 100644 --- a/qml/cell.qml +++ b/qml/cell.qml @@ -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" + } } } }