|
Krita Source Code Documentation
|
A base class for levels slider like widgets: a slider with a gradient and multiple handles. More...
#include <KisLevelsSlider.h>
Inheritance diagram for KisLevelsSlider:Classes | |
| struct | Handle |
Public Slots | |
| 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 | 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 | |
| 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 | |
| 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 | paintGradient (QPainter &painter, const QRect &rect)=0 |
| Derived classes must override this function to draw the gradient inside the given rect. A border is automatically drawn after. | |
| 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. | |
Protected Attributes | |
| 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 | |
| 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} |
A base class for levels slider like widgets: a slider with a gradient and multiple handles.
Definition at line 21 of file KisLevelsSlider.h.
| KisLevelsSlider::KisLevelsSlider | ( | QWidget * | parent | ) |
Definition at line 19 of file KisLevelsSlider.cpp.
| KisLevelsSlider::~KisLevelsSlider | ( | ) |
Definition at line 29 of file KisLevelsSlider.cpp.
|
protected |
Given a normalized position, this function returns the closest handle to that position.
Definition at line 113 of file KisLevelsSlider.cpp.
References sortedHandles().
|
protected |
Given a widget-relative x position, this function returns the closest handle to that position.
Definition at line 142 of file KisLevelsSlider.cpp.
References closestHandleToPosition(), and positionFromX().
|
virtual |
Gets the rect where the gradient will be painted.
Definition at line 95 of file KisLevelsSlider.cpp.
References handleHeight, and handleWidth.
| QColor KisLevelsSlider::handleColor | ( | int | handleIndex | ) | const |
Gets the color associated with a given handle.
Definition at line 39 of file KisLevelsSlider.cpp.
References m_handles.
|
signal |
Signal emitted when the color associated with a handle changes.
|
protected |
Definition at line 153 of file KisLevelsSlider.cpp.
References m_handles, m_selectedHandle, normalPositionIncrement, setHandlePosition(), and slowPositionIncrement.
| qreal KisLevelsSlider::handlePosition | ( | int | handleIndex | ) | const |
Gets the normalized position of a given handle.
Definition at line 32 of file KisLevelsSlider.cpp.
References m_handles.
|
signal |
Signal emitted when the position of a handle changes.
|
overrideprotected |
Definition at line 287 of file KisLevelsSlider.cpp.
References handleIncrementInput(), m_handles, and m_selectedHandle.
|
overrideprotected |
Definition at line 280 of file KisLevelsSlider.cpp.
References m_hoveredHandle.
|
override |
Definition at line 90 of file KisLevelsSlider.cpp.
References handleHeight, and handleWidth.
|
overrideprotected |
Definition at line 262 of file KisLevelsSlider.cpp.
References closestHandleToX(), m_handles, m_hoveredHandle, m_selectedHandle, positionFromX(), and setHandlePosition().
|
overrideprotected |
Definition at line 239 of file KisLevelsSlider.cpp.
References closestHandleToPosition(), handleWidth, m_handles, m_selectedHandle, positionFromX(), setHandlePosition(), and xFromPosition().
|
overrideprotected |
Definition at line 212 of file KisLevelsSlider.cpp.
References gradientRect(), handleHeight, handleWidth, paintGradient(), paintHandle(), palette, and sortedHandles().
|
protectedpure virtual |
Derived classes must override this function to draw the gradient inside the given rect. A border is automatically drawn after.
Implemented in KisInputLevelsSlider.
|
protectedvirtual |
Override this function to paint custom handles.
Reimplemented in KisThresholdSlider.
Definition at line 169 of file KisLevelsSlider.cpp.
References KisPaintingTweaks::blendColors(), KisLevelsSlider::Handle::color, handleWidth, KisLevelsSlider::Handle::index, m_hoveredHandle, m_selectedHandle, and palette.
|
protected |
Given a widget-relative x position in pixels, this function returns the normalized position relative to the gradient rect.
Definition at line 136 of file KisLevelsSlider.cpp.
References gradientRect().
|
virtualslot |
Sets the color associated with the given handle.
Definition at line 71 of file KisLevelsSlider.cpp.
References handleColorChanged(), and m_handles.
|
virtualslot |
Sets the normalized position of the given handle.
Definition at line 46 of file KisLevelsSlider.cpp.
References handlePositionChanged(), m_constrainPositions, m_handles, and minimumSpaceBetweenHandles.
|
override |
Definition at line 85 of file KisLevelsSlider.cpp.
References handleHeight, and handleWidth.
|
protected |
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.
Definition at line 101 of file KisLevelsSlider.cpp.
References m_handles.
|
overrideprotected |
Definition at line 308 of file KisLevelsSlider.cpp.
References handleIncrementInput().
|
protected |
Given a gradient rect relative position, this function returns the x position in pixels relative to the widget.
Definition at line 147 of file KisLevelsSlider.cpp.
References gradientRect().
|
staticconstexprprotected |
Definition at line 74 of file KisLevelsSlider.h.
|
staticconstexprprotected |
Definition at line 73 of file KisLevelsSlider.h.
|
protected |
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.
Definition at line 89 of file KisLevelsSlider.h.
The collection of handles.
Definition at line 82 of file KisLevelsSlider.h.
|
protected |
Definition at line 92 of file KisLevelsSlider.h.
|
protected |
Definition at line 91 of file KisLevelsSlider.h.
|
staticconstexprprotected |
Definition at line 75 of file KisLevelsSlider.h.
|
staticconstexprprotected |
Definition at line 76 of file KisLevelsSlider.h.
|
staticconstexprprotected |
Definition at line 77 of file KisLevelsSlider.h.