15#ifndef QGSCOLORSWATCHGRID_H
16#define QGSCOLORSWATCHGRID_H
23#include <QWidgetAction>
57 QString
context()
const {
return mContext; }
64 void setContext(
const QString &context );
78 void setBaseColor(
const QColor &baseColor );
108 void paintEvent( QPaintEvent *event )
override;
122 bool mDrawBoxDepressed =
false;
123 int mCurrentHoverBox = -1;
125 bool mFocused =
false;
126 int mCurrentFocusBox = 0;
130 int mLabelHeight = 0;
132 int mLabelMargin = 0;
137 int mSwatchOutlineSize = 0;
140 int mSwatchMargin = 0;
143 int mSwatchSpacing = 0;
145 bool mPressedOnWidget =
false;
151 int calculateHeight()
const;
157 void draw( QPainter &painter );
164 int swatchForPosition( QPoint position )
const;
170 void updateTooltip(
int colorIdx );
176 QPixmap transparentBackground();
253 void refreshColors();
264 QMenu *mMenu =
nullptr;
268 bool mSuppressRecurse =
false;
269 bool mDismissOnColorSelection =
true;
276 void setColor(
const QColor &color );
Abstract base class for color schemes.
void setDismissOnColorSelection(bool dismiss)
Sets whether the parent menu should be dismissed and closed when a color is selected from the action'...
void setBaseColor(const QColor &baseColor)
Sets the base color for the color grid.
QString context() const
Gets the current context for the color grid.
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
bool dismissOnColorSelection() const
Returns whether the parent menu will be dismissed after a color is selected from the action's color w...
QgsColorSwatchGridAction(QgsColorScheme *scheme, QMenu *menu=nullptr, const QString &context=QString(), QWidget *parent=nullptr)
Construct a new color swatch grid action.
QColor baseColor() const
Gets the base color for the color grid.
void setContext(const QString &context)
Sets the current context for the color grid.
A grid of color swatches, which allows for user selection.
void mouseMoveEvent(QMouseEvent *event) override
void mousePressEvent(QMouseEvent *event) override
QColor baseColor() const
Gets the base color for the widget.
QgsColorSwatchGrid(QgsColorScheme *scheme, const QString &context=QString(), QWidget *parent=nullptr)
Construct a new color swatch grid.
void paintEvent(QPaintEvent *event) override
QgsNamedColorList * colors()
Gets the list of colors shown in the grid.
void colorChanged(const QColor &color)
Emitted when a color has been selected from the widget.
QSize minimumSizeHint() const override
void mouseReleaseEvent(QMouseEvent *event) override
QSize sizeHint() const override
friend class QgsColorTooltip
void focusInEvent(QFocusEvent *event) override
void keyPressEvent(QKeyEvent *event) override
void focusOutEvent(QFocusEvent *event) override
void hovered()
Emitted when mouse hovers over widget.
QString context() const
Gets the current context for the grid.
QList< QPair< QColor, QString > > QgsNamedColorList
List of colors paired with a friendly display name identifying the color.