| 1 |
/* |
| 2 |
* SPDX-License-Identifier: GPL-3.0-only |
| 3 |
* Audacity-CLA-applies |
| 4 |
* |
| 5 |
* Audacity |
| 6 |
* A Digital Audio Editor |
| 7 |
* |
| 8 |
* Copyright (C) 2024 Audacity BVBA and others |
| 9 |
* |
| 10 |
* This program is free software: you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU General Public License version 3 as |
| 12 |
* published by the Free Software Foundation. |
| 13 |
* |
| 14 |
* This program is distributed in the hope that it will be useful, |
| 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 |
* GNU General Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU General Public License |
| 20 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 21 |
*/ |
| 22 |
import QtQuick 2.15 |
| 23 |
|
| 24 |
import Muse.Ui 1.0 |
| 25 |
import Muse.UiComponents 1.0 |
| 26 |
|
| 27 |
Rectangle { |
| 28 |
id: root |
| 29 |
|
| 30 |
property bool highlight: false |
| 31 |
property var mouseArea: null |
| 32 |
property color baseColor: "transparent" |
| 33 |
|
| 34 |
color: baseColor |
| 35 |
|
| 36 |
border.width: ui.theme.borderWidth |
| 37 |
border.color: ui.theme.strokeColor |
| 38 |
|
| 39 |
Rectangle { |
| 40 |
id: topBackground |
| 41 |
|
| 42 |
anchors.fill: parent |
| 43 |
color: "transparent" |
| 44 |
} |
| 45 |
|
| 46 |
Rectangle { |
| 47 |
id: focusBorder |
| 48 |
|
| 49 |
anchors.fill: parent |
| 50 |
|
| 51 |
visible: root.highlight |
| 52 |
|
| 53 |
color: "transparent" |
| 54 |
|
| 55 |
border.color: ui.theme.fontPrimaryColor |
| 56 |
border.width: ui.theme.navCtrlBorderWidth |
| 57 |
radius: Number(parent.radius) > 0 ? parent.radius : 0 |
| 58 |
} |
| 59 |
|
| 60 |
states: [ |
| 61 |
State { |
| 62 |
name: "PRESSED" |
| 63 |
when: root.mouseArea.pressed |
| 64 |
|
| 65 |
PropertyChanges { |
| 66 |
target: topBackground |
| 67 |
color: ui.theme.buttonColor |
| 68 |
opacity: ui.theme.buttonOpacityHit |
| 69 |
} |
| 70 |
}, |
| 71 |
|
| 72 |
State { |
| 73 |
name: "HOVERED" |
| 74 |
when: root.mouseArea.containsMouse && !root.mouseArea.pressed |
| 75 |
|
| 76 |
PropertyChanges { |
| 77 |
target: topBackground |
| 78 |
color: ui.theme.buttonColor |
| 79 |
opacity: ui.theme.buttonOpacityHover |
| 80 |
} |
| 81 |
} |
| 82 |
] |
| 83 |
} |