From 84d3669888ba39ee9064218aa8cfd4db9f2dfaf2 Mon Sep 17 00:00:00 2001 From: hlorus <64740362+hlorus@users.noreply.github.com> Date: Mon, 3 Jun 2024 10:02:05 +0200 Subject: [PATCH] MeasureGui: Paint icons in textcolor --- src/Gui/SoTextLabel.cpp | 1 + src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp | 15 ++++++++++++--- src/Mod/Measure/Gui/ViewProviderMeasureBase.h | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Gui/SoTextLabel.cpp b/src/Gui/SoTextLabel.cpp index a081055819..6b2f55d53c 100644 --- a/src/Gui/SoTextLabel.cpp +++ b/src/Gui/SoTextLabel.cpp @@ -385,6 +385,7 @@ SoFrameLabel::SoFrameLabel() void SoFrameLabel::setIcon(const QPixmap &pixMap) { iconPixmap = pixMap; + drawImage(); } diff --git a/src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp b/src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp index 38fd2d9631..ce7697bdc9 100644 --- a/src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp +++ b/src/Mod/Measure/Gui/ViewProviderMeasureBase.cpp @@ -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(pcObj); positionAnno(measureObj); - - // Set the icon - pLabel->setIcon(Gui::BitmapFactory().pixmapFromSvg(sPixmap, QSize(20, 20))); + updateIcon(); } diff --git a/src/Mod/Measure/Gui/ViewProviderMeasureBase.h b/src/Mod/Measure/Gui/ViewProviderMeasureBase.h index 6246b20514..979e06eacb 100644 --- a/src/Mod/Measure/Gui/ViewProviderMeasureBase.h +++ b/src/Mod/Measure/Gui/ViewProviderMeasureBase.h @@ -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();