diff --git a/src/activities/numeration_weights_integer/NumberClassDragElement.qml b/src/activities/numeration_weights_integer/NumberClassDragElement.qml index 15399c01b..96c07abb5 100644 --- a/src/activities/numeration_weights_integer/NumberClassDragElement.qml +++ b/src/activities/numeration_weights_integer/NumberClassDragElement.qml @@ -1,79 +1,98 @@ /* GCompris - NumberClassDragElement.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" // TODO: make text fitting in Rectangle Rectangle { id: numberClassDragElement width: parent.width - parent.width/5 height: parent.height / 15 property int lastX property int lastY property int lastZ property string name property bool dragEnabled: true - Drag.active: numberClassDragElementMouseArea.drag.active + Drag.active: true //numberClassDragElementMouseArea.drag.active + + Drag.hotSpot.x: width / 2 + Drag.hotSpot.y: height / 2 + + // I've added this property for simplicity's sake. + property bool dragActive: numberClassDragElementMouseArea.drag.active + + onDragActiveChanged: { + if (dragActive) { + print("drag started") + Drag.start(); + } else { + print("drag finished") + Drag.drop(); + } + } + + // Drag.dragType: Drag.Automatic + opacity: dragEnabled ? 1 : 0.5 //number of available items GCText { id: numberClassElementCaption anchors.fill: parent //? here text does not fit in parent anchors.bottom: parent.bottom fontSizeMode: Text.Fit color: "white" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter text: name } MouseArea { id: numberClassDragElementMouseArea anchors.fill: parent drag.target: (numberClassDragElement.dragEnabled) ? parent : null drag.axis: numberClassDragElement.x < parent.width ? Drag.XAxis : Drag.XAndYAxis Drag.hotSpot.x: width / 2 Drag.hotSpot.y: height / 2 onPressed: { instruction.hide() //set the initial position numberClassDragElement.lastX = numberClassDragElement.x numberClassDragElement.lastY = numberClassDragElement.y } onReleased: { parent.Drag.drop() //set the element to its initial coordinates numberClassDragElement.x = numberClassDragElement.lastX numberClassDragElement.y = numberClassDragElement.lastY } } } diff --git a/src/activities/numeration_weights_integer/resource/tutorial1.qml b/src/activities/numeration_weights_integer/resource/tutorial1.qml index 60e19309d..45bb22149 100644 --- a/src/activities/numeration_weights_integer/resource/tutorial1.qml +++ b/src/activities/numeration_weights_integer/resource/tutorial1.qml @@ -1,71 +1,73 @@ /* 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.6 import GCompris 1.0 import "../../../core" import "../../../activities" Rectangle { id: tutorial1 Component.onCompleted: { tutorial1.state = '' tutorial1.state === '' ? tutorial1.state = 'other' : tutorial1.state = '' - console.log("test") + console.log("tutorial1_completed") } anchors.fill: parent color: "#80FFFFFF" states: [ // This adds a second state to the container where the rectangle is farther to the right State { name: "other" PropertyChanges { target: numberClassDragElements.itemAt(0) - x: 200 + x: 400 y: 200 } } ] transitions: [ // This adds a transition that defaults to applying to all state changes Transition { id: transition_id // This applies a default NumberAnimation to any changes a state change makes to x or y properties NumberAnimation { properties: "x,y" } onRunningChanged: { if(!transition_id.running) { - numberClassDragElements.itemAt(0).Drag.drop() - console.log("mince") + //var tt = numberClassDragElements.itemAt(0).Drag.drop() + + //console.log("--" + tt + "") + //console.log(tt) } } } ] }