Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_popup_palette.h
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2009 Vera Lukman <shicmap@gmail.com>
3 SPDX-FileCopyrightText: 2016 Scott Petrovic <scottpetrovic@gmail.com>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7
8#ifndef KIS_POPUP_PALETTE_H
9#define KIS_POPUP_PALETTE_H
10
11#include <QPushButton>
12#include <QSlider>
13#include <QGraphicsOpacityEffect>
14#include "KisViewManager.h"
15#include "kactioncollection.h"
16#include "kis_tool_button.h"
20
22class QWidget;
23class KoColor;
27class KisDockerHud;
33
34
36 int ringCount{1};
40 qreal firstRowPos{0};
41 qreal secondRowPos{0};
42 qreal thirdRowPos{0};
43};
44
45class KisPopupPalette : public QWidget, public KisPopupWidgetInterface
46{
47 Q_OBJECT
48 Q_INTERFACES(KisPopupWidgetInterface)
49
50 Q_PROPERTY(int hoveredPreset READ hoveredPreset WRITE setHoveredPreset)
51 Q_PROPERTY(int hoveredColor READ hoveredColor WRITE setHoveredColor)
52 Q_PROPERTY(int selectedColor READ selectedColor WRITE setSelectedColor)
53
54public:
56 QWidget *parent = 0);
57 ~KisPopupPalette() override;
58 QSize sizeHint() const override;
59
60 //functions to set up selectedColor
61 void setSelectedColor(int x);
62 int selectedColor() const;
63 void setParent(QWidget *parent);
64
65
66 void popup(const QPoint& position) override;
67 void dismiss() override;
68 bool onScreen() override;
69
70 void ensureWithinParent(const QPoint& globalPos, bool useUpperLeft);
71
72protected:
73 void showEvent(QShowEvent *event) override;
74 void paintEvent(QPaintEvent*) override;
75 void resizeEvent(QResizeEvent*) override;
76 void tabletEvent(QTabletEvent *event) override;
77 void mouseReleaseEvent(QMouseEvent*) override;
78 void mouseMoveEvent(QMouseEvent*) override;
79 void mousePressEvent(QMouseEvent*) override;
80 bool eventFilter(QObject *, QEvent *) override;
81
87 int calculateColorIndex(QPointF position, int numColors) const;
92 int findPresetSlot(QPointF position) const;
93
94 //functions to set up hoveredBrush
95 void setHoveredPreset(int x);
96 int hoveredPreset() const;
97 //functions to set up hoveredColor
98 void setHoveredColor(int x);
99 int hoveredColor() const;
100
101private:
102 void reconfigure();
103
104 QPainterPath drawDonutPathFull(int, int, int, int);
105 QPainterPath drawDonutPathAngle(int, int, int);
106 QPainterPath drawFgBgColorIndicator(int type) const;
107 QRectF rotationIndicatorRect(qreal rotationAngle) const;
108 bool isPointInPixmap(QPointF&, int pos);
109
110 QPointF drawPointOnAngle(qreal angle, qreal radius) const;
117 QPainterPath createPathFromPresetIndex(int index) const;
118
120
121 QPoint m_mirrorPos {};
130 bool m_isOverFgBgColors {false};
131 bool m_snapRotation {false};
133 qreal m_snapRadius {15};
134 std::array<QRect, 24> m_snapRects{};
135 std::array<QLineF, 24> m_snapLines {};
136
138
144 QScopedPointer<KisSignalCompressor> m_colorChangeCompressor;
146
147 QSpacerItem *m_mainArea {0};
149 QWidget* m_bottomBarWidget {0};
150 qreal m_popupPaletteSize {385.0};
157
167 bool m_isZoomingCanvas {false};
168
172 QPushButton *fitToViewButton {0};
173 QSlider *zoomCanvasSlider {0};
177
179
180 // updates the transparency and effects of the whole widget
181 QGraphicsOpacityEffect *opacityChange {0};
183
184Q_SIGNALS:
190 void finished() override; // KisPopupWidgetInterface.
191
192public Q_SLOTS:
193 void slotUpdateIcons();
194
195private Q_SLOTS:
196 void slotSetMirrorPos();
197 void slotRemoveMirrorPos();
200 void slotExternalFgColorChanged(const KoColor &color);
202 void slotSetSelectedColor(int x) { setSelectedColor(x); update(); }
203 void slotUpdate();
204 void slotShowTagsPopup();
205 void showHudWidget(bool visible);
206 void showBottomBarWidget(bool visible);
209 void slotZoomSliderChanged(int zoom);
210
213};
214
215#endif // KIS_POPUP_PALETTE_H
A KisActionManager class keeps track of KisActions. These actions are always associated with the GUI....
A container for a set of QAction objects.
QPainterPath drawDonutPathAngle(int, int, int)
QPainterPath drawFgBgColorIndicator(int type) const
void zoomLevelChanged(int)
void sigUpdateCanvas()
bool isPointInPixmap(QPointF &, int pos)
int findPresetSlot(QPointF position) const
/ find the index of the brush preset slot containing @position.
bool onScreen() override
Returns whether the widget is active (on screen) or not.
KisHighlightedToolButton * canvasOnlyButton
QSize sizeHint() const override
std::array< QRect, 24 > m_snapRects
void tabletEvent(QTabletEvent *event) override
KisActionManager * m_actionManager
KisRoundHudButton * m_dockerHudButton
KisViewManager * m_viewManager
void finished() override
QPointF drawPointOnAngle(qreal angle, qreal radius) const
void ensureWithinParent(const QPoint &globalPos, bool useUpperLeft)
KisKActionCollection * m_actionCollection
KisRoundHudButton * m_tagsButton
QPushButton * zoomToOneHundredPercentButton
void slotExternalFgColorChanged(const KoColor &color)
void resizeEvent(QResizeEvent *) override
QRectF m_resetCanvasRotationIndicatorRect
void calculatePresetLayout()
Determine the number of rings to distribute the presets and calculate the radius of the brush preset ...
void slotSetSelectedColor(int x)
KisRoundHudButton * m_bottomBarButton
void slotZoomSliderChanged(int zoom)
CachedPresetLayout m_cachedPresetLayout
QPainterPath drawDonutPathFull(int, int, int, int)
void sigChangefGColor(const KoColor &)
KisHighlightedToolButton * mirrorMode
std::array< QLineF, 24 > m_snapLines
int calculateColorIndex(QPointF position, int numColors) const
Calculate index of recent color in array.
KisCoordinatesConverter * m_coordinatesConverter
void slotDisplayConfigurationChanged()
QRectF rotationIndicatorRect(qreal rotationAngle) const
void sigChangeActivePaintop(int)
void showBottomBarWidget(bool visible)
void dismiss() override
Called when you want to dismiss a popup widget.
QSpacerItem * m_mainArea
void setParent(QWidget *parent)
KisMouseClickEater * m_clicksEater
void showEvent(QShowEvent *event) override
void showHudWidget(bool visible)
QWidget * m_bottomBarWidget
QScopedPointer< KisSignalCompressor > m_colorChangeCompressor
KisColorSelectorInterface * m_colorSelector
KisFavoriteResourceManager * m_resourceManager
KisRoundHudButton * m_clearColorHistoryButton
KisDockerHud * m_dockerHud
void setHoveredPreset(int x)
void mouseMoveEvent(QMouseEvent *) override
void mouseReleaseEvent(QMouseEvent *) override
QPainterPath createPathFromPresetIndex(int index) const
KisAcyclicSignalConnector * m_acyclicConnector
QGraphicsOpacityEffect * opacityChange
bool m_isOverResetCanvasRotationIndicator
void paintEvent(QPaintEvent *) override
void setSelectedColor(int x)
void mousePressEvent(QMouseEvent *) override
QRectF m_canvasRotationIndicatorRect
void slotZoomToOneHundredPercentClicked()
void popup(const QPoint &position) override
Called when and where you want a widget to popup.
const KoColorDisplayRendererInterface * m_displayRenderer
void setHoveredColor(int x)
void sigUpdateRecentColor(int)
bool eventFilter(QObject *, QEvent *) override
QPushButton * fitToViewButton
The PopupWidgetInterface abstract class defines the basic interface that will be used by all popup wi...
The KisVisualColorSelector class.