File indexing completed on 2024-06-23 04:28:11
0001 /* 0002 * SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef KOSHAPEGRADIENTHANDLES_H 0008 #define KOSHAPEGRADIENTHANDLES_H 0009 0010 #include <QPointF> 0011 #include <QGradient> 0012 #include <KoFlake.h> 0013 0014 class KoShape; 0015 class KoViewConverter; 0016 class KUndo2Command; 0017 0018 class KoShapeGradientHandles 0019 { 0020 public: 0021 struct Handle { 0022 enum Type { 0023 None, 0024 LinearStart, 0025 LinearEnd, 0026 RadialCenter, 0027 RadialRadius, 0028 RadialFocalPoint 0029 }; 0030 0031 Handle() : type(None) {} 0032 Handle(Type t, const QPointF &p) : type(t), pos(p) {} 0033 0034 Type type; 0035 QPointF pos; 0036 }; 0037 0038 public: 0039 KoShapeGradientHandles(KoFlake::FillVariant fillVariant, KoShape *shape); 0040 QVector<Handle> handles() const; 0041 QGradient::Type type() const; 0042 0043 KUndo2Command* moveGradientHandle(Handle::Type handleType, const QPointF &absoluteOffset); 0044 Handle getHandle(Handle::Type handleType); 0045 0046 0047 0048 private: 0049 const QGradient* gradient() const; 0050 QPointF getNewHandlePos(const QPointF &oldPos, const QPointF &absoluteOffset, QGradient::CoordinateMode mode); 0051 0052 private: 0053 KoFlake::FillVariant m_fillVariant; 0054 KoShape *m_shape; 0055 }; 0056 0057 #endif // KOSHAPEGRADIENTHANDLES_H