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

0001 /* This file is part of the KDE project
0002  * SPDX-FileCopyrightText: 2006 Thomas Zander <zander@kde.org>
0003  * SPDX-FileCopyrightText: 2008 Jan Hambrecht <jaham@gmx.net>
0004  * SPDX-FileCopyrightText: 2010 Thorsten Zachmann <zachmann@kde.org>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.0-or-later
0007  */
0008 #ifndef KOFLAKE_H
0009 #define KOFLAKE_H
0010 
0011 #include "kritaflake_export.h"
0012 
0013 class QGradient;
0014 class QRectF;
0015 class QPointF;
0016 class QSizeF;
0017 
0018 class KoShape;
0019 class QTransform;
0020 
0021 #include <Qt>
0022 
0023 /**
0024  * Flake reference
0025  */
0026 namespace KoFlake
0027 {
0028     enum FillVariant {
0029         Fill,
0030         StrokeFill
0031     };
0032 
0033     enum FillType {
0034         None,
0035         Solid,
0036         Gradient,
0037         Pattern,
0038         MeshGradient
0039     };
0040 
0041     enum MarkerPosition {
0042         StartMarker,
0043         MidMarker,
0044         EndMarker
0045     };
0046 
0047     /// the selection type for KoSelection::selectedObjects()
0048     enum SelectionType {
0049         FullSelection,      ///< Create a list of all user-shapes in the selection. This excludes KoShapeGroup grouping objects that may be selected.
0050         StrippedSelection,  ///< Create a stripped list, without children if the container is also in the list.
0051         TopLevelSelection   ///< Create a list, much like the StrippedSelection, but have the KoShapeGroup instead of all of its children if one is selected.
0052     };
0053 
0054     /// Enum determining which handle is meant, used in KoInteractionTool
0055     enum SelectionHandle {
0056         TopMiddleHandle,    ///< The handle that is at the top - center of a selection
0057         TopRightHandle,     ///< The handle that is at the top - right of  a selection
0058         RightMiddleHandle,  ///< The handle that is at the right - center of a selection
0059         BottomRightHandle,  ///< The handle that is at the bottom right of a selection
0060         BottomMiddleHandle, ///< The handle that is at the bottom center of a selection
0061         BottomLeftHandle,   ///< The handle that is at the bottom left of a selection
0062         LeftMiddleHandle,   ///< The handle that is at the left center of a selection
0063         TopLeftHandle,      ///< The handle that is at the top left of a selection
0064         NoHandle            ///< Value to indicate no handle
0065     };
0066 
0067     /**
0068      * Used to change the behavior of KoShapeManager::shapeAt()
0069      */
0070     enum ShapeSelection {
0071         Selected,   ///< return the first selected with the highest z-ordering (i.e. on top).
0072         Unselected, ///< return the first unselected on top.
0073         NextUnselected, ///< return the first unselected directly under a selected shape, or the top most one if nothing is selected.
0074         ShapeOnTop  ///< return the shape highest z-ordering, regardless of selection.
0075     };
0076 
0077     /**
0078      * Used to see which style type is active
0079      */
0080     enum StyleType {
0081         Background, ///< the background / fill style is active
0082         Foreground  ///< the foreground / stroke style is active
0083     };
0084 
0085     enum AnchorPosition {
0086         TopLeft,
0087         Top,
0088         TopRight,
0089         Left,
0090         Center,
0091         Right,
0092         BottomLeft,
0093         Bottom,
0094         BottomRight,
0095         NoAnchor,
0096         NumAnchorPositions
0097     };
0098 
0099     KRITAFLAKE_EXPORT QPointF anchorToPoint(AnchorPosition anchor, const QRectF rect, bool *valid = 0);
0100 
0101     enum CanvasResource {
0102         HotPosition = 1410100299
0103     };
0104 
0105     /// clones the given gradient
0106     KRITAFLAKE_EXPORT QGradient *cloneGradient(const QGradient *gradient);
0107 
0108     KRITAFLAKE_EXPORT QGradient *mergeGradient(const QGradient *coordsSource, const QGradient *fillSource);
0109 
0110     /**
0111      * Convert absolute to relative position
0112      *
0113      * @param absolute absolute position
0114      * @param size for which the relative position needs to be calculated
0115      *
0116      * @return relative position
0117      */
0118     KRITAFLAKE_EXPORT QPointF toRelative(const QPointF &absolute, const QSizeF &size);
0119 
0120     /**
0121      * Convert relative size to absolute size
0122      *
0123      * @param relative relative position
0124      * @param size for which the absolute position needs to be calculated
0125      *
0126      * @return absolute position
0127      */
0128     KRITAFLAKE_EXPORT QPointF toAbsolute(const QPointF &relative, const QSizeF &size);
0129 
0130     KRITAFLAKE_EXPORT Qt::Orientation significantScaleOrientation(qreal scaleX, qreal scaleY);
0131 
0132     KRITAFLAKE_EXPORT void scaleShape(KoShape *shape, qreal scaleX, qreal scaleY,
0133                                       const QPointF &absoluteStillPoint,
0134                                       const QTransform &postScalingCoveringTransform);
0135 
0136     KRITAFLAKE_EXPORT void scaleShapeGlobal(KoShape *shape, qreal scaleX, qreal scaleY,
0137                           const QPointF &absoluteStillPoint);
0138 
0139 
0140     KRITAFLAKE_EXPORT void resizeShape(KoShape *shape, qreal scaleX, qreal scaleY,
0141                               const QPointF &absoluteStillPoint,
0142                               bool useGlobalMode);
0143 
0144     KRITAFLAKE_EXPORT void resizeShapeCommon(KoShape *shape, qreal scaleX, qreal scaleY,
0145                                        const QPointF &absoluteStillPoint,
0146                                        bool useGlobalMode,
0147                                        bool usePostScaling, const QTransform &postScalingCoveringTransform);
0148 }
0149 
0150 #endif