Warning, /education/gcompris/src/activities/click_on_letter/Carriage.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - Carriage.qml
0002 *
0003 * SPDX-FileCopyrightText: 2014 Holger Kaelberer <holger.k@elberer.de>
0004 *
0005 * Authors:
0006 * Pascal Georges <pascal.georges1@free.fr> (GTK+ version)
0007 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ Mostly full rewrite)
0008 * Holger Kaelberer <holger.k@elberer.de> (Qt Quick port)
0009 *
0010 * SPDX-License-Identifier: GPL-3.0-or-later
0011 */
0012
0013 import QtQuick 2.12
0014 import GCompris 1.0
0015 import QtGraphicalEffects 1.0
0016 import "../../core"
0017 import "click_on_letter.js" as Activity
0018
0019 Item {
0020 id: carriageItem
0021 property int nbCarriage
0022 property bool isCarriage: index <= nbCarriage
0023 property bool clickEnabled
0024 property bool isSelected
0025 property alias successAnimation: successAnimation
0026 property alias particle: particle
0027
0028 Image {
0029 id: carriageImage
0030 width: parent.width
0031 height: parent.height
0032 sourceSize.width: width
0033 fillMode: Image.PreserveAspectFit
0034 source: isCarriage ?
0035 Activity.url + "carriage.svg":
0036 Activity.url + "cloud.svg"
0037 z: (state == 'scaled') ? 1 : -1
0038
0039 Rectangle {
0040 id: carriageBg
0041 visible: isCarriage
0042 width: parent.width - 8
0043 height: parent.height / 1.8
0044 anchors.bottom: parent.top
0045 anchors.bottomMargin: - parent.height / 1.5
0046 radius: height / 10
0047 color: "#f0d578"
0048 border.color: "#b98a1c"
0049 border.width: 3
0050 }
0051
0052 Rectangle {
0053 id: selector
0054 z: 9
0055 visible: isSelected && items.keyNavigationMode
0056 anchors.fill: parent
0057 radius: 5
0058 color: "#800000ff"
0059 }
0060
0061 GCText {
0062 id: text
0063 anchors.horizontalCenter: isCarriage ?
0064 carriageBg.horizontalCenter :
0065 parent.horizontalCenter
0066 anchors.verticalCenter: isCarriage ?
0067 carriageBg.verticalCenter :
0068 parent.verticalCenter
0069 z: 11
0070 text: letter
0071 width: parent.width * 0.9
0072 height: parent.height * 0.9
0073 horizontalAlignment: Text.AlignHCenter
0074 verticalAlignment: Text.AlignVCenter
0075 fontSizeMode: Text.Fit
0076 minimumPointSize: 7
0077 fontSize: largeSize
0078 font.bold: true
0079 style: Text.Outline
0080 styleColor: "#2a2a2a"
0081 color: "white"
0082 }
0083
0084 DropShadow {
0085 anchors.fill: text
0086 cached: false
0087 horizontalOffset: 1
0088 verticalOffset: 1
0089 radius: 3
0090 samples: 16
0091 color: "#422a2a2a"
0092 source: text
0093 }
0094
0095 MouseArea {
0096 id: mouseArea
0097 anchors.fill: parent
0098 hoverEnabled: ApplicationInfo.isMobile ? false : true
0099
0100 onClicked: {
0101 if(carriageItem.clickEnabled) {
0102 items.lastSelectedIndex = train.currentIndex
0103 items.keyNavigationMode = false;
0104 items.buttonsBlocked = true;
0105 if (Activity.checkAnswer(index)) {
0106 successAnimation.restart();
0107 particle.burst(30);
0108 } else {
0109 background.moveErrorRectangle(carriageItem);
0110 }
0111 }
0112 }
0113 }
0114
0115 ParticleSystemStarLoader {
0116 z: 10
0117 id: particle
0118 clip: false
0119 }
0120
0121 states: State {
0122 name: "scaled"; when: mouseArea.containsMouse
0123 PropertyChanges {
0124 target: carriageItem
0125 scale: /*carriageImage.scale * */ 1.2
0126 z: 2
0127 }
0128 }
0129
0130 transitions: Transition {
0131 NumberAnimation { properties: "scale"; easing.type: Easing.OutCubic }
0132 }
0133
0134 SequentialAnimation {
0135 id: successAnimation
0136 NumberAnimation {
0137 target: carriageImage
0138 easing.type: Easing.InOutQuad
0139 property: "rotation"
0140 to: 20; duration: 100
0141 }
0142 NumberAnimation {
0143 target: carriageImage
0144 easing.type: Easing.InOutQuad
0145 property: "rotation"; to: -20
0146 duration: 100 }
0147 NumberAnimation {
0148 target: carriageImage
0149 easing.type: Easing.InOutQuad
0150 property: "rotation"
0151 to: 0; duration: 50
0152 }
0153 }
0154 }
0155 }