Scroll the color picker dialog to the selected color if it's off-screen

Thu, 21 Mar 2013 12:57:06 +0200

author
Santeri Piippo <crimsondusk64@gmail.com>
date
Thu, 21 Mar 2013 12:57:06 +0200
changeset 58
4db04d4857c0
parent 57
6e89589f1fe8
child 59
21eae5342dc6

Scroll the color picker dialog to the selected color if it's off-screen

colors.cpp file | annotate | diff | comparison | revisions
zz_colorSelectDialog.cpp file | annotate | diff | comparison | revisions
--- a/colors.cpp	Thu Mar 21 03:20:02 2013 +0200
+++ b/colors.cpp	Thu Mar 21 12:57:06 2013 +0200
@@ -41,8 +41,11 @@
 	{17,	"Light Green",	"#80FF80",	1.0},
 	{18,	"Light Yellow",	"#FFFF80",	1.0},
 	{19,	"Tan",			"#EECC99",	1.0},
+	{21,	"Phosphorus",	"#E0FFB0",	0.975},
 	{22,	"Purple",		"#A000A0",	1.0},
 	{24,	"Edge Color",	"#000000",	1.0},
+	{25,	"Orange",		"#FF8000",	1.0},
+	{26,	"Magenta",		"#FFA0FF",	1.0},
 	{27,	"Lime",			"#00FF00",	1.0},
 	{28,	"Sand",			"#989070",	1.0},
 	{32,	"Smoke",		"#101010",	0.5},
@@ -61,6 +64,9 @@
 	{45,	"Trans Pink",	"#FF2080",	0.5},
 	{46,	"Trans Yellow",	"#FFEE00",	0.5},
 	{47,	"Clear",		"#FFFFFF",	0.5},
+	{79,	"Ghost White",	"#FFFFFF",	0.875},
+	{294,	"Trans Phosphorus",	"#E0FFB0",	0.6},
+	{378,	"Sand Green",	"#80A080",	1.0},
 };
 
 color* g_LDColors[MAX_COLORS];
--- a/zz_colorSelectDialog.cpp	Thu Mar 21 03:20:02 2013 +0200
+++ b/zz_colorSelectDialog.cpp	Thu Mar 21 12:57:06 2013 +0200
@@ -24,6 +24,7 @@
 #include <qboxlayout.h>
 #include <qgraphicsitem.h>
 #include <qevent.h>
+#include <qscrollbar.h>
 #include "zz_colorSelectDialog.h"
 #include "colors.h"
 
@@ -58,6 +59,13 @@
 	qView->setMinimumWidth (lWidth);
 	qView->setMaximumHeight (g_lHeight);
 	qView->setMinimumHeight (g_lHeight);
+	qView->setHorizontalScrollBarPolicy (Qt::ScrollBarAlwaysOff);
+	
+	// If we have a default color selected, scroll down so that it is visible.
+	if (dDefault >= ((g_dNumColumns * g_dNumRows) - 2)) {
+		ulong ulNewY = ((dDefault / g_dNumColumns) - 3) * g_dSquareSize;
+		qView->verticalScrollBar ()->setSliderPosition (ulNewY);
+	}
 	
 	qColorInfo = new QLabel;
 	drawColorInfo ();

mercurial