MeasureGui: Paint icons in textcolor

This commit is contained in:
hlorus
2024-06-03 10:02:05 +02:00
committed by Yorik van Havre
parent e490531510
commit 84d3669888
3 changed files with 14 additions and 3 deletions

View File

@@ -385,6 +385,7 @@ SoFrameLabel::SoFrameLabel()
void SoFrameLabel::setIcon(const QPixmap &pixMap)
{
iconPixmap = pixMap;
drawImage();
}

View File

@@ -213,6 +213,7 @@ void ViewProviderMeasureBase::onChanged(const App::Property* prop)
if (prop == &TextColor) {
const App::Color& color = TextColor.getValue();
pLabel->textColor.setValue(color.r, color.g, color.b);
updateIcon();
}
else if (prop == &TextBackgroundColor) {
const App::Color& color = TextBackgroundColor.getValue();
@@ -281,14 +282,22 @@ void ViewProviderMeasureBase::positionAnno(const Measure::MeasureBase* measureOb
}
void ViewProviderMeasureBase::updateIcon() {
// This assumes the icons main color is black
Gui::ColorMap colorMap {
{ 0x000000, TextColor.getValue().getPackedRGB() >> 8 },
};
pLabel->setIcon(Gui::BitmapFactory().pixmapFromSvg(sPixmap, QSize(20, 20), colorMap));
}
void ViewProviderMeasureBase::attach(App::DocumentObject *pcObj)
{
ViewProviderDocumentObject::attach(pcObj);
auto measureObj = static_cast<MeasureBase*>(pcObj);
positionAnno(measureObj);
// Set the icon
pLabel->setIcon(Gui::BitmapFactory().pixmapFromSvg(sPixmap, QSize(20, 20)));
updateIcon();
}

View File

@@ -121,6 +121,7 @@ protected:
void setLabelValue(const Base::Quantity& value);
void setLabelValue(const QString& value);
void setLabelTranslation(const SbVec3f& position);
void updateIcon();
SoPickStyle* getSoPickStyle();
SoDrawStyle* getSoLineStylePrimary();