9#ifndef KIS_LEVELS_SLIDER_H
10#define KIS_LEVELS_SLIDER_H
15#include "kritawidgets_export.h"
29 QSize sizeHint()
const override;
30 QSize minimumSizeHint()
const override;
35 qreal handlePosition(
int handleIndex)
const;
39 QColor handleColor(
int handleIndex)
const;
43 virtual QRect gradientRect()
const;
49 virtual void setHandlePosition(
int handleIndex, qreal newPosition);
53 virtual void setHandleColor(
int handleIndex,
const QColor &newColor);
73 static constexpr int handleWidth{11};
74 static constexpr int handleHeight{11};
75 static constexpr qreal minimumSpaceBetweenHandles{0.001};
76 static constexpr qreal normalPositionIncrement{0.01};
77 static constexpr qreal slowPositionIncrement{0.001};
105 int closestHandleToPosition(qreal position)
const;
110 qreal positionFromX(
int x)
const;
115 int closestHandleToX(
int x)
const;
120 int xFromPosition(qreal position)
const;
129 virtual void paintHandle(QPainter &painter,
const QRect &
rect,
const Handle &handle);
131 void handleIncrementInput(
int direction, Qt::KeyboardModifiers modifiers);
133 void paintEvent(QPaintEvent *e)
override;
134 void mousePressEvent(QMouseEvent *e)
override;
135 void mouseMoveEvent(QMouseEvent *e)
override;
136 void leaveEvent(QEvent *e)
override;
137 void keyPressEvent(QKeyEvent *e)
override;
138 void wheelEvent(QWheelEvent *e)
override;
158 qreal blackPoint()
const;
162 qreal whitePoint()
const;
168 virtual void setBlackPoint(qreal newBlackPoint);
172 virtual void setWhitePoint(qreal newWhitePoint);
181 virtual void reset(qreal newBlackPoint, qreal newWhitePoint);
204 void paintGradient(QPainter &painter,
const QRect &
rect)
override;
212 virtual void paintBottomGradientMiddleSection(QImage &gradientImage,
const QVector<Handle> &sortedHandles_);
234 void setHandlePosition(
int handleIndex, qreal newPosition)
override;
238 void setGamma(qreal newGamma);
242 void reset(qreal newBlackPoint, qreal newWhitePoint)
override;
246 void reset(qreal newBlackPoint, qreal newWhitePoint, qreal newGamma);
255 void paintBottomGradientMiddleSection(QImage &gradientImage,
const QVector<Handle> &sortedHandles_)
override;
260 qreal gammaToPosition()
const;
261 qreal positionToGamma()
const;
291 qreal threshold()
const;
299 void setHandlePosition(
int handleIndex, qreal newPosition)
override;
305 void setBlackPoint(qreal newBlackPoint)
override;
311 void setWhitePoint(qreal newWhitePoint)
override;
312 void reset(qreal newBlackPoint, qreal newWhitePoint)
override;
316 void setThreshold(qreal newGamma);
325 void paintBottomGradientMiddleSection(QImage &gradientImage,
const QVector<Handle> &sortedHandles_)
override;
326 void paintHandle(QPainter &painter,
const QRect &
rect,
const Handle &handle)
override;
A base class for levels slider like widgets: a slider with a gradient and multiple handles.
int m_constrainPositions
This variable indicates if the handles can have unordered positions. If it is set to true then the us...
void handlePositionChanged(int handleIndex, qreal position)
Signal emitted when the position of a handle changes.
void handleColorChanged(int handleIndex, const QColor &color)
Signal emitted when the color associated with a handle changes.
virtual void paintGradient(QPainter &painter, const QRect &rect)=0
Derived classes must override this function to draw the gradient inside the given rect....
QVector< Handle > m_handles
The collection of handles.
This is a simple output levels slider. It is basically the same as KisInputLevelsSlider but the handl...
This is a threshold slider that only has one handle.
void thresholdChanged(qreal newThreshold)
Signal emitted when the threshold value changes.