File indexing completed on 2024-12-22 04:13:07

0001 /*
0002  *  SPDX-FileCopyrightText: 2004 Cyrille Berger <cberger@cberger.net>
0003  *  SPDX-FileCopyrightText: 2016 Sven Langkamp <sven.langkamp@gmail.com>
0004  *
0005  *  SPDX-License-Identifier: GPL-2.0-or-later
0006  */
0007 
0008 #ifndef _KIS_STOP_GRADIENT_EDITOR_H_
0009 #define _KIS_STOP_GRADIENT_EDITOR_H_
0010 
0011 #include "kritaui_export.h"
0012 #include "ui_wdgstopgradienteditor.h"
0013 #include <boost/optional.hpp>
0014 #include <KoStopGradient.h>
0015 #include <KisGradientWidgetsUtils.h>
0016 
0017 class KRITAUI_EXPORT KisStopGradientEditor : public QWidget, public Ui::KisWdgStopGradientEditor
0018 {
0019     Q_OBJECT
0020 
0021 public:
0022     enum SortFlag {
0023         SORT_ASCENDING = 1 << 0,
0024         EVEN_DISTRIBUTION = 1 << 1
0025     };
0026     Q_DECLARE_FLAGS( SortFlags, SortFlag);
0027 
0028 
0029     KisStopGradientEditor(QWidget *parent);
0030     KisStopGradientEditor(KoStopGradientSP gradient, QWidget *parent, const char* name, const QString& caption, KoCanvasResourcesInterfaceSP canvasResourcesInterface);
0031 
0032     void setCompactMode(bool value);
0033 
0034     void setGradient(KoStopGradientSP gradient);
0035 
0036     void setCanvasResourcesInterface(KoCanvasResourcesInterfaceSP canvasResourcesInterface);
0037     KoCanvasResourcesInterfaceSP canvasResourcesInterface() const;
0038 
0039     void notifyGlobalColorChanged(const KoColor &color);
0040 
0041     boost::optional<KoColor> currentActiveStopColor() const;
0042 
0043 Q_SIGNALS:
0044     void sigGradientChanged();
0045 
0046 private:
0047     KoStopGradientSP m_gradient;
0048     KoCanvasResourcesInterfaceSP m_canvasResourcesInterface;
0049     QAction *m_editStopAction;
0050     QAction *m_deleteStopAction;
0051 
0052 private Q_SLOTS:
0053     void stopChanged(int stop);
0054     void stopTypeChanged(KisGradientWidgetsUtils::ColorType type);
0055     void colorChanged(const KoColor& color);
0056     void opacityChanged(qreal value);
0057     void positionChanged(qreal value);
0058     void nameChanged();
0059     void reverse();
0060     void distributeStopsEvenly();
0061     void sortByValue(SortFlags flags);
0062     void sortByHue(SortFlags flags);
0063     void editSelectedStop();
0064 };
0065 
0066 Q_DECLARE_OPERATORS_FOR_FLAGS(KisStopGradientEditor::SortFlags);
0067 #endif