Warning, /education/gcompris/src/activities/enumerate/ItemToEnumerate.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ItemToEnumerate.qml
0002 *
0003 * SPDX-FileCopyrightText: 2014 Thib ROMAIN <thibrom@gmail.com>
0004 *
0005 * Authors:
0006 * Bruno Coudoin <bruno.coudoin@gcompris.net> (GTK+ version)
0007 * Thib ROMAIN <thibrom@gmail.com> (Qt Quick port)
0008 *
0009 * SPDX-License-Identifier: GPL-3.0-or-later
0010 */
0011 import QtQuick 2.12
0012 import GCompris 1.0
0013 import "enumerate.js" as Activity
0014
0015 Image {
0016 sourceSize.width: Math.min(90 * ApplicationInfo.ratio, main.width / 5)
0017 fillMode: Image.PreserveAspectFit
0018 z: 0
0019 // Let the items comes from random side of the screen
0020 x: Math.random() > 0.5 ? -width : main.width
0021 y: Math.random() > 0.5 ? -height : main.height
0022
0023 property real xRatio
0024 property real yRatio
0025 property Item main
0026
0027 Component.onCompleted: {
0028 xRatio = Activity.getRandomInt(10, main.width - 220 * ApplicationInfo.ratio) /
0029 (main.width - 220 * ApplicationInfo.ratio)
0030 yRatio = Activity.getRandomInt(10, main.height - 180 * ApplicationInfo.ratio) /
0031 (main.height - 180 * ApplicationInfo.ratio)
0032 positionMe()
0033 }
0034
0035 function positionMe() {
0036 x = (main.width - 220 * ApplicationInfo.ratio) * xRatio
0037 y = (main.height- 180 * ApplicationInfo.ratio) * yRatio
0038 }
0039
0040 Drag.active: dragArea.drag.active
0041 Drag.hotSpot.x: width / 2
0042 Drag.hotSpot.y: height / 2
0043
0044 MouseArea {
0045 id: dragArea
0046 anchors.fill: parent
0047 drag.target: parent
0048 onPressed: {
0049 parent.z = ++Activity.globalZ
0050 }
0051 onReleased: parent.Drag.drop()
0052 }
0053
0054 Behavior on x {
0055 PropertyAnimation {
0056 duration: 2000
0057 easing.type: Easing.InOutQuad
0058 }
0059 }
0060 Behavior on y {
0061 PropertyAnimation {
0062 duration: 2000
0063 easing.type: Easing.InOutQuad
0064 }
0065 }
0066 }