KDecoration2

decorationshadow.cpp
1/*
2 * SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
5 */
6#include "decorationshadow.h"
7#include "decorationshadow_p.h"
8
9namespace KDecoration2
10{
11DecorationShadow::Private::Private(DecorationShadow *parent)
12 : q(parent)
13{
14}
15
16DecorationShadow::Private::~Private() = default;
17
18DecorationShadow::DecorationShadow()
19 : QObject()
20 , d(new Private(this))
21{
22}
23
24DecorationShadow::~DecorationShadow() = default;
25
26QRect DecorationShadow::topLeftGeometry() const
27{
28 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
29 return QRect();
30 }
31 return QRect(0, 0, d->innerShadowRect.left(), d->innerShadowRect.top());
32}
33
34QRect DecorationShadow::topGeometry() const
35{
36 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
37 return QRect();
38 }
39 return QRect(d->innerShadowRect.left(), 0, d->innerShadowRect.width(), d->innerShadowRect.top());
40}
41
42QRect DecorationShadow::topRightGeometry() const
43{
44 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
45 return QRect();
46 }
47 return QRect(d->innerShadowRect.left() + d->innerShadowRect.width(),
48 0,
49 d->shadow.width() - d->innerShadowRect.width() - d->innerShadowRect.left(),
50 d->innerShadowRect.top());
51}
52
53QRect DecorationShadow::rightGeometry() const
54{
55 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
56 return QRect();
57 }
58 return QRect(d->innerShadowRect.left() + d->innerShadowRect.width(),
59 d->innerShadowRect.top(),
60 d->shadow.width() - d->innerShadowRect.width() - d->innerShadowRect.left(),
61 d->innerShadowRect.height());
62}
63
64QRect DecorationShadow::bottomRightGeometry() const
65{
66 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
67 return QRect();
68 }
69 return QRect(d->innerShadowRect.left() + d->innerShadowRect.width(),
70 d->innerShadowRect.top() + d->innerShadowRect.height(),
71 d->shadow.width() - d->innerShadowRect.width() - d->innerShadowRect.left(),
72 d->shadow.height() - d->innerShadowRect.top() - d->innerShadowRect.height());
73}
74
75QRect DecorationShadow::bottomGeometry() const
76{
77 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
78 return QRect();
79 }
80 return QRect(d->innerShadowRect.left(),
81 d->innerShadowRect.top() + d->innerShadowRect.height(),
82 d->innerShadowRect.width(),
83 d->shadow.height() - d->innerShadowRect.top() - d->innerShadowRect.height());
84}
85
86QRect DecorationShadow::bottomLeftGeometry() const
87{
88 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
89 return QRect();
90 }
91 return QRect(0,
92 d->innerShadowRect.top() + d->innerShadowRect.height(),
93 d->innerShadowRect.left(),
94 d->shadow.height() - d->innerShadowRect.top() - d->innerShadowRect.height());
95}
96
97QRect DecorationShadow::leftGeometry() const
98{
99 if (d->innerShadowRect.isNull() || d->shadow.isNull()) {
100 return QRect();
101 }
102 return QRect(0, d->innerShadowRect.top(), d->innerShadowRect.left(), d->innerShadowRect.height());
103}
104
105#ifndef K_DOXYGEN
106
107QImage DecorationShadow::shadow() const
108{
109 return d->shadow;
110}
111
112QMargins DecorationShadow::padding() const
113{
114 return d->padding;
115}
116
117QRect DecorationShadow::innerShadowRect() const
118{
119 return d->innerShadowRect;
120}
121
122int DecorationShadow::paddingTop() const
123{
124 return d->padding.top();
125}
126
127int DecorationShadow::paddingBottom() const
128{
129 return d->padding.bottom();
130}
131
132int DecorationShadow::paddingRight() const
133{
134 return d->padding.right();
135}
136
137int DecorationShadow::paddingLeft() const
138{
139 return d->padding.left();
140}
141
142void DecorationShadow::setShadow(const QImage &shadow)
143{
144 if (d->shadow == shadow) {
145 return;
146 }
147 d->shadow = shadow;
148 Q_EMIT shadowChanged(d->shadow);
149}
150
151#endif
152
153void DecorationShadow::setPadding(const QMargins &margins)
154{
155 if (d->padding == margins) {
156 return;
157 }
158 d->padding = margins;
159 Q_EMIT paddingChanged();
160}
161
162void DecorationShadow::setInnerShadowRect(const QRect &rect)
163{
164 if (d->innerShadowRect == rect) {
165 return;
166 }
167 d->innerShadowRect = rect;
168 Q_EMIT innerShadowRectChanged();
169}
170
171}
172
173#include "moc_decorationshadow.cpp"
Framework for creating window decorations.
int top() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:18 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.