r14139 by fschmid - Allow color "None" for gradient stops

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 11 12:40:33 CEST 2009


Revision: 14139
Author: fschmid
Date: 2009-10-11T09:39:12.425423Z
Commit message: Allow color "None" for gradient stops

Changeset: 
M  /trunk/Scribus/scribus/pdflib_core.cpp
M  /trunk/Scribus/scribus/pslib.cpp
M  /trunk/Scribus/scribus/util_color.cpp
M  /trunk/Scribus/scribus/ui/gradienteditor.cpp
M  /trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 14138)
+++ scribus/pdflib_core.cpp	(revision 14139)
@@ -4958,6 +4958,26 @@
 	RGBColor rgb;
 	CMYKColor cmyk;
 	int h, s, v, k;
+	if (farbe == CommonStrings::None)
+	{
+		if (Options.isGrayscale)
+			tmp = "0.0";
+		if (Options.UseRGB)
+			tmp = "1.0 1.0 1.0";
+		else
+		{
+			if ((doc.HasCMS) && (Options.UseProfiles))
+			{
+				if (Options.SComp == 3)
+					tmp = "1.0 1.0 1.0";
+				else
+					tmp = "0.0 0.0 0.0 0.0";
+			}
+			else
+				tmp = "0.0 0.0 0.0 0.0";
+		}
+		return tmp;
+	}
 	ScColor tmpC(doc.PageColors[farbe]);
 	QColor tmpR;
 	if (Options.isGrayscale)
@@ -5722,8 +5742,18 @@
 			if (oneSameSpot)
 			{
 				PutDoc("/Domain [0.0 1.0]\n");
-				ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
-				cmykValues.getValues(cc, mc, yc, kc);
+				if (colorNames[c] == CommonStrings::None)
+				{
+					cc = 0;
+					mc = 0;
+					yc = 0;
+					kc = 0;
+				}
+				else
+				{
+					ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
+					cmykValues.getValues(cc, mc, yc, kc);
+				}
 				colorDesc = "{\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul exch\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul exch\n";
@@ -5733,15 +5763,35 @@
 			else if (twoSpot)
 			{
 				PutDoc("/Domain [0.0 1.0 0.0 1.0]\n");
-				ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
-				cmykValues.getValues(cc, mc, yc, kc);
+				if (colorNames[c] == CommonStrings::None)
+				{
+					cc = 0;
+					mc = 0;
+					yc = 0;
+					kc = 0;
+				}
+				else
+				{
+					ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
+					cmykValues.getValues(cc, mc, yc, kc);
+				}
 				colorDesc = "{\nexch\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub exch\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub exch\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub exch\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(kc) / 255.0)+" mul 1.0 exch sub exch pop 5 -1 roll\n";
-				ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
-				cmykValues.getValues(cc, mc, yc, kc);
+				if (colorNames[c+1] == CommonStrings::None)
+				{
+					cc = 0;
+					mc = 0;
+					yc = 0;
+					kc = 0;
+				}
+				else
+				{
+					ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
+					cmykValues.getValues(cc, mc, yc, kc);
+				}
 				colorDesc += "dup "+FToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll mul 1.0 exch sub 5 1 roll\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)+" mul 1.0 exch sub 5 -1 roll mul 1.0 exch sub 4 1 roll\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(yc) / 255.0)+" mul 1.0 exch sub 4 -1 roll mul 1.0 exch sub 3 1 roll\n";
@@ -5752,13 +5802,33 @@
 				PutDoc("/Domain [0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0 0.0 1.0]\n");
 				if (oneSpot1)
 				{
-					ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
-					cmykValues.getValues(cc, mc, yc, kc);
+					if (colorNames[c] == CommonStrings::None)
+					{
+						cc = 0;
+						mc = 0;
+						yc = 0;
+						kc = 0;
+					}
+					else
+					{
+						ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c]], &doc, cmykValues);
+						cmykValues.getValues(cc, mc, yc, kc);
+					}
 				}
 				else
 				{
-					ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
-					cmykValues.getValues(cc, mc, yc, kc);
+					if (colorNames[c+1] == CommonStrings::None)
+					{
+						cc = 0;
+						mc = 0;
+						yc = 0;
+						kc = 0;
+					}
+					else
+					{
+						ScColorEngine::getCMYKValues(doc.PageColors[colorNames[c+1]], &doc, cmykValues);
+						cmykValues.getValues(cc, mc, yc, kc);
+					}
 				}
 				colorDesc = "{\ndup "+FToStr(static_cast<double>(cc) / 255.0)+" mul 1.0 exch sub 6 -1 roll 1.0 exch sub mul 1.0 exch sub 5 1 roll\n";
 				colorDesc += "dup "+FToStr(static_cast<double>(mc) / 255.0)  +" mul 1.0 exch sub 5 -1 roll 1.0 exch sub mul 1.0 exch sub 4 1 roll\n";
