r23907 by jghali - Make gradient mask related code more easily understandable

scribus-commit scribus-commit at lists.scribus.net
Fri Jun 26 19:39:39 UTC 2020


Author: jghali
Date: Fri Jun 26 19:39:39 2020
New Revision: 23907

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=23907
Log:
Make gradient mask related code more easily understandable

Modified:
    trunk/Scribus/scribus/canvasmode_editgradient.cpp
    trunk/Scribus/scribus/pageitem.cpp
    trunk/Scribus/scribus/pageitem_imageframe.cpp
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
    trunk/Scribus/scribus/scpageoutput.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusstructs.h
    trunk/Scribus/scribus/ui/propertiespalette.cpp
    trunk/Scribus/scribus/ui/transparencypalette.cpp

Modified: trunk/Scribus/scribus/canvasmode_editgradient.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/canvasmode_editgradient.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_editgradient.cpp	(original)
+++ trunk/Scribus/scribus/canvasmode_editgradient.cpp	Fri Jun 26 19:39:39 2020
@@ -152,7 +152,7 @@
 		qmatrix.translate(0, currItem->GrMaskStartY * (1.0 - currItem->GrMaskScale));
 		qmatrix.translate(-currItem->GrMaskStartX, -currItem->GrMaskStartY);
 		qmatrix.scale(1, currItem->GrMaskScale);
-		if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+		if ((currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_RadialLumAlpha))
 			psx->drawPoint(qmatrix.map(QPointF(currItem->GrMaskFocalX, currItem->GrMaskFocalY)));
 		QTransform m;
 		m.translate(currItem->GrMaskStartX, currItem->GrMaskStartY);
@@ -422,7 +422,7 @@
 				currItem->GrMaskStartY -= np.y();
 				currItem->GrMaskFocalX -= np.x();
 				currItem->GrMaskFocalY -= np.y();
-				if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+				if ((currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_RadialLumAlpha))
 				{
 					double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 					double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
@@ -461,7 +461,7 @@
 				QPointF shRe = m.map(shR - np);
 				currItem->GrMaskFocalX = shRe.x();
 				currItem->GrMaskFocalY = shRe.y();
-				if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+				if ((currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_RadialLumAlpha))
 				{
 					double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 					double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);
@@ -497,7 +497,7 @@
 			{
 				currItem->GrMaskEndX -= np.x();
 				currItem->GrMaskEndY -= np.y();
-				if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+				if ((currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_RadialLumAlpha))
 				{
 					double radEnd = distance(currItem->GrMaskEndX - currItem->GrMaskStartX, currItem->GrMaskEndY - currItem->GrMaskStartY);
 					double radFoc = distance(currItem->GrMaskFocalX - currItem->GrMaskStartX, currItem->GrMaskFocalY - currItem->GrMaskStartY);

Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp	(original)
+++ trunk/Scribus/scribus/pageitem.cpp	Fri Jun 26 19:39:39 2020
@@ -1968,9 +1968,9 @@
 	p->setBrushOpacity(1.0 - fillTransparency());
 	p->setPenOpacity(1.0 - lineTransparency());
 	p->setFillRule(fillRule);
-	if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
-	{
-		if ((GrMask == 1) || (GrMask == 2))
+	if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial) || (GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha))
+	{
+		if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial))
 			p->setMaskMode(1);
 		else
 			p->setMaskMode(3);
@@ -1979,22 +1979,22 @@
 		if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal)))
 			mask_gradient = m_Doc->docGradients[gradientMaskVal];
 		p->mask_gradient = mask_gradient;
-		if ((GrMask == 1) || (GrMask == 4))
+		if ((GrMask == GradMask_Linear) || (GrMask == GradMask_LinearLumAlpha))
 			p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskStartX, GrMaskStartY), GrMaskScale, GrMaskSkew);
 		else
 			p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX, GrMaskStartY), FPoint(GrMaskEndX, GrMaskEndY), FPoint(GrMaskFocalX, GrMaskFocalY), GrMaskScale, GrMaskSkew);
 	}
