Remove reliance on QML timer - still need to fix non-circular emoji mask

This commit is contained in:
Zach Fox 2019-08-15 13:04:50 -07:00
parent dcae607cfb
commit 9ae5eba12a
2 changed files with 20 additions and 32 deletions

View file

@ -12,7 +12,7 @@ Item {
property int size: 200 // The size of the circle in pixel property int size: 200 // The size of the circle in pixel
property real arcBegin: 0 // start arc angle in degree property real arcBegin: 0 // start arc angle in degree
property real arcEnd: 270 // end arc angle in degree property real arcEnd: 360 // end arc angle in degree
property real arcOffset: 0 // rotation property real arcOffset: 0 // rotation
property bool isPie: false // paint a pie instead of an arc property bool isPie: false // paint a pie instead of an arc
property bool showBackground: false // a full circle as a background of the arc property bool showBackground: false // a full circle as a background of the arc
@ -39,10 +39,10 @@ Item {
Behavior on arcEnd { Behavior on arcEnd {
id: animationArcEnd id: animationArcEnd
enabled: false enabled: true
NumberAnimation { NumberAnimation {
duration: root.animationDuration duration: root.animationDuration
easing.type: Easing.InOutCubic easing.type: Easing.OutQuad
} }
} }

View file

@ -94,16 +94,6 @@ Rectangle {
clip: true clip: true
color: simplifiedUI.colors.darkBackground color: simplifiedUI.colors.darkBackground
Image {
id: mainEmojiImage
width: 180
height: 180
anchors.centerIn: parent
source: ""
fillMode: Image.PreserveAspectFit
visible: false
}
Image { Image {
id: mainEmojiLowOpacity id: mainEmojiLowOpacity
width: 180 width: 180
@ -115,10 +105,20 @@ Rectangle {
visible: true visible: true
} }
Image {
id: mainEmojiImage
width: 180
height: 180
anchors.centerIn: parent
source: ""
fillMode: Image.PreserveAspectFit
visible: false
}
// The overlay used during the pie timeout // The overlay used during the pie timeout
ProgressCircle { ProgressCircle {
property int arcChangeSize: 15
id: progressCircle id: progressCircle
animationDuration: 7000 // Must match `TOTAL_EMOJI_DURATION_MS` in `simplifiedEmoji.js`
anchors.centerIn: mainEmojiImage anchors.centerIn: mainEmojiImage
size: mainEmojiImage.width * 2 size: mainEmojiImage.width * 2
opacity: 0.5 opacity: 0.5
@ -127,7 +127,7 @@ Rectangle {
showBackground: false showBackground: false
isPie: true isPie: true
arcBegin: 0 arcBegin: 0
arcEnd: 0 arcEnd: 360
visible: false visible: false
} }
@ -136,16 +136,6 @@ Rectangle {
source: mainEmojiImage source: mainEmojiImage
maskSource: progressCircle maskSource: progressCircle
} }
Timer {
id: arcTimer
interval: 5000
repeat: true
running: false
onTriggered: {
progressCircle.arcEnd = ((progressCircle.arcEnd - progressCircle.arcChangeSize) > 0) ? (progressCircle.arcEnd - progressCircle.arcChangeSize) : 0;
}
}
} }
Rectangle { Rectangle {
@ -283,16 +273,14 @@ Rectangle {
switch(message.method) { switch(message.method) {
case "beginCountdownTimer": case "beginCountdownTimer":
var degreesInCircle = 360; progressCircle.endAnimation = true;
progressCircle.arcEnd = degreesInCircle; progressCircle.arcEnd = 0;
arcTimer.interval = message.data.interval;
progressCircle.arcChangeSize = degreesInCircle / (message.data.duration / arcTimer.interval);
arcTimer.start();
root.isSelected = true; root.isSelected = true;
break; break;
case "clearCountdownTimer": case "clearCountdownTimer":
progressCircle.arcEnd = 0; progressCircle.endAnimation = false;
arcTimer.stop(); progressCircle.arcEnd = 360;
progressCircle.endAnimation = true;
root.isSelected = false; root.isSelected = false;
break; break;
default: default: