1/* GCompris - LyricsArea.qml
2*
3* SPDX-FileCopyrightText: 2018 Aman Kumar Gupta <gupta2140@gmail.com>
4*
5* Authors:
6*   Beth Hadley <bethmhadley@gmail.com> (GTK+ version)
7*   Johnny Jazeix <jazeix@gmail.com> (Qt Quick port)
8*   Aman Kumar Gupta <gupta2140@gmail.com> (Qt Quick port)
9*
10*   SPDX-License-Identifier: GPL-3.0-or-later
11*/
12import QtQuick 2.9
13import GCompris 1.0
14
15import "../../core"
16
17Rectangle {
18    id: lyricsArea
19
20    property string title: ""
21    property string origin: ""
22    property string lyrics: ""
23
24    border.width: 3
25    radius: 5
26    border.color: "black"
27    opacity: 0.8
28    visible: background.isLyricsMode
29    Item {
30        id: melodyTitle
31        width: parent.width
32        height: parent.height / 6
33        GCText {
34            id: titleText
35            fontSizeMode: Text.Fit
36            wrapMode: Text.WordWrap
37            text: qsTr("Title: %1").arg(lyricsArea.title)
38            anchors.fill: parent
39            anchors.rightMargin: parent.width * 0.02
40            anchors.leftMargin: parent.width * 0.02
41            horizontalAlignment: Text.AlignHCenter
42            verticalAlignment: Text.AlignVCenter
43            font.bold: true
44            color: "green"
45        }
46    }
47
48    Rectangle {
49        id: titleUnderline
50        width: titleText.contentWidth
51        height: 3
52        color: "black"
53        anchors.top: melodyTitle.bottom
54        anchors.horizontalCenter: melodyTitle.horizontalCenter
55    }
56
57    Item {
58        id: melodyOrigin
59        width: parent.width
60        height: parent.height / 8
61        anchors.top: titleUnderline.bottom
62        GCText {
63            fontSizeMode: Text.Fit
64            wrapMode: Text.WordWrap
65            text: qsTr("Origin: %1").arg(lyricsArea.origin)
66            anchors.fill: parent
67            anchors.rightMargin: parent.width * 0.02
68            anchors.leftMargin: parent.width * 0.02
69            horizontalAlignment: Text.AlignHCenter
70            verticalAlignment: Text.AlignVCenter
71            font.italic: true
72            color: "red"
73        }
74    }
75
76    Item {
77        id: melodyLyrics
78        width: parent.width
79        height: parent.height - melodyTitle.height - melodyOrigin.height - 20
80        anchors.top: melodyOrigin.bottom
81        GCText {
82            fontSizeMode: Text.Fit
83            wrapMode: Text.WordWrap
84            text: lyricsArea.lyrics
85            anchors.fill: parent
86            anchors.rightMargin: parent.width * 0.05
87            anchors.leftMargin: parent.width * 0.05
88            horizontalAlignment: Text.AlignHCenter
89            verticalAlignment: Text.AlignVCenter
90        }
91    }
92
93    function resetLyricsArea() {
94        lyricsArea.title = ""
95        lyricsArea.origin = ""
96        lyricsArea.lyrics = ""
97        optionsRow.lyricsOrPianoModeIndex = 0
98    }
99
100    function setLyrics(title, origin, lyrics) {
101        resetLyricsArea()
102        lyricsArea.title = title
103        lyricsArea.origin = origin
104        lyricsArea.lyrics = lyrics
105        optionsRow.lyricsOrPianoModeIndex = 1
106    }
107}
108