-	else if ((GrMask == 3) || (GrMask == 6) || (GrMask == 7) || (GrMask == 8))
+	else if ((GrMask == GradMask_Pattern) || (GrMask == GradMask_PatternLumAlpha) || (GrMask == GradMask_PatternLumAlphaInverted) || (GrMask == GradMask_PatternInverted))
 	{
 		ScPattern *patternMask = m_Doc->checkedPattern(patternMaskVal);
 		if (patternMask)
 		{
 			p->setPatternMask(patternMask, patternMaskScaleX, patternMaskScaleY, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
-			if (GrMask == 3)
+			if (GrMask == GradMask_Pattern)
 				p->setMaskMode(2);
-			else if (GrMask == 6)
+			else if (GrMask == GradMask_PatternLumAlpha)
 				p->setMaskMode(4);
-			else if (GrMask == 7)
+			else if (GrMask == GradMask_PatternLumAlphaInverted)
 				p->setMaskMode(5);
 			else
 				p->setMaskMode(6);
@@ -8578,7 +8578,7 @@
 			lists.collectColor(cstops.at(cst)->name);
 		}
 	}
-	if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
+	if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial) || (GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha))
 	{
 		QList<VColorStop*> cstops = mask_gradient.colorStops();
 		for (int cst = 0; cst < mask_gradient.stops(); ++cst)

Modified: trunk/Scribus/scribus/pageitem_imageframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/pageitem_imageframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_imageframe.cpp	(original)
+++ trunk/Scribus/scribus/pageitem_imageframe.cpp	Fri Jun 26 19:39:39 2020
@@ -170,9 +170,9 @@
 				mscalex *= 1.0 / pixm.imgInfo.lowResScale;
 				mscaley *= 1.0 / pixm.imgInfo.lowResScale;
 			}
-			if ((GrMask == 1) || (GrMask == 2) || (GrMask == 4) || (GrMask == 5))
-			{
-				if ((GrMask == 1) || (GrMask == 2))
+			if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial) || (GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha))
+			{
+				if ((GrMask == GradMask_Linear) || (GrMask == GradMask_Radial))
 					p->setMaskMode(1);
 				else
 					p->setMaskMode(3);
@@ -181,23 +181,23 @@
 				if (!(gradientMaskVal.isEmpty()) && (m_Doc->docGradients.contains(gradientMaskVal)))
 					mask_gradient = m_Doc->docGradients[gradientMaskVal];
 				p->mask_gradient = mask_gradient;
-				if ((GrMask == 1) || (GrMask == 4))
+				if ((GrMask == GradMask_Linear) || (GrMask == GradMask_LinearLumAlpha))
 					p->setGradientMask(VGradient::linear, FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), FPoint(GrMaskEndX * mscalex, GrMaskEndY * mscaley), FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), GrMaskScale, GrMaskSkew);
 				else
 					p->setGradientMask(VGradient::radial, FPoint(GrMaskStartX * mscalex, GrMaskStartY * mscaley), FPoint(GrMaskEndX * mscalex, GrMaskEndY * mscaley), FPoint(GrMaskFocalX * mscalex, GrMaskFocalY * mscaley), GrMaskScale, GrMaskSkew);
 			}
