-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMaterial_Button.qml
109 lines (107 loc) · 3.73 KB
/
Material_Button.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
import QtQuick 2.15
import QtQuick.Controls.Material 2.15
import QtQuick.Controls.Material.impl 2.15
import QtQuick.Controls 6.2
import Qt5Compat.GraphicalEffects
Button {
id: control
property color color
property color rippleColor: "#0e000000"
property double radius: 4
property bool elevated: true
property int elevation: 8
property bool roundLeftTop: true
property bool roundRightTop: true
property bool roundLeftBottom: true
property bool roundRightBottom: true
implicitWidth: 100
implicitHeight: 50
topInset: 0
bottomInset: 0
background: Rectangle {
id: controlBackground
color: control.color
radius: control.radius
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
visible: !control.roundLeftTop
width: control.radius * 2
height: control.radius * 2
color: control.color
}
Rectangle {
anchors.right: parent.right
anchors.top: parent.top
visible: !control.roundRightTop
width: control.radius * 2
height: control.radius * 2
color: control.color
}
Rectangle {
anchors.left: parent.left
anchors.bottom: parent.bottom
visible: !control.roundLeftBottom
width: control.radius * 2
height: control.radius * 2
color: control.color
}
Rectangle {
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !control.roundRightBottom
width: control.radius * 2
height: control.radius * 2
color: control.color
}
layer.enabled: control.elevated
layer.effect: ElevationEffect {
elevation: control.elevation
}
Ripple {
clipRadius: control.radius
width: parent.width
height: parent.height
pressed: control.pressed
anchor: control
active: control.down || control.visualFocus || control.hovered
color: control.rippleColor
layer.enabled: true
layer.effect: OpacityMask {
maskSource: Rectangle { // set it to controlBackground would cause rendering error
width: controlBackground.width
height: controlBackground.height
radius: control.radius
Rectangle {
anchors.left: parent.left
anchors.top: parent.top
visible: !control.roundLeftTop
width: control.radius * 2
height: control.radius * 2
}
Rectangle {
anchors.right: parent.right
anchors.top: parent.top
visible: !control.roundRightTop
width: control.radius * 2
height: control.radius * 2
}
Rectangle {
anchors.left: parent.left
anchors.bottom: parent.bottom
visible: !control.roundLeftBottom
width: control.radius * 2
height: control.radius * 2
}
Rectangle {
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: !control.roundRightBottom
width: control.radius * 2
height: control.radius * 2
}
}
}
}
}
}