fix changing images and some ui glitches
This commit is contained in:
parent
d81fb1f7fb
commit
ed73ea2527
@ -4,13 +4,16 @@ package main
|
|||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var imgready = false
|
var imgready = false
|
||||||
|
|
||||||
func imgProvider(id string, width, height int) image.Image {
|
func imgProvider(id string, width, height int) image.Image {
|
||||||
if imgready {
|
if imgready && (len(id) > 0) {
|
||||||
i, _ := strconv.Atoi(id)
|
//fmt.Println("source (provider): ", id)
|
||||||
|
i1 := strings.Index(id, `;`)
|
||||||
|
i, _ := strconv.Atoi(id[:i1])
|
||||||
return slides[i].getImage(width, height)
|
return slides[i].getImage(width, height)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
35
main.go
35
main.go
@ -8,7 +8,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/go-gl/gl/v2.1/gl"
|
"github.com/go-gl/gl/v2.1/gl"
|
||||||
"github.com/go-gl/glfw/v3.1/glfw"
|
"github.com/go-gl/glfw/v3.1/glfw"
|
||||||
@ -306,9 +308,9 @@ func (cl *cell) setSignal() {
|
|||||||
} else {
|
} else {
|
||||||
selSlide = cl.qmlcell.Int("index")
|
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.clearcache()
|
||||||
})
|
})
|
||||||
|
|
||||||
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
|
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
|
||||||
@ -321,14 +323,12 @@ func (cl *cell) setSignal() {
|
|||||||
|
|
||||||
window.ObjectByName("imgpicker").On("accepted", func() {
|
window.ObjectByName("imgpicker").On("accepted", func() {
|
||||||
//url := window.Call("getFileDialogUrl")
|
//url := window.Call("getFileDialogUrl")
|
||||||
url := filepath.Clean(strings.Replace(window.ObjectByName("imgpicker").String("fileUrl"), "file:","",1))
|
url := filepath.Clean(strings.Replace(window.ObjectByName("imgpicker").String("fileUrl"), "file:", "", 1))
|
||||||
|
|
||||||
slides[rhtClkCell].img.Clear()
|
slides[rhtClkCell].img.Clear()
|
||||||
slides[rhtClkCell].img.ReadImage(url)
|
slides[rhtClkCell].img.ReadImage(url)
|
||||||
fmt.Println(url)
|
setupScene()
|
||||||
setupScene()
|
cl.clearcache()
|
||||||
|
|
||||||
fmt.Println(window.ObjectByName("imgpicker").String("fileUrl"))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
cl.qmlcell.ObjectByName("cellMouse").On("doubleClicked", func() {
|
||||||
@ -349,6 +349,18 @@ func (cl *cell) setSignal() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cl *cell) clearcache() {
|
||||||
|
str := cl.qmlimg.String("source")
|
||||||
|
//fmt.Println("source (click): ", str)
|
||||||
|
i := strings.Index(str, `;`)
|
||||||
|
str1 := str[:i]
|
||||||
|
//fmt.Println("ext (click): ", str1)
|
||||||
|
i1, _ := strconv.Atoi(str[i+1:])
|
||||||
|
str = str1 + `;` + strconv.Itoa(i1+1)
|
||||||
|
//fmt.Println("new source (click): ", str)
|
||||||
|
cl.qmlimg.Set("source", str)
|
||||||
|
}
|
||||||
|
|
||||||
func (sl *slide) addCell( /*cl *cell*/ ) {
|
func (sl *slide) addCell( /*cl *cell*/ ) {
|
||||||
var cl cell
|
var cl cell
|
||||||
|
|
||||||
@ -368,8 +380,11 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
|
|||||||
cl.setSignal()
|
cl.setSignal()
|
||||||
|
|
||||||
cl.qmlimg = qimg.Create(nil)
|
cl.qmlimg = qimg.Create(nil)
|
||||||
|
fmt.Println("index", cl.index)
|
||||||
|
fmt.Printf("objectName: %s\n", fmt.Sprintf("cellImg%d", cl.index))
|
||||||
cl.qmlimg.Set("objectName", fmt.Sprintf("cellImg%d", cl.index))
|
cl.qmlimg.Set("objectName", fmt.Sprintf("cellImg%d", cl.index))
|
||||||
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d", cl.index))
|
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d"+`;`+"0", cl.index))
|
||||||
|
fmt.Println("source: ", cl.qmlimg.String("source"))
|
||||||
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
||||||
cl.qmlimg.Set("index", cl.index)
|
cl.qmlimg.Set("index", cl.index)
|
||||||
|
|
||||||
|
119
main.qml
119
main.qml
@ -16,10 +16,10 @@ ApplicationWindow {
|
|||||||
height: 600
|
height: 600
|
||||||
property bool cls: false
|
property bool cls: false
|
||||||
|
|
||||||
/*function getFileDialogUrl() {
|
|
||||||
return
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
/*function getFileDialogUrl() {
|
||||||
|
return
|
||||||
|
}*/
|
||||||
onClosing: if (!cls) {
|
onClosing: if (!cls) {
|
||||||
close.accepted = false
|
close.accepted = false
|
||||||
}
|
}
|
||||||
@ -64,17 +64,15 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Menu {
|
||||||
Menu {
|
objectName: "mnuCtx"
|
||||||
objectName: "mnuCtx"
|
title: "new image..."
|
||||||
title: "new image..."
|
MenuItem {
|
||||||
MenuItem {
|
objectName: "mnuImgPick"
|
||||||
objectName: "mnuImgPick"
|
text: "new Image..."
|
||||||
text: "new Image..."
|
onTriggered: imgpicker.open()
|
||||||
onTriggered: imgpicker.open()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SplitView {
|
SplitView {
|
||||||
id: mainSlider
|
id: mainSlider
|
||||||
@ -124,58 +122,58 @@ ApplicationWindow {
|
|||||||
color: "#00000000"
|
color: "#00000000"
|
||||||
transformOrigin: Item.TopLeft
|
transformOrigin: Item.TopLeft
|
||||||
border.width: 0
|
border.width: 0
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: textEdit
|
id: textEdit
|
||||||
property int cell
|
property int cell
|
||||||
x: 232
|
x: 232
|
||||||
y: 622
|
y: 622
|
||||||
objectName: "textEdit"
|
objectName: "textEdit"
|
||||||
width: 200
|
width: 200
|
||||||
height: 200
|
height: 200
|
||||||
color: "#ffffff"
|
color: "#ffffff"
|
||||||
visible: false
|
visible: false
|
||||||
property bool txt: true
|
property bool txt: true
|
||||||
Keys.onPressed: {
|
Keys.onPressed: {
|
||||||
if ((event.key == Qt.Key_Return)
|
if ((event.key == Qt.Key_Return)
|
||||||
&& (event.modifiers & Qt.ControlModifier)) {
|
&& (event.modifiers & Qt.ControlModifier)) {
|
||||||
txt = true
|
txt = true
|
||||||
|
|
||||||
x = -100
|
x = -100
|
||||||
y = -100
|
y = -100
|
||||||
visible = false
|
visible = false
|
||||||
focus = true
|
focus = true
|
||||||
enabled = false
|
enabled = false
|
||||||
opacity = 0
|
opacity = 0
|
||||||
textEdit1.focus = false
|
textEdit1.focus = false
|
||||||
|
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.key == Qt.Key_Escape) {
|
if (event.key == Qt.Key_Escape) {
|
||||||
txt = false
|
txt = false
|
||||||
x = -100
|
x = -100
|
||||||
y = -100
|
y = -100
|
||||||
visible = false
|
visible = false
|
||||||
focus = true
|
focus = true
|
||||||
enabled = false
|
enabled = false
|
||||||
opacity = 0
|
opacity = 0
|
||||||
textEdit1.focus = false
|
textEdit1.focus = false
|
||||||
|
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea {
|
TextArea {
|
||||||
id: textEdit1
|
id: textEdit1
|
||||||
objectName: "textEdit1"
|
objectName: "textEdit1"
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
clip: true
|
clip: true
|
||||||
textFormat: Text.AutoText
|
textFormat: Text.AutoText
|
||||||
visible: true
|
visible: true
|
||||||
font.pixelSize: 12
|
font.pixelSize: 12
|
||||||
z: 99
|
z: 99
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
id: data1
|
id: data1
|
||||||
@ -241,5 +239,4 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
22
qml/cell.qml
22
qml/cell.qml
@ -30,26 +30,32 @@ Rectangle {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
acceptedButtons: Qt.AllButtons
|
acceptedButtons: Qt.AllButtons
|
||||||
|
|
||||||
onMouseXChanged: if (containsMouse) {
|
onMouseXChanged: cellHover()
|
||||||
parent.parent.border.color = "skyblue"
|
|
||||||
parent.parent.color = "darkblue"
|
|
||||||
parent.color = "white"
|
|
||||||
} else if (focus) {
|
|
||||||
parent.color = "black"
|
|
||||||
}
|
|
||||||
|
|
||||||
onExited: focusChanged(focus)
|
onExited: focusChanged(focus)
|
||||||
|
|
||||||
|
function cellHover() {
|
||||||
|
if (containsMouse) {
|
||||||
|
parent.parent.border.color = "skyblue"
|
||||||
|
parent.parent.color = "darkblue"
|
||||||
|
parent.color = "white"
|
||||||
|
} else if (focus) {
|
||||||
|
parent.color = "black"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function notSelected() {
|
function notSelected() {
|
||||||
|
|
||||||
parent.parent.border.color = "black"
|
parent.parent.border.color = "black"
|
||||||
parent.parent.color = "white"
|
parent.parent.color = "white"
|
||||||
parent.color = "black"
|
parent.color = "black"
|
||||||
|
cellHover()
|
||||||
}
|
}
|
||||||
|
|
||||||
function selected() {
|
function selected() {
|
||||||
parent.parent.border.color = "blue"
|
parent.parent.border.color = "blue"
|
||||||
|
parent.color = "black"
|
||||||
parent.parent.color = "gainsboro"
|
parent.parent.color = "gainsboro"
|
||||||
|
cellHover()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,5 @@ Image {
|
|||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
|
//cache: false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user