| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2021 Mathias Wein <[email protected]> |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: GPL-3.0-or-later |
| 5 |
*/ |
| 6 |
|
| 7 |
#ifndef WGSELECTORWIDGETBASE_H |
| 8 |
#define WGSELECTORWIDGETBASE_H |
| 9 |
|
| 10 |
#include <kis_display_color_converter.h> |
| 11 |
#include <KisVisualColorModel.h> |
| 12 |
#include <QPointer> |
| 13 |
#include <QSharedPointer> |
| 14 |
#include <QWidget> |
| 15 |
|
| 16 |
class WGSelectorDisplayConfig : public QObject |
| 17 |
{ |
| 18 |
Q_OBJECT |
| 19 |
public: |
| 20 |
WGSelectorDisplayConfig() = default; |
| 21 |
~WGSelectorDisplayConfig() = default; |
| 22 |
const KisDisplayColorConverter *displayConverter() const; |
| 23 |
void setDisplayConverter(const KisDisplayColorConverter *converter); |
| 24 |
|
| 25 |
bool previewInPaintingCS() const { return m_previewInPaintingCS; } |
| 26 |
void setPreviewInPaintingCS(bool enabled); |
| 27 |
Q_SIGNALS: |
| 28 |
void sigDisplayConfigurationChanged(); |
| 29 |
private: |
| 30 |
QPointer<const KisDisplayColorConverter> m_displayConverter; |
| 31 |
bool m_previewInPaintingCS {false}; |
| 32 |
}; |
| 33 |
|
| 34 |
typedef QSharedPointer<WGSelectorDisplayConfig> WGSelectorDisplayConfigSP; |
| 35 |
|
| 36 |
class WGSelectorWidgetBase : public QWidget |
| 37 |
{ |
| 38 |
Q_OBJECT |
| 39 |
public: |
| 40 |
enum UiMode { |
| 41 |
DockerMode, |
| 42 |
PopupMode |
| 43 |
}; |
| 44 |
|
| 45 |
explicit WGSelectorWidgetBase(WGSelectorDisplayConfigSP displayConfig, QWidget *parent = nullptr, UiMode uiMode = UiMode::DockerMode); |
| 46 |
UiMode uiMode() const; |
| 47 |
void setUiMode(UiMode mode); |
| 48 |
WGSelectorDisplayConfigSP displayConfiguration() const; |
| 49 |
const KisDisplayColorConverter *displayConverter() const; |
| 50 |
/*! |
| 51 |
* \brief The position, relative to the top left corner, where the cursor |
| 52 |
* of the cursor shall be when showing the popup. |
| 53 |
* |
| 54 |
* The default implementation returns the widget center. |
| 55 |
* \return desired cursor position relative to the top left corner |
| 56 |
*/ |
| 57 |
virtual QPoint popupOffset() const; |
| 58 |
virtual void setModel(KisVisualColorModelSP model); |
| 59 |
virtual void updateSettings(); |
| 60 |
|
| 61 |
Q_SIGNALS: |
| 62 |
void sigColorInteraction(bool active); |
| 63 |
void sigChannelValuesChanged(const QVector4D &values); |
| 64 |
private: |
| 65 |
QPointer<const KisDisplayColorConverter> m_converter; |
| 66 |
WGSelectorDisplayConfigSP m_displayConfig; |
| 67 |
UiMode m_uiMode {DockerMode}; |
| 68 |
}; |
| 69 |
|
| 70 |
#endif // WGSELECTORWIDGETBASE_H |