summaryrefslogtreecommitdiff
path: root/cui/source/tabpages/tpgradnt.cxx
diff options
context:
space:
mode:
authorArmin Le Grand (allotropia) <armin.le.grand.extern@allotropia.de>2023-04-18 15:36:35 +0200
committerArmin Le Grand <Armin.Le.Grand@me.com>2023-04-19 20:43:45 +0200
commit4409cd197dfb1fab05c0285f3ae17a107c99b77e (patch)
treec89a73f29f03d4e656042f0b8b88e329b16fd5de /cui/source/tabpages/tpgradnt.cxx
parent730b329b51797254aca58843ad7937ee7662cf7f (diff)
MCGR: 2nd corrections/adaptions to MCGR
Adapted handling of 'border' argument from our gradients for oox export, so that it looks the same. Also added quite some cases to peserve in-between GradientStops for current UI implementations to be able to edit the gradients as usual without losing the in-between GradientStops. While we will not be able to modify these, we are at least able to modify all the other gradient attributes, including start/endColor. Done this for TransparencyGradients, too. Also moved more stuff to the gradient tooling in basegfx. Change-Id: I6e94011bbf3715baa1401ab97e5b59811298342f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150577 Tested-by: Jenkins Reviewed-by: Armin Le Grand <Armin.Le.Grand@me.com>
Diffstat (limited to 'cui/source/tabpages/tpgradnt.cxx')
-rw-r--r--cui/source/tabpages/tpgradnt.cxx38
1 files changed, 26 insertions, 12 deletions
diff --git a/cui/source/tabpages/tpgradnt.cxx b/cui/source/tabpages/tpgradnt.cxx
index dfe59e878334..57eed4dd4ce5 100644
--- a/cui/source/tabpages/tpgradnt.cxx
+++ b/cui/source/tabpages/tpgradnt.cxx
@@ -197,9 +197,7 @@ bool SvxGradientTabPage::FillItemSet( SfxItemSet* rSet )
// gradient was passed (unidentified)
{
pXGradient.reset(new XGradient(
- basegfx::utils::createColorStopsFromStartEndColor(
- m_xLbColorFrom->GetSelectEntryColor().getBColor(),
- m_xLbColorTo->GetSelectEntryColor().getBColor()),
+ createColorStops(),
static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()),
Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource
static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
@@ -297,9 +295,7 @@ void SvxGradientTabPage::ModifiedHdl_Impl( void const * pControl )
css::awt::GradientStyle eXGS = static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active());
XGradient aXGradient(
- basegfx::utils::createColorStopsFromStartEndColor(
- m_xLbColorFrom->GetSelectEntryColor().getBColor(),
- m_xLbColorTo->GetSelectEntryColor().getBColor()),
+ createColorStops(),
eXGS,
Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource
static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
@@ -366,9 +362,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickAddHdl_Impl, weld::Button&, void)
if( !nError )
{
XGradient aXGradient(
- basegfx::utils::createColorStopsFromStartEndColor(
- m_xLbColorFrom->GetSelectEntryColor().getBColor(),
- m_xLbColorTo->GetSelectEntryColor().getBColor()),
+ createColorStops(),
static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()),
Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource
static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
@@ -408,9 +402,7 @@ IMPL_LINK_NOARG(SvxGradientTabPage, ClickModifyHdl_Impl, weld::Button&, void)
OUString aName( m_pGradientList->GetGradient( static_cast<sal_uInt16>(nPos) )->GetName() );
XGradient aXGradient(
- basegfx::utils::createColorStopsFromStartEndColor(
- m_xLbColorFrom->GetSelectEntryColor().getBColor(),
- m_xLbColorTo->GetSelectEntryColor().getBColor()),
+ createColorStops(),
static_cast<css::awt::GradientStyle>(m_xLbGradientType->get_active()),
Degree10(static_cast<sal_Int16>(m_xMtrAngle->get_value(FieldUnit::NONE) * 10)), // should be changed in resource
static_cast<sal_uInt16>(m_xMtrCenterX->get_value(FieldUnit::NONE)),
@@ -557,6 +549,12 @@ void SvxGradientTabPage::ChangeGradientHdl_Impl()
m_xLbColorTo->SetNoSelection();
m_xLbColorTo->SelectEntry(Color(pGradient->GetColorStops().back().getStopColor()));
+ // MCGR: preserve in-between ColorStops if given
+ if (pGradient->GetColorStops().size() > 2)
+ m_aColorStops = basegfx::ColorStops(pGradient->GetColorStops().begin() + 1, pGradient->GetColorStops().end() - 1);
+ else
+ m_aColorStops.clear();
+
m_xMtrAngle->set_value(pGradient->GetAngle().get() / 10, FieldUnit::NONE); // should be changed in resource
m_xSliderAngle->set_value(pGradient->GetAngle().get() / 10);
m_xMtrBorder->set_value(pGradient->GetBorder(), FieldUnit::NONE);
@@ -640,4 +638,20 @@ sal_Int32 SvxGradientTabPage::SearchGradientList(std::u16string_view rGradientNa
return nPos;
}
+basegfx::ColorStops SvxGradientTabPage::createColorStops()
+{
+ basegfx::ColorStops aColorStops;
+
+ aColorStops.emplace_back(0.0, m_xLbColorFrom->GetSelectEntryColor().getBColor());
+
+ if(!m_aColorStops.empty())
+ {
+ aColorStops.insert(aColorStops.begin(), m_aColorStops.begin(), m_aColorStops.end());
+ }
+
+ aColorStops.emplace_back(1.0, m_xLbColorTo->GetSelectEntryColor().getBColor());
+
+ return aColorStops;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */