From 312a32f6b6c83c5747b617249d794fc87ffd8b9b Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 25 Oct 2021 21:07:06 +0100 Subject: tdf#145296 use a 'clickable' widget for custom spacing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I7c0b609a074a68dcc7ca4f6a775743e836a6caa7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124165 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svx/source/tbxctrls/fontworkgallery.cxx | 55 ++++++----- svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui | 109 +++++++++------------ 2 files changed, 81 insertions(+), 83 deletions(-) (limited to 'svx') diff --git a/svx/source/tbxctrls/fontworkgallery.cxx b/svx/source/tbxctrls/fontworkgallery.cxx index a5c812c03b63..a0071644d09f 100644 --- a/svx/source/tbxctrls/fontworkgallery.cxx +++ b/svx/source/tbxctrls/fontworkgallery.cxx @@ -470,17 +470,17 @@ public: virtual void statusChanged( const css::frame::FeatureStateEvent& Event ) override; private: rtl::Reference mxControl; - std::unique_ptr mxVeryTight; - std::unique_ptr mxTight; - std::unique_ptr mxNormal; - std::unique_ptr mxLoose; - std::unique_ptr mxVeryLoose; - std::unique_ptr mxCustom; + std::unique_ptr mxVeryTight; + std::unique_ptr mxTight; + std::unique_ptr mxNormal; + std::unique_ptr mxLoose; + std::unique_ptr mxVeryLoose; + std::unique_ptr mxCustom; std::unique_ptr mxKernPairs; bool mbSettingValue; DECL_LINK( KernSelectHdl, weld::Toggleable&, void ); - DECL_LINK( SelectHdl, weld::Toggleable&, void ); + DECL_LINK( SelectHdl, weld::Button&, void ); void implSetCharacterSpacing( sal_Int32 nCharacterSpacing, bool bEnabled ); void implSetKernCharacterPairs(bool bKernOnOff, bool bEnabled); @@ -494,21 +494,21 @@ constexpr OUStringLiteral gsFontworkKernCharacterPairs(u".uno:FontworkKernCharac FontworkCharacterSpacingWindow::FontworkCharacterSpacingWindow(svt::PopupWindowController* pControl, weld::Widget* pParent) : WeldToolbarPopup(pControl->getFrameInterface(), pParent, "svx/ui/fontworkcharacterspacingcontrol.ui", "FontworkCharacterSpacingControl") , mxControl(pControl) - , mxVeryTight(m_xBuilder->weld_radio_button("verytight")) - , mxTight(m_xBuilder->weld_radio_button("tight")) - , mxNormal(m_xBuilder->weld_radio_button("normal")) - , mxLoose(m_xBuilder->weld_radio_button("loose")) - , mxVeryLoose(m_xBuilder->weld_radio_button("veryloose")) - , mxCustom(m_xBuilder->weld_radio_button("custom")) + , mxVeryTight(m_xBuilder->weld_toggle_button("verytight")) + , mxTight(m_xBuilder->weld_toggle_button("tight")) + , mxNormal(m_xBuilder->weld_toggle_button("normal")) + , mxLoose(m_xBuilder->weld_toggle_button("loose")) + , mxVeryLoose(m_xBuilder->weld_toggle_button("veryloose")) + , mxCustom(m_xBuilder->weld_toggle_button("custom")) , mxKernPairs(m_xBuilder->weld_check_button("kernpairs")) , mbSettingValue(false) { - mxVeryTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); - mxTight->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); - mxNormal->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); - mxLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); - mxVeryLoose->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); - mxCustom->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxVeryTight->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxTight->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxNormal->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxLoose->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxVeryLoose->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); + mxCustom->connect_clicked(LINK(this, FontworkCharacterSpacingWindow, SelectHdl)); mxKernPairs->connect_toggled(LINK(this, FontworkCharacterSpacingWindow, KernSelectHdl)); @@ -542,7 +542,6 @@ void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharact mxNormal->set_active(false); mxLoose->set_active(false); mxVeryLoose->set_active(false); - mxCustom->set_active(true); switch(nCharacterSpacing) { @@ -563,6 +562,12 @@ void FontworkCharacterSpacingWindow::implSetCharacterSpacing( sal_Int32 nCharact break; } + mxCustom->set_active(!mxVeryTight->get_active() && + !mxTight->get_active() && + !mxNormal->get_active() && + !mxLoose->get_active() && + !mxVeryLoose->get_active()); + mbSettingValue = bSettingValue; } @@ -619,10 +624,14 @@ IMPL_LINK_NOARG(FontworkCharacterSpacingWindow, KernSelectHdl, weld::Toggleable& mxControl->EndPopupMode(); } -IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Toggleable&, rButton, void) +IMPL_LINK(FontworkCharacterSpacingWindow, SelectHdl, weld::Button&, rButton, void) { - if (!rButton.get_active()) - return; + mxVeryTight->set_active(&rButton == mxVeryTight.get()); + mxTight->set_active(&rButton == mxTight.get()); + mxNormal->set_active(&rButton == mxNormal.get()); + mxLoose->set_active(&rButton == mxLoose.get()); + mxVeryLoose->set_active(&rButton == mxVeryLoose.get()); + mxCustom->set_active(&rButton == mxCustom.get()); if (mbSettingValue) return; diff --git a/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui b/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui index aee1943bb10a..df7f5e19668e 100644 --- a/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui +++ b/svx/uiconfig/ui/fontworkcharacterspacingcontrol.ui @@ -1,121 +1,110 @@ - + - False - True - 4 + False + True + 4 - + True - False + False True True - 6 + 6 - + _Very Tight True - True - False - True - True - normal + True + False + True - 0 - 0 + 0 + 0 - + _Tight True - True - False - True - True - normal + True + False + True - 0 - 1 + 0 + 1 - + _Normal True - True - False - True + True + False + True True - True - 0 - 2 + 0 + 2 - + _Loose True - True - False - True - True - normal + True + False + True - 0 - 3 + 0 + 3 - + Very _Loose True - True - False - True - True - normal + True + False + True - 0 - 4 + 0 + 4 - + _Custom... True - True - False - True - True - normal + True + False + True - 0 - 5 + 0 + 5 _Kern Character Pairs True - True - False - True - True + True + False + True + True - 0 - 6 + 0 + 6 -- cgit