This is a input levels slider that has a gamma handle. The handles are constrained so that the black point handle can not pass the white point handle and vice-versa.
More...
|
| void | reset (qreal newBlackPoint, qreal newWhitePoint) override |
| |
| void | reset (qreal newBlackPoint, qreal newWhitePoint, qreal newGamma) |
| |
| void | setGamma (qreal newGamma) |
| | Sets the gamma value.
|
| |
| void | setHandlePosition (int handleIndex, qreal newPosition) override |
| |
| 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.
|
| |
| 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.
|
| |
|
| void | paintBottomGradientMiddleSection (QImage &gradientImage, const QVector< Handle > &sortedHandles_) override |
| | 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.
|
| |
| 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.
|
| |
This is a input levels slider that has a gamma handle. The handles are constrained so that the black point handle can not pass the white point handle and vice-versa.
Definition at line 220 of file KisLevelsSlider.h.
| void KisInputLevelsSliderWithGamma::paintBottomGradientMiddleSection |
( |
QImage & | gradientImage, |
|
|
const QVector< Handle > & | sortedHandles_ ) |
|
overrideprotectedvirtual |
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 from KisInputLevelsSlider.
Definition at line 526 of file KisLevelsSlider.cpp.
527{
529 return;
530 }
533 return;
534 }
535
536 const qreal inverseGamma = 1.0 /
m_gamma;
537 const int startPos = static_cast<int>(qRound(sortedHandles_.first().position * static_cast<qreal>(gradientImage.width() - 1)));
538 const int endPos = static_cast<int>(qRound(sortedHandles_.last().position * static_cast<qreal>(gradientImage.width() - 1))) + 1;
539 QRgb *pixel =
reinterpret_cast<QRgb*
>(gradientImage.bits()) + startPos;
540 for (
int x = startPos;
x < endPos; ++
x, ++pixel) {
541 const qreal t =
static_cast<qreal
>(
x - startPos) /
static_cast<qreal
>(endPos - startPos);
543 sortedHandles_.last().color,
544 sortedHandles_.first().color,
545 std::pow(t, inverseGamma)
546 ).rgba();
547 }
548}
QColor blendColors(const QColor &c1, const QColor &c2, qreal r1)
References KisPaintingTweaks::blendColors(), m_gamma, KisLevelsSlider::m_handles, and KisInputLevelsSlider::paintBottomGradientMiddleSection().