From 50fcdab1c10a724bd07842b22d54341cde310ee5 Mon Sep 17 00:00:00 2001 From: Laurent Pugin Date: Wed, 15 Nov 2023 16:49:00 +0100 Subject: [PATCH] Add support for `note@head.color`. --- include/vrv/devicecontext.h | 5 +++++ include/vrv/svgdevicecontext.h | 5 +++++ src/svgdevicecontext.cpp | 6 ++++++ src/view_element.cpp | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/include/vrv/devicecontext.h b/include/vrv/devicecontext.h index ad834a24a09..e493d38b611 100644 --- a/include/vrv/devicecontext.h +++ b/include/vrv/devicecontext.h @@ -262,6 +262,11 @@ class DeviceContext { virtual void EndCustomGraphic(){}; ///@} + /** + * Method for changing the color of a custom graphic + */ + virtual void SetCustomGraphicColor(const std::string &color){}; + /** * @name Methods for re-starting and ending a graphic for objects drawn in separate steps * The methods can be used to the output together, for example for a Beam diff --git a/include/vrv/svgdevicecontext.h b/include/vrv/svgdevicecontext.h index fa200895d0d..0e7b43e4afd 100644 --- a/include/vrv/svgdevicecontext.h +++ b/include/vrv/svgdevicecontext.h @@ -130,6 +130,11 @@ class SvgDeviceContext : public DeviceContext { void EndCustomGraphic() override; ///@} + /** + * Method for changing the color of a custom graphic + */ + virtual void SetCustomGraphicColor(const std::string &color) override; + /** * @name Methods for re-starting and ending a graphic for objects drawn in separate steps */ diff --git a/src/svgdevicecontext.cpp b/src/svgdevicecontext.cpp index 66ae7598022..5071cec78f9 100644 --- a/src/svgdevicecontext.cpp +++ b/src/svgdevicecontext.cpp @@ -407,6 +407,12 @@ void SvgDeviceContext::EndCustomGraphic() m_currentNode = m_svgNodeStack.back(); } +void SvgDeviceContext::SetCustomGraphicColor(const std::string &color) +{ + m_currentNode.append_attribute("color") = color.c_str(); + m_currentNode.append_attribute("fill") = color.c_str(); +} + void SvgDeviceContext::EndResumedGraphic(Object *object, View *view) { m_svgNodeStack.pop_back(); diff --git a/src/view_element.cpp b/src/view_element.cpp index 56a19e03251..8edc887561b 100644 --- a/src/view_element.cpp +++ b/src/view_element.cpp @@ -1481,6 +1481,10 @@ void View::DrawNote(DeviceContext *dc, LayerElement *element, Layer *layer, Staf dc->StartCustomGraphic("notehead"); + if (note->HasHeadColor()) { + dc->SetCustomGraphicColor(note->GetHeadColor()); + } + this->DrawSmuflCode(dc, noteX, noteY, fontNo, staff->m_drawingStaffSize, drawingCueSize, true); // handle notehead enclosure