r24412 by jghali - Store mark position in ColorChart in a size independent way

scribus-commit scribus-commit at lists.scribus.net
Mon Jan 18 10:41:39 UTC 2021


Author: jghali
Date: Mon Jan 18 10:41:39 2021
New Revision: 24412

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24412
Log:
Store mark position in ColorChart in a size independent way

Modified:
    trunk/Scribus/scribus/ui/colorchart.cpp
    trunk/Scribus/scribus/ui/colorchart.h

Modified: trunk/Scribus/scribus/ui/colorchart.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24412&path=/trunk/Scribus/scribus/ui/colorchart.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/colorchart.cpp	(original)
+++ trunk/Scribus/scribus/ui/colorchart.cpp	Mon Jan 18 10:41:39 2021
@@ -85,11 +85,13 @@
 	p2.drawPixmap(0, 0, m_pixmap);
 	if (m_drawMark)
 	{
+		double markX = m_markX * width();
+		double markY = m_markY * height();
 		p2.setPen(QPen(Qt::black, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin));
-		p2.drawLine(m_markX - 5, m_markY - 5, m_markX - 1, m_markY - 1);
-		p2.drawLine(m_markX - 5, m_markY + 5, m_markX - 1, m_markY + 1);
-		p2.drawLine(m_markX + 2, m_markY + 2, m_markX + 6, m_markY + 6);
-		p2.drawLine(m_markX + 2, m_markY - 2, m_markX + 6, m_markY - 6);
+		p2.drawLine(markX - 5, markY - 5, markX - 1, markY - 1);
+		p2.drawLine(markX - 5, markY + 5, markX - 1, markY + 1);
+		p2.drawLine(markX + 2, markY + 2, markX + 6, markY + 6);
+		p2.drawLine(markX + 2, markY - 2, markX + 6, markY - 6);
 		m_drawMark = false;
 	}
 	p2.end();
@@ -114,8 +116,8 @@
 
 void ColorChart::drawMark(int x, int y)
 {
-	m_markX = x;
-	m_markY = y;
+	m_markX = x / (double) width();
+	m_markY = y / (double) height();
 	m_drawMark = true;
 	update();
 }

Modified: trunk/Scribus/scribus/ui/colorchart.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24412&path=/trunk/Scribus/scribus/ui/colorchart.h
==============================================================================
--- trunk/Scribus/scribus/ui/colorchart.h	(original)
+++ trunk/Scribus/scribus/ui/colorchart.h	Mon Jan 18 10:41:39 2021
@@ -55,12 +55,12 @@
 	int drawMode {0};
 
 protected:
-	ScribusDoc* m_doc;
+	ScribusDoc* m_doc { nullptr };
 
 	int m_currentValue { 255 };
-	int m_markX { 0 };
-	int m_markY { 0 };
-	bool m_drawMark {false};
+	double m_markX { 0.0 };
+	double m_markY { 0.0 };
+	bool m_drawMark { false };
 	
 	QPixmap m_pixmap;
 




More information about the scribus-commit mailing list