Skip to content

Commit 0ca36fe

Browse files
committed
New keypad button design
Represent the button pressed state as raising/lowering the button. Hovering is shown separately by a change in color.
1 parent d39ca63 commit 0ca36fe

File tree

3 files changed

+31
-36
lines changed

3 files changed

+31
-36
lines changed

qml/Keypad.qml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ Rectangle {
193193
text: "var"
194194
Layout.preferredWidth: -1
195195
Layout.fillWidth: false
196-
border.width: 1
197196
clip: false
198197
keymap_id: 56
199198
Layout.column: 2
@@ -324,7 +323,6 @@ Rectangle {
324323
NBigButton {
325324
id: nButton7
326325
width: 33
327-
color: "#68cce0"
328326
text: "ctrl"
329327
anchors.top: gridLayout1.top
330328
anchors.topMargin: 0

qml/NButton.qml

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,40 @@ Rectangle {
66
property string back_color: "#223"
77
property string font_color: "#fff"
88
property alias text: label.text
9-
property bool active: pressed || mouseArea.containsMouse
109
property bool pressed: false
1110
// Pressing the right mouse button "locks" the button in enabled state
1211
property bool fixed: false
1312
property int keymap_id: 1
1413

1514
signal clicked()
1615

17-
border.width: active ? 2 : 1
18-
border.color: "#888"
1916
radius: 4
20-
color: active ? active_color : back_color
17+
color: "#888"
18+
19+
Rectangle {
20+
width: parent.width
21+
height: parent.height
22+
x: pressed ? -0 : -1
23+
y: pressed ? -0 : -1
24+
radius: parent.radius
25+
border.width: 1
26+
border.color: parent.color
27+
color: mouseArea.containsMouse ? active_color : back_color
28+
29+
Text {
30+
id: label
31+
text: "Foo"
32+
anchors.fill: parent
33+
anchors.centerIn: parent
34+
font.pixelSize: height*0.55
35+
color: font_color
36+
font.bold: true
37+
// Workaround: Text.AutoText doesn't seem to work for properties (?)
38+
textFormat: text.indexOf(">") == -1 ? Text.PlainText : Text.RichText
39+
verticalAlignment: Text.AlignVCenter
40+
horizontalAlignment: Text.AlignHCenter
41+
}
42+
}
2143

2244
onPressedChanged: {
2345
if(pressed)
@@ -37,20 +59,6 @@ Rectangle {
3759
}
3860
}
3961

40-
Text {
41-
id: label
42-
text: "Foo"
43-
anchors.fill: parent
44-
anchors.centerIn: parent
45-
font.pixelSize: height*0.55
46-
color: font_color
47-
font.bold: true
48-
// Workaround: Text.AutoText doesn't seem to work for properties (?)
49-
textFormat: text.indexOf(">") == -1 ? Text.PlainText : Text.RichText
50-
verticalAlignment: Text.AlignVCenter
51-
horizontalAlignment: Text.AlignHCenter
52-
}
53-
5462
// This is needed to support pressing multiple buttons at once on multitouch
5563
MultiPointTouchArea {
5664
id: multiMouseArea

qml/NDualButton.qml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,31 +36,20 @@ Rectangle {
3636
}
3737

3838
Rectangle {
39-
id: rectangle1
4039
width: 8
41-
height: 20
42-
color: "#222233"
43-
radius: 0
40+
height: 21
41+
color: "#888"
4442
anchors.verticalCenterOffset: 5
45-
anchors.horizontalCenterOffset: 0
46-
z: 0
47-
anchors.verticalCenter: parent.verticalCenter
48-
anchors.horizontalCenter: parent.horizontalCenter
49-
border.width: 1
50-
border.color: "#888"
43+
anchors.centerIn: parent
5144
}
5245

5346
Rectangle {
54-
id: rectangle2
5547
width: 8
5648
height: 18
5749
color: "#222233"
58-
radius: 0
59-
anchors.verticalCenterOffset: 5
60-
anchors.horizontalCenterOffset: 0
50+
anchors.verticalCenterOffset: 4
51+
anchors.centerIn: parent
6152
z: 1
62-
anchors.horizontalCenter: parent.horizontalCenter
63-
anchors.verticalCenter: parent.verticalCenter
6453
}
6554

6655
Text {

0 commit comments

Comments
 (0)