-			else if ((GrMask == 3) || (GrMask == 6) || (GrMask == 7) || (GrMask == 8))
+			else if ((GrMask == GradMask_Pattern) || (GrMask == GradMask_PatternLumAlpha) || (GrMask == GradMask_PatternLumAlphaInverted) || (GrMask == GradMask_PatternInverted))
 			{
 				if ((patternMaskVal.isEmpty()) || (!m_Doc->docPatterns.contains(patternMaskVal)))
 					p->setMaskMode(0);
 				else
 				{
 					p->setPatternMask(&m_Doc->docPatterns[patternMaskVal], patternMaskScaleX * mscalex, patternMaskScaleY * mscaley, patternMaskOffsetX, patternMaskOffsetY, patternMaskRotation, patternMaskSkewX, patternMaskSkewY, patternMaskMirrorX, patternMaskMirrorY);
-					if (GrMask == 3)
+					if (GrMask == GradMask_Pattern)
 						p->setMaskMode(2);
-					else if (GrMask == 6)
+					else if (GrMask == GradMask_PatternLumAlpha)
 						p->setMaskMode(4);
-					else if (GrMask == 7)
+					else if (GrMask == GradMask_PatternLumAlphaInverted)
 						p->setMaskMode(5);
 					else
 						p->setMaskMode(6);

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Fri Jun 26 19:39:39 2020
@@ -6180,7 +6180,7 @@
 		scaleX = 1.0 / (currItem->width() / pat.width);
 		scaleY = 1.0 / (currItem->height() / pat.height);
 	}
-	if ((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5))
+	if ((currItem->GrMask == GradMask_Linear) || (currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_LinearLumAlpha) || (currItem->GrMask == GradMask_RadialLumAlpha))
 	{
 		QList<double> StopVec;
 		QList<double> TransVec;
@@ -6384,7 +6384,7 @@
 		Transpar[GXName] = writeGState("/SMask << /S /Luminosity /G " + Pdf::toPdf(formObject) + " 0 R >>\n/AIS false\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
 		tmp = Pdf::toName(GXName) + " gs\n";
 	}
-	else if ((currItem->GrMask == 3) || (currItem->GrMask == 6) || (currItem->GrMask == 7) || (currItem->GrMask == 8))
+	else if ((currItem->GrMask == GradMask_Pattern) || (currItem->GrMask == GradMask_PatternLumAlpha) || (currItem->GrMask == GradMask_PatternLumAlphaInverted) || (currItem->GrMask == GradMask_PatternInverted))
 	{
 		QByteArray tmpOut;
 		PDF_PatternFillStroke(tmpOut, currItem, 2);
@@ -6443,13 +6443,13 @@
 		ResCount++;
 		GXName = ResNam + Pdf::toPdf(ResCount);
 		ResCount++;
-		if (currItem->GrMask == 6)
+		if (currItem->GrMask == GradMask_PatternLumAlpha)
 			Transpar[GXName] = writeGState("/SMask << /S /Luminosity /G " + Pdf::toPdf(formObject) + " 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
-		else if (currItem->GrMask == 7)
+		else if (currItem->GrMask == GradMask_PatternLumAlphaInverted)
 			Transpar[GXName] = writeGState("/SMask << /S /Luminosity /G " + Pdf::toPdf(formObject) + " 0 R /BC [ 1 1 1 ] /TR << /FunctionType 2 /Domain [ 0 1 ] /Range [ 0 1 ] /C0 [ 1 ] /C1 [ 0 ] /N 1 >> >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n/AIS true\n");
-		else if (currItem->GrMask == 3)
+		else if (currItem->GrMask == GradMask_Pattern)
 			Transpar[GXName] = writeGState("/SMask << /S /Alpha /G " + Pdf::toPdf(formObject) + " 0 R >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
-		else if (currItem->GrMask == 8)
+		else if (currItem->GrMask == GradMask_PatternInverted)
 			Transpar[GXName] = writeGState("/SMask << /S /Alpha /G " + Pdf::toPdf(formObject) + " 0 R /BC [ 1 1 1 ] /TR << /FunctionType 2 /Domain [ 0 1 ] /Range [ 0 1 ] /C0 [ 1 ] /C1 [ 0 ] /N 1 >> >>\n/BM /" + blendMode(currItem->fillBlendmode()) + "\n");
 		tmp = Pdf::toName(GXName) + " gs\n";
 	}

Modified: trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/svgexplugin/svgexplugin.cpp	Fri Jun 26 19:39:39 2020
@@ -1856,7 +1856,7 @@
 			trans += " rotate(" + FToStr(item->rotation()) + ")";
 		ob.setAttribute("transform", trans);
 	}
-	if ((item->GrMask == 3) || (item->GrMask == 6))
+	if ((item->GrMask == GradMask_Pattern) || (item->GrMask == GradMask_PatternLumAlpha))
 	{
 		QString pattID = item->patternMask() + IToStr(m_pattCount);
 		m_pattCount++;
@@ -1885,9 +1885,9 @@
 		m_globalDefs.appendChild(patt);
 		ob.setAttribute("fill", "url(#" + pattID + ")");
 	}
-	else if ((item->GrMask == 1) || (item->GrMask == 2) || (item->GrMask == 4) || (item->GrMask == 5))
-	{
-		if ((item->GrMask == 1) || (item->GrMask == 4))
+	else if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_Radial) || (item->GrMask == GradMask_LinearLumAlpha) || (item->GrMask == GradMask_RadialLumAlpha))
+	{
+		if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_LinearLumAlpha))
 		{
 			grad = m_domDoc.createElement("linearGradient");
 			grad.setAttribute("x1", FToStr(item->GrMaskStartX));

Modified: trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	(original)
+++ trunk/Scribus/scribus/plugins/export/xpsexport/xpsexplugin.cpp	Fri Jun 26 19:39:39 2020
@@ -2255,7 +2255,7 @@
 		ob = p_docu.createElement("Glyph.OpacityMask");
 	else
 		ob = p_docu.createElement("Path.OpacityMask");
-	if ((Item->GrMask == 1) || (Item->GrMask == 2))
+	if ((Item->GrMask == GradMask_Linear) || (Item->GrMask == GradMask_Radial))
 	{
 		QDomElement gr;
 		double GrStartX = (Item->GrMaskStartX + xOffset) * conversionFactor;
@@ -2264,7 +2264,7 @@
 		double GrFocalY = (Item->GrMaskFocalY + yOffset) * conversionFactor;
 		double GrEndX = (Item->GrMaskEndX + xOffset) * conversionFactor;
 		double GrEndY = (Item->GrMaskEndY + yOffset) * conversionFactor;
-		if ((Item->GrMask == 1) || (Item->GrMask == 4))
+		if ((Item->GrMask == GradMask_Linear) || (Item->GrMask == GradMask_LinearLumAlpha))
 		{
 			gr = p_docu.createElement("LinearGradientBrush");
 			gr.setAttribute("MappingMode", "Absolute");
@@ -2293,7 +2293,7 @@
 		else
 			gradientSkew = tan(M_PI / 180.0 * Item->GrMaskSkew);
 		QTransform qmatrix;
-		if (Item->GrMask == 1)
+		if (Item->GrMask == GradMask_Linear)
 		{
 			qmatrix.translate(GrStartX, GrStartY);
 			qmatrix.shear(-gradientSkew, 0);
@@ -2311,7 +2311,7 @@
 		}
 		gr.setAttribute("Transform", MatrixToStr(qmatrix));
 		QDomElement grs;
-		if (Item->GrMask == 1)
+		if (Item->GrMask == GradMask_Linear)
 			grs = p_docu.createElement("LinearGradientBrush.GradientStops");
 		else
 			grs = p_docu.createElement("RadialGradientBrush.GradientStops");
@@ -2334,7 +2334,7 @@
 		gr.appendChild(grs);
 		ob.appendChild(gr);
 	}
-	else if (Item->GrMask == 3)
+	else if (Item->GrMask == GradMask_Pattern)
 	{
 		ScPattern pa = m_Doc->docPatterns[Item->patternMask()];
 		QDomElement gr = p_docu.createElement("VisualBrush");
@@ -2651,7 +2651,7 @@
 	int GrMask = Item->GrMask;
 	if ((GrType == Gradient_4Colors) || (GrType == Gradient_Diamond) || (GrType == Gradient_Mesh) || (GrType == Gradient_PatchMesh) || (GrType == Gradient_Conical))
 		ret = true;
-	if ((GrMask == 4) || (GrMask == 5) || (GrMask == 6) || (GrMask == 7) || (GrMask == 8))
+	if ((GrMask == GradMask_LinearLumAlpha) || (GrMask == GradMask_RadialLumAlpha) || (GrMask == GradMask_PatternLumAlpha) || (GrMask == GradMask_PatternLumAlphaInverted) || (GrMask == GradMask_PatternInverted))
 		ret = true;
 	if (Item->fillBlendmode() != 0)
 		ret = true;

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus12format/scribus12format.cpp	Fri Jun 26 19:39:39 2020
@@ -670,7 +670,7 @@
 		currItem->GrStrokeSkew   = Buffer->GrStrokeSkew;
 	}
 	currItem->GrMask = Buffer->GrMask;
-	if ((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5))
+	if ((currItem->GrMask == GradMask_Linear) || (currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_LinearLumAlpha) || (currItem->GrMask == GradMask_RadialLumAlpha))
 	{
 		currItem->mask_gradient = Buffer->mask_gradient;
 		currItem->GrMaskStartX = Buffer->GrMaskStartX;
@@ -682,7 +682,7 @@
 		currItem->GrMaskScale  = Buffer->GrMaskScale;
 		currItem->GrMaskSkew   = Buffer->GrMaskSkew;
 	}
-	else if ((currItem->GrMask == 3) || (currItem->GrMask == 6))
+	else if ((currItem->GrMask == GradMask_Pattern) || (currItem->GrMask == GradMask_PatternLumAlpha))
 	{
 		currItem->setPatternMask(Buffer->patternMaskVal);
 		currItem->setMaskTransform(Buffer->patternMaskScaleX, Buffer->patternMaskScaleY, Buffer->patternMaskOffsetX, Buffer->patternMaskOffsetY, Buffer->patternMaskRotation, Buffer->patternMaskSkewX, Buffer->patternMaskSkewY);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp	Fri Jun 26 19:39:39 2020
@@ -5760,6 +5760,20 @@
 		}
 //		currItem->updateGradientVectors();
 	}
+	switch (currItem->GrType)
+	{
+		case Gradient_LinearLegacy1:
+		case Gradient_LinearLegacy2:
+		case Gradient_LinearLegacy3:
+		case Gradient_LinearLegacy4:
+			currItem->GrType = Gradient_Linear;
+			break;
+		case Gradient_RadialLegacy5:
+			currItem->GrType = Gradient_Radial;
+			break;
+		default:
+			break;
+	}
 
 	currItem->setStrokePattern( attrs.valueAsString("patternS", "") );
 	double patternScaleX   = attrs.valueAsDouble("pScaleXS", 100.0);
@@ -5808,11 +5822,11 @@
 	QString GrNameM = "";
 	GrNameM = attrs.valueAsString("GRNAMEM","");
 	currItem->GrMask = attrs.valueAsInt("GRTYPM", 0);
-	if ((currItem->GrMask == 1) || (currItem->GrMask == 4))
+	if ((currItem->GrMask == GradMask_Linear) || (currItem->GrMask == GradMask_LinearLumAlpha))
 		currItem->mask_gradient = VGradient(VGradient::linear);
-	else if ((currItem->GrMask == 2) || (currItem->GrMask == 5))
+	else if ((currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_RadialLumAlpha))
 		currItem->mask_gradient = VGradient(VGradient::radial);
-	if (((currItem->GrMask == 1) || (currItem->GrMask == 2) || (currItem->GrMask == 4) || (currItem->GrMask == 5)) && (GrNameM.isEmpty()))
+	if (((currItem->GrMask == GradMask_Linear) || (currItem->GrMask == GradMask_Radial) || (currItem->GrMask == GradMask_LinearLumAlpha) || (currItem->GrMask == GradMask_RadialLumAlpha)) && (GrNameM.isEmpty()))
 		currItem->mask_gradient.clearStops();
 	currItem->GrMaskStartX = attrs.valueAsDouble("GRSTARTXM", 0.0);
 	currItem->GrMaskStartY = attrs.valueAsDouble("GRSTARTYM", 0.0);

Modified: trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxar.cpp	(original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxar.cpp	Fri Jun 26 19:39:39 2020
@@ -1478,7 +1478,7 @@
 					if (txDat.GradMask > 0)
 					{
 						item->GrMask = txDat.GradMask;
-						if ((item->GrMask == 1) || (item->GrMask == 2))
+						if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_Radial))
 						{
 							item->mask_gradient = txDat.MaskGradient;
 							item->setMaskVector(txDat.GradMaskX1 - item->xPos(), txDat.GradMaskY1 - item->yPos(), txDat.GradMaskX2 - item->xPos(), txDat.GradMaskY2 - item->yPos(), txDat.GradMaskX1 - item->xPos(), txDat.GradMaskY1 - item->yPos(), txDat.GradMaskScale, txDat.GradMaskSkew);
@@ -3754,7 +3754,7 @@
 			if (gc->GradMask > 0)
 			{
 				item->GrMask = gc->GradMask;
-				if ((item->GrMask == 1) || (item->GrMask == 2))
+				if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_Radial))
 				{
 					item->mask_gradient = gc->MaskGradient;
 					item->setMaskVector(gc->GradMaskX1 - item->xPos(), gc->GradMaskY1 - item->yPos(), gc->GradMaskX2 - item->xPos(), gc->GradMaskY2 - item->yPos(), gc->GradMaskX1 - item->xPos(), gc->GradMaskY1 - item->yPos(), gc->GradMaskScale, gc->GradMaskSkew);

Modified: trunk/Scribus/scribus/scpageoutput.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/scpageoutput.cpp
==============================================================================
--- trunk/Scribus/scribus/scpageoutput.cpp	(original)
+++ trunk/Scribus/scribus/scpageoutput.cpp	Fri Jun 26 19:39:39 2020
@@ -352,13 +352,13 @@
 	painter->setPenOpacity(1.0 - item->lineTransparency());
 	painter->setFillRule(item->fillRule);
 
-	if ((item->GrMask == 1) || (item->GrMask == 2) || (item->GrMask == 4) || (item->GrMask == 5))
+	if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_Radial) || (item->GrMask == GradMask_LinearLumAlpha) || (item->GrMask == GradMask_RadialLumAlpha))
 	{
 		QString gradientMaskVal = item->gradientMaskVal;
 		FPoint fpMaskStart(item->GrMaskStartX, item->GrMaskStartY);
 		FPoint fpMaskEnd(item->GrMaskEndX, item->GrMaskEndY);
 		FPoint fpMaskFocal(item->GrMaskFocalX, item->GrMaskFocalY);
-		if ((item->GrMask == 1) || (item->GrMask == 2))
+		if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_Radial))
 			painter->setMaskMode(1);
 		else
 			painter->setMaskMode(3);
