Warning, file /plasma/breeze/libbreezecommon/breezeboxshadowrenderer.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002  * SPDX-FileCopyrightText: 2018 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 // own
0010 #include "breezecommon_export.h"
0011 
0012 // Qt
0013 #include <QColor>
0014 #include <QImage>
0015 #include <QPoint>
0016 #include <QSize>
0017 
0018 namespace Breeze
0019 {
0020 class BREEZECOMMON_EXPORT BoxShadowRenderer
0021 {
0022 public:
0023     // Compiler generated constructors & destructor are fine.
0024 
0025     /**
0026      * Set the size of the box.
0027      * @param size The size of the box.
0028      **/
0029     void setBoxSize(const QSize &size);
0030 
0031     /**
0032      * Set the radius of box' corners.
0033      * @param radius The border radius, in pixels.
0034      **/
0035     void setBorderRadius(qreal radius);
0036 
0037     /**
0038      * Add a shadow.
0039      * @param offset The offset of the shadow.
0040      * @param radius The blur radius.
0041      * @param color The color of the shadow.
0042      **/
0043     void addShadow(const QPoint &offset, int radius, const QColor &color);
0044 
0045     /**
0046      * Render the shadow.
0047      **/
0048     QImage render() const;
0049 
0050     /**
0051      * Calculate the minimum size of the box.
0052      *
0053      * This helper computes the minimum size of the box so the shadow behind it has
0054      * full its strength.
0055      *
0056      * @param radius The blur radius of the shadow.
0057      **/
0058     static QSize calculateMinimumBoxSize(int radius);
0059 
0060     /**
0061      * Calculate the minimum size of the shadow texture.
0062      *
0063      * This helper computes the minimum size of the resulting texture so the shadow
0064      * is not clipped.
0065      *
0066      * @param boxSize The size of the box.
0067      * @param radius The blur radius.
0068      * @param offset The offset of the shadow.
0069      **/
0070     static QSize calculateMinimumShadowTextureSize(const QSize &boxSize, int radius, const QPoint &offset);
0071 
0072 private:
0073     QSize m_boxSize;
0074     qreal m_borderRadius = 0.0;
0075 
0076     struct Shadow {
0077         QPoint offset;
0078         int radius;
0079         QColor color;
0080     };
0081 
0082     QVector<Shadow> m_shadows;
0083 };
0084 
0085 } // namespace Breeze