no more gltext
copy example from imagick have sonEdit show at start (only for now) remake songEdit.qml (was causing crash in qtcreator)
This commit is contained in:
parent
b85f6c86c8
commit
b4737bf4f8
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,3 +22,5 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
14
glfw.go
14
glfw.go
@ -5,12 +5,10 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
|
||||||
|
|
||||||
"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"
|
||||||
"github.com/lordwelch/qml"
|
"github.com/lordwelch/qml"
|
||||||
"github.com/go-gl/gltext"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -21,18 +19,8 @@ var (
|
|||||||
projMonitor *glfw.Monitor
|
projMonitor *glfw.Monitor
|
||||||
tex1 *uint32 //identifier for opengl texture
|
tex1 *uint32 //identifier for opengl texture
|
||||||
texDel Bool //if texture should be deleted
|
texDel Bool //if texture should be deleted
|
||||||
flt *os.File
|
|
||||||
f *gltext.Font
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadfont(){
|
|
||||||
|
|
||||||
flt,err = os.Open("Comfortaa-Regular.ttf")
|
|
||||||
if err != nil {
|
|
||||||
f, err = gltext.LoadTruetype(flt, 30, 32, 255, gltext.LeftToRight)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func setupScene() {
|
func setupScene() {
|
||||||
|
|
||||||
gl.ClearColor(0, 0, 0, 0)
|
gl.ClearColor(0, 0, 0, 0)
|
||||||
@ -75,7 +63,6 @@ func drawSlide() {
|
|||||||
gl.Vertex3f(-1, -1, 0)
|
gl.Vertex3f(-1, -1, 0)
|
||||||
|
|
||||||
gl.End()
|
gl.End()
|
||||||
f.Printf(5,10,"test")
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,7 +142,6 @@ func glInit() {
|
|||||||
if err := gl.Init(); err != nil {
|
if err := gl.Init(); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
loadfont()
|
|
||||||
|
|
||||||
win.SetPos(projMonitor.GetPos())
|
win.SetPos(projMonitor.GetPos())
|
||||||
setupScene()
|
setupScene()
|
||||||
|
83
imagick.go
83
imagick.go
@ -2,12 +2,19 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
"image"
|
"image"
|
||||||
. "math"
|
"log"
|
||||||
|
"math"
|
||||||
|
"os/exec"
|
||||||
|
|
||||||
"gopkg.in/gographics/imagick.v2/imagick"
|
"gopkg.in/gographics/imagick.v2/imagick"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
fontlst []string
|
||||||
|
)
|
||||||
|
|
||||||
/*resizeImage() mw fullsize image
|
/*resizeImage() mw fullsize image
|
||||||
newwidth, newheight = size to be resized to
|
newwidth, newheight = size to be resized to
|
||||||
keepSpecSize = return image with exactly the size specified or just the size of the resized image
|
keepSpecSize = return image with exactly the size specified or just the size of the resized image
|
||||||
@ -81,9 +88,79 @@ func (cl cell) getImage(width, height int) (img *image.RGBA) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Text effect 1 - shadow effect using MagickShadowImage
|
||||||
|
func textEffect1() {
|
||||||
|
imagick.Initialize()
|
||||||
|
defer imagick.Terminate()
|
||||||
|
mw := imagick.NewMagickWand()
|
||||||
|
defer mw.Destroy()
|
||||||
|
dw := imagick.NewDrawingWand()
|
||||||
|
defer dw.Destroy()
|
||||||
|
pw := imagick.NewPixelWand()
|
||||||
|
defer pw.Destroy()
|
||||||
|
pw.SetColor("none")
|
||||||
|
|
||||||
|
// Create a new transparent image
|
||||||
|
mw.NewImage(0, 0, pw)
|
||||||
|
|
||||||
|
// Set up a 72 point white font
|
||||||
|
pw.SetColor("white")
|
||||||
|
dw.SetFillColor(pw)
|
||||||
|
dw.SetFont("Verdana-Bold-Italic")
|
||||||
|
dw.SetFontSize(72)
|
||||||
|
|
||||||
|
// Add a black outline to the text
|
||||||
|
pw.SetColor("black")
|
||||||
|
dw.SetStrokeColor(pw)
|
||||||
|
|
||||||
|
// Turn antialias on - not sure this makes a difference
|
||||||
|
dw.SetTextAntialias(true)
|
||||||
|
|
||||||
|
// Now draw the text
|
||||||
|
dw.Annotation(25, 65, "Magick")
|
||||||
|
|
||||||
|
// Draw the image on to the mw
|
||||||
|
mw.DrawImage(dw)
|
||||||
|
|
||||||
|
// Trim the image down to include only the text
|
||||||
|
mw.TrimImage(0)
|
||||||
|
|
||||||
|
// equivalent to the command line +repage
|
||||||
|
mw.ResetImagePage("")
|
||||||
|
|
||||||
|
// Make a copy of the text image
|
||||||
|
cw := mw.Clone()
|
||||||
|
|
||||||
|
// Set the background colour to blue for the shadow
|
||||||
|
pw.SetColor("blue")
|
||||||
|
mw.SetImageBackgroundColor(pw)
|
||||||
|
|
||||||
|
// Opacity is a real number indicating (apparently) percentage
|
||||||
|
mw.ShadowImage(70, 4, 5, 5)
|
||||||
|
|
||||||
|
// Composite the text on top of the shadow
|
||||||
|
mw.CompositeImage(cw, imagick.COMPOSITE_OP_OVER, 5, 5)
|
||||||
|
cw.Destroy()
|
||||||
|
|
||||||
|
// and write the result
|
||||||
|
mw.WriteImage("text_shadow.png")
|
||||||
|
}
|
||||||
|
|
||||||
|
func findfonts() {
|
||||||
|
cmd := exec.Command("grep", "-ivE", `\-Oblique$|-Bold$|-Italic$|-Light$`)
|
||||||
|
cmd.Stdin = strings.NewReader(strings.Join(imagick.QueryFonts("*"), "\n"))
|
||||||
|
var out bytes.Buffer
|
||||||
|
cmd.Stdout = &out
|
||||||
|
err := cmd.Run()
|
||||||
|
if err != nil {
|
||||||
|
log.Print(err)
|
||||||
|
}
|
||||||
|
fontlst = strings.Seperate(out.String(), "\n")
|
||||||
|
}
|
||||||
|
|
||||||
func round(a float64) int {
|
func round(a float64) int {
|
||||||
if a < 0 {
|
if a < 0 {
|
||||||
return int(Ceil(a - 0.5))
|
return int(math.Ceil(a - 0.5))
|
||||||
}
|
}
|
||||||
return int(Floor(a + 0.5))
|
return int(math.Floor(a + 0.5))
|
||||||
}
|
}
|
||||||
|
15
main.go
15
main.go
@ -45,7 +45,7 @@ func main() {
|
|||||||
func run() error {
|
func run() error {
|
||||||
imagick.Initialize()
|
imagick.Initialize()
|
||||||
|
|
||||||
engine := qml.NewEngine()
|
engine = qml.NewEngine()
|
||||||
engine.AddImageProvider("images", imgProvider)
|
engine.AddImageProvider("images", imgProvider)
|
||||||
//path for qml files TODO: change to somewhere else
|
//path for qml files TODO: change to somewhere else
|
||||||
path, err = osext.ExecutableFolder()
|
path, err = osext.ExecutableFolder()
|
||||||
@ -56,6 +56,11 @@ func run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
edtQml, err = engine.LoadFile(path + "/qml/tst.qml")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
cellQml, err = engine.LoadFile(path + "/qml/cell.qml")
|
cellQml, err = engine.LoadFile(path + "/qml/cell.qml")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -66,7 +71,8 @@ func run() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
window = mainQml.CreateWindow(nil)
|
window = mainQml.CreateWindow(engine.Context())
|
||||||
|
window2 := edtQml.CreateWindow(engine.Context())
|
||||||
|
|
||||||
textEdit = window.ObjectByName("textEdit")
|
textEdit = window.ObjectByName("textEdit")
|
||||||
//signals for whole qml
|
//signals for whole qml
|
||||||
@ -77,6 +83,7 @@ func run() error {
|
|||||||
imgready = true
|
imgready = true
|
||||||
|
|
||||||
window.Show()
|
window.Show()
|
||||||
|
window2.Show()
|
||||||
slides[0].clearcache()
|
slides[0].clearcache()
|
||||||
qml.RunMain(glInit)
|
qml.RunMain(glInit)
|
||||||
|
|
||||||
@ -94,7 +101,7 @@ func (sl *slide) add( /*cl *cell*/ ) {
|
|||||||
|
|
||||||
//increase count on parent QML element
|
//increase count on parent QML element
|
||||||
window.ObjectByName("gridRect").Set("count", window.ObjectByName("gridRect").Int("count")+1)
|
window.ObjectByName("gridRect").Set("count", window.ObjectByName("gridRect").Int("count")+1)
|
||||||
cl.qmlcell = cellQml.Create(nil)
|
cl.qmlcell = cellQml.Create(engine.Context())
|
||||||
cl.qmlcell.Set("objectName", fmt.Sprintf("cellRect%d", len(*sl)))
|
cl.qmlcell.Set("objectName", fmt.Sprintf("cellRect%d", len(*sl)))
|
||||||
cl.qmlcell.Set("parent", window.ObjectByName("data1"))
|
cl.qmlcell.Set("parent", window.ObjectByName("data1"))
|
||||||
cl.qmlcell.Set("index", cl.index)
|
cl.qmlcell.Set("index", cl.index)
|
||||||
@ -111,7 +118,7 @@ func (sl *slide) add( /*cl *cell*/ ) {
|
|||||||
*sl = append(*sl, &cl)
|
*sl = append(*sl, &cl)
|
||||||
|
|
||||||
//seperate image object in QML
|
//seperate image object in QML
|
||||||
cl.qmlimg = qimg.Create(nil)
|
cl.qmlimg = qimg.Create(engine.Context())
|
||||||
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"+`;`+"0", cl.index))
|
cl.qmlimg.Set("source", fmt.Sprintf("image://images/%d"+`;`+"0", cl.index))
|
||||||
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
cl.qmlimg.Set("parent", window.ObjectByName("data2"))
|
||||||
|
2
main.qml
2
main.qml
@ -26,7 +26,9 @@ ApplicationWindow {
|
|||||||
|
|
||||||
FileDialog {
|
FileDialog {
|
||||||
id: imgpicker
|
id: imgpicker
|
||||||
|
// @disable-check M16
|
||||||
title: "Choose an image for this slide"
|
title: "Choose an image for this slide"
|
||||||
|
// @disable-check M16
|
||||||
objectName: "imgpicker"
|
objectName: "imgpicker"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
qml.go
2
qml.go
@ -17,8 +17,10 @@ var (
|
|||||||
qimg qml.Object //file for the image object
|
qimg qml.Object //file for the image object
|
||||||
cellQml qml.Object //file for the cell object
|
cellQml qml.Object //file for the cell object
|
||||||
mainQml qml.Object //main QML file
|
mainQml qml.Object //main QML file
|
||||||
|
edtQml qml.Object
|
||||||
textEdit qml.Object
|
textEdit qml.Object
|
||||||
window *qml.Window
|
window *qml.Window
|
||||||
|
engine *qml.Engine
|
||||||
quickEdit Bool = false
|
quickEdit Bool = false
|
||||||
imgready Bool = false
|
imgready Bool = false
|
||||||
)
|
)
|
||||||
|
203
qml/songEdit.qml
203
qml/songEdit.qml
@ -1,12 +1,11 @@
|
|||||||
import QtQuick 2.4
|
import QtQuick 2.4
|
||||||
import QtQuick.Controls 1.3
|
import QtQuick.Controls 1.3
|
||||||
import QtQuick.Window 2.0
|
import QtQuick.Layouts 1.1
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
|
||||||
ApplicationWindow {
|
ApplicationWindow {
|
||||||
id: songEdit
|
minimumHeight: 480
|
||||||
title: "Song Editor"
|
minimumWidth: 640
|
||||||
visible: true
|
|
||||||
objectName: "SongEdit"
|
|
||||||
|
|
||||||
menuBar: MenuBar {
|
menuBar: MenuBar {
|
||||||
Menu {
|
Menu {
|
||||||
@ -39,32 +38,43 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GroupBox {
|
|
||||||
anchors.top: parent
|
|
||||||
anchors.bottom: textArea
|
|
||||||
ComboBox {
|
|
||||||
id: verseSelector
|
|
||||||
model: ["V1", "V2"]
|
|
||||||
anchors.left: parent
|
|
||||||
anchors.right: imageSelector
|
|
||||||
anchors.top: parent
|
|
||||||
anchors.bottom: parent
|
|
||||||
}
|
|
||||||
ComboBox {
|
|
||||||
id: imageSelector
|
|
||||||
anchors.left: verseSelector
|
|
||||||
anchors.right: parent
|
|
||||||
anchors.top: parent
|
|
||||||
anchors.bottom: parent
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SplitView {
|
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: rowLayout1
|
||||||
|
enabled: true
|
||||||
|
smooth: true
|
||||||
|
antialiasing: true
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: rowlayout3
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.alignment: Qt.AlignTop
|
||||||
|
Layout.maximumWidth: 225
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: columnlayout2
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: label1
|
||||||
|
text: qsTr("Label")
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
}
|
||||||
ListView {
|
ListView {
|
||||||
width: 180
|
id: listView1
|
||||||
height: 200
|
clip: true
|
||||||
|
highlight: Rectangle {
|
||||||
|
color: "lightsteelblue"
|
||||||
|
radius: 5
|
||||||
|
}
|
||||||
|
width: 110
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
focus: true
|
||||||
|
keyNavigationWraps: true
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "v1"
|
name: "v1"
|
||||||
@ -82,20 +92,41 @@ ApplicationWindow {
|
|||||||
name: "v5"
|
name: "v5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate: Component {
|
delegate: Item {
|
||||||
id: contactsDelegate
|
x: 5
|
||||||
|
width: 80
|
||||||
|
height: 40
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: contactInfo
|
|
||||||
text: name
|
text: name
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
font.bold: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
focus: true
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: columnlayout3
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
Label {
|
||||||
|
id: label2
|
||||||
|
text: qsTr("Label")
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
}
|
}
|
||||||
ListView {
|
ListView {
|
||||||
width: 180
|
id: listView2
|
||||||
height: 200
|
clip: true
|
||||||
|
highlight: Rectangle {
|
||||||
|
color: "lightsteelblue"
|
||||||
|
radius: 5
|
||||||
|
}
|
||||||
|
width: 110
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
|
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
ListElement {
|
ListElement {
|
||||||
name: "v1"
|
name: "v1"
|
||||||
@ -113,17 +144,107 @@ ApplicationWindow {
|
|||||||
name: "v5"
|
name: "v5"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegate: Component {
|
delegate: Item {
|
||||||
id: contactsDelegate1
|
x: 5
|
||||||
|
width: 80
|
||||||
|
height: 40
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: contactInfo
|
|
||||||
text: name
|
text: name
|
||||||
|
anchors.verticalCenter: parent.verticalCenter
|
||||||
|
font.bold: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
focus: true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TextArea {
|
}
|
||||||
id: textArea
|
|
||||||
|
ColumnLayout {
|
||||||
|
id: columnlayout4
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
Layout.fillHeight: true
|
||||||
|
|
||||||
|
RowLayout {
|
||||||
|
id: rowLayout3
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
Layout.maximumHeight: 30
|
||||||
|
Layout.minimumHeight: 30
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: textColorPicker
|
||||||
|
objectName: "textColorPicker"
|
||||||
|
text: "Text Color"
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
tooltip: "Pick the color of the text"
|
||||||
|
}
|
||||||
|
|
||||||
|
ToolButton {
|
||||||
|
id: outlineColorPicker
|
||||||
|
objectName: "outlineColorPicker"
|
||||||
|
text: "Outline Color"
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
tooltip: "Pick the color of the text outline"
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: fontPicker
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
objectName: "fontPicker"
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
id: fontSize
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
objectName: "fontSize"
|
||||||
|
maximumValue: 1000
|
||||||
|
value: 1
|
||||||
|
suffix: "Pt"
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBox {
|
||||||
|
id: outlineSize
|
||||||
|
stepSize: 0.1
|
||||||
|
decimals: 1
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
objectName: "outlineSize"
|
||||||
|
maximumValue: 10
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RowLayout {
|
||||||
|
id: rowLayout2
|
||||||
|
Layout.preferredHeight: 30
|
||||||
|
Layout.maximumHeight: 30
|
||||||
|
Layout.minimumHeight: 30
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: versePicker
|
||||||
|
objectName: "versePicker"
|
||||||
|
}
|
||||||
|
|
||||||
|
ComboBox {
|
||||||
|
id: imgPicker
|
||||||
|
objectName: "imgPicker"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextEdit {
|
||||||
|
id: textEdit1
|
||||||
|
width: 80
|
||||||
|
height: 20
|
||||||
|
text: qsTr("Text Edit")
|
||||||
|
textFormat: Text.AutoText
|
||||||
|
cursorVisible: true
|
||||||
|
Layout.fillHeight: true
|
||||||
|
Layout.fillWidth: true
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignTop
|
||||||
|
font.pixelSize: 12
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user