diff options
author | Regina Henschel <rb.henschel@t-online.de> | 2023-06-21 15:01:20 +0200 |
---|---|---|
committer | Regina Henschel <rb.henschel@t-online.de> | 2023-06-23 10:54:24 +0200 |
commit | bb19bda1dc620f0f8662776d9818aedf45486994 (patch) | |
tree | b3642e60db311287a935b54d46fd7b440e2d36f0 /sd/source | |
parent | 8ec8d592e31aebe19075e9f89c4c2c7abcf8d420 (diff) |
tdf#155901 MCGR: preserve first and last gradient stop too
Error was, that only the in-between gradient stops were preserve. First
stop was set with fixed offset 0, last stop with fixed offset 1. The
offsets of first and last gradient stop of the original gradient were
lost. Now in all cases (hopefully) the complete gradient stops vector is
preserved and the original offset is used, if e.g. the user changes the
color.
For calculating transparence the indirect way over Color is removed.
Instead percent is directly transformed to the 0..1 values of BColor.
That avoids rounding errors.
Change-Id: Icdf699a6c2e9c6289d2f77033858448e58396a60
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153395
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
Diffstat (limited to 'sd/source')
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.cxx | 25 | ||||
-rw-r--r-- | sd/source/ui/sidebar/SlideBackground.hxx | 4 |
2 files changed, 18 insertions, 11 deletions
diff --git a/sd/source/ui/sidebar/SlideBackground.cxx b/sd/source/ui/sidebar/SlideBackground.cxx index 274789cf523b..dd2a0f491418 100644 --- a/sd/source/ui/sidebar/SlideBackground.cxx +++ b/sd/source/ui/sidebar/SlideBackground.cxx @@ -403,9 +403,11 @@ void SlideBackground::Update() const Color aEndColor(aBGradient.GetColorStops().back().getStopColor()); mxFillGrad2->SelectEntry(aEndColor); - // MCGR: preserve in-between ColorStops if given - if (aBGradient.GetColorStops().size() > 2) - maColorStops = basegfx::BColorStops(aBGradient.GetColorStops().begin() + 1, aBGradient.GetColorStops().end() - 1); + // MCGR: preserve ColorStops if given. + // tdf#155901 We need offset of first and last stop, so include them. + if (aBGradient.GetColorStops().size() >= 2) + maColorStops = basegfx::BColorStops(aBGradient.GetColorStops().begin(), + aBGradient.GetColorStops().end()); else maColorStops.clear(); } @@ -1289,14 +1291,19 @@ basegfx::BColorStops SlideBackground::createColorStops() { basegfx::BColorStops aColorStops; - aColorStops.emplace_back(0.0, mxFillGrad1->GetSelectEntryColor().getBColor()); - - if(!maColorStops.empty()) + if (maColorStops.size() >= 2) { - aColorStops.insert(aColorStops.begin(), maColorStops.begin(), maColorStops.end()); + aColorStops.emplace_back(maColorStops.front().getStopOffset(), + mxFillGrad1->GetSelectEntryColor().getBColor()); + aColorStops.insert(aColorStops.begin(), maColorStops.begin() + 1, maColorStops.end() - 1); + aColorStops.emplace_back(maColorStops.back().getStopOffset(), + mxFillGrad2->GetSelectEntryColor().getBColor()); + } + else + { + aColorStops.emplace_back(0.0, mxFillGrad1->GetSelectEntryColor().getBColor()); + aColorStops.emplace_back(1.0, mxFillGrad2->GetSelectEntryColor().getBColor()); } - - aColorStops.emplace_back(1.0, mxFillGrad2->GetSelectEntryColor().getBColor()); return aColorStops; } diff --git a/sd/source/ui/sidebar/SlideBackground.hxx b/sd/source/ui/sidebar/SlideBackground.hxx index 3a2dd2475680..8d5932629bcd 100644 --- a/sd/source/ui/sidebar/SlideBackground.hxx +++ b/sd/source/ui/sidebar/SlideBackground.hxx @@ -138,7 +138,7 @@ private: MapUnit meUnit; - // MCGR: Preserve in-between ColorStops until we have an UI to edit these + // MCGR: Preserve ColorStops until we have a UI to edit these basegfx::BColorStops maColorStops; DECL_LINK(FillBackgroundHdl, weld::ComboBox&, void); @@ -176,7 +176,7 @@ private: static FieldUnit GetCurrentUnit(SfxItemState eState, const SfxPoolItem* pState); - // MCGR: Preserve in-between ColorStops until we have an UI to edit these + // MCGR: Preserve ColorStops until we have a UI to edit these basegfx::BColorStops createColorStops(); }; |