| 1 |
/* |
| 2 |
* This file is part of unity-2d |
| 3 |
* |
| 4 |
* Copyright 2011 Canonical Ltd. |
| 5 |
* |
| 6 |
* This program is free software; you can redistribute it and/or modify |
| 7 |
* it under the terms of the GNU General Public License as published by |
| 8 |
* the Free Software Foundation; version 3. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
import QtQuick 2.0 |
| 20 |
import "utils.js" as Utils |
| 21 |
import "units.js" as Units |
| 22 |
|
| 23 |
AbstractButton { |
| 24 |
id: button |
| 25 |
|
| 26 |
property alias text: textBox.text |
| 27 |
|
| 28 |
height: Units.tvPx(64) |
| 29 |
width: Units.tvPx(366) |
| 30 |
|
| 31 |
Rectangle { |
| 32 |
id: background |
| 33 |
anchors.fill: parent |
| 34 |
|
| 35 |
color: "white" |
| 36 |
radius: Units.tvPx(16) |
| 37 |
|
| 38 |
Behavior on opacity { NumberAnimation { duration: 250 } } |
| 39 |
} |
| 40 |
|
| 41 |
Rectangle { |
| 42 |
id: border |
| 43 |
anchors.fill: parent |
| 44 |
color: "transparent" |
| 45 |
border.color: "white" |
| 46 |
border.width: 3 |
| 47 |
radius: Units.tvPx(16) |
| 48 |
|
| 49 |
Behavior on opacity { NumberAnimation { duration: 250 } } |
| 50 |
} |
| 51 |
|
| 52 |
TextCustom { |
| 53 |
id: textBox |
| 54 |
anchors.centerIn: parent |
| 55 |
color: "white" |
| 56 |
fontSize: "small" |
| 57 |
} |
| 58 |
|
| 59 |
// Note that the glow when selected is outside the item |
| 60 |
BorderImage { |
| 61 |
id: glow |
| 62 |
anchors.fill: parent |
| 63 |
anchors.margins: Units.tvPx(-19) |
| 64 |
anchors.topMargin: Units.tvPx(-18) |
| 65 |
anchors.rightMargin: Units.tvPx(-20) |
| 66 |
|
| 67 |
source: "artwork/button_glow.sci" |
| 68 |
Behavior on opacity { NumberAnimation { duration: 250 } } |
| 69 |
} |
| 70 |
|
| 71 |
states: [ |
| 72 |
State { |
| 73 |
name: "default" |
| 74 |
PropertyChanges { target: glow; opacity: 0.0 } |
| 75 |
PropertyChanges { target: border; opacity: 0.5 } |
| 76 |
PropertyChanges { target: background; opacity: 0.2 } |
| 77 |
}, |
| 78 |
State { |
| 79 |
name: "selected" |
| 80 |
PropertyChanges { target: glow; opacity: 1.0 } |
| 81 |
PropertyChanges { target: border; opacity: 0.0 } |
| 82 |
PropertyChanges { target: background; opacity: 0.05 } |
| 83 |
} |
| 84 |
] |
| 85 |
} |