File indexing completed on 2024-05-19 04:25:09

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.setCosmetic(true);
0024     handlePen.setJoinStyle(Qt::RoundJoin);
0025 
0026     style->handleIterations << KisHandleStyle::IterationStyle(handlePen, handleFill);
0027 }
0028 
0029 static const QColor primaryColor(0, 0, 90, 180);
0030 static const QColor secondaryColor(0, 0, 255, 127);
0031 static const QColor gradientFillColor(255, 197, 39);
0032 static const QColor highlightColor(255, 100, 100);
0033 static const QColor highlightOutlineColor(155, 0, 0);
0034 static const QColor selectionColor(164, 227, 243);
0035 
0036 }
0037 
0038 
0039 KisHandleStyle &KisHandleStyle::inheritStyle()
0040 {
0041     static QScopedPointer<KisHandleStyle> style;
0042 
0043     if (!style) {
0044         style.reset(new KisHandleStyle());
0045         style->lineIterations << KisHandleStyle::IterationStyle();
0046         style->handleIterations << KisHandleStyle::IterationStyle();
0047     }
0048 
0049     return *style;
0050 }
0051 
0052 KisHandleStyle &KisHandleStyle::primarySelection()
0053 {
0054     static QScopedPointer<KisHandleStyle> style;
0055 
0056     if (!style) {
0057         style.reset(new KisHandleStyle());
0058         initDashedStyle(primaryColor, Qt::white, style.data());
0059     }
0060 
0061     return *style;
0062 }
0063 
0064 KisHandleStyle &KisHandleStyle::secondarySelection()
0065 {
0066     static QScopedPointer<KisHandleStyle> style;
0067 
0068     if (!style) {
0069         style.reset(new KisHandleStyle());
0070         initDashedStyle(secondaryColor, Qt::white, style.data());
0071     }
0072 
0073     return *style;
0074 }
0075 
0076 KisHandleStyle &KisHandleStyle::gradientHandles()
0077 {
0078     static QScopedPointer<KisHandleStyle> style;
0079 
0080     if (!style) {
0081         style.reset(new KisHandleStyle());
0082         initDashedStyle(primaryColor, gradientFillColor, style.data());
0083     }
0084 
0085     return *style;
0086 }
0087 
0088 KisHandleStyle &KisHandleStyle::gradientArrows()
0089 {
0090     return primarySelection();
0091 }
0092 
0093 
0094 KisHandleStyle &KisHandleStyle::highlightedPrimaryHandles()
0095 {
0096     static QScopedPointer<KisHandleStyle> style;
0097 
0098     if (!style) {
0099         style.reset(new KisHandleStyle());
0100         initDashedStyle(highlightOutlineColor, highlightColor, style.data());
0101     }
0102 
0103     return *style;
0104 }
0105 
0106 KisHandleStyle &KisHandleStyle::highlightedPrimaryHandlesWithSolidOutline()
0107 {
0108     static QScopedPointer<KisHandleStyle> style;
0109 
0110     if (!style) {
0111         style.reset(new KisHandleStyle());
0112         QPen h = QPen(highlightOutlineColor, 2);
0113         h.setCosmetic(true);
0114         style->handleIterations << KisHandleStyle::IterationStyle(h, highlightColor);
0115         QPen l = QPen(highlightOutlineColor, 1);
0116         l.setCosmetic(true);
0117         l.setJoinStyle(Qt::RoundJoin);
0118         style->lineIterations << KisHandleStyle::IterationStyle(l, Qt::NoBrush);
0119     }
0120 
0121     return *style;
0122 }
0123 
0124 KisHandleStyle &KisHandleStyle::partiallyHighlightedPrimaryHandles()
0125 {
0126     static QScopedPointer<KisHandleStyle> style;
0127 
0128     if (!style) {
0129         style.reset(new KisHandleStyle());
0130         initDashedStyle(highlightOutlineColor, selectionColor, style.data());
0131     }
0132 
0133     return *style;
0134 }
0135 
0136 KisHandleStyle &KisHandleStyle::selectedPrimaryHandles()
0137 {
0138     static QScopedPointer<KisHandleStyle> style;
0139 
0140     if (!style) {
0141         style.reset(new KisHandleStyle());
0142         initDashedStyle(primaryColor, selectionColor, style.data());
0143     }
0144 
0145     return *style;
0146 }
0147