| 1 |
// Copyright (C) 2016 The Qt Company Ltd. |
| 2 |
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 |
|
| 4 |
import QtQuick 2.0 |
| 5 |
|
| 6 |
Rectangle { |
| 7 |
id: planetButton |
| 8 |
|
| 9 |
property alias text: planetText.text |
| 10 |
property alias source: planetImage.source |
| 11 |
property alias focusPlanet: planetImage.focusPlanet |
| 12 |
property Item planetSelector: parent.parent |
| 13 |
property int buttonSize: 70 |
| 14 |
property int fontSize: 16 |
| 15 |
|
| 16 |
width: buttonSize |
| 17 |
height: buttonSize |
| 18 |
color: "transparent" |
| 19 |
|
| 20 |
Image { |
| 21 |
id: planetImage |
| 22 |
anchors.fill: parent |
| 23 |
property int focusPlanet |
| 24 |
|
| 25 |
MouseArea { |
| 26 |
anchors.fill: parent |
| 27 |
hoverEnabled: true |
| 28 |
onClicked: { planetSelector.focusedPlanet = focusPlanet } |
| 29 |
onEntered: PropertyAnimation { target: planetText; property: "opacity"; to: 1 } |
| 30 |
onExited: PropertyAnimation { |
| 31 |
target: planetText |
| 32 |
property: "opacity" |
| 33 |
to: { |
| 34 |
if (planetText.text != "Solar System") |
| 35 |
0 |
| 36 |
else |
| 37 |
1 |
| 38 |
} |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
Text { |
| 44 |
id: planetText |
| 45 |
anchors.centerIn: parent |
| 46 |
font.family: "Helvetica" |
| 47 |
font.pixelSize: fontSize |
| 48 |
font.weight: Font.Light |
| 49 |
color: "white" |
| 50 |
opacity: { |
| 51 |
if (text == "Solar System" || (Qt.platform.os === "tvos" && planetButton.activeFocus)) |
| 52 |
opacity = 1 |
| 53 |
else |
| 54 |
opacity = 0 |
| 55 |
} |
| 56 |
} |
| 57 |
} |