|
Krita Source Code Documentation
|
This is a simple input levels slider that has no gamma handle. Use it if you want to show a simple mapping or contrast adjustment. The handles are constrained so that the black point handle can not pass the white point handle and vice-versa. More...
#include <KisLevelsSlider.h>
Inheritance diagram for KisInputLevelsSlider:Public Slots | |
| virtual void | reset (qreal newBlackPoint, qreal newWhitePoint) |
| Sometimes you want to set the range to a totally different place, but the new black point can be greater than the old white point so the new black point position will be constrained to the old white position. This function allows to set both values at once to prevent that undesirable effect. Use it when the widget has to show new values, for a different set of levels parameters for example. | |
| virtual void | setBlackPoint (qreal newBlackPoint) |
| Sets the black point. | |
| virtual void | setWhitePoint (qreal newWhitePoint) |
| Sets the white point. | |
Public Slots inherited from KisLevelsSlider | |
| virtual void | setHandleColor (int handleIndex, const QColor &newColor) |
| Sets the color associated with the given handle. | |
| virtual void | setHandlePosition (int handleIndex, qreal newPosition) |
| Sets the normalized position of the given handle. | |
Signals | |
| void | blackPointChanged (qreal newBlackPoint) |
| Signal emitted when the black point changes. | |
| void | whitePointChanged (qreal newWhitePoint) |
| Signal emitted when the white point changes. | |
Signals inherited from KisLevelsSlider | |
| void | handleColorChanged (int handleIndex, const QColor &color) |
| Signal emitted when the color associated with a handle changes. | |
| void | handlePositionChanged (int handleIndex, qreal position) |
| Signal emitted when the position of a handle changes. | |
Public Member Functions | |
| qreal | blackPoint () const |
| Get the normalized black point. | |
| KisInputLevelsSlider (QWidget *parent=nullptr) | |
| qreal | whitePoint () const |
| Get the normalized white point. | |
| ~KisInputLevelsSlider () | |
Public Member Functions inherited from KisLevelsSlider | |
| virtual QRect | gradientRect () const |
| Gets the rect where the gradient will be painted. | |
| QColor | handleColor (int handleIndex) const |
| Gets the color associated with a given handle. | |
| qreal | handlePosition (int handleIndex) const |
| Gets the normalized position of a given handle. | |
| KisLevelsSlider (QWidget *parent) | |
| QSize | minimumSizeHint () const override |
| QSize | sizeHint () const override |
| ~KisLevelsSlider () | |
Protected Member Functions | |
| virtual void | paintBottomGradientMiddleSection (QImage &gradientImage, const QVector< Handle > &sortedHandles_) |
| This is used to fill the space between the tho handles in the bottom bar of the "gradient". It just paints a linear gradient that goes from black (first handle's color) to white (last handle's color). Derived classes can override this function if they only want to change that area. "gradientImage" is a 256x1px image. | |
| void | paintGradient (QPainter &painter, const QRect &rect) override |
| Custom gradient painter. This paints two bars in the gradient rect, one on top of the other. The top one shows a simple black to white (more exactly, color of the first handle to color of the last handle) linear gradient. The bottom one shows black (first handle's color) from the right side of the rect to the black point, and white (last handle's color) from the white point to the left side of the rect. In the middle of the two handles, the "paintBottomGradientMiddleSection" is used to fill the bar. | |
Protected Member Functions inherited from KisLevelsSlider | |
| int | closestHandleToPosition (qreal position) const |
| Given a normalized position, this function returns the closest handle to that position. | |
| int | closestHandleToX (int x) const |
| Given a widget-relative x position, this function returns the closest handle to that position. | |
| void | handleIncrementInput (int direction, Qt::KeyboardModifiers modifiers) |
| void | keyPressEvent (QKeyEvent *e) override |
| void | leaveEvent (QEvent *e) override |
| void | mouseMoveEvent (QMouseEvent *e) override |
| void | mousePressEvent (QMouseEvent *e) override |
| void | paintEvent (QPaintEvent *e) override |
| virtual void | paintHandle (QPainter &painter, const QRect &rect, const Handle &handle) |
| Override this function to paint custom handles. | |
| qreal | positionFromX (int x) const |
| Given a widget-relative x position in pixels, this function returns the normalized position relative to the gradient rect. | |
| QVector< Handle > | sortedHandles () const |
| Regardless the index of a handle, they can be unordered in terms of the position. This returns a sorted vector with the handles that have a smaller position first. If two handles have the same position then the index is used for sorting. | |
| void | wheelEvent (QWheelEvent *e) override |
| int | xFromPosition (qreal position) const |
| Given a gradient rect relative position, this function returns the x position in pixels relative to the widget. | |
Additional Inherited Members | |
Protected Attributes inherited from KisLevelsSlider | |
| int | m_constrainPositions |
| This variable indicates if the handles can have unordered positions. If it is set to true then the user won't be able to move a handle pass another one. If it is set to false then the ser will be able to move the handles freely. | |
| QVector< Handle > | m_handles |
| The collection of handles. | |
| int | m_hoveredHandle |
| int | m_selectedHandle |
Static Protected Attributes inherited from KisLevelsSlider | |
| static constexpr int | handleHeight {11} |
| static constexpr int | handleWidth {11} |
| static constexpr qreal | minimumSpaceBetweenHandles {0.001} |
| static constexpr qreal | normalPositionIncrement {0.01} |
| static constexpr qreal | slowPositionIncrement {0.001} |
This is a simple input levels slider that has no gamma handle. Use it if you want to show a simple mapping or contrast adjustment. The handles are constrained so that the black point handle can not pass the white point handle and vice-versa.
Definition at line 147 of file KisLevelsSlider.h.
| KisInputLevelsSlider::KisInputLevelsSlider | ( | QWidget * | parent = nullptr | ) |
Definition at line 319 of file KisLevelsSlider.cpp.
References connect(), KisLevelsSlider::handlePositionChanged(), KisLevelsSlider::m_handles, and KisLevelsSlider::m_selectedHandle.
| KisInputLevelsSlider::~KisInputLevelsSlider | ( | ) |
Definition at line 342 of file KisLevelsSlider.cpp.
| qreal KisInputLevelsSlider::blackPoint | ( | ) | const |
Get the normalized black point.
Definition at line 345 of file KisLevelsSlider.cpp.
References KisLevelsSlider::m_handles.
|
signal |
Signal emitted when the black point changes.
|
protectedvirtual |
This is used to fill the space between the tho handles in the bottom bar of the "gradient". It just paints a linear gradient that goes from black (first handle's color) to white (last handle's color). Derived classes can override this function if they only want to change that area. "gradientImage" is a 256x1px image.
Reimplemented in KisInputLevelsSliderWithGamma, and KisThresholdSlider.
Definition at line 391 of file KisLevelsSlider.cpp.
References KisPaintingTweaks::blendColors(), and KisLevelsSlider::m_handles.
|
overrideprotectedvirtual |
Custom gradient painter. This paints two bars in the gradient rect, one on top of the other. The top one shows a simple black to white (more exactly, color of the first handle to color of the last handle) linear gradient. The bottom one shows black (first handle's color) from the right side of the rect to the black point, and white (last handle's color) from the white point to the left side of the rect. In the middle of the two handles, the "paintBottomGradientMiddleSection" is used to fill the bar.
Implements KisLevelsSlider.
Definition at line 410 of file KisLevelsSlider.cpp.
References KisPaintingTweaks::blendColors(), KisLevelsSlider::m_handles, paintBottomGradientMiddleSection(), and KisLevelsSlider::sortedHandles().
|
virtualslot |
Sometimes you want to set the range to a totally different place, but the new black point can be greater than the old white point so the new black point position will be constrained to the old white position. This function allows to set both values at once to prevent that undesirable effect. Use it when the widget has to show new values, for a different set of levels parameters for example.
Definition at line 365 of file KisLevelsSlider.cpp.
References KisLevelsSlider::m_constrainPositions, KisLevelsSlider::minimumSpaceBetweenHandles, setBlackPoint(), setWhitePoint(), and whitePoint().
|
virtualslot |
Sets the black point.
Definition at line 355 of file KisLevelsSlider.cpp.
References KisLevelsSlider::m_handles, and KisLevelsSlider::setHandlePosition().
|
virtualslot |
Sets the white point.
Definition at line 360 of file KisLevelsSlider.cpp.
References KisLevelsSlider::m_handles, and KisLevelsSlider::setHandlePosition().
| qreal KisInputLevelsSlider::whitePoint | ( | ) | const |
Get the normalized white point.
Definition at line 350 of file KisLevelsSlider.cpp.
References KisLevelsSlider::m_handles.
|
signal |
Signal emitted when the white point changes.