fix changing images and some ui glitches
This commit is contained in:
parent
d81fb1f7fb
commit
ed73ea2527
@ -4,13 +4,16 @@ package main
|
||||
import (
|
||||
"image"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var imgready = false
|
||||
|
||||
func imgProvider(id string, width, height int) image.Image {
|
||||
if imgready {
|
||||
i, _ := strconv.Atoi(id)
|
||||
if imgready && (len(id) > 0) {
|
||||
//fmt.Println("source (provider): ", id)
|
||||
i1 := strings.Index(id, `;`)
|
||||
i, _ := strconv.Atoi(id[:i1])
|
||||
return slides[i].getImage(width, height)
|
||||
|
||||
} else {
|
||||
|
25
main.go
25
main.go
@ -10,6 +10,8 @@ import (
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
|
||||
"strconv"
|
||||
|
||||
"github.com/go-gl/gl/v2.1/gl"
|
||||
"github.com/go-gl/glfw/v3.1/glfw"
|
||||
"github.com/kardianos/osext"
|
||||
@ -306,9 +308,9 @@ func (cl *cell) setSignal() {
|
||||
} else {
|
||||
selSlide = cl.qmlcell.Int("index")
|
||||
cl.qmlcell.ObjectByName("cellMouse").Set("focus", true)
|
||||
cl.img.FlipImage()
|
||||
setupScene()
|
||||
}
|
||||
cl.clearcache()
|
||||
})
|
||||
|
||||
cl.qmlcell.ObjectByName("cellMouse").On("focusChanged", func(focus bool) {
|
||||
@ -325,10 +327,8 @@ func (cl *cell) setSignal() {
|
||||
|
||||
slides[rhtClkCell].img.Clear()
|
||||
slides[rhtClkCell].img.ReadImage(url)
|
||||
fmt.Println(url)
|
||||
setupScene()
|
||||
|
||||
fmt.Println(window.ObjectByName("imgpicker").String("fileUrl"))
|
||||
cl.clearcache()
|
||||
})
|
||||
|
||||
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*/ ) {
|
||||
var cl cell
|
||||
|
||||
@ -368,8 +380,11 @@ func (sl *slide) addCell( /*cl *cell*/ ) {
|
||||
cl.setSignal()
|
||||
|
||||
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("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("index", cl.index)
|
||||
|
||||
|
5
main.qml
5
main.qml
@ -16,10 +16,10 @@ ApplicationWindow {
|
||||
height: 600
|
||||
property bool cls: false
|
||||
|
||||
|
||||
/*function getFileDialogUrl() {
|
||||
return
|
||||
}*/
|
||||
|
||||
onClosing: if (!cls) {
|
||||
close.accepted = false
|
||||
}
|
||||
@ -64,7 +64,6 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Menu {
|
||||
objectName: "mnuCtx"
|
||||
title: "new image..."
|
||||
@ -75,7 +74,6 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SplitView {
|
||||
id: mainSlider
|
||||
objectName: "mainSlider"
|
||||
@ -241,5 +239,4 @@ ApplicationWindow {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
12
qml/cell.qml
12
qml/cell.qml
@ -30,26 +30,32 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.AllButtons
|
||||
|
||||
onMouseXChanged: if (containsMouse) {
|
||||
onMouseXChanged: cellHover()
|
||||
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"
|
||||
}
|
||||
|
||||
onExited: focusChanged(focus)
|
||||
}
|
||||
|
||||
function notSelected() {
|
||||
|
||||
parent.parent.border.color = "black"
|
||||
parent.parent.color = "white"
|
||||
parent.color = "black"
|
||||
cellHover()
|
||||
}
|
||||
|
||||
function selected() {
|
||||
parent.parent.border.color = "blue"
|
||||
parent.color = "black"
|
||||
parent.parent.color = "gainsboro"
|
||||
cellHover()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,5 @@ Image {
|
||||
fillMode: Image.PreserveAspectFit
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
|
||||
|
||||
//cache: false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user