@@ -366,12 +366,12 @@
 			gradientMaskVal = "";
 		if (!(gradientMaskVal.isEmpty()) && (m_doc->docGradients.contains(gradientMaskVal)))
 			painter->m_maskGradient = VGradientEx(m_doc->docGradients[gradientMaskVal], *m_doc);
-		if ((item->GrMask == 1) || (item->GrMask == 4))
+		if ((item->GrMask == GradMask_Linear) || (item->GrMask == GradMask_LinearLumAlpha))
 			painter->setGradientMask(VGradientEx::linear, fpMaskStart, fpMaskEnd, fpMaskStart, item->GrMaskScale, item->GrMaskSkew);
 		else
 			painter->setGradientMask(VGradientEx::radial, fpMaskStart, fpMaskEnd, fpMaskFocal, item->GrMaskScale, item->GrMaskSkew);
 	}
-	else if ((item->GrMask == 3) || (item->GrMask == 6) || (item->GrMask == 7) || (item->GrMask == 8))
+	else if ((item->GrMask == GradMask_Pattern) || (item->GrMask == GradMask_PatternLumAlpha) || (item->GrMask == GradMask_PatternLumAlphaInverted) || (item->GrMask == GradMask_PatternInverted))
 	{
 		QString patternMaskVal = item->patternMaskVal;
 		ScPattern *patternMask = m_doc->checkedPattern(patternMaskVal);
@@ -379,11 +379,11 @@
 		{
 			painter->setPatternMask(patternMask, item->patternMaskScaleX, item->patternMaskScaleY, item->patternMaskOffsetX, item->patternMaskOffsetY,
 				                    item->patternMaskRotation, item->patternMaskSkewX, item->patternMaskSkewY, item->patternMaskMirrorX, item->patternMaskMirrorY);
-			if (item->GrMask == 3)
+			if (item->GrMask == GradMask_Pattern)
 				painter->setMaskMode(2);
-			else if (item->GrMask == 6)
+			else if (item->GrMask == GradMask_PatternLumAlpha)
 				painter->setMaskMode(4);
-			else if (item->GrMask == 7)
+			else if (item->GrMask == GradMask_PatternLumAlphaInverted)
 				painter->setMaskMode(5);
 			else
 				painter->setMaskMode(6);

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp	(original)
+++ trunk/Scribus/scribus/scribusdoc.cpp	Fri Jun 26 19:39:39 2020
@@ -15168,7 +15168,7 @@
 		item->patternTransform(psx, psy, pox, poy, prot, pskx, psky);
 		item->setPatternTransform(psx * grScXi, psy * grScYi, pox, poy, prot, pskx, psky);
 	}
-	if ((item->GrMask == 3) || (item->GrMask == 6) || (item->GrMask == 7) || (item->GrMask == 8))
+	if ((item->GrMask == GradMask_Pattern) || (item->GrMask == GradMask_PatternLumAlpha) || (item->GrMask == GradMask_PatternLumAlphaInverted) || (item->GrMask == GradMask_PatternInverted))
 	{
 		double psx, psy, pox, poy, prot, pskx, psky;
 		item->maskTransform(psx, psy, pox, poy, prot, pskx, psky);

Modified: trunk/Scribus/scribus/scribusstructs.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/scribusstructs.h
==============================================================================
--- trunk/Scribus/scribus/scribusstructs.h	(original)
+++ trunk/Scribus/scribus/scribusstructs.h	Fri Jun 26 19:39:39 2020
@@ -118,6 +118,19 @@
 	Gradient_PatchMesh = 12,
 	Gradient_Conical = 13,
 	Gradient_Hatch = 14
+};
+
+enum
+{
+	GradMask_None = 0,
+	GradMask_Linear = 1,
+	GradMask_Radial = 2,
+	GradMask_Pattern = 3,
+	GradMask_LinearLumAlpha = 4,
+	GradMask_RadialLumAlpha = 5,
+	GradMask_PatternLumAlpha = 6,
+	GradMask_PatternLumAlphaInverted = 7,
+	GradMask_PatternInverted = 8
 };
 
 struct SingleLine

Modified: trunk/Scribus/scribus/ui/propertiespalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/ui/propertiespalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/propertiespalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/propertiespalette.cpp	Fri Jun 26 19:39:39 2020
@@ -677,7 +677,7 @@
 		m_item->setGradientMaskFocal(fx / m_unitRatio, fy / m_unitRatio);
 		m_item->setGradientMaskScale(sg);
 		m_item->setGradientMaskSkew(sk);
-		if ((m_item->GrMask == 1) || (m_item->GrMask == 4))
+		if ((m_item->GrMask == GradMask_Linear) || (m_item->GrMask == GradMask_LinearLumAlpha))
 		{
 			m_item->setGradientMaskFocal(m_item->GrMaskStartX, m_item->GrMaskStartY);
 		}

Modified: trunk/Scribus/scribus/ui/transparencypalette.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=23907&path=/trunk/Scribus/scribus/ui/transparencypalette.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/transparencypalette.cpp	(original)
+++ trunk/Scribus/scribus/ui/transparencypalette.cpp	Fri Jun 26 19:39:39 2020
@@ -293,16 +293,16 @@
 		if (gradientType->currentIndex() == 0)
 		{
 			if (transpCalcGradient->isChecked())
-				emit NewGradient(4);
+				emit NewGradient(GradMask_LinearLumAlpha);
 			else
-				emit NewGradient(1);
+				emit NewGradient(GradMask_Linear);
 		}
 		else
 		{
 			if (transpCalcGradient->isChecked())
-				emit NewGradient(5);
+				emit NewGradient(GradMask_RadialLumAlpha);
 			else
-				emit NewGradient(2);
+				emit NewGradient(GradMask_Radial);
 		}
 		connect(namedGradient, SIGNAL(activated(const QString &)), this, SLOT(setNamedGradient(const QString &)));
 	}
