Warning, /education/gcompris/src/core/ControlButton.qml is written in an unsupported language. File is not indexed.
0001 /* GCompris - ControlButton.qml
0002 *
0003 * SPDX-FileCopyrightText: 2016 Holger Kaelberer <holger.k@elberer.de>
0004 *
0005 * Authors:
0006 * Holger Kaelberer <holger.k@elberer.de>
0007 *
0008 * SPDX-License-Identifier: GPL-3.0-or-later
0009 */
0010 import QtQuick 2.12
0011 import GCompris 1.0
0012
0013 /**
0014 * A QML to use as button
0015 *
0016 * Currently used in land_safe and gravity activities
0017 */
0018
0019 Image {
0020 id: root
0021 state: "notclicked"
0022 sourceSize.width: 54 * ApplicationInfo.ratio
0023
0024 signal clicked
0025 signal pressed
0026 signal released
0027
0028 /** How much the mousearea should exceed the visible item on each border */
0029 property double exceed: 0
0030
0031 MouseArea {
0032 id: mouseArea
0033 anchors.left: parent.left
0034 anchors.leftMargin: -root.exceed
0035 anchors.top: parent.top
0036 anchors.topMargin: -root.exceed
0037 width: root.width + 2*root.exceed
0038 height: root.height + 2*root.exceed
0039 hoverEnabled: !ApplicationInfo.isMobile
0040 onClicked: root.clicked()
0041 onPressed: root.pressed()
0042 onReleased: root.released()
0043 }
0044
0045 states: [
0046 State {
0047 name: "notclicked"
0048 PropertyChanges {
0049 target: root
0050 scale: 1.0
0051 }
0052 },
0053 State {
0054 name: "clicked"
0055 when: mouseArea.pressed
0056 PropertyChanges {
0057 target: root
0058 scale: 0.9
0059 }
0060 },
0061 State {
0062 name: "hover"
0063 when: mouseArea.containsMouse
0064 PropertyChanges {
0065 target: root
0066 scale: 1.1
0067 }
0068 }
0069 ]
0070
0071 Behavior on scale { NumberAnimation { duration: 70 } }
0072 }