Plasma-framework

RaisedButtonBackground.qml
1/*
2 * SPDX-FileCopyrightText: 2020 Noah Davis <noahadvs@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5
6import QtQuick
7import org.kde.ksvg as KSvg
8import org.kde.kirigami as Kirigami
9
10Item {
11 id: root
12 required property bool hovered
13 required property bool pressed
14 required property bool checked
15 required property bool focused
16
17 readonly property bool showPressed: checked || pressed
18 readonly property bool showFocused: focused && surfaceFocused.usedPrefix != "normal"
19
20 property var margins: showPressed ? surfacePressed.margins : (showFocused ? surfaceFocused.margins : surfaceNormal.margins)
21 property real leftMargin: margins.left
22 property real topMargin: margins.top
23 property real rightMargin: margins.right
24 property real bottomMargin: margins.bottom
25 property string usedPrefix: showPressed ? surfacePressed.usedPrefix : (showFocused ? surfaceFocused.usedPrefix : surfaceNormal.usedPrefix)
26
28 anchors.fill: parent
29 showShadow: enabled && !root.checked && !root.pressed
30 }
31
32 KSvg.FrameSvgItem {
33 id: surfaceNormal
34 anchors.fill: parent
35 imagePath: "widgets/button"
36 prefix: "normal"
37 }
38
39 // Intentionally lower than surfacePressed, surfaceFocused
41 anchors.fill: parent
42 showFocus: root.focused && !root.pressed
43 }
44
45 // Intentionally lower than surfacePressed and surfaceFocused
47 anchors.fill: parent
48 showHover: root.hovered && !root.pressed
49 }
50
51 KSvg.FrameSvgItem {
52 id: surfacePressed
53 anchors.fill: parent
54 imagePath: "widgets/button"
55 prefix: "pressed"
56 opacity: root.showPressed ? 1 : 0
57 Behavior on opacity {
58 enabled: Kirigami.Units.shortDuration > 0
59 OpacityAnimator { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutQuad }
60 }
61 }
62
64 id: surfaceFocused
65 anchors.fill: parent
66 imagePath: "widgets/button"
67 prefix: ["focus-background", "normal"]
68 opacity: root.showFocused ? 1 : 0
69 Behavior on opacity {
70 enabled: Kirigami.Units.shortDuration > 0
71 OpacityAnimator { duration: Kirigami.Units.shortDuration; easing.type: Easing.OutQuad }
72 }
73 }
74
75}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:54:11 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.