File indexing completed on 2024-05-12 15:57:02

0001 /*
0002  *  SPDX-FileCopyrightText: 2017 Dmitry Kazakov <dimula73@gmail.com>
0003  *
0004  *  SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "KisHandleStyle.h"
0008 #include "kis_painting_tweaks.h"
0009 
0010 namespace {
0011 void initDashedStyle(const QColor &baseColor, const QColor &handleFill, KisHandleStyle *style) {
0012     QPen ants;
0013     QPen outline;
0014     KisPaintingTweaks::initAntsPen(&ants, &outline);
0015 
0016     ants.setColor(baseColor);
0017 
0018     style->lineIterations << KisHandleStyle::IterationStyle(outline, Qt::NoBrush);
0019     style->lineIterations << KisHandleStyle::IterationStyle(ants, Qt::NoBrush);
0020 
0021     QPen handlePen(baseColor);
0022     handlePen.setWidth(2);
0023     handlePen.setJoinStyle(Qt::RoundJoin);
0024 
0025     style->handleIterations << KisHandleStyle::IterationStyle(handlePen, handleFill);
0026 }
0027 
0028 static const QColor primaryColor(0, 0, 90, 180);
0029 static const QColor secondaryColor(0, 0, 255, 127);
0030 static const QColor gradientFillColor(255, 197, 39);
0031 static const QColor highlightColor(255, 100, 100);
0032 static const QColor highlightOutlineColor(155, 0, 0);
0033 static const QColor selectionColor(164, 227, 243);
0034 
0035 }
0036 
0037 
0038 KisHandleStyle &KisHandleStyle::inheritStyle()
0039 {
0040     static QScopedPointer<KisHandleStyle> style;
0041 
0042     if (!style) {
0043         style.reset(new KisHandleStyle());
0044         style->lineIterations << KisHandleStyle::IterationStyle();
0045         style->handleIterations << KisHandleStyle::IterationStyle();
0046     }
0047 
0048     return *style;
0049 }
0050 
0051 KisHandleStyle &KisHandleStyle::primarySelection()
0052 {
0053     static QScopedPointer<KisHandleStyle> style;
0054 
0055     if (!style) {
0056         style.reset(new KisHandleStyle());
0057         initDashedStyle(primaryColor, Qt::white, style.data());
0058     }
0059 
0060     return *style;
0061 }
0062 
0063 KisHandleStyle &KisHandleStyle::secondarySelection()
0064 {
0065     static QScopedPointer<KisHandleStyle> style;
0066 
0067     if (!style) {
0068         style.reset(new KisHandleStyle());
0069         initDashedStyle(secondaryColor, Qt::white, style.data());
0070     }
0071 
0072     return *style;
0073 }
0074 
0075 KisHandleStyle &KisHandleStyle::gradientHandles()
0076 {
0077     static QScopedPointer<KisHandleStyle> style;
0078 
0079     if (!style) {
0080         style.reset(new KisHandleStyle());
0081         initDashedStyle(primaryColor, gradientFillColor, style.data());
0082     }
0083 
0084     return *style;
0085 }
0086 
0087 KisHandleStyle &KisHandleStyle::gradientArrows()
0088 {
0089     return primarySelection();
0090 }
0091 
0092 
0093 KisHandleStyle &KisHandleStyle::highlightedPrimaryHandles()
0094 {
0095     static QScopedPointer<KisHandleStyle> style;
0096 
0097     if (!style) {
0098         style.reset(new KisHandleStyle());
0099         initDashedStyle(highlightOutlineColor, highlightColor, style.data());
0100     }
0101 
0102     return *style;
0103 }
0104 
0105 KisHandleStyle &KisHandleStyle::highlightedPrimaryHandlesWithSolidOutline()
0106 {
0107     static QScopedPointer<KisHandleStyle> style;
0108 
0109     if (!style) {
0110         style.reset(new KisHandleStyle());
0111         style->handleIterations << KisHandleStyle::IterationStyle(highlightOutlineColor, highlightColor);
0112         style->lineIterations << KisHandleStyle::IterationStyle(highlightOutlineColor, Qt::NoBrush);
0113     }
0114 
0115     return *style;
0116 }
0117 
0118 KisHandleStyle &KisHandleStyle::partiallyHighlightedPrimaryHandles()
0119 {
0120     static QScopedPointer<KisHandleStyle> style;
0121 
0122     if (!style) {
0123         style.reset(new KisHandleStyle());
0124         initDashedStyle(highlightOutlineColor, selectionColor, style.data());
0125     }
0126 
0127     return *style;
0128 }
0129 
0130 KisHandleStyle &KisHandleStyle::selectedPrimaryHandles()
0131 {
0132     static QScopedPointer<KisHandleStyle> style;
0133 
0134     if (!style) {
0135         style.reset(new KisHandleStyle());
0136         initDashedStyle(primaryColor, selectionColor, style.data());
0137     }
0138 
0139     return *style;
0140 }
0141