File indexing completed on 2024-05-12 15:56:49

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net>
0003  * SPDX-FileCopyrightText: 2010 Thomas Zander <zander@kde.org>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #ifndef KOSHAPESHADOW_H
0009 #define KOSHAPESHADOW_H
0010 
0011 #include "kritaflake_export.h"
0012 
0013 #include <QtGlobal>
0014 
0015 class KoShape;
0016 class KoShapeSavingContext;
0017 class QPainter;
0018 class QPointF;
0019 class QColor;
0020 struct KoInsets;
0021 
0022 class KRITAFLAKE_EXPORT KoShapeShadow
0023 {
0024 public:
0025     KoShapeShadow();
0026     ~KoShapeShadow();
0027 
0028     KoShapeShadow(const KoShapeShadow &rhs);
0029     KoShapeShadow& operator=(const KoShapeShadow &rhs);
0030 
0031     /**
0032      * Paints the shadow of the shape.
0033      * @param shape the shape to paint around
0034      * @param painter the painter to paint shadows to canvas
0035      * @param converter to convert between internal and view coordinates.
0036      */
0037     void paint(KoShape *shape, QPainter &painter);
0038 
0039     /**
0040      * Sets the shadow offset from the topleft corner of the shape
0041      * @param offset the shadow offset
0042      */
0043     void setOffset(const QPointF &offset);
0044 
0045     /// Returns the shadow offset
0046     QPointF offset() const;
0047 
0048     /**
0049      * Sets the shadow color, including the shadow opacity.
0050      * @param color the shadow color and opacity
0051      */
0052     void setColor(const QColor &color);
0053 
0054     /// Returns the shadow color including opacity
0055     QColor color() const;
0056 
0057     /**
0058      * Sets the shadow blur radius of the shape
0059      * @param blur the shadow blur radius
0060      */
0061     void setBlur(qreal blur);
0062 
0063     /// Returns the shadow blur radius
0064     qreal blur() const;
0065 
0066     /// Sets the shadow visibility
0067     void setVisible(bool visible);
0068 
0069     /// Returns if shadow is visible
0070     bool isVisible() const;
0071 
0072     /// Fills the insets object with the space the shadow takes around a shape
0073     void insets(KoInsets &insets) const;
0074 
0075     /**
0076      * Increments the use-value.
0077      * Returns true if the new value is non-zero, false otherwise.
0078      */
0079     bool ref();
0080     /**
0081      * Decrements the use-value.
0082      * Returns true if the new value is non-zero, false otherwise.
0083      */
0084     bool deref();
0085     /// Return the usage count
0086     int useCount() const;
0087 
0088 private:
0089     class Private;
0090     Private * const d;
0091 };
0092 
0093 #endif // KOSHAPESHADOW_H