Debian Codegraph @

tests/manual/distancefieldtext/main.qml

raw
1 // Copyright (C) 2016 Klaralvdalens Datakonsult AB (KDAB).
2 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4 import QtQuick 2.0
5 import QtQuick.Scene3D 2.0
6
7 Item {
8 id: root
9 property string currentFont
10 property bool bold : false
11 property bool italic : false
12
13 Scene3D {
14 id: scene3d
15 anchors.left: parent.left
16 anchors.top: parent.top
17 anchors.bottom: parent.bottom
18 anchors.right: settingsPane.left
19 focus: true
20 aspects: ["input", "logic", "render"]
21 cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
22
23 TextScene {
24 id: textScene
25 fontFamily: root.currentFont
26 fontBold: bold
27 fontItalic: italic
28 }
29 }
30
31 MouseArea {
32 anchors.fill: parent
33 onClicked: {
34 textScene.clicked()
35 }
36 }
37
38 Item {
39 id: settingsPane
40
41 anchors.right: parent.right
42 anchors.top: parent.top
43 anchors.bottom: parent.bottom
44 width: 400
45
46 Rectangle {
47 width: parent.width/2
48 height:50
49 color: root.bold ? "#000066" : "#222222"
50 Text {
51 anchors.centerIn: parent
52 text: "Bold"
53 font.pointSize: 20
54 color: "#ffffff"
55 }
56 MouseArea {
57 anchors.fill: parent
58 onClicked: root.bold = !root.bold
59 }
60 }
61
62 Rectangle {
63 x: parent.width/2
64 width: parent.width/2
65 height:50
66 color: root.italic ? "#000066" : "#222222"
67 Text {
68 anchors.centerIn: parent
69 text: "Italic"
70 font.pointSize: 20
71 color: "#ffffff"
72 }
73 MouseArea {
74 anchors.fill: parent
75 onClicked: root.italic = !root.italic
76 }
77 }
78
79 ListView {
80 anchors.fill: parent
81 anchors.topMargin: 50
82 model: Qt.fontFamilies()
83
84 delegate: Rectangle {
85 height: fontFamilyText.height + 10
86 width: parent.width
87 color: (modelData == root.currentFont) ? "#000066" : "#222222"
88
89 Text {
90 id: fontFamilyText
91 anchors.centerIn: parent
92 font.pointSize: 14
93 font.family: modelData
94 text: modelData
95 color: "#ffffff"
96 }
97
98 MouseArea {
99 anchors.fill: parent
100 onClicked: {
101 root.currentFont = modelData;
102
103 }
104 }
105 }
106 }
107 }
108 }