Index: scribus/ui/gradienteditor.cpp
===================================================================
--- scribus/ui/gradienteditor.cpp	(revision 14138)
+++ scribus/ui/gradienteditor.cpp	(revision 14139)
@@ -55,7 +55,7 @@
 void GradientEditor::setColors(ColorList &colorList)
 {
 	m_colorList = colorList;
-	stopColor->updateBox(colorList, ColorCombo::fancyPixmaps, false);
+	stopColor->updateBox(colorList, ColorCombo::fancyPixmaps, true);
 }
 
 void GradientEditor::setPos(double p)
@@ -77,7 +77,19 @@
 	disconnect(stopColor, SIGNAL(activated(const QString &)), this, SLOT(setStopColor(const QString &)));
 	disconnect(stopShade, SIGNAL(valueChanged(int)), this, SLOT(setStopShade(int)));
 	stopShade->setValue(shade);
-	setCurrentComboItem(stopColor, name);
+	QString nam = name;
+	if (name == CommonStrings::None)
+	{
+		stopShade->setEnabled(false);
+		stopOpacity->setEnabled(false);
+		nam = CommonStrings::tr_NoneColor;
+	}
+	else
+	{
+		stopShade->setEnabled(true);
+		stopOpacity->setEnabled(true);
+	}
+	setCurrentComboItem(stopColor, nam);
 	connect(stopColor, SIGNAL(activated(const QString &)), this, SLOT(setStopColor(const QString &)));
 	connect(stopShade, SIGNAL(valueChanged(int)), this, SLOT(setStopShade(int)));
 }
@@ -96,7 +108,20 @@
 
 void GradientEditor::setStopColor(const QString &Color)
 {
-	Preview->setActColor(setColor(Color, stopShade->value()), Color, stopShade->value());
+	if (Color == CommonStrings::tr_NoneColor)
+	{
+		Preview->setActColor(QColor(255, 255, 255, 0), CommonStrings::None, 100);
+		Preview->setActTrans(0.0);
+		stopShade->setEnabled(false);
+		stopOpacity->setEnabled(false);
+	}
+	else
+	{
+		Preview->setActColor(setColor(Color, stopShade->value()), Color, stopShade->value());
+		Preview->setActTrans(stopOpacity->value() / 100.0);
+		stopShade->setEnabled(true);
+		stopOpacity->setEnabled(true);
+	}
 	emit gradientChanged();
 }
 
Index: scribus/util_color.cpp
===================================================================
--- scribus/util_color.cpp	(revision 14138)
+++ scribus/util_color.cpp	(revision 14139)
@@ -136,6 +136,8 @@
 
 QColor SetColor(ScribusDoc *currentDoc, QString color, int shad)
 {
+	if (color == CommonStrings::None)
+		return QColor(0, 0, 0, 0);
 	const ScColor& col = currentDoc->PageColors[color];
 	return ScColorEngine::getShadeColorProof(col, currentDoc, shad);
 }
Index: scribus/plugins/svgexplugin/svgexplugin.cpp
===================================================================
--- scribus/plugins/svgexplugin/svgexplugin.cpp	(revision 14138)
+++ scribus/plugins/svgexplugin/svgexplugin.cpp	(revision 14139)
@@ -1561,7 +1561,10 @@
 				{
 					QDomElement itcl = docu.createElement("stop");
 					itcl.setAttribute("offset", FToStr(cstops.at(cst)->rampPoint*100)+"%");
-					itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
+					if (cstops.at(cst)->name == CommonStrings::None)
+						itcl.setAttribute("stop-opacity", FToStr(0));
+					else
+						itcl.setAttribute("stop-opacity", FToStr(cstops.at(cst)->opacity));
 					itcl.setAttribute("stop-color", SetColor(cstops.at(cst)->name, cstops.at(cst)->shade));
 					grad.appendChild(itcl);
 				}
@@ -1711,6 +1714,8 @@
 
 QString SVGExPlug::SetColor(QString farbe, int shad)
 {
+	if (farbe == CommonStrings::None)
+		return "#FFFFFF";
 	const ScColor& col = m_Doc->PageColors[farbe];
 	return ScColorEngine::getShadeColorProof(col, m_Doc, shad).name();
 }
Index: scribus/pslib.cpp
===================================================================
--- scribus/pslib.cpp	(revision 14138)
+++ scribus/pslib.cpp	(revision 14139)
@@ -3597,6 +3597,14 @@
 
 void PSLib::SetColor(const QString& farb, double shade, int *h, int *s, int *v, int *k, bool gcr)
 {
+	if (farb == CommonStrings::None)
+	{
+		*h = 0;
+		*s = 0;
+		*v = 0;
+		*k = 0;
+		return;
+	}
 	ScColor& col = m_Doc->PageColors[farb];
 	SetColor(col, shade, h, s, v, k, gcr);
 }




More information about the scribus-commit mailing list