diff --git a/imagick.go b/imagick.go index e0d18d0..6ee803e 100644 --- a/imagick.go +++ b/imagick.go @@ -2,6 +2,7 @@ package main import ( + "strings" "bytes" "image" "log" @@ -69,7 +70,7 @@ func resizeImage(mw *imagick.MagickWand, newWidth, newHeight int, keepSpecSize, } //getImage() from imagick to image.RGBA -func (cl cell) getImage(width, height int) (img *image.RGBA) { +func (cl *cell) getImage(width, height int) (img *image.RGBA) { mw := cl.img.GetImage() if (width == 0) || (height == 0) { width = int(mw.GetImageWidth()) @@ -88,10 +89,8 @@ func (cl cell) getImage(width, height int) (img *image.RGBA) { return } -// Text effect 1 - shadow effect using MagickShadowImage -func textEffect1() { - imagick.Initialize() - defer imagick.Terminate() +// adding text to image copied from example +func (cl *cell) imgtext() { mw := imagick.NewMagickWand() defer mw.Destroy() dw := imagick.NewDrawingWand() @@ -117,7 +116,7 @@ func textEffect1() { dw.SetTextAntialias(true) // Now draw the text - dw.Annotation(25, 65, "Magick") + dw.Annotation(25, 65, cl.text) // Draw the image on to the mw mw.DrawImage(dw) @@ -155,7 +154,7 @@ func findfonts() { if err != nil { log.Print(err) } - fontlst = strings.Seperate(out.String(), "\n") + fontlst = strings.Split(out.String(), "\n") } func round(a float64) int { diff --git a/main.go b/main.go index ad82e63..357327f 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "fmt" + "image/color" "os" "path/filepath" @@ -21,6 +22,13 @@ type cell struct { qmlimg qml.Object qmlcell qml.Object index int + font struct { + name string + size int + color color.RGBA + outline float32 + outlineColor color.RGBA + } } type slide []*cell @@ -56,7 +64,7 @@ func run() error { return err } - edtQml, err = engine.LoadFile(path + "/qml/tst.qml") + edtQml, err = engine.LoadFile(path + "/qml/songEdit.qml") if err != nil { return err } @@ -127,7 +135,7 @@ func (sl *slide) add( /*cl *cell*/ ) { } -//(cell) remove() should destroy everything +//(cell) remove() should destroy everything for this cell func (cl *cell) remove() { cl.text = "" cl.qmlimg.Destroy() @@ -144,7 +152,7 @@ func (sl *slide) remove(i int) { *sl, (*sl)[len((*sl))-1] = append((*sl)[:i], (*sl)[i+1:]...), nil } -//Toggle lazy wanted a func for it +//Toggle, lazy wanted a func for it func (bl *Bool) Toggle() { if *bl == false { *bl = true diff --git a/qml/songEdit.qml b/qml/songEdit.qml index 02f8a9d..7c35bd1 100755 --- a/qml/songEdit.qml +++ b/qml/songEdit.qml @@ -7,6 +7,20 @@ ApplicationWindow { minimumHeight: 480 minimumWidth: 640 + ColorDialog { + id: textClrDialog + //objectname: "textClrDialog" + title: "Please choose a color for the text" + showAlphaChannel: true + } + + ColorDialog { + id: outlineClrDialog + //objectname: "outlineClrDialog" + title: "Please choose a color for the text" + showAlphaChannel: true + } + menuBar: MenuBar { Menu { title: "&File" @@ -34,7 +48,7 @@ ApplicationWindow { Menu { title: "&Help" MenuItem { - action: aboutAction + //action: aboutAction } } } @@ -233,17 +247,18 @@ ApplicationWindow { objectName: "imgPicker" } } - TextEdit { + TextArea { 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 + selectByKeyboard: true + selectByMouse: true } } } diff --git a/xml.go b/xml.go deleted file mode 100644 index b6938b0..0000000 --- a/xml.go +++ /dev/null @@ -1,60 +0,0 @@ -// PresentationApp project xml.go -package main - -type _ struct { - Song struct { - Version string `xml:"version,attr"` - CreatedIn string `xml:"createdIn,attr"` - ModifiedIn string `xml:"modifiedIn,attr"` - ModifiedDate string `xml:"modifiedDate,attr"` - Properties struct { - Copyright string `xml:"copyright,omitempty"` - CcliNo string `xml:"ccliNo,omitempty"` - Released string `xml:"released,omitempty"` - Transposition string `xml:"transposition,omitempty"` - Key string `xml:"key,omitempty"` - Variant string `xml:"variant,omitempty"` - Publisher string `xml:"publisher,omitempty"` - Version string `xml:"version,omitempty"` - Keywords string `xml:"keywords,omitempty"` - VerseOrder string `xml:"verseOrder"` - Comments []string `xml:"comments,omitempty"` - - Title []struct { - Original string `xml:"original,attr,omitempty"` - Lang string `xml:"lang,attr,omitempty"` - } `xml:"titles>title"` - - Author []struct { - Type string `xml:"type,attr,omitempty"` - Lang string `xml:"lang,attr,omitempty"` - } `xml:"authors>author,omitempty"` - - Tempo struct { - Type string `xml:"type,attr,omitempty"` - Value string `xml:",innerxml"` - } `xml:"tempo,omitempty"` - - Songbook []struct { - Name string `xml:"name,attr"` - Entry string `xml:"entry,attr,omitempty"` - } `xml:"songbooks>songbook,omitempty"` - - Theme []struct { - Lang string `xml:"lang,attr,omitempty"` - Value string `xml:",innerxml"` - } `xml:"themes>theme"` - } `xml:"properties"` - - Verse []struct { - Lang string `xml:"lang,attr,omitempty"` - Transliteration string `xml:"translit,attr,omitempty"` - Name string `xml:"name,attr"` - Lines []struct { - Part string `xml:"part,attr"` - Value string `xml:",innerxml"` - } `xml:"lines"` - Comments []string `xml:"comments,omitempty"` - } `xml:"lyrics>verse"` - } `xml:"song"` -}