@@ -311,20 +311,20 @@
 		if (transpCalcPattern->isChecked())
 		{
 			if (usePatternInverted->isChecked())
-				emit NewGradient(7);
+				emit NewGradient(GradMask_PatternLumAlphaInverted);
 			else
-				emit NewGradient(6);
+				emit NewGradient(GradMask_PatternLumAlpha);
 		}
 		else
 		{
 			if (usePatternInverted->isChecked())
-				emit NewGradient(8);
+				emit NewGradient(GradMask_PatternInverted);
 			else
-				emit NewGradient(3);
+				emit NewGradient(GradMask_Pattern);
 		}
 	}
 	else
-		emit NewGradient(0);
+		emit NewGradient(GradMask_None);
 }
 
 void TransparencyPalette::slotGradType(int type)
@@ -332,16 +332,16 @@
 	if (type == 0)
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(4);
-		else
-			emit NewGradient(1);
+			emit NewGradient(GradMask_LinearLumAlpha);
+		else
+			emit NewGradient(GradMask_Linear);
 	}
 	else
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(5);
-		else
-			emit NewGradient(2);
+			emit NewGradient(GradMask_RadialLumAlpha);
+		else
+			emit NewGradient(GradMask_Radial);
 	}
 }
 
@@ -362,16 +362,16 @@
 	if (gradientType->currentIndex() == 0)
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(4);
-		else
-			emit NewGradient(1);
+			emit NewGradient(GradMask_LinearLumAlpha);
+		else
+			emit NewGradient(GradMask_Linear);
 	}
 	else
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(5);
-		else
-			emit NewGradient(2);
+			emit NewGradient(GradMask_RadialLumAlpha);
+		else
+			emit NewGradient(GradMask_Radial);
 	}
 }
 
