-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
197 lines (167 loc) · 6.79 KB
/
main.qml
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import QtQuick 2.12
import QtQuick.Window 2.13
import QtQuick.Controls.Material 2.3
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3
import FontEditor 1.0
import QtGraphicalEffects 1.0
ApplicationWindow {
visible: true
width: 1200
height: 960
title: qsTr("CFont editor")
menuBar: MenuBar {
Menu {
title: "File"
MenuItem {
text: "New font..."
// shortcut: StandardKey.New
}
}
}
FontSelector {
id: _selector
fontIndex: _fontCbox.currentIndex
encoding: _encodingBox.currentText
pointSize: _sizeSpinner.value
antialiased: _antialiasing.checked
}
ToolBar {
id: _toolbar
RowLayout {
Label {
text: "Font:"
}
ComboBox {
id: _fontCbox
Layout.minimumWidth: 300
model: _selector.fonts
editable: true
onAccepted: {
focus = false
}
}
ComboBox {
id: _weightCombo
model: ["Thin", "ExtraLight", "Light", "Normal", "Medium", "DemiBold", "Bold", "ExtraBold", "Black"]
property var weights: [Font.Thin, Font.ExtraLight, Font.Light, Font.Normal, Font.Medium, Font.DemiBold, Font.Bold, Font.ExtraBold, Font.Black]
onCurrentIndexChanged: {
_selector.weight = weights[currentIndex]
}
}
ToolButton {
id: _antialiasing
text: "AA"
checkable: true
}
Label {
text: "Encoding:"
}
ComboBox {
id: _encodingBox
model: _selector.encodings
editable: true
width: 300
onAccepted: {
focus = false
}
}
Label {
text: "Pixel size:"
}
SpinBox {
id: _sizeSpinner
Component.onCompleted: {
value = 20;
}
}
ToolButton {
id: _renderAsText
checkable: true
text: "Render as text"
}
Label {
text: _selector.fontSize.width + "x" + _selector.fontSize.height
}
}
}
RowLayout {
anchors.fill: parent
anchors.margins: 8
anchors.topMargin: _toolbar.height + 8
// ColumnLayout {
// id: zoomView
// Layout.minimumWidth: glyphGrid.currentItem.glyph.width * 10
// Glyph {
// Layout.minimumWidth: glyphGrid.currentItem.glyph.width * 10
// Layout.minimumHeight: glyphGrid.currentItem.glyph.height * 10
// charCode: glyphGrid.currentItem.glyph.charCode
// }
// }
Flow {
id: glyphGrid
Layout.fillWidth: true
Layout.fillHeight: true
Layout.minimumWidth: 600
spacing: 4
// columnSpacing: 2
// rowSpacing: 2
// columns: 16
// rows: 16
Repeater {
model: 255 - 32
delegate: Glyph {
id: _glyph
width: implicitWidth * 2
height: fontSelector.fontHeight * 2
transform: Scale {
xScale: 2.0
yScale: 2.0
origin.x: 0
origin.y: 0
}
// anchors.centerIn: parent
charCode: index + 32
fontSelector: _selector
color: "#008"
backgroundColor: "#fff"
renderAsText: _renderAsText.checked
}
// Rectangle {
// clip: true
// implicitHeight: Math.max(_selector.fontHeight + 22, 60)
// implicitWidth: Math.max(_selector.fontWidth + 8, 48)
// property bool isCurrent: GridView.isCurrentItem
// property alias glyph: _glyph
// color: "#ddd"
// border.width: isCurrent ? 4 : 1
// border.color: isCurrent ? "#0FF" : "#000"
// Text {
// id: _heading
// text: _glyph.glyph + " (" + _glyph.charCode + ")"
// width: parent.width
// horizontalAlignment: Qt.AlignHCenter
// font.pointSize: 8
// }
// Rectangle {
// width: _selector.fontWidth + 4
// height: _selector.fontHeight + 4
// border.color: "#0f0"
// border.width: 1
// anchors.centerIn: parent
// anchors.verticalCenterOffset: _heading.paintedHeight / 2
// color: _glyph.backgroundColor
// }
// // MouseArea {
// // anchors.fill: parent
// // enabled: true
// // onClicked: {
// // console.log("Clicked", glyphGrid.currentIndex, index)
// // glyphGrid.currentIndex = index
// // }
// // }
// }
}
}
}
}