Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.
C++
Wide Gamut Selector: Add static hue edge to the hue bar selectors too.
Wolthera van Hövell tot Westerflierd3def9598fb4
diff --git a/libs/widgets/KisVisualRectangleSelectorShape.cpp b/libs/widgets/KisVisualRectangleSelectorShape.cppindex 221d243865..798b6ebacb 100644--- a/libs/widgets/KisVisualRectangleSelectorShape.cpp+++ b/libs/widgets/KisVisualRectangleSelectorShape.cpp@@ -281,6 +281,42 @@ QRegion KisVisualRectangleSelectorShape::getMaskMap()}QImage KisVisualRectangleSelectorShape::renderAlphaMask() const+{+ // Hi-DPI aware rendering requires that we determine the device pixel dimension;+ // actual widget size in device pixels is not accessible unfortunately, it might be 1px smaller...+ KisVisualColorSelector::RenderMode mode = colorSelector()->renderMode();+ if (isHueControl() && mode == KisVisualColorSelector::StaticBackground) {+ return QImage();+ }+ qreal startRatio = 0.0;+ qreal endRatio = 1.0;++ if (mode == KisVisualColorSelector::CompositeBackground && isHueControl()) {+ startRatio = 0.25;+ }++ return renderAlphaMaskImpl(startRatio, endRatio);+}++QImage KisVisualRectangleSelectorShape::renderStaticAlphaMask() const+{+ // Hi-DPI aware rendering requires that we determine the device pixel dimension;+ // actual widget size in device pixels is not accessible unfortunately, it might be 1px smaller...+ KisVisualColorSelector::RenderMode mode = colorSelector()->renderMode();+ if (isHueControl() && mode == KisVisualColorSelector::DynamicBackground) {+ return QImage();+ }+ qreal startRatio = 0.0;+ qreal endRatio = 1.0;++ if (mode == KisVisualColorSelector::CompositeBackground && isHueControl()) {+ endRatio = 0.25;+ }++ return renderAlphaMaskImpl(startRatio, endRatio);+}++QImage KisVisualRectangleSelectorShape::renderAlphaMaskImpl(qreal ratioStart, qreal ratioEnd) const{// Hi-DPI aware rendering requires that we determine the device pixel dimension;// actual widget size in device pixels is not accessible unfortunately, it might be 1px smaller...@@ -295,18 +331,29 @@ QImage KisVisualRectangleSelectorShape::renderAlphaMask() constpainter.setBrush(Qt::white);painter.setPen(Qt::NoPen);+ const int marginMajor = 3;+ const int marginMinor = 2;+if (getDimensions() == onedimensional) {if (m_type == KisVisualRectangleSelectorShape::vertical) {- painter.drawRect(2, 3, width() - 4, height() - 6);+ const int barWidth = width() - (marginMinor*2);+ const int start = (barWidth*ratioStart);+ const int end = (barWidth*ratioEnd) - start;+ painter.drawRect(start + marginMinor, marginMajor, end, height() - (2*marginMajor));+} else if (m_type == KisVisualRectangleSelectorShape::horizontal) {- painter.drawRect(3, 2, width() - 6, height() - 4);+ const int barWidth = height() - (marginMinor*2);+ const int start = (barWidth*ratioStart);+ const int end = (barWidth*ratioEnd) - start;+ painter.drawRect(marginMajor, start + marginMinor, width() - (2*marginMajor), end);+} else /*if (m_type == border || m_type == borderMirrored)*/ {painter.drawRect(2, 2, width() - 4, height() - 4);painter.setBrush(Qt::black);painter.drawRect(m_barWidth, m_barWidth, width() - 2 * m_barWidth, height() - 2 * m_barWidth);}} else {- painter.drawRect(3, 3, width() - 6, height() - 6);+ painter.drawRect(marginMajor, marginMajor, width() - marginMajor*2, height() - marginMajor*2);}return alphaMask;diff --git a/libs/widgets/KisVisualRectangleSelectorShape.h b/libs/widgets/KisVisualRectangleSelectorShape.hindex 11d347fc69..ee31a57ad0 100644--- a/libs/widgets/KisVisualRectangleSelectorShape.h+++ b/libs/widgets/KisVisualRectangleSelectorShape.h@@ -34,8 +34,10 @@ public:protected:QRect getAvailableSpace(QRect geom, bool stretch);QImage renderAlphaMask() const override;+ QImage renderStaticAlphaMask() const override;private:+ QImage renderAlphaMaskImpl(qreal ratioStart, qreal ratioEnd) const;QPointF convertShapeCoordinateToWidgetCoordinate(QPointF coordinate) const override;QPointF convertWidgetCoordinateToShapeCoordinate(QPointF coordinate) const override;