zz_colorSelectDialog.cpp

changeset 137
2b8b63be67fb
parent 135
c243df39913e
child 147
291a1fe2d278
equal deleted inserted replaced
136:13db97be14cb 137:2b8b63be67fb
26 #include <qevent.h> 26 #include <qevent.h>
27 #include <qscrollbar.h> 27 #include <qscrollbar.h>
28 #include "zz_colorSelectDialog.h" 28 #include "zz_colorSelectDialog.h"
29 #include "colors.h" 29 #include "colors.h"
30 #include "config.h" 30 #include "config.h"
31 #include "misc.h"
31 32
32 static const short g_dNumColumns = 8; 33 static const short g_dNumColumns = 8;
33 static const short g_dNumRows = 10; 34 static const short g_dNumRows = 10;
34 static const short g_dSquareSize = 32; 35 static const short g_dSquareSize = 32;
35 static const long g_lWidth = (g_dNumColumns * g_dSquareSize); 36 static const long g_lWidth = (g_dNumColumns * g_dSquareSize);
113 // Use the user preferences for main color here 114 // Use the user preferences for main color here
114 qColor = gl_maincolor.value.chars (); 115 qColor = gl_maincolor.value.chars ();
115 qColor.setAlpha (gl_maincolor_alpha * 255.0f); 116 qColor.setAlpha (gl_maincolor_alpha * 255.0f);
116 } 117 }
117 118
118 uchar ucLuma = (0.2126f * qColor.red()) + 119 bool dark = (luma (qColor) < 80);
119 (0.7152f * qColor.green()) + (0.0722f * qColor.blue());
120 bool bDark = (ucLuma < 80);
121 120
122 gs_scene->addRect (x, y, w, w, qPen, qColor); 121 gs_scene->addRect (x, y, w, w, qPen, qColor);
123 QGraphicsTextItem* qText = gs_scene->addText (format ("%lu", i).chars()); 122 QGraphicsTextItem* qText = gs_scene->addText (format ("%lu", i).chars());
124 qText->setDefaultTextColor ((bDark) ? Qt::white : Qt::black); 123 qText->setDefaultTextColor ((dark) ? Qt::white : Qt::black);
125 qText->setPos (x, y); 124 qText->setPos (x, y);
126 125
127 if (i == selColor) { 126 if (i == selColor) {
128 QGraphicsPixmapItem* qCursorPic; 127 QGraphicsPixmapItem* qCursorPic;
129 qCursorPic = gs_scene->addPixmap (QPixmap ("icons/colorcursor.png")); 128 qCursorPic = gs_scene->addPixmap (QPixmap ("icons/colorcursor.png"));

mercurial