diff --git a/src/activities/numeration_weights_integer/NumberWeightDragElement.qml b/src/activities/numeration_weights_integer/NumberWeightDragElement.qml index 785119c75..e53ac3190 100644 --- a/src/activities/numeration_weights_integer/NumberWeightDragElement.qml +++ b/src/activities/numeration_weights_integer/NumberWeightDragElement.qml @@ -1,105 +1,109 @@ /* GCompris - NumberWeightDragElement.qml * * Copyright (C) 2019 Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 //? import "../../core" import "numeration_weights_integer.js" as Activity Rectangle { id: numberWeightDragElement property bool animationIsRunning property int lastX property int lastY property string imageName property string name property bool canDrag: true property string caption property string src property int weightValue property bool selected // callback defined in each numberWeightDragElement called when we release the element in background //? property var releaseElement: null //? width: parent.width - parent.width/5 height: parent.height / 15 color: "transparent" border.color: "red" border.width: selected === true ? 1 : 0 Drag.active: numberWeightDragElementMouseArea.drag.active || animationIsRunning + onStateChanged: { + console.log("state changed") + } + src: "resource/images/" + imageName Image { id: numberWeightDragElementImage sourceSize.width: parent.width sourceSize.height: parent.height source: imageName !== "" ? numberWeightDragElement.src : "" anchors.fill: parent //number of available items GCText { id: numberWeightDragElementCaption anchors.fill: parent anchors.margins: 10 fontSizeMode: Text.Fit color: "white" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: numberWeightDragElement.caption } } MouseArea { id: numberWeightDragElementMouseArea anchors.fill: parent onPressed: { //set the initial position numberWeightDragElement.lastX = numberWeightDragElement.x numberWeightDragElement.lastY = numberWeightDragElement.y } onPositionChanged: { Activity.unselectAllNumberWeightDragElement() } onClicked: { Activity.selectNumberWeightDragElement(index) } drag.target: numberWeightDragElement drag.axis: numberWeightDragElement.x < parent.width ? Drag.XAxis : Drag.XAndYAxis Drag.hotSpot.x: width Drag.hotSpot.y: height onReleased: { parent.Drag.drop() //set the element to its initial coordinates numberWeightDragElement.x = numberWeightDragElement.lastX numberWeightDragElement.y = numberWeightDragElement.lastY } } } diff --git a/src/activities/numeration_weights_integer/NumberWeightHeaderElement.qml b/src/activities/numeration_weights_integer/NumberWeightHeaderElement.qml index 9c5aaccc5..d11a9f175 100644 --- a/src/activities/numeration_weights_integer/NumberWeightHeaderElement.qml +++ b/src/activities/numeration_weights_integer/NumberWeightHeaderElement.qml @@ -1,115 +1,109 @@ /* GCompris - NumberWeightHeaderElement.qml * * Copyright (C) 2019 Emmanuel Charruau * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.6 import GCompris 1.0 import "../../core" import "numeration_weights_integer.js" as Activity Rectangle { id: numberWeightHeaderElement property string defaultColor: "darkred" property string overlapColor: "blue" color: "darkred" radius: 0.2 anchors.top: parent.top //? property int lastX property int lastY property Item dragParent property alias textAlias: numberWeightHeaderCaption.text border.color: "red" border.width: 0 DropArea { id: numberWeightsHeaderDropArea anchors.fill: parent keys: "numberWeightHeaderKey" onEntered: { numberWeightHeaderElement.color = overlapColor } onExited: { numberWeightHeaderElement.color = defaultColor } onDropped: { numberWeightHeaderElement.color = defaultColor numberWeightHeaderCaption.text = drag.source.caption } Image { id: numberWeightHeaderImage anchors.fill: parent sourceSize.width: parent.width sourceSize.height: parent.height GCText { id: numberClassElementCaption anchors.fill: parent anchors.bottom: parent.bottom fontSizeMode: Text.Fit color: "white" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } } GCText { id: numberWeightHeaderCaption anchors.fill: parent anchors.margins: 10 //? find a way to fit the text without truncating it fontSizeMode: Text.Fit color: "white" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter wrapMode: TextEdit.WordWrap text: qsTr("Drag column weight here.") } MouseArea { - anchors.fill: parent - onClicked: { - /* if (numberWeightHeaderImage.status === Image.Ready) { //? needs certainly to be removed - Activity.removeNumberWeightComponent(numberWeightImageTile) - } - else {*/ - if (Activity.selectedNumberWeightDragElementIndex !== -1) { - if (numberWeightDragListModel.get(Activity.selectedNumberWeightDragElementIndex).dragkeys === "numberWeightHeaderKey") { - //numberWeightHeaderImage.source = numberWeightDragListModel.get(Activity.selectedNumberWeightDragElementIndex).imageName - numberWeightHeaderCaption.text = numberWeightDragListModel.get(Activity.selectedNumberWeightDragElementIndex).caption - } + anchors.fill: parent + onClicked: { + if (Activity.selectedNumberWeightDragElementIndex !== -1) { + if (numberWeightDragListModel.get(Activity.selectedNumberWeightDragElementIndex).dragkeys === "numberWeightHeaderKey") { + numberWeightHeaderCaption.text = numberWeightDragListModel.get(Activity.selectedNumberWeightDragElementIndex).caption } - // } - } + } + } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial1.qml b/src/activities/numeration_weights_integer/resource/tutorial1.qml index f4fe9cc8c..623f7119a 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial1.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial1.qml @@ -1,113 +1,115 @@ /* GCompris - tutorial1.qml * * Copyright (C) 2018 Timothée Giet * * Authors: * Timothée Giet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" Item { id: tutorial1 property bool animationIsRunning: animationIsRunning property int unitClassDragButtonOrigX property int unitClassDragButtonOrigY property int thousandClassDragButtonOrigX property int thousandClassDragButtonOrigY Component.onCompleted: { console.log("tutorial1_screen_loaded") animUnitClassX.running = true animUnitClassY.running = true } + + NumberAnimation{ id: animUnitClassX target: numberClassDragElements.itemAt(0) property: "x"; to: background.width * 2/3 duration: 300 //0 onStarted: { unitClassDragButtonOrigX = numberClassDragElements.itemAt(0).x unitClassDragButtonOrigY = numberClassDragElements.itemAt(0).y animationIsRunning = true numberClassDragElements.itemAt(0).animationIsRunning = animationIsRunning console.log("onStarted") } onFinished: { numberClassDragElements.itemAt(0).Drag.drop() console.log("Sent Drag drop") animationIsRunning = false numberClassDragElements.itemAt(0).x = unitClassDragButtonOrigX numberClassDragElements.itemAt(0).z = 1000 animThousandClassX.running = true animThousandClassY.running = true } } NumberAnimation{ id: animUnitClassY target: numberClassDragElements.itemAt(0) property: "y"; to: background.height * 1/3 duration: 300 //0 onFinished: { numberClassDragElements.itemAt(0).y = unitClassDragButtonOrigY } } NumberAnimation{ id: animThousandClassX target: numberClassDragElements.itemAt(1) property: "x"; to: background.width * 1/3 duration: 300 //0 onStarted: { thousandClassDragButtonOrigX = numberClassDragElements.itemAt(1).x thousandClassDragButtonOrigY = numberClassDragElements.itemAt(1).y animationIsRunning = true numberClassDragElements.itemAt(1).animationIsRunning = animationIsRunning console.log("onStarted") } onFinished: { numberClassDragElements.itemAt(1).Drag.drop() console.log("Sent Drag drop") animationIsRunning = false numberClassDragElements.itemAt(1).x = thousandClassDragButtonOrigX numberClassDragElements.itemAt(1).z = 1000 } } NumberAnimation{ id: animThousandClassY target: numberClassDragElements.itemAt(1) property: "y"; to: background.height * 1/3 duration: 300 //0 onFinished: { numberClassDragElements.itemAt(1).y = thousandClassDragButtonOrigY } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial2.qml b/src/activities/numeration_weights_integer/resource/tutorial2.qml index 19e0d891c..0d327bfc4 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial2.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial2.qml @@ -1,132 +1,126 @@ /* GCompris - tutorial1.qml * * Copyright (C) 2018 Timothée Giet * * Authors: * Timothée Giet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see . */ import QtQuick 2.13 import GCompris 1.0 import "../../../core" import "../../../activities" Item { id: tutorial2 property bool animationIsRunning: animationIsRunning property int unitWeightColumnDragButtonOrigX property int unitWeightColumnDragButtonOrigY property int thousandClassDragButtonOrigX property int thousandClassDragButtonOrigY property int animationSequenceIndex: 0 - property int numberClassIndex: 1 + property int numberClassIndex: 0 property int numberColumnWeightIndex: 2 property int numberColumnWeightDragButtonIndex: 0 property int headerOriginY Component.onCompleted: { console.log("tutorial2_screen_loaded") - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true + numberWeightsParallelAnimation.running = true + numberWeightsParallelAnimation.running = true headerOriginY = numberClassDropAreaRepeater.itemAt(0).numberWeightsDropAreasRepeater.itemAt(0).mapToItem(activity, 0, 0).y } - NumberAnimation { - id: animUnitColumnWeightX + ParallelAnimation { + id: numberWeightsParallelAnimation + + NumberAnimation { + id: animUnitColumnWeightX + + target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) + property: "x"; + to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).mapToItem(activity, 0, 0).x + duration: 3000 + } + + NumberAnimation { + id: animUnitColumnWeightY + + target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) + property: "y"; + to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).mapToItem(activity, 0, 0).y + duration: 3000 + } - target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) - property: "x"; - to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).mapToItem(activity, 0, 0).x - duration: 3000 onStarted: { unitWeightColumnDragButtonOrigX = numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x unitWeightColumnDragButtonOrigY = numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).Drag.start() animationIsRunning = true numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).animationIsRunning = animationIsRunning + console.log("ttt") } + onFinished: { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).Drag.drop() - animationIsRunning = false numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).z = 1000 if (animationSequenceIndex === 0) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY animationSequenceIndex = 1 - numberClassIndex = 1 + numberClassIndex = 0 numberColumnWeightIndex = 1 numberColumnWeightDragButtonIndex = 1 - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true - animUnitColumnWeightX.start() + numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 1) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY animationSequenceIndex = 2 - numberClassIndex = 1 + numberClassIndex = 0 numberColumnWeightIndex = 0 numberColumnWeightDragButtonIndex = 2 - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true - animUnitColumnWeightX.start() - console.log("fail") + numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 2) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY animationSequenceIndex = 3 - numberClassIndex = 0 + numberClassIndex = 1 numberColumnWeightIndex = 2 numberColumnWeightDragButtonIndex = 0 - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true - animUnitColumnWeightX.start() + numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 3) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY animationSequenceIndex = 4 - numberClassIndex = 0 + numberClassIndex = 1 numberColumnWeightIndex = 1 numberColumnWeightDragButtonIndex = 1 - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true + numberWeightsParallelAnimation.running = true } else if (animationSequenceIndex === 4) { numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).x = unitWeightColumnDragButtonOrigX - animationSequenceIndex = 5 - numberClassIndex = 0 + numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY + numberClassIndex = 1 numberColumnWeightIndex = 0 numberColumnWeightDragButtonIndex = 2 - animUnitColumnWeightX.running = true - animUnitColumnWeightY.running = true + numberWeightsParallelAnimation.running = true } } } - - NumberAnimation { - id: animUnitColumnWeightY - - target: numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex) - property: "y"; - //to: numberClassDropAreaRepeater.itemAt(numberClassIndex).numberWeightsDropAreasRepeater.itemAt(numberColumnWeightIndex).mapToItem(activity, 0, 0).y - to : 33 //headerOriginY - duration: 3000 - onFinished: { - numberWeightDragElements.itemAt(numberColumnWeightDragButtonIndex).y = unitWeightColumnDragButtonOrigY - } - } - - - - }