@@ -380,16 +380,16 @@
 	if (gradientType->currentIndex() == 0)
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(4);
-		else
-			emit NewGradient(1);
+			emit NewGradient(GradMask_LinearLumAlpha);
+		else
+			emit NewGradient(GradMask_Linear);
 	}
 	else
 	{
 		if (transpCalcGradient->isChecked())
-			emit NewGradient(5);
-		else
-			emit NewGradient(2);
+			emit NewGradient(GradMask_RadialLumAlpha);
+		else
+			emit NewGradient(GradMask_Radial);
 	}
 }
 
@@ -398,16 +398,16 @@
 	if (transpCalcPattern->isChecked())
 	{
 		if (usePatternInverted->isChecked())
-			emit NewGradient(7);
-		else
-			emit NewGradient(6);
+			emit NewGradient(GradMask_PatternLumAlphaInverted);
+		else
+			emit NewGradient(GradMask_PatternLumAlpha);
 	}
 	else
 	{
 		if (usePatternInverted->isChecked())
-			emit NewGradient(8);
-		else
-			emit NewGradient(3);
+			emit NewGradient(GradMask_PatternInverted);
+		else
+			emit NewGradient(GradMask_Pattern);
 	}
 }
 
@@ -417,7 +417,7 @@
 	{
 		TGradDia->unitChange(currentDoc->unitIndex());
 		TGradDia->setValues(currentItem->GrMaskStartX, currentItem->GrMaskStartY, currentItem->GrMaskEndX, currentItem->GrMaskEndY, currentItem->GrMaskFocalX, currentItem->GrMaskFocalY, currentItem->GrMaskScale, currentItem->GrMaskSkew, 0, 0);
-		if ((currentItem->GrMask == 1) || (currentItem->GrMask == 4))
+		if ((currentItem->GrMask == GradMask_Linear) || (currentItem->GrMask == GradMask_LinearLumAlpha))
 			TGradDia->selectLinear();
 		else
 			TGradDia->selectRadial();




More information about the scribus-commit mailing list