HAL
shadow_effect.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include <QGraphicsEffect>
29 
30 namespace hal
31 {
32 
41  {
42  Q_OBJECT
43 
44  public:
50  explicit ShadowEffect(QObject* parent = nullptr);
51 
57  void draw(QPainter* painter);
58 
66  QRectF boundingRectFor(const QRectF& rect) const;
67 
73  inline void setDistance(qreal distance)
74  {
75  mDistance = distance;
77  }
78 
84  inline qreal distance() const
85  {
86  return mDistance;
87  }
88 
94  inline void setBlurRadius(qreal blurRadius)
95  {
96  mBlurRadius = blurRadius;
98  }
99 
105  inline qreal blurRadius() const
106  {
107  return mBlurRadius;
108  }
109 
115  inline void setColor(const QColor& color)
116  {
117  mColor = color;
118  }
119 
125  inline QColor color() const
126  {
127  return mColor;
128  }
129 
130  private:
131  qreal mDistance;
132  qreal mBlurRadius;
133  QColor mColor;
134  };
135 }
Creates a shadow effect around QObjects.
Definition: shadow_effect.h:41
void setColor(const QColor &color)
QColor color() const
void draw(QPainter *painter)
qreal distance() const
Definition: shadow_effect.h:84
ShadowEffect(QObject *parent=nullptr)
void setDistance(qreal distance)
Definition: shadow_effect.h:73
qreal blurRadius() const
QRectF boundingRectFor(const QRectF &rect) const
void setBlurRadius(qreal blurRadius)
Definition: shadow_effect.h:94
void updateBoundingRect()
Q_OBJECTQ_OBJECT
QObject * parent() const const