You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

190 lines
3.4 KiB

import QtQuick 2.0
import QtGraphicalEffects 1.13
import "qrc:/theme"
import "qrc:/const"
Item {
id: control
property var angle: 0
property var thickness: Const.macroLightThickness
property var colorMode: 0 // 0->None; 1->White; 2->Green; 3->Yellow
property color lightColor: getColor()
property color lightDeep: getColorDeep()
property var timeFactor: 1
property bool indicator: false
width: Const.macroButton + 2 * thickness
height: Const.macroButton + 2 * thickness
function getColor() {
switch(colorMode) {
case(0): return Theme.current.none
case(1): return Theme.current.white
case(2): return Theme.current.green
case(3): return Theme.current.yellow
}
}
function getColorDeep() {
switch(colorMode) {
case(0): return Theme.current.noneDeep
case(1): return Theme.current.whiteDeep
case(2): return Theme.current.greenDeep
case(3): return Theme.current.yellowDeep
}
}
Item {
id: shadowedRing
anchors.fill: parent
Item {
id: coloredRing
width: parent.width
height: parent.height
Rectangle {
id: lightRing
width: parent.width
height: parent.height
radius: width / 2
color: "transparent"
border{
color: lightColor
width: thickness
}
}
Item {
id: borderGrad
implicitWidth: parent.implicitWidth
implicitHeight: parent.implicitHeight
anchors.fill: parent
layer.enabled: true
layer.effect: OpacityMask {
maskSource: lightRing
}
Rectangle {
width: parent.width
height: parent.height
color: "transparent"
LinearGradient {
id: linGrad
anchors.fill: parent
start: Qt.point(0, parent.height)
end: Qt.point(0, 0)
gradient: Gradient {
GradientStop {
position: 0
color: lightDeep
}
GradientStop {
position: 1
color: lightColor
}
}
}
}
Rectangle {
id: indic
width: thickness * 2
height: width
color: lightDeep
y: 0.5 * thickness
anchors.horizontalCenter: parent.horizontalCenter
visible: indicator
transform: Rotation {
angle: 45
origin {
x: indic.width / 2
y: indic.height / 2
}
axis {
z: 1
x: 0
y: 0
}
}
}
transform: Rotation {
origin {
x: borderGrad.width / 2
y: borderGrad.height / 2
}
axis {
z: 1
x: 0
y: 0
}
angle: control.angle
Behavior on angle {
NumberAnimation {
duration: 200 * timeFactor
easing.type: Easing.OutQuad
}
}
}
}
}
DropShadow {
id: dropDown
anchors.fill: coloredRing
source: coloredRing
horizontalOffset: 3
verticalOffset: 3
radius: 4
samples: 8
color: Theme.current.light
}
DropShadow {
id: dropUp
anchors.fill: coloredRing
source: coloredRing
horizontalOffset: - 3
verticalOffset: - 3
radius: 4
samples: 8
color: Theme.current.light
}
InnerShadow {
id: inner
anchors.fill: coloredRing
source: coloredRing
horizontalOffset: 3
verticalOffset: 3
radius: 3
samples: 6
smooth: true
color: Theme.current.lightShadow
}
}
// Glow {
// id: glow
// property var base: shadowedRing
// anchors.fill: base
// source: base
// radius: 10
// samples: 20
// color: Theme.current.light //orange ? "#FFEAA5" : (green ? "#B8E49B" : (white ? "white" : "transparent"))
// transparentBorder: true
// }
}