Kirigami2

CornerShadow.qml
1 /*
2  * SPDX-FileCopyrightText: 2016 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.1
8 import QtGraphicalEffects 1.0 as GE
9 import org.kde.kirigami 2.4 as Kirigami
10 
11 GE.RadialGradient {
12  id: shadow
13  /**
14  * @brief This property holds the corner of the shadow that will determine
15  * the direction of the gradient.
16  *
17  * The acceptable values are:
18  * Qt.TopLeftCorner, TopRightCorner, BottomLeftCorner, BottomRightCorner
19  *
20  * default: ``Qt.TopRightCorner``
21  *
22  * @see Qt::Corner
23  */
24  property int corner: Qt.TopRightCorner
25 
26  readonly property real margin: -Math.floor(radius/3)
27 
28  property int radius: Kirigami.Units.gridUnit
29 
30  width: radius - margin
31  height: radius - margin
32 
33  horizontalRadius: width
34  verticalRadius: height
35  horizontalOffset: {
36  switch (corner) {
37  case Qt.TopLeftCorner:
38  case Qt.BottomLeftCorner:
39  return -width/2;
40  default:
41  return width/2;
42  }
43  }
44  verticalOffset: {
45  switch (corner) {
46  case Qt.TopLeftCorner:
47  case Qt.TopRightCorner:
48  return -width/2;
49  default:
50  return width/2;
51  }
52  }
53 
54  gradient: Gradient {
55  GradientStop {
56  position: 0.0
57  color: Qt.rgba(0, 0, 0, 0.25)
58  }
59  GradientStop {
60  position: 1 - radius/(radius - margin)
61  color: Qt.rgba(0, 0, 0, 0.25)
62  }
63  GradientStop {
64  position: 1 - radius/(radius - margin) + radius/(radius - margin) * 0.2
65  color: Qt.rgba(0, 0, 0, 0.1)
66  }
67  GradientStop {
68  position: 1 - radius/(radius - margin) + radius/(radius - margin) * 0.35
69  color: Qt.rgba(0, 0, 0, 0.02)
70  }
71  GradientStop {
72  position: 1.0
73  color: "transparent"
74  }
75  }
76 }
77 
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.