Verified Commit d65c3a37 authored by Artem Sidyakin's avatar Artem Sidyakin
Browse files

Brewing ready

- brewing is done and animated
- sugar is fixed
parent a65e9f11
......@@ -6,11 +6,10 @@ Item {
property alias questionVisible: question.visible
property bool showLabels: true
property real sugarAmount: 2
property int foamAmount: 2
property int milkAmount: 4
property int coffeeAmount: 3
property real coffeeAmount: 0
property real milkAmount: 0
property real foamAmount: 0
property real sugarAmount: 0
Image {
id: emptySpace
......@@ -18,15 +17,14 @@ Item {
sourceSize.height: background.height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_back.png"
//visible: false
}
Item {
id: foam
anchors.fill: emptySpace
anchors.topMargin: foamAmount === 0 ? emptySpace.height : emptySpace.height * 0.1//((10 - milkAmount - coffeeAmount - foamAmount) / 10)
anchors.topMargin: foamAmount === 0 ? emptySpace.height : emptySpace.height * ((10 - milkAmount - coffeeAmount - foamAmount) / 10)
clip: true
//visible: false
visible: milk.visible
Image {
anchors.bottom: foam.bottom
height: emptySpace.height
......@@ -41,7 +39,7 @@ Item {
anchors.fill: emptySpace
anchors.topMargin: milkAmount === 0 ? emptySpace.height : emptySpace.height * 0.8 * ((10 - milkAmount - coffeeAmount) / 10)
clip: true
//visible: false
visible: milkAmount > 0
Image {
anchors.bottom: milk.bottom
height: emptySpace.height
......@@ -56,7 +54,6 @@ Item {
anchors.fill: emptySpace
anchors.topMargin: coffeeAmount === 0 ? emptySpace.height : emptySpace.height * 0.8 * ((10 - coffeeAmount) / 10)
clip: true
//visible: false
Image {
anchors.bottom: coffee.bottom
height: emptySpace.height
......@@ -93,50 +90,70 @@ Item {
showIt: root.showLabels
}
// Item {
// id: sugarItem
// anchors.horizontalCenter: emptySpace.horizontalCenter
// anchors.bottom: emptySpace.bottom
// // anchors.left: emptySpace.left
// // anchors.right: emptySpace.right
// width: 300//emptySpace.width
// height: width
// // rotation: -45
// Rectangle {
// anchors.bottom: parent.bottom
// anchors.horizontalCenter: parent.horizontalCenter
// // anchors.leftMargin: 150
// width: 48
// height: 48
// color: Styles.labelColor
// opacity: root.sugarAmount / 10
// }
// Rectangle {
// x: 74
// y: 40
// width: 32
// height: 32
// color: Styles.labelColor
// visible: root.sugarAmount > 5
// opacity: root.sugarAmount / 30
// }
// Rectangle {
// x: 45
// y: 62
// width: 24
// height: 24
// color: Styles.labelColor
// opacity: root.sugarAmount / 25
// }
// }
Rectangle {
anchors.centerIn: parent
anchors.horizontalCenter: emptySpace.horizontalCenter
anchors.bottom: emptySpace.bottom
width: emptySpace.width / 2
height: width
color: "red"
rotation: -45
visible: false
}
Item {
id: sugarItem
anchors.horizontalCenter: emptySpace.horizontalCenter
anchors.bottom: emptySpace.bottom
anchors.bottomMargin: emptySpace.width * 0.2
//anchors.leftMargin: emptySpace.width * 0.2
width: emptySpace.width / 2
height: width
// anchors.left: emptySpace.left
// anchors.right: emptySpace.right
rotation: -45
Rectangle {
id: sugarBig
anchors.bottom: parent.bottom
anchors.bottomMargin: parent.width * 0.2
anchors.left: parent.left
anchors.leftMargin: parent.width * 0.1
width: parent.width / 4
height: width
color: Styles.labelColor
opacity: root.sugarAmount / 10
}
Rectangle {
id: sugarMid
anchors.right: sugarBig.right
anchors.top: sugarBig.bottom
anchors.topMargin: sugarBig.width * 0.15
width: parent.width / 8
height: width
color: Styles.labelColor
visible: root.sugarAmount > 4
opacity: root.sugarAmount / 20
}
Rectangle {
id: sugarSmall
anchors.left: sugarBig.right
anchors.leftMargin: sugarBig.width * 0.15
anchors.bottom: sugarBig.bottom
width: parent.width / 12
height: width
color: Styles.labelColor
visible: root.sugarAmount > 7
opacity: root.sugarAmount / 30
}
}
Image {
id: background
anchors.centerIn: root
height: parent.height * 0.9
height: parent.height * 0.8
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_front.png"
......@@ -145,9 +162,14 @@ Item {
Image {
id: question
anchors.centerIn: root
height: parent.height * 0.9
height: parent.height * 0.8
sourceSize.height: height
fillMode: Image.PreserveAspectFit
source: "qrc:/images/coffee_cup_large.png"
}
Behavior on coffeeAmount { PropertyAnimation { duration: 1000 } }
Behavior on milkAmount { PropertyAnimation { duration: 1000 } }
Behavior on foamAmount { PropertyAnimation { duration: 1000 } }
Behavior on sugarAmount { PropertyAnimation { duration: 2000 } }
}
......@@ -4,8 +4,14 @@ import QtQuick.Layouts 1.11
Item {
id: root
property real sugar: 0
property real coffee: 0
property real milk: 0
property real foam: 0
signal brewingReady
signal finished
state: "empty"
Rectangle {
anchors.fill: parent
......@@ -19,7 +25,7 @@ Item {
Layout.fillWidth: true
Layout.preferredHeight: parent.height * 0.2
Text {
id: cappuccinoLabel
id: statusLabel
anchors.centerIn: parent
color: Styles.labelColor
text: qsTr("status")
......@@ -33,91 +39,119 @@ Item {
Layout.fillHeight: true
Layout.bottomMargin: 30
questionVisible: false
state: "empty"
showLabels: false
sugarAmount: 3
}
// NavigationButton {
// Layout.alignment: Qt.AlignHCenter
// Layout.preferredHeight: parent.height * 0.2
// text: qsTr("CONTINUE")
// textSize: image.height / 10
// onClicked: {
// root.brewingReady()
// }
// }
}
}
states: [
State {
name: "empty"
PropertyChanges { target: cup; coffeeAmount: 0 }
PropertyChanges { target: cup; milkAmount: 0 }
PropertyChanges { target: cup; foamAmount: 0 }
PropertyChanges {
target: cup
coffeeAmount: 0
milkAmount: 0
foamAmount: 0
sugarAmount: 0
}
},
State {
name: "has-coffee"
PropertyChanges { target: cup; coffeeAmount: 4 }
PropertyChanges { target: cup; milkAmount: 0 }
PropertyChanges { target: cup; foamAmount: 0 }
PropertyChanges {
target: cup
coffeeAmount: root.coffee
milkAmount: 0
foamAmount: 0
sugarAmount: 0
}
},
State {
name: "has-coffee-milk"
PropertyChanges { target: cup; coffeeAmount: 4 }
PropertyChanges { target: cup; milkAmount: 3 }
PropertyChanges { target: cup; foamAmount: 0 }
name: "has-milk"
PropertyChanges {
target: cup
coffeeAmount: root.coffee
milkAmount: root.milk
foamAmount: 0
sugarAmount: 0
}
},
State {
name: "has-coffee-milk-foam"
PropertyChanges { target: cup; coffeeAmount: 4 }
PropertyChanges { target: cup; milkAmount: 3 }
PropertyChanges { target: cup; foamAmount: 2 }
name: "has-foam"
PropertyChanges {
target: cup
coffeeAmount: root.coffee
milkAmount: root.milk
foamAmount: root.foam
sugarAmount: 0
}
},
State {
name: "has-sugar"
PropertyChanges {
target: cup
coffeeAmount: root.coffee
milkAmount: root.milk
foamAmount: root.foam
sugarAmount: root.sugar
}
}
]
function start() {
animation.start()
}
SequentialAnimation {
id: animation
PauseAnimation {
duration: 1500
}
PropertyAction {
target: cup
property: state
value: "has-coffee"
Timer {
id: timerCoffee
interval: 1000 //running: true; repeat: true
onTriggered: {
state = "has-coffee"
if (root.milk > 0) { timerMilk.start() }
else { timerSugar.start() }
}
PauseAnimation {
duration: 1500
}
PropertyAction {
target: cup
property: state
value: "has-coffee-milk"
}
Timer {
id: timerMilk
interval: 2000
onTriggered: {
statusLabel.text = "ADDING MILK..."
state = "has-milk"
timerFoam.start()
}
PauseAnimation {
duration: 1500
}
Timer {
id: timerFoam
interval: 2000
onTriggered: {
statusLabel.text = "FOAMING..."
state = "has-foam"
timerSugar.start()
}
PropertyAction {
target: cup
property: state
value: "has-coffee-milk-foam"
}
Timer {
id: timerSugar
interval: 1000
onTriggered: {
statusLabel.text = "ADDING SUGAR..."
state = "has-sugar"
timerReady.start()
}
PauseAnimation {
duration: 1500
}
Timer {
id: timerReady
interval: 3000
onTriggered: {
statusLabel.text = "YOUR COFFEE IS READY"
timerDone.start()
}
ScriptAction {
script: root.finished()
}
Timer {
id: timerDone
interval: 3000
onTriggered: {
brewingReady()
}
}
Component.onCompleted: {
cup.coffeeAmount = 0;
cup.milkAmount = 0;
cup.foamAmount = 0;
start();
statusLabel.text = "MAKING COFFEE..."
timerCoffee.start()
}
}
......@@ -12,12 +12,19 @@ Window {
Loader {
id: loader
anchors.fill: parent
source: "qrc:/brewing.qml"//"choice.qml"
source: "choice.qml"
Connections {
target: loader.item
onChoiceReady: loader.source = "qrc:/emptycup.qml"
onCupReady: loader.source = "qrc:/brewing.qml"
onCupReady: loader.setSource(
"qrc:/brewing.qml",
{
coffee: 3,
milk: 0,
foam: 2,
sugar: 8
})
onBrewingReady: loader.source = "qrc:/choice.qml"
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment