172 // ----------------------------------------------------------------------------- |
172 // ----------------------------------------------------------------------------- |
173 List<LDQuickColor> quickColorsFromConfig() { |
173 List<LDQuickColor> quickColorsFromConfig() { |
174 List<LDQuickColor> colors; |
174 List<LDQuickColor> colors; |
175 |
175 |
176 for (str colorname : gui_colortoolbar.value.split (":")) { |
176 for (str colorname : gui_colortoolbar.value.split (":")) { |
177 if (colorname == "|") { |
177 if (colorname == "|") |
178 colors << LDQuickColor ({null, null, true}); |
178 colors << LDQuickColor::getSeparator(); |
179 } else { |
179 else { |
180 LDColor* col = getColor (colorname.toLong()); |
180 LDColor* col = getColor (colorname.toLong()); |
181 assert (col != null); |
181 |
182 colors << LDQuickColor ({col, null, false}); |
182 if (col != null) |
|
183 colors << LDQuickColor (col, null); |
183 } |
184 } |
184 } |
185 } |
185 |
186 |
186 return colors; |
187 return colors; |
187 } |
188 } |
191 void ForgeWindow::updateToolBars() { |
192 void ForgeWindow::updateToolBars() { |
192 m_colorButtons.clear(); |
193 m_colorButtons.clear(); |
193 ui->colorToolbar->clear(); |
194 ui->colorToolbar->clear(); |
194 |
195 |
195 for (LDQuickColor& entry : m_quickColors) { |
196 for (LDQuickColor& entry : m_quickColors) { |
196 if (entry.isSeparator) |
197 if (entry.isSeparator()) |
197 ui->colorToolbar->addSeparator(); |
198 ui->colorToolbar->addSeparator(); |
198 else { |
199 else { |
199 QToolButton* colorButton = new QToolButton; |
200 QToolButton* colorButton = new QToolButton; |
200 colorButton->setIcon (makeColorIcon (entry.col, 22)); |
201 colorButton->setIcon (makeColorIcon (entry.color(), 22)); |
201 colorButton->setIconSize (QSize (22, 22)); |
202 colorButton->setIconSize (QSize (22, 22)); |
202 colorButton->setToolTip (entry.col->name); |
203 colorButton->setToolTip (entry.color()->name); |
203 |
204 |
204 connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor())); |
205 connect (colorButton, SIGNAL (clicked()), this, SLOT (slot_quickColor())); |
205 ui->colorToolbar->addWidget (colorButton); |
206 ui->colorToolbar->addWidget (colorButton); |
206 m_colorButtons << colorButton; |
207 m_colorButtons << colorButton; |
207 |
208 |
208 entry.btn = colorButton; |
209 entry.setToolButton (colorButton); |
209 } |
210 } |
210 } |
211 } |
211 |
212 |
212 updateGridToolBar(); |
213 updateGridToolBar(); |
213 } |
214 } |
486 void ForgeWindow::fullRefresh() { |
487 void ForgeWindow::fullRefresh() { |
487 buildObjList(); |
488 buildObjList(); |
488 m_renderer->hardRefresh(); |
489 m_renderer->hardRefresh(); |
489 } |
490 } |
490 |
491 |
|
492 // ============================================================================= |
|
493 // ----------------------------------------------------------------------------- |
491 void ForgeWindow::refresh() { |
494 void ForgeWindow::refresh() { |
492 buildObjList(); |
495 buildObjList(); |
493 m_renderer->update(); |
496 m_renderer->update(); |
494 } |
497 } |
495 |
498 |
917 QImage imageFromScreencap (uchar* data, ushort w, ushort h) { |
920 QImage imageFromScreencap (uchar* data, ushort w, ushort h) { |
918 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
921 // GL and Qt formats have R and B swapped. Also, GL flips Y - correct it as well. |
919 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
922 return QImage (data, w, h, QImage::Format_ARGB32).rgbSwapped().mirrored(); |
920 } |
923 } |
921 |
924 |
|
925 // ============================================================================= |
|
926 // ----------------------------------------------------------------------------- |
|
927 LDQuickColor::LDQuickColor (LDColor* color, QToolButton* toolButton) : |
|
928 m_color (color), |
|
929 m_toolButton (toolButton) {} |
|
930 |
|
931 LDQuickColor LDQuickColor::getSeparator() { |
|
932 return LDQuickColor (null, null); |
|
933 } |
|
934 |
|
935 bool LDQuickColor::isSeparator() const { |
|
936 return color() == null; |
|
937 } |