summaryrefslogtreecommitdiffstats
path: root/tests/manual/distancefieldtext/main.qml
blob: 599a5d26afe7b9a2a3270fa397369c1fa29f308c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick 2.0
import QtQuick.Scene3D 2.0

Item {
    id: root
    property string currentFont
    property bool bold : false
    property bool italic : false

    Scene3D {
        id: scene3d
        anchors.left: parent.left
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.right: settingsPane.left
        focus: true
        aspects: ["input", "logic", "render"]
        cameraAspectRatioMode: Scene3D.AutomaticAspectRatio

        TextScene {
            id: textScene
            fontFamily: root.currentFont
            fontBold: bold
            fontItalic: italic
        }
    }

    MouseArea {
        anchors.fill: parent
        onClicked: {
            textScene.clicked()
        }
    }

    Item {
        id: settingsPane

        anchors.right: parent.right
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        width: 400

        Rectangle {
            width: parent.width/2
            height:50
            color: root.bold ? "#000066" : "#222222"
            Text {
                anchors.centerIn: parent
                text: "Bold"
                font.pointSize: 20
                color: "#ffffff"
            }
            MouseArea {
                anchors.fill: parent
                onClicked: root.bold = !root.bold
            }
        }

        Rectangle {
            x: parent.width/2
            width: parent.width/2
            height:50
            color: root.italic ? "#000066" : "#222222"
            Text {
                anchors.centerIn: parent
                text: "Italic"
                font.pointSize: 20
                color: "#ffffff"
            }
            MouseArea {
                anchors.fill: parent
                onClicked: root.italic = !root.italic
            }
        }

        ListView {
            anchors.fill: parent
            anchors.topMargin: 50
            model: Qt.fontFamilies()

            delegate: Rectangle {
                height: fontFamilyText.height + 10
                width: parent.width
                color: (modelData == root.currentFont) ? "#000066" : "#222222"

                Text {
                    id: fontFamilyText
                    anchors.centerIn: parent
                    font.pointSize: 14
                    font.family: modelData
                    text: modelData
                    color: "#ffffff"
                }

                MouseArea {
                    anchors.fill: parent
                    onClicked: {
                        root.currentFont = modelData;

                    }
                }
            }
        }
    }
}