src/colorSelector.cc

changeset 714
b4a990f59a5e
parent 662
2f1bd9112408
child 757
8ab9fa53142b
equal deleted inserted replaced
713:46377d340c23 714:b4a990f59a5e
41 // ============================================================================= 41 // =============================================================================
42 // ============================================================================= 42 // =============================================================================
43 ColorSelector::ColorSelector (int defval, QWidget* parent) : QDialog (parent) 43 ColorSelector::ColorSelector (int defval, QWidget* parent) : QDialog (parent)
44 { 44 {
45 // Remove the default color if it's invalid 45 // Remove the default color if it's invalid
46 if (!getColor (defval)) 46 if (not getColor (defval))
47 defval = -1; 47 defval = -1;
48 48
49 m_firstResize = true; 49 m_firstResize = true;
50 ui = new Ui_ColorSelUI; 50 ui = new Ui_ColorSelUI;
51 ui->setupUi (this); 51 ui->setupUi (this);
91 91
92 for (int i = 0; i < MAX_COLORS; ++i) 92 for (int i = 0; i < MAX_COLORS; ++i)
93 { 93 {
94 LDColor* info = ::getColor (i); 94 LDColor* info = ::getColor (i);
95 95
96 if (!info) 96 if (not info)
97 continue; 97 continue;
98 98
99 const double x = (i % numCols) * square; 99 const double x = (i % numCols) * square;
100 const double y = (i / numCols) * square; 100 const double y = (i / numCols) * square;
101 const double w = square - (penWidth / 2); 101 const double w = square - (penWidth / 2);
139 139
140 // ============================================================================= 140 // =============================================================================
141 // ============================================================================= 141 // =============================================================================
142 void ColorSelector::drawColorInfo() 142 void ColorSelector::drawColorInfo()
143 { 143 {
144 if (!selection()) 144 if (not selection())
145 { 145 {
146 ui->colorLabel->setText ("---"); 146 ui->colorLabel->setText ("---");
147 return; 147 return;
148 } 148 }
149 149
184 int y = (scenepos.y() - (g_squareSize / 2)) / g_squareSize; 184 int y = (scenepos.y() - (g_squareSize / 2)) / g_squareSize;
185 int idx = (y * g_numColumns) + x; 185 int idx = (y * g_numColumns) + x;
186 186
187 LDColor* col = ::getColor (idx); 187 LDColor* col = ::getColor (idx);
188 188
189 if (!col) 189 if (not col)
190 return; 190 return;
191 191
192 setSelection (col); 192 setSelection (col);
193 drawScene(); 193 drawScene();
194 drawColorInfo(); 194 drawColorInfo();

mercurial