include/basegfx/DrawCommands.hxx | 4 ++++ svgio/qa/cppunit/SvgRead.cxx | 4 +++- svgio/qa/cppunit/data/VisiotorTest-Rect.svg | 4 ++++ svgio/qa/cppunit/data/path.svg | 2 +- svgio/source/svgreader/svgvisitor.cxx | 4 ++++ vcl/source/gdi/FileDefinitionWidgetDraw.cxx | 9 +++++---- vcl/uiconfig/theme_definitions/ios/spinbox-right-pressed.svg | 4 ++-- 7 files changed, 23 insertions(+), 8 deletions(-)
New commits: commit af47db753ff12158466a7737d4ae65018ff0a955 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Apr 5 12:52:58 2019 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Fri Apr 5 22:15:13 2019 +0900 support opacity for widget definition draw SVGs This opacity influences the whole shape (stroke and fill). Reviewed-on: https://gerrit.libreoffice.org/70292 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit fcb00ac8ebe2acb429f09ef5b728b8c73a5bbc37) Change-Id: I82e10e07dbf2f321805b55a5f4831a513e52dab8 diff --git a/include/basegfx/DrawCommands.hxx b/include/basegfx/DrawCommands.hxx index fda21e9231bb..92747c5af4d2 100644 --- a/include/basegfx/DrawCommands.hxx +++ b/include/basegfx/DrawCommands.hxx @@ -62,6 +62,7 @@ public: double mnRy; double mnStrokeWidth; + double mnOpacity; std::shared_ptr<basegfx::BColor> mpFillColor; std::shared_ptr<basegfx::BColor> mpStrokeColor; @@ -71,6 +72,7 @@ public: , mnRx(1.0) , mnRy(1.0) , mnStrokeWidth(1.0) + , mnOpacity(1.0) { } }; @@ -81,6 +83,7 @@ public: basegfx::B2DPolyPolygon maPolyPolygon; double mnStrokeWidth; + double mnOpacity; std::shared_ptr<basegfx::BColor> mpFillColor; std::shared_ptr<basegfx::BColor> mpStrokeColor; @@ -88,6 +91,7 @@ public: : DrawBase(DrawCommandType::Path) , maPolyPolygon(rPolyPolygon) , mnStrokeWidth(1.0) + , mnOpacity(1.0) { } }; diff --git a/svgio/qa/cppunit/SvgRead.cxx b/svgio/qa/cppunit/SvgRead.cxx index 8b13bd68bb45..69a9e0bf1213 100644 --- a/svgio/qa/cppunit/SvgRead.cxx +++ b/svgio/qa/cppunit/SvgRead.cxx @@ -75,7 +75,7 @@ uno::Reference<io::XInputStream> TestParsing::parseSvg(const OUString& aSource) void TestParsing::testSimpleRectangle() { - OUString aSvgFile = "/svgio/qa/cppunit/data/Rect.svg"; + OUString aSvgFile = "/svgio/qa/cppunit/data/VisiotorTest-Rect.svg"; OUString aUrl = m_directories.getURLFromSrc(aSvgFile); OUString aPath = m_directories.getPathFromSrc(aSvgFile); @@ -103,6 +103,7 @@ void TestParsing::testSimpleRectangle() CPPUNIT_ASSERT_EQUAL(ColorData(0xff0000), Color(*pDrawRect->mpStrokeColor).GetRGBColor()); CPPUNIT_ASSERT(bool(pDrawRect->mpFillColor)); CPPUNIT_ASSERT_EQUAL(ColorData(0x00cc00), Color(*pDrawRect->mpFillColor).GetRGBColor()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawRect->mnOpacity, 1E-12); } void TestParsing::testPath() @@ -134,6 +135,7 @@ void TestParsing::testPath() CPPUNIT_ASSERT_EQUAL(ColorData(0xffffff), Color(*pDrawPath->mpStrokeColor).GetRGBColor()); CPPUNIT_ASSERT(bool(pDrawPath->mpFillColor)); CPPUNIT_ASSERT_EQUAL(ColorData(0x007aff), Color(*pDrawPath->mpFillColor).GetRGBColor()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(0.1, pDrawPath->mnOpacity, 1E-12); } CPPUNIT_TEST_SUITE_REGISTRATION(TestParsing); diff --git a/svgio/qa/cppunit/data/VisiotorTest-Rect.svg b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg new file mode 100644 index 000000000000..4cd2d3602ea3 --- /dev/null +++ b/svgio/qa/cppunit/data/VisiotorTest-Rect.svg @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<svg width="120" height="120" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> + <rect x="10" y="10" width="100" height="100" rx="10" ry="10" stroke="#ff0000" opacity="0.1" fill="#00cc00" stroke-width="3" /> +</svg> diff --git a/svgio/qa/cppunit/data/path.svg b/svgio/qa/cppunit/data/path.svg index 1722181c872e..559ceec6d557 100644 --- a/svgio/qa/cppunit/data/path.svg +++ b/svgio/qa/cppunit/data/path.svg @@ -1,3 +1,3 @@ <svg width="44" height="26" xmlns="http://www.w3.org/2000/svg"> - <path d="M1 1 H 43 V 25 H 1 L 1 1 Z" fill="#007aff" stroke="#fff" stroke-width="0"/> + <path d="M1 1 H 43 V 25 H 1 L 1 1 Z" fill="#007aff" stroke="#fff" opacity="0.1" stroke-width="0"/> </svg> diff --git a/svgio/source/svgreader/svgvisitor.cxx b/svgio/source/svgreader/svgvisitor.cxx index 7b92e2fd0afb..011ce5492fa3 100644 --- a/svgio/source/svgreader/svgvisitor.cxx +++ b/svgio/source/svgreader/svgvisitor.cxx @@ -74,6 +74,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) pRectangle->mnStrokeWidth = rRectNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); + pRectangle->mnOpacity = rRectNode.getSvgStyleAttributes()->getOpacity().getNumber(); + const basegfx::BColor* pFillColor = rRectNode.getSvgStyleAttributes()->getFill(); if (pFillColor) pRectangle->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor); @@ -97,6 +99,8 @@ void SvgDrawVisitor::visit(svgio::svgreader::SvgNode const& rNode) pDrawPath->mnStrokeWidth = rPathNode.getSvgStyleAttributes()->getStrokeWidth().getNumber(); + pDrawPath->mnOpacity = rPathNode.getSvgStyleAttributes()->getOpacity().getNumber(); + const basegfx::BColor* pFillColor = rPathNode.getSvgStyleAttributes()->getFill(); if (pFillColor) pDrawPath->mpFillColor = std::make_shared<basegfx::BColor>(*pFillColor); diff --git a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx index f7b3da86eb79..43f8e1487943 100644 --- a/vcl/source/gdi/FileDefinitionWidgetDraw.cxx +++ b/vcl/source/gdi/FileDefinitionWidgetDraw.cxx @@ -188,14 +188,15 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics { rGraphics.SetLineColor(); rGraphics.SetFillColor(ImplColorToSal(Color(*rRectangle.mpFillColor))); - rGraphics.DrawPolyPolygon(basegfx::B2DPolyPolygon(aB2DPolygon), 0.0f, nullptr); + rGraphics.DrawPolyPolygon(basegfx::B2DPolyPolygon(aB2DPolygon), + 1.0 - rRectangle.mnOpacity, nullptr); } if (rRectangle.mpStrokeColor) { rGraphics.SetLineColor(ImplColorToSal(Color(*rRectangle.mpStrokeColor))); rGraphics.SetFillColor(); rGraphics.DrawPolyLine( - aB2DPolygon, 0.0f, + aB2DPolygon, 1.0 - rRectangle.mnOpacity, basegfx::B2DVector(rRectangle.mnStrokeWidth, rRectangle.mnStrokeWidth), basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, nullptr); } @@ -231,7 +232,7 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics { rGraphics.SetLineColor(); rGraphics.SetFillColor(ImplColorToSal(Color(*rPath.mpFillColor))); - rGraphics.DrawPolyPolygon(aPolyPolygon, 0.0f, nullptr); + rGraphics.DrawPolyPolygon(aPolyPolygon, 1.0 - rPath.mnOpacity, nullptr); } if (rPath.mpStrokeColor) { @@ -240,7 +241,7 @@ void drawFromDrawCommands(gfx::DrawRoot const& rDrawRoot, SalGraphics& rGraphics for (auto const& rPolygon : aPolyPolygon) { rGraphics.DrawPolyLine( - rPolygon, 0.0f, + rPolygon, 1.0 - rPath.mnOpacity, basegfx::B2DVector(rPath.mnStrokeWidth, rPath.mnStrokeWidth), basegfx::B2DLineJoin::Round, css::drawing::LineCap_ROUND, 0.0f, nullptr); commit 3d7064803c452d96874de56864f305e113e58b5b Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Apr 5 12:56:04 2019 +0900 Commit: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> CommitDate: Fri Apr 5 22:04:22 2019 +0900 fix spinbox right press SVG - plus sign didn't define a color Change-Id: I1db6c5e4841530be7d46e8829899bf3f8cef8a3b Reviewed-on: https://gerrit.libreoffice.org/70293 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 95573cad5793ab6743307890b56c205e21fe9d6d) diff --git a/vcl/uiconfig/theme_definitions/ios/spinbox-right-pressed.svg b/vcl/uiconfig/theme_definitions/ios/spinbox-right-pressed.svg index ac476a0da90f..41482a4bc961 100644 --- a/vcl/uiconfig/theme_definitions/ios/spinbox-right-pressed.svg +++ b/vcl/uiconfig/theme_definitions/ios/spinbox-right-pressed.svg @@ -1,6 +1,6 @@ <svg version="1.1" viewBox="0 0 44 26" xmlns="http://www.w3.org/2000/svg"> <path d="m0.5 0.5h38.59c2.4433 0 4.4103 1.784 4.4103 4v17c0 2.216-1.967 4-4.4103 4h-38.59z" fill="none" stroke="#007aff" stroke-linecap="round"/> - <rect x="15" y="12" width="14" height="2"/> - <rect x="21" y="6" width="2" height="14"/> + <rect x="15" y="12" width="14" height="2" fill="#007aff" /> + <rect x="21" y="6" width="2" height="14" fill="#007aff" /> <path d="m0.5 0.5h38.59c2.4433 0 4.4103 1.784 4.4103 4v17c0 2.216-1.967 4-4.4103 4h-38.59z" fill="#007aff" opacity=".15" stroke="#007aff" stroke-linecap="round"/> </svg> _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits