Changeset View
Changeset View
Standalone View
Standalone View
source/qml/lib/Surface.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2018 Fabian Riethmayer | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.2 | ||||
21 | import QtQuick.Controls 2.2 | ||||
22 | import org.kde.kirigami 2.4 as Kirigami | ||||
23 | import QtGraphicalEffects 1.0 | ||||
24 | import QtQuick.Templates 2.0 as T | ||||
25 | | ||||
26 | // A breeze surface with shadows, rounded borders, blur | ||||
27 | ItemDelegate { | ||||
28 | id: root | ||||
29 | default property alias contents: content.data | ||||
30 | property string color : "#fcfcfc" | ||||
31 | property int radius: 3 | ||||
32 | property int elevation: 1 | ||||
33 | property Item sourceItem; | ||||
34 | | ||||
35 | | ||||
36 | background: Item { | ||||
37 | anchors.fill: parent | ||||
38 | id: background | ||||
39 | | ||||
40 | FastBlur{ | ||||
41 | id: blur | ||||
42 | anchors.fill: surface | ||||
43 | // TODO visible: surface.isColorHasAlphaValue | ||||
44 | source: ShaderEffectSource { | ||||
45 | id: effectSource | ||||
46 | sourceItem: root.sourceItem | ||||
47 | sourceRect: Qt.rect(root.x * 2, root.y * 2, root.width, root.height) | ||||
48 | } | ||||
49 | radius: 32 | ||||
50 | } | ||||
51 | | ||||
52 | Rectangle { | ||||
53 | anchors.fill: parent | ||||
54 | radius: root.radius | ||||
55 | color: root.color | ||||
56 | id: surface | ||||
57 | } | ||||
58 | } | ||||
59 | | ||||
60 | DropShadow { | ||||
61 | anchors.fill: background | ||||
62 | horizontalOffset: elevation < 2 ? 1 : 3 | ||||
63 | verticalOffset: elevation < 2 ? 1 : 3 | ||||
64 | radius: root.elevation * 4 | ||||
65 | samples: root.elevation * 10 | ||||
66 | color: "#92232627" | ||||
67 | source: background | ||||
68 | } | ||||
69 | | ||||
70 | Item { | ||||
71 | anchors.fill: parent | ||||
72 | id: content | ||||
73 | } | ||||
74 | } |