View Issue Details

IDProjectCategoryView StatusLast Update
0017337ScribusUser Interfacepublic2024-12-14 10:28
Reporternitramr Assigned Tonitramr  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformDesktop PCOSUbuntuOS Version24.10 64-bit
Product Version1.7.0.svn 
Target Version1.7.0Fixed in Version1.7.0.svn 
Summary0017337: Render issues of gradients in color picker
DescriptionIf gradients have some transparency, there are render glitches in the small preview image in color picker.

The patch contains 2 more small fixes of the color picker:
- color preview boxes have a grey outline
- gradient type for conical gradients was set wrongly
Steps To Reproduce1. Create a new document and import the attached pen.svg
2. Ungroup the objects of the svg
3. select an object, open color picker and click on gradient icon (check the gradient previews)
Additional InformationBTW: the import of this svg files has some other issues.
1. if "defs" are not on top in the file structure, Scribus does not assign the gradient to a page object
2. shapes with only an outline get by default a black fill. SVG importer just ignores the global fill property

I'm debugging this at the moment. I just wanted to mention it here, because of the attached svg file.
TagsNo tags attached.
PatchNo

Activities

nitramr

2024-12-13 13:47

developer  

colorpicker_2024-12-13_01.patch (3,672 bytes)   
Index: scribus/ui/colorpicker/colorpicker_gradient.cpp
===================================================================
--- scribus/ui/colorpicker/colorpicker_gradient.cpp	(Revision 26480)
+++ scribus/ui/colorpicker/colorpicker_gradient.cpp	(Arbeitskopie)
@@ -437,10 +437,10 @@
 	case Gradient_4Colors:
 		gradType = VGradient::fourcolor;
 		break;
+	case Gradient_Conical:
 	case Gradient_Mesh:
 		gradType = VGradient::mesh;
 		break;
-	case Gradient_Conical:
 	case Gradient_PatchMesh:
 		gradType = VGradient::freemesh;
 		break;
Index: scribus/ui/widgets/gradientlistbox.cpp
===================================================================
--- scribus/ui/widgets/gradientlistbox.cpp	(Revision 26480)
+++ scribus/ui/widgets/gradientlistbox.cpp	(Arbeitskopie)
@@ -7,6 +7,7 @@
 #include <QHelpEvent>
 #include <QMenu>
 #include <QPainter>
+#include <QPalette>
 #include <QPersistentModelIndex>
 #include <QPixmap>
 #include <QSignalBlocker>
@@ -18,6 +19,7 @@
 #include "scribusapp.h"
 #include "scribusdoc.h"
 #include "scpainter.h"
+#include "util_gui.h"
 
 
 class SCRIBUS_API GradientWideItemDelegate : public ScListBoxPixmap<48, 16>
@@ -33,32 +35,43 @@
 
 void GradientWideItemDelegate::redraw(const QVariant& data) const
 {
-	int w = 48;
-	int h = 16;
+	const int w = 48;
+	const int h = 16;
 
-	QPixmap* pPixmap = ScListBoxPixmap<48, 16>::pmap.data();
-	pPixmap->fill(Qt::transparent);
+	QPalette palette;
+	QPixmap* pixmap = ScListBoxPixmap<w, h>::pmap.data();
+	pixmap->fill(palette.base().color());
 
+
 	if (data.canConvert<GradientPixmapValue>())
 	{
 		GradientPixmapValue item(data.value<GradientPixmapValue>());
-		QImage pixm(w, h, QImage::Format_ARGB32_Premultiplied);
 
-		ScPainter *p = new ScPainter(&pixm, w, h);
-		p->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
-		p->setFillMode(ScPainter::Gradient);
-		p->fill_gradient = item.m_gradient;
-		p->setGradient(VGradient::linear, FPoint(0,h/2), FPoint(w, h/2), FPoint(0,0), 1, 0);
-		p->drawRect(0, 0, w, h);
-		p->end();
-		delete p;
+		QImage image(w, h, QImage::Format_ARGB32_Premultiplied);
 
-		QPainter pb(pPixmap);
-		QBrush b(QColor(205,205,205), IconManager::instance().loadPixmap("testfill.png"));
-		pb.fillRect(0, 0, w, h, b);
-		pb.drawImage(QRect(0, 0, w, h), pixm);
+		// Draw Background
+		QPainter pb(&image);
+		renderCheckerPattern(&pb, image.rect());
 		pb.end();
+
+		// Draw Gradient
+		ScPainter *pg = new ScPainter(&image, image.width(), image.height());
+		pg->setPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
+		pg->setFillMode(ScPainter::Gradient);
+		pg->fill_gradient = item.m_gradient;
+		pg->setGradient(VGradient::linear, FPoint(0, 0), FPoint(image.width(), 0), FPoint(0, 0), 1.0, 0.0);
+		pg->drawRect(0, 0, image.width(), image.height());
+		pg->end();
+		delete pg;
+
+		QPainter painter(pixmap);
+		painter.drawImage(0, 0, image);
+		painter.setPen(QPen(ScQApp->palette().color(QPalette::Mid), 1));
+		painter.drawRect(image.rect().adjusted(0, 0, -1, -1));
+		painter.end();
 	}
+
+
 }
 
 QString GradientWideItemDelegate::text(const QVariant& data) const
Index: scribus/util_gui.cpp
===================================================================
--- scribus/util_gui.cpp	(Revision 26480)
+++ scribus/util_gui.cpp	(Arbeitskopie)
@@ -35,7 +35,7 @@
 {
 	painter->save();
 	painter->setBrush(color);
-	painter->setPen(QPen(ScQApp->palette().color(isEnabled ? QPalette::Active : QPalette::Disabled, QPalette::WindowText), 1));
+	painter->setPen(QPen(ScQApp->palette().color(isEnabled ? QPalette::Active : QPalette::Disabled, QPalette::Mid), 1));
 	painter->drawRect(rect.adjusted(0, 0, -1, -1));
 	painter->restore();
 }
pen.svg (9,926 bytes)   
pen.svg (9,926 bytes)   

Issue History

Date Modified Username Field Change
2024-12-13 13:47 nitramr New Issue
2024-12-13 13:47 nitramr File Added: colorpicker_2024-12-13_01.patch
2024-12-13 13:47 nitramr File Added: pen.svg
2024-12-13 18:29 cbradney Assigned To => nitramr
2024-12-13 18:29 cbradney Status new => resolved
2024-12-13 18:29 cbradney Resolution open => fixed
2024-12-13 18:29 cbradney Fixed in Version => 1.7.0.svn
2024-12-14 10:28 cbradney Status resolved => closed