src/ColorSelector.cc

changeset 642
751a8df42842
parent 639
851634b85893
child 644
93dcd1a0e4bd
equal deleted inserted replaced
641:425b169a82aa 642:751a8df42842
113 m_scene->addRect (x, y, w, w, pen, col); 113 m_scene->addRect (x, y, w, w, pen, col);
114 QGraphicsTextItem* numtext = m_scene->addText (fmt ("%1", i)); 114 QGraphicsTextItem* numtext = m_scene->addText (fmt ("%1", i));
115 numtext->setDefaultTextColor ( (luma (col) < 80) ? Qt::white : Qt::black); 115 numtext->setDefaultTextColor ( (luma (col) < 80) ? Qt::white : Qt::black);
116 numtext->setPos (x, y); 116 numtext->setPos (x, y);
117 117
118 if (getSelection() && i == getSelection()->index) 118 if (selection() && i == selection()->index)
119 { 119 {
120 auto curspic = m_scene->addPixmap (getIcon ("colorcursor")); 120 auto curspic = m_scene->addPixmap (getIcon ("colorcursor"));
121 curspic->setPos (x, y); 121 curspic->setPos (x, y);
122 } 122 }
123 } 123 }
139 139
140 // ============================================================================= 140 // =============================================================================
141 // ============================================================================= 141 // =============================================================================
142 void ColorSelector::drawColorInfo() 142 void ColorSelector::drawColorInfo()
143 { 143 {
144 if (!getSelection()) 144 if (!selection())
145 { 145 {
146 ui->colorLabel->setText ("---"); 146 ui->colorLabel->setText ("---");
147 return; 147 return;
148 } 148 }
149 149
150 ui->colorLabel->setText (fmt ("%1 - %2", getSelection()->index, getSelection()->name)); 150 ui->colorLabel->setText (fmt ("%1 - %2", selection()->index, selection()->name));
151 } 151 }
152 152
153 // ============================================================================= 153 // =============================================================================
154 // ============================================================================= 154 // =============================================================================
155 void ColorSelector::resizeEvent (QResizeEvent* ev) 155 void ColorSelector::resizeEvent (QResizeEvent* ev)
159 // height is not set properly there. 159 // height is not set properly there.
160 if (m_firstResize) 160 if (m_firstResize)
161 { 161 {
162 int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns; 162 int visibleColors = (ui->viewport->height() / g_squareSize) * g_numColumns;
163 163
164 if (getSelection() && getSelection()->index >= visibleColors) 164 if (selection() && selection()->index >= visibleColors)
165 { 165 {
166 int y = (getSelection()->index / g_numColumns) * g_squareSize; 166 int y = (selection()->index / g_numColumns) * g_squareSize;
167 ui->viewport->verticalScrollBar()->setValue (y); 167 ui->viewport->verticalScrollBar()->setValue (y);
168 } 168 }
169 169
170 m_firstResize = false; 170 m_firstResize = false;
171 } 171 }
198 // ============================================================================= 198 // =============================================================================
199 bool ColorSelector::selectColor (int& val, int defval, QWidget* parent) 199 bool ColorSelector::selectColor (int& val, int defval, QWidget* parent)
200 { 200 {
201 ColorSelector dlg (defval, parent); 201 ColorSelector dlg (defval, parent);
202 202
203 if (dlg.exec() && dlg.getSelection() != null) 203 if (dlg.exec() && dlg.selection() != null)
204 { 204 {
205 val = dlg.getSelection()->index; 205 val = dlg.selection()->index;
206 return true; 206 return true;
207 } 207 }
208 208
209 return false; 209 return false;
210 } 210 }

mercurial